[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: writing a macro to process subdirectories
From: |
Robert P. J. Day |
Subject: |
Re: writing a macro to process subdirectories |
Date: |
Fri, 7 Jan 2005 07:25:10 -0500 (EST) |
On Fri, 7 Jan 2005, John Graham-Cumming wrote:
> 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
actually, thinking about it for a few more minutes led me to believe
that i may be asking too much here. for example, the subdirectory
dependencies almost certainly won't be the same from target to target.
if i'm configuring or building, i might have some subdir dependencies.
but if i'm just cleaning, chances are, subdir dependencies won't
exist.
i'll think about this a bit longer, but maybe i'm just being a bit too
ambitious.
rday