[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: writing a macro to process subdirectories
From: |
John Graham-Cumming |
Subject: |
Re: writing a macro to process subdirectories |
Date: |
Fri, 07 Jan 2005 07:16:41 -0500 |
On Fri, 2005-01-07 at 06:22, Robert P. J. Day wrote:
> 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".
You could achieve this with a target specific variable like this:
SUBDIRS = d1 d2 d3
.PHONY: subdirs ${SUBDIRS} clean configure
subdirs: ${SUBDIRS}
${SUBDIRS}:
${MAKE} -C $@ $(SUBDIR_GOAL)
d1: d2 # potential subdir dependency
clean: subdirs
clean: SUBDIR_GOAL=clean
configure: subdirs
configure: SUBDIR_GOAL=configure
Target specific variables are available in the prereqs of a target so
SUBDIR_GOAL will be set appropriately by the clean and configure targets
and then can be used in the subdirs.
Or if you know that you are only going to use one of these specific
targets like clean or configure on the command-line you could do:
SUBDIRS = d1 d2 d3
.PHONY: subdirs ${SUBDIRS} clean configure
subdirs: ${SUBDIRS}
${SUBDIRS}:
${MAKE} -C $@ $(MAKECMDGOALS)
d1: d2 # potential subdir dependency
clean: subdirs
configure: subdirs
John.
--
John Graham-Cumming
Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/