[Top][All Lists]

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

Recursive make and linking

From: Gerhard Fiedler
Subject: Recursive make and linking
Date: Wed, 21 Oct 2009 11:46:32 -0200
User-agent: 40tude_Dialog/


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. It seems that this dependency is checked
at the beginning of the make run, and at this time, the libraries are
still older than the executable. However, after the phony directory
targets are all run through, possibly one or more libraries are now
newer than the executable. 

As it is, I need to run make twice. The first time, it'll run through
all the sub-makes and build whatever library needs to be built, but it
won't link. The second time, it'll again run through all the sub-makes,
but since their libs are all up to date, it won't build any of them --
but it will link, apparently because now make sees the updated libraries
at startup and recognizes that the link target needs to be rebuilt.

It seems that I need to somehow delay the prerequisite checking for the
link rule until after the sub-makes have run. Is there a way to do this?
I tried to make the (phony) directory targets dependent on the library
files they create, but this didn't help. 

Thanks for any help.


reply via email to

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