[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Recursive Make Considered Harmful (was: Re: executing arule prior to
From: |
Johan Bezem |
Subject: |
Re: Recursive Make Considered Harmful (was: Re: executing arule prior to any targets?) |
Date: |
Thu, 24 Oct 2002 09:56:45 +0200 |
Hi,
gk wrote:
<...>
> 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'm using a different approach. Starting from any directory (on every level
of the source tree, which in my case may have unlimited depth), I determine
all subdirectories containing a valid makefile, like
list_dirs := $(dir $(wildcard ./*/Makefile))
(adapted from the original I use, since I traverse the separate 'objects'
tree in stead of the source tree), then I define a special target "RECURSE"
and the set of directories found as .PHONY
.PHONY: RECURSE $(list_dirs)
and if $(list_dirs) is not empty, RECURSE is made dependent on $(list_dirs),
$(list_dirs) as target has an empty dependency list, as well as commands to
call $(MAKE) recursively:
ifneq ($(strip $(list_dirs)),)
RECURSE: $(list_dirs)
$(list_dirs):
\t address@hidden(MAKE) -f ./$@/Makefile $(MAKECMDGOALS)
endif
If, now, you make your first actual target (hare I call it 'all')and other
targets dependent from 'RECURSE', like
all: RECURSE $(OBJECTS)
\t @echo "Make executable"
make will recurse through all subdirectories before checking the objects on
this directory level, and, after that, create the executable.
Again, much simplified from my original makefile because of the other
requirements I have, but I hope the idea is clear.
(The '\t' notation indicates the presence of a TAB character, since I use
space-indentation for non-commands, and I'm not sure what the various make
clients will do with real tabs...)
Advantages:
- I'm not using the shell for recursion (better performance);
- No need to specify (and maintain!) a list of directories to be used, since
make does that automatically;
- Make is in control, and will recurse through all necessary directories
once and only once;
- If you indicate the dependencies between directories using the technique
in my previous mail, like
module1/ : module2/
you are in charge of the order in which make recurses through all
directories, whereas make itself can and will determine any circular
dependencies.
<...>
Ciao,
Johan
- Re: executing a rule prior to any targets?, (continued)
- Re: executing a rule prior to any targets?, Paul D. Smith, 2002/10/19
- Re: executing a rule prior to any targets?, gk, 2002/10/19
- Re: executing a rule prior to any targets?, Paul D. Smith, 2002/10/19
- Re: executing a rule prior to any targets?, gk, 2002/10/20
- Re: executing a rule prior to any targets?, Philip Guenther, 2002/10/20
- Recursive Make Considered Harmful (was: Re: executing a rule prior to any targets?), gk, 2002/10/20
- Re: Recursive Make Considered Harmful (was: Re: executing a rule prior to any targets?), Philip Guenther, 2002/10/20
- Re: Recursive Make Considered Harmful (was: Re: executing a rule prior to any targets?), gk, 2002/10/23
- Re: Recursive Make Considered Harmful (was: Re: executing a rule prior to any targets?), Philip Guenther, 2002/10/24
- Re: Recursive Make Considered Harmful (was: Re: executing a rule prior to any targets?), gk, 2002/10/24
- Re: Recursive Make Considered Harmful (was: Re: executing arule prior to any targets?),
Johan Bezem <=
- Re: Recursive Make Considered Harmful [Long Post], Johan Bezem, 2002/10/22
- Re: Recursive Make Considered Harmful [Long Post], gk, 2002/10/24
- Re: Recursive Make Considered Harmful, gk, 2002/10/25
- Re: executing a rule prior to any targets?, Paul D. Smith, 2002/10/20
- Re: executing a rule prior to any targets?, Paul D. Smith, 2002/10/20
- recursive make example (was: Re: executing a rule prior to any targets?), gk, 2002/10/23
- Re: recursive make example (was: Re: executing a rule prior to any targets?), Paul D. Smith, 2002/10/23