[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Recursive make for 'all' and 'clean' targets
From: |
Todd Showalter |
Subject: |
Re: Recursive make for 'all' and 'clean' targets |
Date: |
Wed, 24 Mar 2010 09:58:29 -0400 |
On Wed, Mar 24, 2010 at 9:05 AM, hi <address@hidden> wrote:
> I have created makefile as follow, which work fine in recursive (plus
> parallel build) for 'allprodbld' target.
>
> The problem I am facing is how can I have recursive 'clean' target? In
> following case 'clean' is not working.
This is what I usually do:
> <Makefile>
>
> ############ actual scenario
> SUBPRODSBLD = prod*
SUBPRODSBLD_CLEAN = $(patsubst %,%.clean,$(SUBPRODSBLD))
.PHONY: $(SUBPRODSBLD_CLEAN)
$(SUBPRODSBLD_CLEAN):
@make -C $(@:.clean=) clean
The idea here is we manufacture fake targets. Each prod*
expansion becomes prodX.clean, which therefore becomes a separate
target, which allows us to have a cleanly separated rule. The target
rule strips .clean off before calling make, so it all works.
I think you could as easily do the target rule with (untested):
%.clean: %
@make -C $< clean
You'd still need to build the $(SUBPRODSBLD_CLEAN) variable, it
just processes it a slightly different way, essentially treating
.clean as a suffix and using suffix rules. As a general tip, you can
use a similar scheme to do other things, like make a foo.run build and
execute the target foo:
foo:
$(CC) $(OBJS) -o $@
%.run: %
$<
Todd.
--
Todd Showalter, President,
Electron Jump Games, Inc.