views:

205

answers:

2

When recursively invoking nmake, via the $(MAKE) macro, how can I pass on the target specified on the command line to the new instance?

So, say I execute the following from the command line:

c:\nmake clean

I want the recursive call to nmake to pass the 'clean' target to the new nmake instance.

A: 

I'm not sure I understand the question but you normally have the rule by virtue of the fact that your executing a specific part of the makefile, such as:

clean:
    cd dir1 && $(MAKE) clean
    cd dir2 && $(MAKE) clean

all:
    cd dir1 && $(MAKE) all
    cd dir2 && $(MAKE) all

If you have some other setup in your makefile, your best bet is to post it so we can do a better analysis.

paxdiablo
+1  A: 

you can write rule like this:

clean all:
    cd dir1 && $(MAKE) $*
    cd dir2 && $(MAKE) $*

$* will be substituted by target name ("clean" or "clean" in this example)

kcwu