[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
recursive make: communicating target to sub-makes
From: |
Daniel Kabs |
Subject: |
recursive make: communicating target to sub-makes |
Date: |
Mon, 09 Jan 2006 13:42:51 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050920 |
Hi there,
I use seperate makefiles for seperate subsystems that compose a larger
system. Each subsystem resides in its own subdirectory. I want "make" to
recursively call all the makefiles in those directories.
SUBDIRS = foo bar baz
all install:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir $@; \
done
The "make" manual discourages to use a shell "for loop" and instead
recommends to declare subdirs as phony targets:
http://www.gnu.org/software/make/manual/html_mono/make.html#SEC41
SUBDIRS = foo bar baz
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
foo: baz
This method is more powerful than the plain "for loop" as you can
declare dependencies (here: foo subdirectory cannot be built until after
the baz subdirectory has finished).
My problem though:
I fail to see how I can apply this construct to have "make all" and
"make install" work recursively. It only works if you call "make subdirs".
How can I take advantage of this construct _and_ propagate a different
target (e.g. "all" or "install") to the sub-makefiles?
Cheers
Daniel Kabs
--
Granted, CVS does not handle binary files as well as it handles
mergeable text files. But even with CVS's handicaps and limitations
WRT binary, CVS is still orders of magnitude better than manually
maintaining versions of files in a directory.(Jim Hyslop on info-cvs)
- recursive make: communicating target to sub-makes,
Daniel Kabs <=