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: Sat, 19 Oct 2002 09:10:21 -0400

%% gk <address@hidden> writes:

  g> Yes, the method you suggest above does work but the problem is that
  g> output is 'swallowed' by assignment to _x and doesn't appear in the
  g> terminal.

That has nothing to do with whether you assign the value to a variable
or not.  That's how the shell function is defined: see the GNU make
manual.  If you didn't assign it to a function you'd get syntax errors,
because the function would expand to the output of the submake, then
make would try to parse that.

$(shell ...) in make works like backticks (``) in sh; that's its whole
purpose.

  g> I would like to be have $(MAKE) recurse run just like if I had
  g> typed 'make recurse' on the command line.

You can't do that using shell.

  g> I wanted to do something similar with a 'debug' rule to echo some
  g> makefile variables to the terminal; to somehow invoke the rule from
  g> the makefile, without it having to be a target.

You can't do that.

Why don't you want it to be a target?

  g> * I do not want to specify 'recurse' as a command line goal; I want to 
  g> build $(MAKECMDGOALS) in each directory in my list:
  g> recurse :
  g>          @for dir in $(SUBDIRS); do\
  g>                  $(MAKE) -C $$dir $(MAKECMDGOALS); \
  g>          done

See the GNU make manual for some reasons why doing submakes inside a
loop like this is suboptimal.

  g> I could add 'recurse' as a command line goal, then remove it from 
  g> $(MAKECMDGOALS) in the makefile:
  g> GOALS = $(filter-out recurse, $(MAKECMDGOALS) )
  g> recurse :
  g>          @for dir in $(SUBDIRS); do\
  g>                  $(MAKE) -C $$dir $(GOALS); \
  g>          done

You will have to do something like this.  I can't think of any other way
to manage it.  You could put the test into the shell script instead of
using make functions, but I don't know that it is much cleaner.

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