help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dependency to generated list of source files


From: Ken Smith
Subject: Re: Dependency to generated list of source files
Date: Fri, 12 Nov 2004 08:50:08 -0500
User-agent: Mutt/1.5.6i

Hi Daniel,

When gmake is finding the dependencies for all, it evaluates
$(srcs_file) and $(objs).  At that time, srcs.txt hasn't been generated
so $(srcs) is the empty string.  Therefore, during the first run of
gmake, all depends only on srcs.txt.  During the second run, srcs.txt
already contains the names of the files you're after so $(objs) gets set
to what you are expecting.

Can you tell me more about your issue?  Why do you want to generate the
list of sources this way?

  Ken

On Fri, Nov 12, 2004 at 11:08:33AM +0100, address@hidden wrote:
> For my project I would like to generate the list of source files before 
> starting the compilation. Example:
> 
> srcs_file := srcs.txt
> srcs = $(shell cat $(srcs_file) 2>/dev/null)
> objs = $(srcs:%.c=%.o)
> 
> all : $(srcs_file) $(objs)
> 
> clean :
>       rm -f $(srcs_file)
>       rm -f $(srcs) $(objs)
> 
> $(srcs_file) :
>       for f in foo.c bar.c; do touch $$f; echo $$f >> $@; done
> 
> %.o : %.c
>       touch $@
> 
> The problem is, that only the second invocation of 'make' builds the targets 
> specified in 'objs'. This is probably because during the first invocation the 
> variable 'objs' has no value.
> 
> Is there a way to avoid two invocations of make?
> 
> Any help is appreciated. Regards,
> Daniel
> 
> 
> 
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make




reply via email to

[Prev in Thread] Current Thread [Next in Thread]