"make clean" recuresively into sub-directories. - Unix

This is a discussion on "make clean" recuresively into sub-directories. - Unix ; 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. I know that automake will easily handle this but my manager does not like automake :-( ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: "make clean" recuresively into sub-directories.

  1. "make clean" recuresively into sub-directories.

    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. I know that automake will easily handle this but my
    manager does not like automake :-(

    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:
    ==============================================
    jigsaw@guam> 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.arm -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.arm -f *.orm -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 zizzyrm -f *.o
    gmake[1]: Leaving directory `/export/guam/jigsaw/dev/jhwgu/src/jz/
    util'
    ================================================

    Could anybody help me out? Thanks in advance!

  2. Re: "make clean" recuresively into sub-directories.

    loudking 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. I know that automake will easily handle this but my
    > manager does not like automake :-(
    >

    Why don't you just put all the targets in a single, flat makefile? See
    the thread "How to suppress 'Entering/Leaving ...' messages while
    running make?" for some discussion.

    --
    Ian Collins.

  3. Re: "make clean" recuresively into sub-directories.

    On May 2, 1:54*pm, Ian Collins wrote:
    >
    > Why don't you just put all the targets in a single, flat makefile? *See
    > the thread "How to suppress 'Entering/Leaving ...' messages while
    > running make?" for some discussion.


    Well, even in that thread not everybody agree with one-big-makefile
    scheme and I myself does not like that idea either, because, to me,
    having hierarchical Makefiles for large projects is just analogous to
    having hierarchical directories for file systems. Anyway that
    discussion is just out of the range of this thread ...

  4. Re: "make clean" recuresively into sub-directories.

    loudking 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. I know that automake will easily handle this but my
    > manager does not like automake :-(


    I highly recommend this paper:

    Recursive Make Considiered Harmful
    http://miller.emu.id.au/pmiller/books/rmch/

    If you use a single top level all problems you may be having
    with recursive Makefiles will disappear.

    I know you're not using automake, but its also possible to use
    this idea with automake.

    Erik
    --
    -----------------------------------------------------------------
    Erik de Castro Lopo
    -----------------------------------------------------------------
    Q. What is the difference between Jurassic Park and Microsoft?
    A. One is an over-rated high tech theme park based on prehistoric
    information and populated mostly by dinosaurs, the other is a
    Steven Spielberg movie.

  5. Re: "make clean" recuresively into sub-directories.

    On May 2, 3:34 pm, loudking wrote:
    > On May 2, 1:54 pm, Ian Collins wrote:
    >
    >
    >
    > > Why don't you just put all the targets in a single, flat makefile? See
    > > the thread "How to suppress 'Entering/Leaving ...' messages while
    > > running make?" for some discussion.

    >
    > Well, even in that thread not everybody agree with one-big-makefile
    > scheme and I myself does not like that idea either, because, to me,
    > having hierarchical Makefiles for large projects is just analogous to
    > having hierarchical directories for file systems.


    For the flaws in this naive analogy, check Erik's cite.

    > Anyway that
    > discussion is just out of the range of this thread ...


    Au contraire, it's directly relevant. :-)

+ Reply to Thread