From 81de60e0aee91c3a8bed85f4c26428b9295b0d92 Mon Sep 17 00:00:00 2001 From: Daniel Cheng Date: Sun, 13 Jan 2019 23:33:10 -0800 Subject: [PATCH] Update global CFLAGS/CXXFLAGS/LIBS at the end of configure.ac Changes to CFLAGS/CXXFLAGS/LIBS affect following lines in configure.ac. As originally written, this would cause random libraries, such as libtorrent, to be linked into the autoconf test program. Occasionally, this would cause the things like the pkgconfig checks to fail with mysterious linker errors (e.g. rakshasa/rtorrent#156). Instead, only populate these global flags with the additional flags for dependencies at the very end, before the invocation of AC_OUTPUT. --- configure.ac | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index cf9bc47f..1d908588 100644 --- a/configure.ac +++ b/configure.ac @@ -42,10 +42,6 @@ PKG_CHECK_MODULES([LIBCURL], [libcurl], , [LIBCURL_CHECK_CONFIG]) PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"]) PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.13.7]) -LIBS="$PTHREAD_LIBS $CURSES_LIB $CPPUNIT_LIBS $LIBCURL $LIBCURL_LIBS $DEPENDENCIES_LIBS $LIBS" -CFLAGS="$CFLAGS $PTHREAD_CFLAGS $CPPUNIT_CFLAGS $LIBCURL_CPPFLAGS $LIBCURL_CFLAGS $DEPENDENCIES_CFLAGS $CURSES_CFLAGS" -CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS $CPPUNIT_CFLAGS $LIBCURL_CPPFLAGS $LIBCURL_CFLAGS $DEPENDENCIES_CFLAGS $CURSES_CFLAGS" - AC_LANG_PUSH(C++) TORRENT_WITH_XMLRPC_C AC_LANG_POP(C++) @@ -62,6 +58,12 @@ CC_ATTRIBUTE_UNUSED( AC_DEFINE([__UNUSED], [], [Null-wrapper if unused attribute is unsupported]) ) +dnl Only update global build variables immediately before generating the output, +dnl to avoid affecting the global build environment for other autoconf checks. +LIBS="$PTHREAD_LIBS $CURSES_LIB $CPPUNIT_LIBS $LIBCURL $LIBCURL_LIBS $DEPENDENCIES_LIBS $LIBS" +CFLAGS="$CFLAGS $PTHREAD_CFLAGS $CPPUNIT_CFLAGS $LIBCURL_CPPFLAGS $LIBCURL_CFLAGS $DEPENDENCIES_CFLAGS $CURSES_CFLAGS" +CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS $CPPUNIT_CFLAGS $LIBCURL_CPPFLAGS $LIBCURL_CFLAGS $DEPENDENCIES_CFLAGS $CURSES_CFLAGS" + AC_OUTPUT([ Makefile doc/Makefile