help-make
[Top][All Lists]
Advanced

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

Re: Recursive Make Considered Harmful (was: Re: executing a rule prior


From: gk
Subject: Re: Recursive Make Considered Harmful (was: Re: executing a rule prior to any targets?)
Date: Wed, 23 Oct 2002 18:13:21 -0700

Hi Phillip,
Thanks for the ideas. I understand most of it.
I'm trying to generalize design for arbitrary languages and dependency generation tools, allowing flexibility of build modes, including 'recursion' for those who want it. But rather than implementing sub-make recursion though, I think it is better to generate a single makefile for a subset of directories. I think this is the only way that make can detect circular dependencies; sub-makes can loop infinitely.

I use a 'project' shell script to set the environment or specify other config files to source before doing a make. My top level makefile is XMLMAKE_PROJECT_MAKEFILE; this includes default rule and pattern rules.

- Default mode: build a single directory (and any prerequisites outside the directory)
    - 'xmlmake -P' option: build the entire project, non-recursively
- 'xmlmake -X' option: build the current directory and all subdirectories, non-recursively
        ( 'xmlmake -X -C $XMLMAKE_PROJECT_DIR' is the same as 'xmlmake -P' )


At 03:01 PM 10/20/2002 -0700, you wrote:
As mentioned above, instead of cd'ing and reinvoking make, I just
set a variable and include the top-level makefile.  For example,
here's what the GNUmakefile in the 'sys_utils' directory looks
like:

        THIS := sys_utils
        TOP := $(patsubst %/${THIS},%,${CURDIR})
        include ${TOP}/GNUmakefile

The top line is the only thing that differs among the subdirectory
GNUmakefiles.  (The 'THIS' variable is used to change the default
target to only include the files 'below' where the make was invoked.)

Does your system allow specifying targets without a full path?
In other words, it would be nice to type:
$cd obj.platform/util/foo/; make bar.o

And have the makefile find the right dependencies, even though your .P makefile knows it as:
${TOP}/obj.platform/util/foo/bar.o: \
 ${TOP}/util/foo/bar.c \

- Greg Keraunen





reply via email to

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