[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: foreach/ordering help
From: |
Russell |
Subject: |
Re: foreach/ordering help |
Date: |
Sun, 03 Nov 2002 12:09:24 +1100 |
Mark Therieau wrote:
>
> I'm trying to create an output file that
> has one filename per line. (I need to feed
> the filenames to the shell one at a time to
> avoid win32 command-line length issues when
> dealing with hundreds/thousands of files)
>
> The makefile below doesn't work because the
> foreach is evaluated *before* the rm command is
> executed. The result is that the "shell echo"
> commands run first to create "c.pfs" and then
> the rm deletes it every time.
>
> Any ideas on a better way to get the rules to
> run in the desired order?
>
> ---------------------------------------------
> CSRCS = file1.c file2.c file999.c file1000.c
> c.pfs:
> @rm -f $@
> @$(foreach f,$(CSRCS),$(shell echo $(f) >> $@))
> ------------------------
I think each line of the command is spawned as a separate
shell process. Try to keep all the commands in one line
(one process):
CSRCS = file1.c file2.c file999.c file1000.c
c.pfs:
@rm -f $@ ; \
$(foreach f,$(CSRCS),$(shell echo $(f) >> $@))
or:
@rm -f $@ && \
$(foreach f,$(CSRCS),$(shell echo $(f) >> $@))
RE: foreach/ordering help, Randy W. Sims, 2002/11/03