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

On Mon, 2015-06-01 at 13:11 +0000, lukeallard...@gmail.com 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%,$^)



_______________________________________________
Help-make mailing list
Help-make@gnu.org
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to