[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: recursive make: communicating target to sub-makes
From: |
James |
Subject: |
Re: recursive make: communicating target to sub-makes |
Date: |
10 Jan 2006 17:58:53 -0800 |
User-agent: |
G2/0.2 |
> SUBDIRS = foo bar baz
> .PHONY: subdirs $(SUBDIRS)
> subdirs: $(SUBDIRS)
> $(SUBDIRS):
> $(MAKE) -C $@
> foo: baz
How about
ALL = $(addsuffix -all,$(SUBDIRS))
INSTALL = $(addsuffix -install,$(SUBDIRS))
all: $(ALL)
install: $(INSTALL)
$(ALL):
$(MAKE) -C $(@:-all=) all
$(INSTALL):
$(MAKE) -C $(@:-install=) install
James
Daniel Kabs wrote:
> 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)