[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
recursive makes and subdirectory dependencies
From: |
Robert P. J. Day |
Subject: |
recursive makes and subdirectory dependencies |
Date: |
Tue, 8 Jun 2004 12:23:05 -0400 (EDT) |
i'm interested in how to combine two different techniques for a
recursive make structure to get the best of both worlds (if that's
possible).
until now, i've used the following approach. in a top-level included
makefile, i've defined the overall set of targets that pretty much all
subdirectories should be able to process:
TARGETS = clean realclean configure compile package ... (and so on)
.PHONY: ${TARGETS}
and a short macro to handle processing any makefile's subdirectories:
define MAKE-SUBDIRS
@for d in ${SUBDIRS} ; do \
${MAKE} -C $$d $@ ; \
done
endef
now, in any makefile throughout my software tree, if i include the above
makefile, i can just define:
SUBDIRS = d1 d2 d3 d4 # the subdirectories for *this* makefile
${TARGETS}:
${MAKE-SUBDIRS}
and i automatically get the canonical targets defined recursively. so
far, so good. (i hope.)
if i need to override one of those targets -- say, "configure" --, i can
(in the appropriate makefile), do:
TARGETS := ${TARGETS:configure=}
${TARGETS}:
${MAKE-SUBDIRS}
configure:
... whatever the redefinition of "configure" is
again, so far, i think this is fairly boilerplate stuff.
but i'd like to cram in to this structure the stuff in section 4.6 in
the make manual, the section on Phony Targets, where i can rewrite
subdirectory processing to support parallel builds and (at least as
important) the notion of the occasional prerequisite between
subdirectories. the technique:
SUBDIRS = d1 d2 d3 d4
.PHONY : subdirs ${SUBDIRS}
subdirs : ${SUBDIRS}
${SUBDIRS} :
${MAKE} -C $@
d3 : d2 # just as an example of a prerequisite
i've just started to ponder this, but is there a standard way to combine
these approaches? it's probably painfully obvious to the make gurus here,
but i don't see it yet.
thanks.
rday
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- recursive makes and subdirectory dependencies,
Robert P. J. Day <=