>   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


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

Reply via email to