build: With LD_LIBRARY_PATH defined, use --disable-new-dtags.
authorNIIBE Yutaka <gniibe@fsij.org>
Wed, 16 Jan 2019 01:59:25 +0000 (10:59 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Wed, 16 Jan 2019 01:59:25 +0000 (10:59 +0900)
* configure.ac (LDADD_FOR_TESTS_KLUDGE): New for --disable-new-dtags.
* tests/Makefile.am (LDADD): Use LDADD_FOR_TESTS_KLUDGE.
* lang/cpp/tests/Makefile.am, lang/qt/tests/Makefile.am: Likewise.
* tests/gpg/Makefile.am, tests/gpgsm/Makefile.am: Likewise.
* tests/json/Makefile.am, tests/opassuan/Makefile.am: Likewise.

--

GnuPG-bug-id: 4298
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
configure.ac
lang/cpp/tests/Makefile.am
lang/qt/tests/Makefile.am
tests/Makefile.am
tests/gpg/Makefile.am
tests/gpgsm/Makefile.am
tests/json/Makefile.am
tests/opassuan/Makefile.am

index ff37794..e59a2f8 100644 (file)
@@ -105,6 +105,41 @@ AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
 # Enable GNU extensions on systems that have them.
 AC_GNU_SOURCE
 
+# Taken from mpfr-4.0.1, then modified for LDADD_FOR_TESTS_KLUDGE
+dnl Under Linux, make sure that the old dtags are used if LD_LIBRARY_PATH
+dnl is defined. The issue is that with the new dtags, LD_LIBRARY_PATH has
+dnl the precedence over the run path, so that if a compatible MPFR library
+dnl is installed in some directory from $LD_LIBRARY_PATH, then the tested
+dnl MPFR library will be this library instead of the MPFR library from the
+dnl build tree. Other OS with the same issue might be added later.
+dnl
+dnl References:
+dnl   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=859732
+dnl   http://lists.gnu.org/archive/html/libtool/2017-05/msg00000.html
+dnl
+dnl We need to check whether --disable-new-dtags is supported as alternate
+dnl linkers may be used (e.g., with tcc: CC=tcc LD=tcc).
+dnl
+case $host in
+  *-*-linux*)
+    if test -n "$LD_LIBRARY_PATH"; then
+      saved_LDFLAGS="$LDFLAGS"
+      LDADD_FOR_TESTS_KLUDGE="-Wl,--disable-new-dtags"
+      LDFLAGS="$LDFLAGS $LDADD_FOR_TESTS_KLUDGE"
+      AC_MSG_CHECKING(whether --disable-new-dtags is supported by the linker)
+      AC_LINK_IFELSE([AC_LANG_SOURCE([[
+int main (void) { return 0; }
+      ]])],
+      [AC_MSG_RESULT(yes (use it since LD_LIBRARY_PATH is set))],
+      [AC_MSG_RESULT(no)
+       LDADD_FOR_TESTS_KLUDGE=""
+      ])
+      LDFLAGS="$saved_LDFLAGS"
+    fi
+    ;;
+esac
+AC_SUBST([LDADD_FOR_TESTS_KLUDGE])
+
 AH_VERBATIM([_REENTRANT],
 [/* To allow the use of GPGME in multithreaded programs we have to use
   special features from the library.
index 67dd3d3..0b27595 100644 (file)
@@ -22,7 +22,7 @@ AM_LDFLAGS = -no-install
 
 LDADD = ../../cpp/src/libgpgmepp.la \
         ../../../src/libgpgme.la @GPG_ERROR_LIBS@ \
-        -lstdc++
+        @LDADD_FOR_TESTS_KLUDGE@ -lstdc++
 
 AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \
               @GPG_ERROR_CFLAGS@ @GPG_ERROR_CFLAGS@ \
index 6d54340..f75d64c 100644 (file)
@@ -37,7 +37,7 @@ AM_LDFLAGS = -no-install
 
 LDADD = ../../cpp/src/libgpgmepp.la ../src/libqgpgme.la \
         ../../../src/libgpgme.la @GPGME_QT_LIBS@ @GPG_ERROR_LIBS@ \
-        @GPGME_QTTEST_LIBS@ -lstdc++
+        @GPGME_QTTEST_LIBS@ @LDADD_FOR_TESTS_KLUDGE@ -lstdc++
 
 AM_CPPFLAGS = -I$(top_srcdir)/lang/cpp/src -I$(top_builddir)/src \
               @GPG_ERROR_CFLAGS@ @GPGME_QT_CFLAGS@ @GPG_ERROR_CFLAGS@ \
index 8faa05a..8950e96 100644 (file)
@@ -29,7 +29,7 @@ EXTRA_DIST = start-stop-agent t-data-1.txt t-data-2.txt ChangeLog-2011
 
 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
 AM_LDFLAGS = -no-install
-LDADD = ../src/libgpgme.la @GPG_ERROR_LIBS@
+LDADD = ../src/libgpgme.la @GPG_ERROR_LIBS@ @LDADD_FOR_TESTS_KLUDGE@
 
 noinst_HEADERS = run-support.h
 
@@ -37,7 +37,8 @@ noinst_PROGRAMS = $(TESTS) run-keylist run-export run-import run-sign \
                  run-verify run-encrypt run-identify run-decrypt run-genkey \
                  run-keysign run-tofu run-swdb run-threaded
 
-run_threaded_LDADD = ../src/libgpgme.la -lpthread @GPG_ERROR_LIBS@
+run_threaded_LDADD = ../src/libgpgme.la -lpthread @GPG_ERROR_LIBS@ \
+                    @LDADD_FOR_TESTS_KLUDGE@
 
 if RUN_GPG_TESTS
 gpgtests = gpg json
index b8d1516..be84290 100644 (file)
@@ -65,11 +65,11 @@ BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \
            gpg-sample.stamp
 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
 AM_LDFLAGS = -no-install
-LDADD = ../../src/libgpgme.la
-t_thread1_LDADD = ../../src/libgpgme.la -lpthread
-t_thread_keylist_LDADD = ../../src/libgpgme.la -lpthread
-t_thread_keylist_verify_LDADD = ../../src/libgpgme.la -lpthread
-t_cancel_LDADD = ../../src/libgpgme.la -lpthread
+LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
+t_thread1_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@
+t_thread_keylist_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@
+t_thread_keylist_verify_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@
+t_cancel_LDADD = ../../src/libgpgme.la -lpthread @LDADD_FOR_TESTS_KLUDGE@
 
 # We don't run t-genkey and t-cancel in the test suite, because it
 # takes too long
index 3706840..63de747 100644 (file)
@@ -38,7 +38,7 @@ EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \
 
 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
 AM_LDFLAGS = -no-install
-LDADD = ../../src/libgpgme.la
+LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
 
 # We don't run t-genkey in the test suite, because it takes too long
 # and needs a working pinentry.
index f4db840..9b2cf71 100644 (file)
@@ -67,8 +67,9 @@ BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \
            gpg-sample.stamp
 t_json_SOURCES = t-json.c
 AM_LDFLAGS = -no-install
-LDADD = ../../src/libgpgme.la
-t_json_LDADD = ../../src/cJSON.o -lm ../../src/libgpgme.la @GPG_ERROR_LIBS@
+LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
+t_json_LDADD = ../../src/cJSON.o -lm ../../src/libgpgme.la @GPG_ERROR_LIBS@ \
+              @LDADD_FOR_TESTS_KLUDGE@
 
 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
 
index 47686eb..b62751d 100644 (file)
@@ -27,7 +27,7 @@ TESTS =
 EXTRA_DIST =
 
 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
-LDADD = ../../src/libgpgme.la
+LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
 
 noinst_PROGRAMS = $(TESTS) t-command