help-make
[Top][All Lists]
Advanced

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

overriding part of another makefile


From: Robert P. J. Day
Subject: overriding part of another makefile
Date: Mon, 15 Dec 2003 08:42:15 -0500 (GMT-05:00)

  (actually, perhaps a question on empty commands.)

  in the make manual, section 3.8, i'm looking at the snippet of a 
makefile that allows one to override perhaps a single rule out of
another makefile:

    foo:
       frobnicate: foo
    %: force
        @$(MAKE) -f Makefile $@
    force: ;

as i read it, having an explicit rule for foo means that that rule will
be used for the "foo" target, but for any other target, the "%" pattern
rule will kick in,and it's how that rule is designed that i'm a little fuzzy
on.

  obviously, for any target other than "foo", you'll want to consult
the other makefile, and you have to *force* its consultation.  the
method used here is to use an empty command which, i want to
clarify, since it has no pre-reqs and no commands, is an empty 
command always considered out of date and therefore must be
updated?  even if nothing actually happens regarding "force" in the
above, given that it's an empty command, is it considered being
updated for the sake of rules like "%" that have it as a prerequisite?

  more to the point, is an empty command considered equivalent
to a PHONY target?  could i have written:

   %: force
        @$(MAKE) -f Makefile $@
    .PHONY: force
    force:

i'm used to creating PHONY targets essentially as subroutines
to run, as in "make clean".  would the above also work in this
context?  or is there a subtle different between the use of an empty
command and a PHONY target in this context that i'm missing?

rday






reply via email to

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