Fix link order for --as-needed (see http://bugs.debian.org/711958)

In Ubuntu, the attached patch was applied to achieve the following:

  * as-needed.patch: Fix object/library link order for --as-needed.

When building with --as-needed, libraries need to be listed on the
link line after the objects that reference them.  In the autotools
world (and elsewhere), the LDFLAGS variable has been split into
LDFLAGS and LDADD to represent the need to list libs last.  This
patch makes that change to your Makefile, so this builds correctly
with --as-needed in LDFLAGS.
This commit is contained in:
Daniel Kahn Gillmor
2013-06-11 10:13:25 -04:00
parent 337581c040
commit c818885733

View File

@@ -53,7 +53,8 @@ INSTALL ?= install
PREFIX ?= /usr/local
CFLAGS += -std=gnu99 -Wall -DFAKE_STAT -DFAKE_INTERNAL_CALLS -fPIC -DPOSIX_REALTIME -DLIMITEDFAKING -DSPAWNSUPPORT
LDFLAGS += -shared -ldl -lm -lpthread
LDFLAGS += -shared
LDADD += -ldl -lm -lpthread
SRC = faketime.c
OBJ = faketime.o faketimeMT.o
@@ -69,7 +70,7 @@ ${OBJ}: faketime.c
${CC} -o $@ -c ${CFLAGS} ${EXTRA_FLAGS} $<
lib%.so.${SONAME}: %.o
${CC} -o $@ -Wl,-soname,$@ $< ${LDFLAGS}
${CC} -o $@ -Wl,-soname,$@ ${LDFLAGS} $< ${LDADD}
clean:
@rm -f ${OBJ} ${LIBS}