# binaries_expand_loadlibes.mk # $Id: binaries_expand_loadlibes.mk,v 1.6 1999/08/26 20:43:29 russo Exp $ # # This is a subroutine of binaries.mk. # # Make has a feature in that given a dependency like `-lX', it will # automatically search for a file like `libX.a'. This is convenient, # but it doesn't go far enough -- sometimes a library is supplied # only as a dso, with extension .so or some such. The library search # behavior in make won't find this. # # It would be nice to have make be able to find such files directly. # (And probably not very difficult; cf. library_search() in remake.c.) # But we probably shouldn't rely on such a change until it's widespread. # So i'm going to do the expansion myself. # # This builds LOADLIBES_DEP from LOADLIBES. Fasten seatbelts! # # scott snyder, jan 1999; adapted from d0_util. # # # First, construct a list of paths to search for libraries. # Use the list of paths in LDFLAGS, and add /usr/lib and /lib. # LOADLIBES_PATH := $(patsubst -L%,%,$(filter -L%,$(LDFLAGS))) /usr/lib /lib # # The expander. # Pick the first of # - A libX.a file on the path. # - A libX.so file on the path. # - The unexpanded name. # expand_libe = $(firstword $(strip\ $(wildcard $(addsuffix\ $(firstword\ $(patsubst -l%,/lib%.a,$(filter -l%,$(l)))\ _xyzzy),\ $(LOADLIBES_PATH)))\ $(wildcard $(addsuffix\ $(firstword\ $(patsubst -l%,/lib%.so,$(filter -l%,$(l)))\ _xyzzy),\ $(LOADLIBES_PATH)))\ $(l))) # # Run all elements of LOADLIBES through the expansion. # Remove NT-style .lib libraries from the list. # LOADLIBES_DEP := $(foreach l,$(filter-out %.lib,$(LOADLIBES)),$(expand_libe))