Philip Guenther wrote:

> On Sun, May 30, 2010 at 3:30 PM, Erik Rull <[email protected]>
> wrote:
>> Per Jessen wrote:
> ...
>>> clean1:
>>> make -C mod1 clean
>>> clean2:
>>> make -C mod2 clean
> ...
>>> clean: clean1 clean2 clean3 clean4 clean5
>>
>> Hm, well, yes - this could be possbile - but quite brute-force ;-)
>> If I add a new module, just the list of targets gets extended and
>> I've nothing to change in the makefile - with your approach a new
>> clean rule must be added manually.
> 
> If only there was some way to express a set of rules that all followed
> a pattern.  We could even call them "pattern rules"...
> 
> clean-%:
>         ${MAKE} -C ${@:clean-%=%} clean
> 
> clean: $(foreach mod,${MODULE_LIST},clean-${mod})
> 

Yep, that's exactly what I was hinting at. 

If the module list isn't fixed, you could take a little step further:

clean: $(foreach mod,$(shell find moduledir -type d),clean-${mod})

Of course, replace 'find moduledir -type d' with whatever will give you
a suitable list of directories.


/Per Jessen, Zürich


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

Reply via email to