help-gnu-utils
[Top][All Lists]
Advanced

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

Re: recursive make: communicating target to sub-makes


From: Daniel Kabs
Subject: Re: recursive make: communicating target to sub-makes
Date: Thu, 16 Feb 2006 10:32:28 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920

Hello,

again replying to myself :-)

 >>SUBDIRS = foo bar baz


ALL = $(addsuffix -all,$(SUBDIRS))
all: $(ALL)
$(ALL):
          $(MAKE) -C $(@:-all=) all
Creating targets using variables is a good idea but I don't see how I can declare dependencies (e.g. say "bar" has to be compiled before "foo"). Well, I can list the SUBDIRS in a certain order but that does not work when "make" runs jobs concurrently (using option -j).

I finally solved this by using the variable MAKECMDGOALS to propagate the target specified on the command line to the sub-makefiles.


all clean install: $(SUBDIRS)

.PHONY: $(SUBDIRS)
$(SUBDIRS):
        $(MAKE) -C $@ $(MAKECMDGOALS)


This way you can run multiple make jobs simultaneously (using -j) and set dependencies, e.g. "bar" depends on "baz", write

bar: baz


Cheers
Daniel Kabs
Germany


reply via email to

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