On Wed, Oct 21, 2009 at 11:46:32AM -0200, Gerhard Fiedler wrote:
> Hello,
>
> I have a problem with the link prerequisites in a recursive make.
>
> Basically, I have a list of directories that are all phony targets and
> that each contain a makefile that builds a static library. The library
> is built into a sub-directory of that makefile directory.
>
> This all works nicely, including automatic dependency generation. Due to
> the directories being phony targets, the sub-makes are always run
> through, and that's ok for this.
>
> My problem is with the linking. The final executable needs to be linked
> when it is not there (of course) or whenever it is older than any of the
> libraries created by the phony targets.
>
> I made the library files prerequisites of the final executable, but this
> doesn't seem to do the trick.
You need to tell make that the static libraries are prerequisites
of the directories.
Something like this:
dirs := foo/ bar/
libs := $(addsuffix lib.a, $(dirs))
program: $(libs)
ld $(libs) -o $@
# This is where you tell make that the libs depend on the dirs so make
# will revisit timestamps of the libs files
$(libs): $(dirs) ;
.PHONY: $(dirs)
$(dirs):
$(MAKE) -c $@
Not tested - but I hope you get the idea.
Sam
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make