On Wed, Mar 24, 2010 at 9:05 AM, hi <[email protected]> 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.


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to