configure: Check for and explicitly link against -latomic
authorMartin Willi <martin@strongswan.org>
Wed, 8 Jun 2016 12:46:35 +0000 (14:46 +0200)
committerMartin Willi <martin@strongswan.org>
Tue, 14 Jun 2016 12:27:20 +0000 (14:27 +0200)
Some C libraries, such as uClibc, require an explicit link for some atomic
functions. Check for any libatomic, and explcily link it.

13 files changed:
configure.ac
src/charon-cmd/Makefile.am
src/charon-nm/Makefile.am
src/charon-systemd/Makefile.am
src/charon/Makefile.am
src/conftest/Makefile.am
src/libcharon/Makefile.am
src/libfast/Makefile.am
src/libstrongswan/Makefile.am
src/libstrongswan/tests/Makefile.am
src/pki/Makefile.am
src/starter/Makefile.am
src/swanctl/Makefile.am

index daabdd7..278714d 100644 (file)
@@ -490,6 +490,11 @@ LIBS=$DLLIB
 AC_SEARCH_LIBS(pthread_create, pthread, [PTHREADLIB=$LIBS])
 AC_SUBST(PTHREADLIB)
 
+# uClibc requires explicit -latomic for __atomic_* operations
+LIBS=""
+AC_SEARCH_LIBS(__atomic_load, atomic, [ATOMICLIB=$LIBS])
+AC_SUBST(ATOMICLIB)
+
 LIBS=$saved_LIBS
 # ------------------------------------------------------
 
index 1f4033a..1d4bf70 100644 (file)
@@ -20,4 +20,4 @@ AM_CPPFLAGS = \
 charon_cmd_LDADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
        $(top_builddir)/src/libcharon/libcharon.la \
-       -lm $(PTHREADLIB) $(DLLIB)
+       -lm $(PTHREADLIB) $(ATOMICLIB) $(DLLIB)
index b6f0c8b..6ab7f27 100644 (file)
@@ -21,4 +21,4 @@ AM_CFLAGS = \
 charon_nm_LDADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
        $(top_builddir)/src/libcharon/libcharon.la \
-       -lm $(PTHREADLIB) $(DLLIB) ${nm_LIBS}
+       -lm $(PTHREADLIB) $(ATOMICLIB) $(DLLIB) ${nm_LIBS}
index 9942a36..6dd7e27 100644 (file)
@@ -14,4 +14,5 @@ charon_systemd_CPPFLAGS = \
 charon_systemd_LDADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
        $(top_builddir)/src/libcharon/libcharon.la \
-       $(systemd_LIBS) $(systemd_daemon_LIBS) $(systemd_journal_LIBS) -lm $(PTHREADLIB) $(DLLIB)
+       $(systemd_LIBS) $(systemd_daemon_LIBS) $(systemd_journal_LIBS) \
+       -lm $(PTHREADLIB) $(ATOMICLIB) $(DLLIB)
index c6a6f40..b78bbd7 100644 (file)
@@ -15,6 +15,6 @@ AM_CPPFLAGS = \
 charon_LDADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
        $(top_builddir)/src/libcharon/libcharon.la \
-       -lm $(PTHREADLIB) $(DLLIB)
+       -lm $(PTHREADLIB) $(ATOMICLIB) $(DLLIB)
 
 EXTRA_DIST = Android.mk
index 2d4e439..4e4e0be 100644 (file)
@@ -20,6 +20,6 @@ conftest_SOURCES = conftest.c conftest.h config.c config.h actions.c actions.h \
 conftest_LDADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
        $(top_builddir)/src/libcharon/libcharon.la \
-       -lm $(PTHREADLIB) $(DLLIB)
+       -lm $(PTHREADLIB) $(ATOMICLIB) $(DLLIB)
 
 EXTRA_DIST = README
index 9f07078..77e2dca 100644 (file)
@@ -159,7 +159,7 @@ AM_LDFLAGS = \
 
 libcharon_la_LIBADD = \
   $(top_builddir)/src/libstrongswan/libstrongswan.la \
-  -lm $(PTHREADLIB) $(DLLIB) $(SOCKLIB)
+  -lm $(PTHREADLIB) $(ATOMICLIB) $(DLLIB) $(SOCKLIB)
 
 if USE_WINDOWS
   libcharon_la_LIBADD += -lws2_32
index 48079c6..1a2da97 100644 (file)
@@ -22,4 +22,4 @@ endif
 
 libfast_la_LIBADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
-       -lfcgi $(clearsilver_LIBS) $(PTHREADLIB)
+       -lfcgi $(clearsilver_LIBS) $(PTHREADLIB) $(ATOMICLIB)
index 0bac61b..9be93f1 100644 (file)
@@ -120,7 +120,9 @@ endif
 
 library.lo :   $(top_builddir)/config.status
 
-libstrongswan_la_LIBADD = $(DLLIB) $(BTLIB) $(SOCKLIB) $(RTLIB) $(BFDLIB) $(UNWINDLIB)
+libstrongswan_la_LIBADD = \
+       $(DLLIB) $(ATOMICLIB)  $(BTLIB) $(SOCKLIB) \
+       $(RTLIB) $(BFDLIB) $(UNWINDLIB)
 
 AM_CPPFLAGS = \
        -I$(top_srcdir)/src/libstrongswan \
index b2d4560..caa9d3a 100644 (file)
@@ -12,7 +12,7 @@ libtest_la_CFLAGS = \
 libtest_la_LDFLAGS = @COVERAGE_LDFLAGS@
 libtest_la_LIBADD = \
   $(top_builddir)/src/libstrongswan/libstrongswan.la \
-  $(PTHREADLIB)
+  $(PTHREADLIB) $(ATOMICLIB)
 
 
 TESTS = tests
index 261e41c..1153794 100644 (file)
@@ -19,7 +19,7 @@ pki_SOURCES = pki.c pki.h command.c command.h \
 
 pki_LDADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
-       $(PTHREADLIB) $(DLLIB)
+       $(PTHREADLIB) $(ATOMICLIB) $(DLLIB)
 
 pki.o :        $(top_builddir)/config.status
 
index 8341ca3..787cec4 100644 (file)
@@ -34,7 +34,7 @@ starter_LDADD = \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
        $(top_builddir)/src/libcharon/libcharon.la \
        libstarter.la \
-       $(SOCKLIB) $(PTHREADLIB)
+       $(SOCKLIB) $(PTHREADLIB) $(ATOMICLIB)
 
 EXTRA_DIST = keywords.txt ipsec.conf Android.mk
 MAINTAINERCLEANFILES = keywords.c
index fb02714..37a0224 100644 (file)
@@ -27,7 +27,7 @@ swanctl_SOURCES = \
 swanctl_LDADD = \
        $(top_builddir)/src/libcharon/plugins/vici/libvici.la \
        $(top_builddir)/src/libstrongswan/libstrongswan.la \
-       $(PTHREADLIB) $(DLLIB)
+       $(PTHREADLIB) $(ATOMICLIB) $(DLLIB)
 
 swanctl.o :            $(top_builddir)/config.status