[Top][All Lists]

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

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

From: Noel Yap
Subject: Re: how to define a set of targets for a recursive structure?
Date: Tue, 16 Dec 2003 13:10:32 -0500

This sounds about right for a recursive make structure.

Alternatively, you can go for a non-recursive make (I call it a recursive 
makefile) structure.  See

In a recursive makefile structure, rather than running make for the 
subdirectories, each subdirectory will publish how to build its stuff via a 
makefile that gets included.  For example, it may have something like:

# contents of d1/
build: build-d1

#clean:         # don't have to include this since there's nothing to clean in 

Within the top-level makefile, you'd do something like:

-include $(addsuffix /,$(TARGETS))


"Robert P. J. Day" wrote:
>   (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,
> onward.)
>   i want to define a standard set of targets for a multi-level directory 
> structure:
> 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 
> have
> 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 $@
>     done
> 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
> clean:
>     .... 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:
> clean;
>     @echo Nothing to do for clean here.
> or
> 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
> subdirectories.
>   is this about right?  sorry for the newbie-level questions, i'm still poring
> over the manual.
> rday
> _______________________________________________
> Help-make mailing list
> address@hidden

NOTICE: If received in error, please destroy and notify sender.  Sender does 
not waive confidentiality or privilege, and use is prohibited.

reply via email to

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