Re: Make with another make as a prerequisite

[email protected]
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <[email protected]>
On Mar 1, 10:45 am, [email protected] wrote:

> Hi.  Say I've got a library of code that I actively maintain in ~/
> libdir and some code that depends on the library in ~/codedir.  If I
> make a change in ~/libdir but do not run make there, I'd like to be
> able to check that when building things in ~/codedir, and make the
> library in ~/libdir and the targets in ~/codedir that depend on the
> library.

I think I've found a simple enough solution to this problem.  First I
run a shell command that makes the library, and then I create a target
with no commands for the library.  (This turns off any implicit rules
for the library, and is described in section 5.9 "Empty Commands" in
the GNU make manual.  I don't want the codedir makefile to worry about
anything involved in making the library.)  Targets in codedir's
makefile list the library target in their prerequisites.  codedir/
makefile looks something like:

dummy = $(shell make -C ../libdir)

mycode: mylib.a mycode.o

mylib.a: ;

The assignment to dummy updates mylib.a if it is needed.  And this
will in turn cause mycode to be updated.  If the assignment to dummy
doesn't update anything, then mycode will depend solely on the
remaining prerequisites.

Thanks for listening!

- Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.