[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Automagic Listing of targets,prereqs
From: |
Paul D. Smith |
Subject: |
Re: Automagic Listing of targets,prereqs |
Date: |
Wed, 16 Apr 2003 12:26:47 -0400 |
%% Tristan Van Berkom <address@hidden> writes:
tvb> I was wondering if there is a way to list targets and
tvb> prerequisites in a way that the Nth element in list 1 depends on
tvb> the Nth element in list 2.
Not using "traditional" make capabilities.
tvb> If one were to write a dependancy like so:
tvb> $(TARGETS):$(PREREQUISISTES)
tvb> this means (mistaken am I ?) that every `single' target in the
tvb> former list depends on `all' the prereq's in the latter list.
You are correct.
tvb> I tried something like this:
tvb> $(foreach prereq, $(PREREQS), \
tvb> $(foreach, target $(TARGETS), \
tvb> $(if $(findstring $(prereq), $(target)), \
tvb> $(target):$(prereq))))
tvb> exept I cant figure out how to violently add newlines instead of
tvb> whitespace in between the elements of the above generated list
tvb> (and even then, would they be considered targets ? I guess so
tvb> since the pre-proccessing gets done before targets are
tvb> considered).
You can get newlines by using the define/enddef feature to declare a
variable value with newlines in it.
But, it would not work. A single line of a makefile cannot expand into
multiple lines. Even if the expansion contains newlines it will still
be considered by the make parser as one line.
tvb> My last resort I guess is to pipe that list through `sed' for the
tvb> newlines; into a file on disk... and then include them in the
tvb> makefile.
Something like that, yes.
tvb> PS: I'm useing GNU Make 3.79
If you upgrade to GNU make 3.80 you can make use of the new $(eval ...)
function feature; this will allow you to do what you want without the
include trick above.
Note that there are a few known bugs in this feature in 3.80; they will
be fixed in the next release.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist