help-make
[Top][All Lists]
Advanced

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

Re: Using "-l" libraries as targets


From: Paul Smith
Subject: Re: Using "-l" libraries as targets
Date: Mon, 01 Jun 2015 13:33:48 -0400

We prefer inline posting to top-posting, on the mailing lists.

On Mon, 2015-06-01 at 13:11 +0000, address@hidden wrote:
> It’s probably a very nice case, but having a prerequisite
> like “-lfoo” that matches a “libfoo.a” target would be useful for
> decoupling say one makefile with the rule “main.exe: -lfoo” and
> another in subdir “foo” that has “libfoo.a: libfoo.a(foo/foo.o)”. The
> only change needed to have make choose between building the lib and
> searching for it would be whether to “include foo/Makefile” / add “-f
> foo/Makefile” when invoking make.

The problem is, "-lfoo" is ambiguous.  What if you wanted to build
"libfoo.so", not "libfoo.a"?  Or some other type of library?

In order to have this work, as I mentioned before, make would have to
treat this kind of like a pattern where it tries each of the different
kinds of libraries in turn to see if there's some rule that can be used
to build them.

I think it's better to just always use "libfoo.a" as a prerequisite, if
that's what you want.  It's easy enough to use patsubst in the recipe to
convert them to -l options, if you want:

   $(LINK.cc) -o $@ $(patsubst lib%.a,-l%,$^)





reply via email to

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