Use _LDADD to specify libraries instead of _LDFLAGS

This is because _LDFLAGS comes before _LDADD.  If we specify a library
and another library in _LDADD depends on it, we get undefined
reference error.
This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-25 00:58:30 +09:00
parent 682db00ba9
commit fbd9bcb00e
4 changed files with 19 additions and 31 deletions

View File

@ -236,7 +236,7 @@ AC_LANG_POP()
# Checks for libraries. # Checks for libraries.
# Additional libraries required for tests. # Additional libraries required for tests.
TESTLDFLAGS= TESTLDADD=
# Additional libraries required for programs under src directory. # Additional libraries required for programs under src directory.
APPLDFLAGS= APPLDFLAGS=
@ -245,7 +245,7 @@ LIBS_OLD=$LIBS
# Search for dlsym function, which is used in tests. Linux needs -ldl, # Search for dlsym function, which is used in tests. Linux needs -ldl,
# but netbsd does not need it. # but netbsd does not need it.
AC_SEARCH_LIBS([dlsym], [dl]) AC_SEARCH_LIBS([dlsym], [dl])
TESTLDFLAGS="$LIBS $TESTLDFLAGS" TESTLDADD="$LIBS $TESTLDADD"
LIBS=$LIBS_OLD LIBS=$LIBS_OLD
LIBS_OLD=$LIBS LIBS_OLD=$LIBS
@ -636,7 +636,7 @@ if test "x$threads" != "xyes" ||
AC_DEFINE([NOTHREADS], [1], [Define to 1 if you want to disable threads.]) AC_DEFINE([NOTHREADS], [1], [Define to 1 if you want to disable threads.])
fi fi
AC_SUBST([TESTLDFLAGS]) AC_SUBST([TESTLDADD])
AC_SUBST([APPLDFLAGS]) AC_SUBST([APPLDFLAGS])
AC_CONFIG_FILES([ AC_CONFIG_FILES([

View File

@ -33,12 +33,10 @@ AM_CPPFLAGS = \
@LIBEVENT_OPENSSL_CFLAGS@ \ @LIBEVENT_OPENSSL_CFLAGS@ \
@OPENSSL_CFLAGS@ \ @OPENSSL_CFLAGS@ \
@DEFS@ @DEFS@
AM_LDFLAGS = \ LDADD = $(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/third-party/libhttp-parser.la \
@LIBEVENT_OPENSSL_LIBS@ \ @LIBEVENT_OPENSSL_LIBS@ \
@OPENSSL_LIBS@ @OPENSSL_LIBS@
LDADD = \
$(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/third-party/libhttp-parser.la
noinst_PROGRAMS = client libevent-client libevent-server deflate noinst_PROGRAMS = client libevent-client libevent-server deflate
@ -63,22 +61,18 @@ if ENABLE_ASIO_LIB
noinst_PROGRAMS += asio-sv asio-sv2 asio-sv3 noinst_PROGRAMS += asio-sv asio-sv2 asio-sv3
ASIOCPPFLAGS = ${BOOST_CPPFLAGS} ${AM_CPPFLAGS} ASIOCPPFLAGS = ${BOOST_CPPFLAGS} ${AM_CPPFLAGS}
ASIOLDFLAGS = @JEMALLOC_LIBS@ ASIOLDADD = $(top_builddir)/src/libnghttp2_asio.la @JEMALLOC_LIBS@
ASIOLDADD = $(top_builddir)/src/libnghttp2_asio.la
asio_sv_SOURCES = asio-sv.cc asio_sv_SOURCES = asio-sv.cc
asio_sv_CPPFLAGS = ${ASIOCPPFLAGS} asio_sv_CPPFLAGS = ${ASIOCPPFLAGS}
asio_sv_LDFLAGS = ${ASIOLDFLAGS}
asio_sv_LDADD = ${ASIOLDADD} asio_sv_LDADD = ${ASIOLDADD}
asio_sv2_SOURCES = asio-sv2.cc asio_sv2_SOURCES = asio-sv2.cc
asio_sv2_CPPFLAGS = ${ASIOCPPFLAGS} asio_sv2_CPPFLAGS = ${ASIOCPPFLAGS}
asio_sv2_LDFLAGS = ${ASIOLDFLAGS}
asio_sv2_LDADD = ${ASIOLDADD} asio_sv2_LDADD = ${ASIOLDADD}
asio_sv3_SOURCES = asio-sv3.cc asio_sv3_SOURCES = asio-sv3.cc
asio_sv3_CPPFLAGS = ${ASIOCPPFLAGS} asio_sv3_CPPFLAGS = ${ASIOCPPFLAGS}
asio_sv3_LDFLAGS = ${ASIOLDFLAGS}
asio_sv3_LDADD = ${ASIOLDADD} asio_sv3_LDADD = ${ASIOLDADD}
endif # ENABLE_ASIO_LIB endif # ENABLE_ASIO_LIB

View File

@ -41,7 +41,9 @@ AM_CPPFLAGS = \
@JANSSON_CFLAGS@ \ @JANSSON_CFLAGS@ \
@ZLIB_CFLAGS@ \ @ZLIB_CFLAGS@ \
@DEFS@ @DEFS@
AM_LDFLAGS = \
LDADD = $(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/third-party/libhttp-parser.la \
@JEMALLOC_LIBS@ \ @JEMALLOC_LIBS@ \
@LIBSPDYLAY_LIBS@ \ @LIBSPDYLAY_LIBS@ \
@XML_LIBS@ \ @XML_LIBS@ \
@ -51,10 +53,6 @@ AM_LDFLAGS = \
@ZLIB_LIBS@ \ @ZLIB_LIBS@ \
@APPLDFLAGS@ @APPLDFLAGS@
LDADD = \
$(top_builddir)/lib/libnghttp2.la \
$(top_builddir)/third-party/libhttp-parser.la
if ENABLE_APP if ENABLE_APP
bin_PROGRAMS += nghttp nghttpd nghttpx bin_PROGRAMS += nghttp nghttpd nghttpx
@ -131,8 +129,7 @@ noinst_LIBRARIES = libnghttpx.a
libnghttpx_a_SOURCES = ${NGHTTPX_SRCS} libnghttpx_a_SOURCES = ${NGHTTPX_SRCS}
nghttpx_SOURCES = shrpx.cc shrpx.h nghttpx_SOURCES = shrpx.cc shrpx.h
nghttpx_LDFLAGS = nghttpx_LDADD = libnghttpx.a ${LDADD}
nghttpx_LDADD = libnghttpx.a ${LDADD} ${AM_LDFLAGS}
if HAVE_CUNIT if HAVE_CUNIT
check_PROGRAMS += nghttpx-unittest check_PROGRAMS += nghttpx-unittest
@ -148,9 +145,7 @@ nghttpx_unittest_SOURCES = shrpx-unittest.cc \
memchunk_test.cc memchunk_test.h memchunk_test.cc memchunk_test.h
nghttpx_unittest_CPPFLAGS = ${AM_CPPFLAGS}\ nghttpx_unittest_CPPFLAGS = ${AM_CPPFLAGS}\
-DNGHTTP2_TESTS_DIR=\"$(top_srcdir)/tests\" -DNGHTTP2_TESTS_DIR=\"$(top_srcdir)/tests\"
nghttpx_unittest_LDFLAGS = ${AM_LDFLAGS} \ nghttpx_unittest_LDADD = libnghttpx.a ${LDADD} @CUNIT_LIBS@ @TESTLDADD@
@CUNIT_LIBS@ @TESTLDFLAGS@
nghttpx_unittest_LDADD = libnghttpx.a ${LDADD}
TESTS += nghttpx-unittest TESTS += nghttpx-unittest
endif # HAVE_CUNIT endif # HAVE_CUNIT
@ -187,14 +182,13 @@ libnghttp2_asio_la_SOURCES = \
ssl.cc ssl.h ssl.cc ssl.h
libnghttp2_asio_la_CPPFLAGS = ${AM_CPPFLAGS} ${BOOST_CPPFLAGS} libnghttp2_asio_la_CPPFLAGS = ${AM_CPPFLAGS} ${BOOST_CPPFLAGS}
libnghttp2_asio_la_LDFLAGS = \ libnghttp2_asio_la_LDFLAGS = -no-undefined -version-info 0:0:0
libnghttp2_asio_la_LIBADD = \
$(top_builddir)/lib/libnghttp2.la \
${BOOST_LDFLAGS} \ ${BOOST_LDFLAGS} \
${BOOST_ASIO_LIB} \ ${BOOST_ASIO_LIB} \
${BOOST_THREAD_LIB} \ ${BOOST_THREAD_LIB} \
${BOOST_SYSTEM_LIB} \ ${BOOST_SYSTEM_LIB} \
@OPENSSL_LIBS@ \ @OPENSSL_LIBS@
-no-undefined \
-version-info 0:0:0
libnghttp2_asio_la_LIBADD = $(top_builddir)/lib/libnghttp2.la
endif # ENABLE_ASIO_LIB endif # ENABLE_ASIO_LIB

View File

@ -49,8 +49,8 @@ HFILES = nghttp2_pq_test.h nghttp2_map_test.h nghttp2_queue_test.h \
main_SOURCES = $(HFILES) $(OBJECTS) main_SOURCES = $(HFILES) $(OBJECTS)
main_LDADD = ${top_builddir}/lib/libnghttp2.la main_LDADD = ${top_builddir}/lib/libnghttp2.la @CUNIT_LIBS@ @TESTLDADD@
main_LDFLAGS = -static @CUNIT_LIBS@ @TESTLDFLAGS@ main_LDFLAGS = -static
if ENABLE_FAILMALLOC if ENABLE_FAILMALLOC
failmalloc_SOURCES = failmalloc.c failmalloc_test.c failmalloc_test.h \ failmalloc_SOURCES = failmalloc.c failmalloc_test.c failmalloc_test.h \