[Top][All Lists]

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

Re: .PHONY targets and prerequisite checking

From: Martin Willers
Subject: Re: .PHONY targets and prerequisite checking
Date: Sun, 30 Jul 2006 17:43:39 +0200
User-agent: KMail/1.9.1

> [...]
> 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)

        $(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.


reply via email to

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