help-make
[Top][All Lists]
Advanced

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

.PHONY, FORCE, target execution


From: Leeuwesteijn,Joost
Subject: .PHONY, FORCE, target execution
Date: Tue, 2 May 2006 10:59:16 +0200

Hi all,

In my quest for "the perfect build environment"(tm) I ran into the following
I-dont-get-it:

See the zut.mk example below. When I run 'make -f zut.mk' I expected the
banner target to be executed twice, but it doesn't. Just once, for module1.
I thought .PHONY targets would  always be executed, but 'always' seems to be
limited to once; which is probably the 'make' thing to do.

Is it possible to force the execution of the banner target? Or is there some
other, gnu-make-preferred way, of accomplishing this? I have quite a lot of
double code in my makefiles and I was hoping to reduce it this way, with
target specific variables for the specifics. I'll create a separate post for
that because it has some more issues.

This example has only one recipe line in the banner target so you could
argue to put it in a variable and add that to the other targets, but what if
you have multiple recipe lines and need specific module variables? This is
pretty much the last step towards a lean and mean build environment.

Regards,
Joost Leeuwesteijn

zut.mk :
==============================================

.PHONY : all
all : module1 module2

# -------------------------------------

.PHONY : module1
module1 : MODULENAME:=module1
module1 : banner do_module1

.PHONY : do_module1
do_module1 :
                @echo "Build module1 here..."

# -------------------------------------

.PHONY : module2
module2 : MODULENAME:=module2
module2 : banner do_module2

.PHONY : do_module2
do_module2 :
                @echo "Build module2 here..."

# -------------------------------------

.PHONY : banner
banner :
                @echo "BANNER --- $(MODULENAME) --- BANNER"

==============================================




reply via email to

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