help-make
[Top][All Lists]
Advanced

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

Re: executing a rule prior to any targets?


From: Paul D. Smith
Subject: Re: executing a rule prior to any targets?
Date: Fri, 18 Oct 2002 23:52:59 -0400

%% gk <address@hidden> writes:

  g> It appears that $(if ) does not allow semi-colon inside $(shell )
  g> function?  There is no problem with my rule since 'make recurse'
  g> works when the $(if ) function is removed.

  g> --- From command shell I execute:
  g> $export RECURSE=1
  g> $make
  g> Makefile:3: *** unterminated call to function 'if': missing ')'. Stop.

It doesn't matter whether RECURSE is set or not; you'll still get the
same problem.  This is a parsing issue, not a command invocation issue.

  g> $(if $(RECURSE), $(shell RECURSE=; $(MAKE) recurse ) )

This is a bug; please report it on the make project on Savannah
(savannah.gnu.org).

There are any number of ways to avoid it, though; note that Bourne shell
syntax allows variables to be set in the same command line, like this:

  $(if $(RECURSE), $(shell RECURSE= $(MAKE) recurse ) )

Or you could use make's capability of setting variables on the command
line, rather than relying on the shell:

  $(if $(RECURSE), $(shell $(MAKE) recurse RECURSE= ) )

Or you could put this into a variable assignment, where it won't be
parsed as a possible rule:

  _x := $(if $(RECURSE), $(shell RECURSE=; $(MAKE) recurse ) )

This is typically how $(shell ...) would be used, otherwise the output
of the make command would be considered make syntax which should be
parsed, which is probably not what you want.

-- 
-------------------------------------------------------------------------------
 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




reply via email to

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