Pattern grouping in .LIBPATTERNS

Boris Kolpackov <[email protected]>
Newsgroups gmane.comp.gnu.make.devel
Organization Code Synthesis Tools CC
Message-ID <[email protected]>
Paul, all,

Today I ran into an annoying discrepancy in behavior between make and 
ld when it comes to searching for libraries specified as -lfoo. The
linker searches for libfoo.so and libfoo.a in each directory specified
with -L. GNU make first searches for libfoo.so in each directory specified
with vpath/VPATH and then does the same for libfoo.a.

In my case I have libfoo.so in /usr/lib and libfoo.a in /tmp/lib. I want
to link to the static version and specified /tmp/lib in vpath. But no
matter what I do, make picks /usr/lib/libfoo.so.

There doesn't seem to be a way to resolve this short of removing lib%.so
from .LIBPATTERNS which is too pervasive. I don't know if anyone relies
on the current behavior but I think it would be too risky to change it
(thought it would be "the right thing to do", IMO).

So I would like to implement the pattern grouping feature for .LIBPATTERNS.
For example:

.LIBPATTERNS := (lib%.so lib%.a)

This would result in the ld-compatible behavior. That is, patterns
specified in parenthesis are searched at once as each directory is
considered.

Anyone sees any problems with this?

Boris

-- 
Boris Kolpackov, Code Synthesis        http://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli
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.