[PATCH] tests: Fix pthread linking error.

Ben Kibbey bjk at luxsci.net
Sun Nov 7 19:37:39 CET 2021


* m4/ax_pthread.m4: Add.
* configure.ac: Test for pthreads via AX_PTHREAD.
* tests/Makefile.am: Add @PTHREAD_LIBS@ and @PTHREAD_CFLAGS at .
* tests/gpg/Makefile.am: Ditto.

--

Fixes linking issue for Android on arm64 and possibly others.

Signed-off-by: Ben Kibbey <bjk at luxsci.net>
---
 configure.ac          |  1 +
 tests/Makefile.am     |  4 +++-
 tests/gpg/Makefile.am | 16 ++++++++++++----
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 296553e3..5f320312 100644
--- a/configure.ac
+++ b/configure.ac
@@ -142,6 +142,7 @@ int main (void) { return 0; }
 esac
 AC_SUBST([LDADD_FOR_TESTS_KLUDGE])
 
+AX_PTHREAD
 AH_VERBATIM([_REENTRANT],
 [/* To allow the use of GPGME in multithreaded programs we have to use
   special features from the library.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8950e965..e1727c8d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,8 +37,10 @@ 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 @GPG_ERROR_LIBS@ \
 		     @LDADD_FOR_TESTS_KLUDGE@
+run_threaded_CFLAGS = @PTHREAD_CFLAGS@
+run_threaded_LDFLAGS = @PTHREAD_LIBS@
 
 if RUN_GPG_TESTS
 gpgtests = gpg json
diff --git a/tests/gpg/Makefile.am b/tests/gpg/Makefile.am
index bab9dd9a..b53884a4 100644
--- a/tests/gpg/Makefile.am
+++ b/tests/gpg/Makefile.am
@@ -68,10 +68,18 @@ BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \
 AM_CPPFLAGS = -I$(top_builddir)/src @GPG_ERROR_CFLAGS@
 AM_LDFLAGS = -no-install
 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@
+t_thread1_LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
+t_thread1_CFLAGS = @PTHREAD_CFLAGS@
+t_thread1_LDFLAGS = @PTHREAD_LIBS@
+t_thread_keylist_LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
+t_thread_keylist_CFLAGS = @PTHREAD_CFLAGS@
+t_thread_keylist_LDFLAGS = @PTHREAD_LIBS@
+t_thread_keylist_verify_LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
+t_thread_keylist_verify_CFLAGS = @PTHREAD_CFLAGS@
+t_thread_keylist_verify_LDFLAGS = @PTHREAD_LIBS@
+t_cancel_LDADD = ../../src/libgpgme.la @LDADD_FOR_TESTS_KLUDGE@
+t_cancel_CFLAGS = @PTHREAD_CFLAGS@
+t_cancel_LDFLAGS = @PTHREAD_LIBS@
 
 # We don't run t-genkey and t-cancel in the test suite, because it
 # takes too long
-- 
2.33.0




More information about the Gnupg-devel mailing list