[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: writing a macro to process subdirectories
From: |
Paul D. Smith |
Subject: |
Re: writing a macro to process subdirectories |
Date: |
Fri, 7 Jan 2005 11:03:29 -0500 |
%% "Robert P. J. Day" <address@hidden> writes:
rpjd> however, reading the make manual, i see an alternative form of
rpjd> processing SUBDIRS that i prefer, since it supports parallel
rpjd> processing and subdirectory dependencies:
rpjd> SUBDIRS = d1 d2 d3
rpjd> .PHONY: subdirs ${SUBDIRS}
rpjd> subdirs: ${SUBDIRS}
rpjd> ${SUBDIRS}:
rpjd> ${MAKE} -C $@
rpjd> d1: d2 # potential subdir dependency
rpjd> but this second form doesn't accommodate a subdirectory target, such
rpjd> as "configure" or "clean".
I used suffixes for this before, like this:
SUBDIRS := d1 d2 d3
TARGETS := clean all configure
ALLSUBDIRS := $(foreach t,$(TARGETS),$(addsuffix .$(t),$(SUBDIRS)))
clean: $(addsuffix .clean,$(SUBDIRS))
all: $(addsuffix .all,$(SUBDIRS))
configure: $(addsuffix .configure,$(SUBDIRS))
$(ALLSUBDIRS):
$(MAKE) -C $(patsubst .%,%,$(suffix $@)) $(basename $@)
or whatever. You can use $(eval ...) to make this much more clean. And
you'll need to make sure you declare all that stuff (certainly the
directories themselves) .PHONY.
Dependencies are more painful but again you can use loops and eval to
handle it.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist