> [...]
> However, this re-links toplevel on each invokation of "make",
> even if no files have been changed at all.
> [...]

I poked into this a little more some time ago, and this is what I'm using now:

------------- Top-Level Makefile ------------------------------
MODULES := foo bar

MODULE_LIBS := $(patsubst %,-l%,$(MODULES))
MODULE_DIRS := $(patsubst %,-L%,$(MODULES))

vpath %.a $(MODULES)

.PHONY: all
all: $(MODULES) toplevel

toplevel: main.o $(MODULE_LIBS)
        $(CC) -o $@ main.o $(MODULE_DIRS) $(MODULE_LIBS)

.PHONY: $(MODULES)
$(MODULES):
        $(MAKE) -C $@
---------------------------------------------------------------

Paul's solution isn't quite enough - you'd need two passes of 'make' with that 
(because after building eg. foo/libfoo.a, the prerequisite-check 
for 'toplevel' has already been done, so 'toplevel' would not be updated, 
unless you'd run 'make' a second time).
With this two-stage approach above, everything is working as it should.

-- 
 Martin


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to