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) >> $@))


_______________________________________________
Help-make mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/help-make

Reply via email to