%% [EMAIL PROTECTED] writes:

  jc> Consider the following Makefile:

  jc>    clean: GOAL= clean

  jc>    ifneq ($(GOAL),clean)
  jc>    include foo.mk
  jc>    endif

  jc>    clean:
  jc>        echo $(GOAL)

  jc> If I type make clean, I would expect the Makefile to skip inclusion of
  jc> foo.mk.

No.

You've assigned the variable GOAL with a target-specific variable.  That
means that the variable has that value _within the context of that
target_.  That is, when make is actually in the process of invoking that
target's commands.

The if-statement is evaluated while reading the makefile, long before
make even starts to build any targets, much less the clean target.  So,
the value of GOAL is empty.

Check the section on target-specific variables more carefully; this is
stated explicitly there.  Also helpful may be the chapter on `How `make'
Reads a Makefile'.

You want to use the builtin variable MAKECMDGOALS, and test that to see
if it's "clean".

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

Reply via email to