On Sat, 2011-01-22 at 15:23 +0100, Christof Warlich wrote:
> First, here is what I'd like to ask for: A third type of prerequisites
> besides the existing two ("ordinary prerequisites" and "order-only
> prerequisites", let's call them "dependency-only prerequisites") that,
> like "order-only prerequisites", are _not_ included in the automatic
> variable $^, but that behave like ordinary prerequisites otherwise.
> 
> I have set up an example to understand why I think this would be
> useful: Consider a tool that makes its targets from several files
> given on its command line, but that may have additional dependencies
> that must not be passed to that tool. In such a case neither of the
> automatic variables $< nor $^ match, as the first only expands to the
> first prerequisite, while the latter expands to all prerequisites.

I'm certainly open to discussing things like this, but offhand I don't
see this situation as generic and wide-spread enough to justify new
fundamental make syntax.  The situation described here is easily managed
with existing behavior, so I'd like to see a more compelling use-case.

In your example, where you know that you want to avoid a particular
header in a particular rule, all you have to do is use $(filter-out ...)
to remove it.

For example, change your rule to look like this:

        %.sum: *.c *.h ${SUM}
             ${SUM} $(filter-out $(SUM),$^) >$@
        %: %_*.c sum.h
             gcc $(filter-out sum.h,$^) -o $@

You can create generic variables if you like, such as:

        EXCLUDE_foo = bar.x baz.y
        
        foo: foo.c foo.h bar.c bar.h baz.c bar.x baz.y
                $(CREATE) $(filter-out $(EXCLUDE_$@),$^) > $@

or similar.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email protected]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to