help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: clean recursively into sub-directories


From: John Calcote
Subject: Re: clean recursively into sub-directories
Date: Tue, 29 Apr 2008 08:57:27 -0600
User-agent: Thunderbird 2.0.0.12 (X11/20080226)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hongliang,

You have multiple conflicting rules for "all" and "clean". Here's the
right way to do this (untested):

============================================

SUBDIRS = gen ora util

.PHONY: all clean

all clean:
        for dir in $(SUBDIRS); do \
          $(MAKE) -C $$dir -f Makefile.hvr_gcc $@; \
        done

============================================

Cleaner and simpler. Note that the inter-directory dependencies are now
maintained by the order of the SUBDIRS list, not by make itself.

John

Hongliang Wang wrote:
> Hello all,
> 
> I have three sub-directories (gen, ora, util) under the top-level directory 
> and I want to run Makefiles recursively into these sub-directories.
> 
> My Makefile at top-level directory is
> 
> ============================================
> SRC = gen ora util
> 
> SUBDIRS = gen ora util
> 
> .PHONY: all $(SUBDIRS)
> 
> all: $(SUBDIRS)
> 
> $(SUBDIRS):
>       $(MAKE) -C $@ -f Makefile.hvr_gcc
> 
> util: ora
> 
> ora: gen
> 
> .PHONY: clean $(SRC)
> 
> clean: $(SRC)
> 
> $(SRC): 
>       $(MAKE) -C $@ -f Makefile.hvr_gcc clean
> 
> ==============================================
> 
> It just follows the example code from the offical manual of GNU Make. But 
> since I would like this Makefile to run "make clean" also recureively into 
> sub-directories, I add the "clean" target and it stops working.
> 
> However, when I run "make" or "make clean" under the top-level directory, the 
> result is:
> 
> ==============================================
> address@hidden> gmake -f Makefile
> Makefile:54: warning: overriding commands for target `gen'
> Makefile:41: warning: ignoring old commands for target `gen'
> Makefile:54: warning: overriding commands for target `ora'
> Makefile:41: warning: ignoring old commands for target `ora'
> Makefile:54: warning: overriding commands for target `util'
> Makefile:41: warning: ignoring old commands for target `util'
> gmake -C gen -f Makefile.hvr_gcc clean
> gmake[1]: Entering directory `/export/guam/jigsaw/dev/jhwgu/src/jz/gen'
> rm -f libzizzy.a
> rm -f *.o
> gmake[1]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz/gen'
> gmake -C ora -f Makefile.hvr_gcc clean
> gmake[1]: Entering directory `/export/guam/jigsaw/dev/jhwgu/src/jz/ora'
> rm -f libzizora.a
> rm -f *.o
> rm -f ../gen/*.o
> gmake[1]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz/ora'
> gmake -C util -f Makefile.hvr_gcc clean
> gmake[1]: Entering directory `/export/guam/jigsaw/dev/jhwgu/src/jz/util'
> rm -f zizzy
> rm -f *.o
> gmake[1]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz/util'
> ================================================
> 
> Could anybody help me out? Thanks in advance!
> _________________________________________________________________
> News, entertainment and everything you care about at Live.com. Get it now!
> http://www.live.com/getstarted.aspx
> 
> 
> _______________________________________________
> Help-make mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-make
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFIFzdXdcgqmRY/OH8RApWiAJ992MAbkhVSe5rGUPhDhNtdjxyx+QCfb+fA
VD8zJuZ/s5bCJMQrDDpj7lg=
=84VL
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]