HandyGandy
HandyGandy

Reputation: 720

How to trace a recursive make?

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?

Upvotes: 1

Views: 1401

Answers (3)

moleeye
moleeye

Reputation: 76

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

Upvotes: 0

Dan
Dan

Reputation: 5975

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.

Upvotes: 3

Carl Norum
Carl Norum

Reputation: 225002

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
$

Upvotes: 3

Related Questions