[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, 6 Aug 2006 17:52:20 +0200 |
User-agent: |
KMail/1.9.1 |
> mw> Paul's solution isn't quite enough
>
> You didn't quote it, but IIRC my solution was to use order-only
> prerequisites for this, right?
Yes.
> mw> - you'd need two passes of 'make' with that (because after
> mw> building eg. foo/libfoo.a, the prerequisite-check for 'toplevel'
> mw> has already been done, so 'toplevel' would not be updated, unless
> mw> you'd run 'make' a second time). With this two-stage approach
> mw> above, everything is working as it should.
>
> Hm. Interesting.
>
> It seems to me like it would make sense for GNU make to always build all
> order-only prerequisites first, before any of the "normal"
> prerequisites.
>
> Would that be good enough? Or am I forgetting something?
It would probably be an improvement. However, I can imagine situations where
it's not enough. What I'd really like is to have full control over the which
prerequisites are to be satisfied in what order.
This could be done if this:
MODULES := foo bar
MODULE_LIBS := $(patsubst %,-l%,$(MODULES))
MODULE_DIRS := $(patsubst %,-L%,$(MODULES))
vpath %.a $(MODULES)
toplevel: main.o | $(MODULES)
toplevel: liblinux1.a liblinux2.a | selectplatform
$(CC) -o $@ main.o $(MODULE_DIRS) $(MODULE_LIBS) -L. -lplatform
# Need fully built $(MODULES) for these.
liblinux1.a:
touch $@
liblinux2.a:
touch $@
.PHONY: selectplatform
selectplatform:
# Somehow determine which platform library to use.
ln -s liblinux2.a libplatform.a
.PHONY: $(MODULES)
$(MODULES):
$(MAKE) -C $@
did what I'd intuitively expect, that is, build main.o and $(MODULES) first,
and only then build the platform libs and after that create the symlink. This
example (which admittedly is a little bit contrived) wouldn't be possible if
order-only prerequisites were always built first.
Is this feasible?
--
Martin