From 16ee3bc890cedc1d26a84db458ba788ecb28533d Mon Sep 17 00:00:00 2001 From: Wouter Verhelst Date: Sun, 30 Apr 2017 19:10:27 +0200 Subject: [PATCH 1/2] Search for tcmalloc with AC_CHECK_LIB Currently we just unconditionally add it to LDFLAGS, without checking whether it even exists. That creates confusing error messages down the line. Instead, use AC_CHECK_LIB to see whether the library is there, and provide a proper error message if not. This should fix OpenLightingProject/ola#1201. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b3f30aa0ef..6e4efdb960 100644 --- a/configure.ac +++ b/configure.ac @@ -693,7 +693,7 @@ AS_IF([test "x$enable_root_check" = xno], # Use tcmalloc. This is used by the buildbot leak checks. AC_ARG_ENABLE([tcmalloc], AS_HELP_STRING([--enable-tcmalloc], [Use tcmalloc])) AS_IF([test "x$enable_tcmalloc" = xyes], - [LDFLAGS="$LDFLAGS -ltcmalloc"]) + [AC_CHECK_LIB([tcmalloc], [malloc], [LDFLAGS="$LDFLAGS -ltcmalloc"], [AS_ERROR([tcmalloc not found, but enabled on command line])])]) # Optionally set the Doxygen version to "Latest Git" for website latest # version. From 2584446266df010a9923a7ec1e98a54b7047c3c3 Mon Sep 17 00:00:00 2001 From: Wouter Verhelst Date: Sun, 30 Apr 2017 19:16:39 +0200 Subject: [PATCH 2/2] Stop messing with LDFLAGS, use AM_LDFLAGS instead Automake defines LDFLAGS (and CFLAGS, and a number of other variables) as user variables (i.e., reserved for the user, not for the build system), and provides AM_* alternatives for the build system to mangle instead. The advantage of this is that the user can mangle those variables by running "make LDFLAGS=-lfoo" without having to fiddle with configure, and without losing whatever flags the configure run added. In addition, since doing "LDFLAGS=-lfoo ./configure" is also supported, LDFLAGS is captured at AC_OUTPUT time, and therefore should not be directly mangled by the configure script; otherwise a user might try to do something which will break the build. We do so anyway, which might cause things to break in some corner cases. Fix this misbehaviour by setting AM_LDFLAGS rather than LDLFLAGS, and AC_SUBST'ing it into the build system at the end of the configure run. --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 6e4efdb960..e01d980500 100644 --- a/configure.ac +++ b/configure.ac @@ -693,7 +693,7 @@ AS_IF([test "x$enable_root_check" = xno], # Use tcmalloc. This is used by the buildbot leak checks. AC_ARG_ENABLE([tcmalloc], AS_HELP_STRING([--enable-tcmalloc], [Use tcmalloc])) AS_IF([test "x$enable_tcmalloc" = xyes], - [AC_CHECK_LIB([tcmalloc], [malloc], [LDFLAGS="$LDFLAGS -ltcmalloc"], [AS_ERROR([tcmalloc not found, but enabled on command line])])]) + [AC_CHECK_LIB([tcmalloc], [malloc], [AM_LDFLAGS="$AM_LDFLAGS -ltcmalloc"], [AS_ERROR([tcmalloc not found, but enabled on command line])])]) # Optionally set the Doxygen version to "Latest Git" for website latest # version. @@ -892,6 +892,7 @@ AC_CONFIG_FILES([include/ola/base/Version.h ]) # Makefiles AC_CONFIG_FILES([Makefile java/Makefile]) +AC_SUBST(AM_LDFLAGS) AC_OUTPUT echo \ @@ -900,7 +901,7 @@ ${PACKAGE_NAME} Version ${PACKAGE_VERSION} Prefix: '${prefix}' Compiler: '${CXX} ${CXXFLAGS} ${CPPFLAGS}' -Linker: '${LD} ${LDFLAGS} ${LIBS}' +Linker: '${LD} ${AM_LDFLAGS} ${LIBS}' Python: ${PYTHON} Python API: ${enable_python_libs}