build: put libraries in LDADD, not LDFLAGS

Automake linking looks like this (I'm simplifying a bit):

    $(CC) $(foo_CFLAGS) $(foo_LDFLAGS) -ofoo $(objects) $(foo_LDADD)

The correct order is that if a library A is used to satisfy the symbol
requirements of an object or library B, then A must come after B on the
link line. Otherwise, static linking or linking with -Wl,--as-needed
will fail. As a result, libraries and the -L options used to locate them
should always be in LDADD (for executables) or LIBADD (for libraries),
never in LDFLAGS.

Ubuntu's linker defaults to the equivalent of -Wl,--as-needed, so
this causes failure to build on Ubuntu, which can be reproduced with

    ./autogen.sh CC="gcc -Wl,--as-needed" && make

on other distributions.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #75
Approved by: alexlarsson
This commit is contained in:
Simon McVittie
2016-06-09 08:40:16 +01:00
committed by Atomic Bot
parent 6ad6c24bf3
commit f6ca369012

View File

@@ -10,4 +10,4 @@ bwrap_SOURCES = \
$(NULL)
bwrap_CFLAGS = $(AM_CFLAGS)
bwrap_LDFLAGS = $(SELINUX_LIBS)
bwrap_LDADD = $(SELINUX_LIBS)