[Top][All Lists]

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

how to define a set of targets for a recursive structure?

From: Robert P. J. Day
Subject: how to define a set of targets for a recursive structure?
Date: Tue, 16 Dec 2003 12:19:37 -0500 (EST)

  (sorry about all the traffic my previous posting caused -- i didn't realize i
was disturbing the hornet's nest quite that much.  i did eventually figure out
that i was looking at the wrong section in the make manual.  and now, 

  i want to define a standard set of targets for a multi-level directory 
build, rebuild, clean, realclean, install, ... etc etc, that sort of thing.  
these targets
should be defined at the top-level makefile and, as the make progresses 
recursively, at some lower level, unless that target is explicitly handled
somehow by a lower-level makefile, the sub-directory makes should be
invoked for it.  i'm just trying to get this nailed exactly, so here's what i 
so far.

  at the top level, i can define

TARGETS = build rebuild clean realclean install check ...

SUBDIRS = d1 d2 d3 d4 d5

    for d in $(SUBDIRS) ; do   # ignore possible syntax errors for now
        $(MAKE) -C $d $@

so that, obviously, regardless of the target used for the top-level make, this
will recursively invoke all subdirectories with the same target.

  now, at any level where that target can actually be handled, i can do the
following (as i read it):

TARGETS :=  $(TARGETS:clean=)     # just as an example
SUBDIRS = ... subdirectories at *this* level

    .... whatever it actually takes to clean at this level ...

    for d in $(SUBDIRS) ...    # recursively deal with remaining targets

  and, finally, if a subdirectory has *nothing* to do for a given target, what's
the best thing to do?  i see a couple of options:

    @echo Nothing to do for clean here.


clean: ;

  this should let me have a fairly modular structure so that all top-level
targets will either be processed at some level or recursively passed to the

  is this about right?  sorry for the newbie-level questions, i'm still poring
over the manual.


reply via email to

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