[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
writing a macro to process subdirectories
From: |
Robert P. J. Day |
Subject: |
writing a macro to process subdirectories |
Date: |
Fri, 7 Jan 2005 06:22:49 -0500 (EST) |
from a .mk file i got from someone else, there's a fairly standard
define to recursively process subdirectories:
define MAKE-SUBDIRS
@for d in $(SUBDIRS); \
do \
if test -d $$d; then \
echo $(MAKE) -C $$d $@; \
$(MAKE) -C $$d $@; \
else \
echo DIR $$d skipped; \
fi; \
done
endef
given this, obviously, you can define numerous targets of the form for
recursive processing:
configure build clean:
${MAKE-SUBDIRS}
and subsequently invoke, say, "make clean".
however, reading the make manual, i see an alternative form of
processing SUBDIRS that i prefer, since it supports parallel
processing and subdirectory dependencies:
SUBDIRS = d1 d2 d3
.PHONY: subdirs ${SUBDIRS}
subdirs: ${SUBDIRS}
${SUBDIRS}:
${MAKE} -C $@
d1: d2 # potential subdir dependency
but this second form doesn't accommodate a subdirectory target, such
as "configure" or "clean".
is there a standard way to combine the best features of these two
techniques to get the best of both worlds? it's probably obvious,
i'm just not seeing it.
rday
- writing a macro to process subdirectories,
Robert P. J. Day <=