views:

120

answers:

3

I need to work on a system that uses automake tools and makes recursively.

'make -n' only traces the top level of make.

Is there a way to cause make to execute a make -n whenever he encounters a make command?

+3  A: 

Use $(MAKE) to call your submakefiles, instead of using make. That should work. Check out How the MAKE variable works in the manual. Here's a quick example:

Makefile:

all:
    @$(MAKE) -f Makefile2

Makefile2:

all:
    @echo Makefile2

Command line:

$ make
Makefile2
$ make -n
make -f Makefile2
echo Makefile2
$
Carl Norum
+3  A: 

Does your recursive makefile look like this:

foo:
    make -C src1
    make -C src2

Or like this:

foo:
    ${MAKE} -C src1
    ${MAKE} -C src2

I think you need to use the second style if you want flags passed to child make processes. Could be your problem.

Dan
A: 

Setting the environment variable "MAKEFLAGS" to "n" may do what you need.

There are some more advanced tricks for tracing make commands here: http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make

The simplest of these tricks comes down to adding SHELL="sh -x" to your make command (running without "-n" in that case).

moleeye