From ba4681ef1eafe6de3742e037da01c1e069777470 Mon Sep 17 00:00:00 2001 From: Jin^eLD Date: Sun, 23 Mar 2014 01:23:36 +0100 Subject: [PATCH 1/2] Fix shared/static settings when building vs. NaCl library Make sure the shared lib build is really disabled when compiling vs. NaCl: moved settings before libtool initialization fixed parameter name --- configure.ac | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 896e586a..df026990 100644 --- a/configure.ac +++ b/configure.ac @@ -207,6 +207,11 @@ AC_ARG_WITH(libsodium-libs, ] ) +if test "x$WANT_NACL" = "xyes"; then + enable_shared=no + enable_static=yes +fi + # Checks for programs. AC_PROG_CC AM_PROG_CC_C_O @@ -214,12 +219,6 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL -if test "x$WANT_NACL" = "xyes"; then - disable_shared=yes - enable_static=yes -fi - - WIN32=no AC_CANONICAL_HOST case $host_os in From 70475d281dacb742e807c78a7f0fc951d85044a3 Mon Sep 17 00:00:00 2001 From: Jin^eLD Date: Sun, 23 Mar 2014 02:01:45 +0100 Subject: [PATCH 2/2] Fix NaCl builds for *BSD From what I see there is a difference between *BSD and Linux when linking vs. toxcore which has been bulit vs. the NaCl library: on Linux it only links if NaCl's object files (i.e. randombytes.o) is present in the linker options, however on *BSD systems this will cause a linking error, see: https://github.com/Tox/toxic/issues/31#issuecomment-38224441 This commit makes sure that we do not add the NaCl object files to our pkg-config settings on *BSD, but do add them on Linux. --- configure.ac | 13 +++++++++++-- libtoxcore.pc.in | 2 +- other/Makefile.inc | 1 + testing/Makefile.inc | 6 ++++++ toxcore/Makefile.inc | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index df026990..e97da02e 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,7 @@ NCURSES_FOUND="no" LIBCONFIG_FOUND="no" LIBCHECK_FOUND="no" WANT_NACL="no" +ADD_NACL_OBJECTS_TO_PKGCONFIG="yes" TOXCORE_LT_LDFLAGS="-version-info $LIBTOXCORE_LT_VERSION" TOXAV_LT_LDFLAGS="-version-info $LIBTOXAV_LT_VERSION" @@ -233,6 +234,7 @@ case $host_os in LDFLAGS="$LDFLAGS -L/usr/local/lib" CFLAGS="$CFLAGS -I/usr/local/include" CPPFLAGS="$CPPFLAGS -I/usr/local/include" + ADD_NACL_OBJECTS_TO_PKGCONFIG="no" ;; esac AM_CONDITIONAL(WIN32, test "x$WIN32" = "xyes") @@ -244,6 +246,8 @@ AC_SUBST(EXTRA_LT_LDFLAGS) if test "x$WANT_NACL" = "xyes"; then NACL_LIBS= NACL_LDFLAGS= + NACL_OBJECTS= + NACL_OBJECTS_PKGCONFIG= LDFLAGS_SAVE="$LDFLAGS" if test -n "$NACL_SEARCH_LIBS"; then LDFLAGS="-L$NACL_SEARCH_LIBS $LDFLAGS" @@ -267,14 +271,19 @@ if test "x$WANT_NACL" = "xyes"; then if (test -f "$NACL_SEARCH_LIBS/cpucycles.o") && (test -f "$NACL_SEARCH_LIBS/randombytes.o"); then - NACL_LIBS="$NACL_LIBS $NACL_SEARCH_LIBS/cpucycles.o $NACL_SEARCH_LIBS/randombytes.o" + NACL_OBJECTS="$NACL_SEARCH_LIBS/cpucycles.o $NACL_SEARCH_LIBS/randombytes.o" + if test "x$ADD_NACL_OBJECTS_TO_PKGCONFIG" = "xyes"; then + NACL_OBJECTS_PKGCONFIG="$NACL_OBJECTS" + fi else - AC_MSG_ERROR([nacl weirdness: required object files cpucycles.o randombytes.o not found]) + AC_MSG_ERROR([required NaCl object files cpucycles.o randombytes.o not found, please specify their location using the --with-nacl-libs parameter]) fi LDFLAGS="$LDFLAGS_SAVE" AC_SUBST(NACL_LIBS) AC_SUBST(NACL_LDFLAGS) + AC_SUBST(NACL_OBJECTS) + AC_SUBST(NACL_OBJECTS_PKGCONFIG) else LIBSODIUM_LIBS= LIBSODIUM_LDFLAGS= diff --git a/libtoxcore.pc.in b/libtoxcore.pc.in index 1e2b9365..57d3f8ef 100644 --- a/libtoxcore.pc.in +++ b/libtoxcore.pc.in @@ -7,5 +7,5 @@ Name: libtoxcore Description: Tox protocol library Requires: Version: @PACKAGE_VERSION@ -Libs: -L${libdir} @NACL_LDFLAGS@ -ltoxcore @NACL_LIBS@ @LIBS@ +Libs: @NACL_OBJECTS_PKGCONFIG@ -L${libdir} @NACL_LDFLAGS@ -ltoxcore @NACL_LIBS@ @LIBS@ Cflags: -I${includedir} diff --git a/other/Makefile.inc b/other/Makefile.inc index 72a514ad..368a32f2 100644 --- a/other/Makefile.inc +++ b/other/Makefile.inc @@ -12,6 +12,7 @@ DHT_bootstrap_LDADD = $(LIBSODIUM_LDFLAGS) \ $(NACL_LDFLAGS) \ libtoxcore.la \ $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NACL_LIBS) \ $(WINSOCK2_LIBS) diff --git a/testing/Makefile.inc b/testing/Makefile.inc index 31c84678..812a5be1 100644 --- a/testing/Makefile.inc +++ b/testing/Makefile.inc @@ -36,6 +36,7 @@ DHT_test_LDADD = $(LIBSODIUM_LDFLAGS) \ $(NACL_LDFLAGS) \ libtoxcore.la \ $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NACL_LIBS) \ $(WINSOCK2_LIBS) @@ -52,6 +53,7 @@ Lossless_UDP_testclient_LDADD = \ $(NACL_LDFLAGS) \ libtoxcore.la \ $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NACL_LIBS) \ $(WINSOCK2_LIBS) @@ -68,6 +70,7 @@ Lossless_UDP_testserver_LDADD = \ $(NACL_LDFLAGS) \ libtoxcore.la \ $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NACL_LIBS) \ $(WINSOCK2_LIBS) @@ -82,6 +85,7 @@ Messenger_test_LDADD = $(LIBSODIUM_LDFLAGS) \ $(NACL_LDFLAGS) \ libtoxcore.la \ $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NACL_LIBS) \ $(WINSOCK2_LIBS) @@ -98,6 +102,7 @@ crypto_speed_test_LDADD = \ $(NACL_LDFLAGS) \ libtoxcore.la \ $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NACL_LIBS) \ $(WINSOCK2_LIBS) @@ -114,6 +119,7 @@ tox_sync_LDADD = $(LIBSODIUM_LDFLAGS) \ $(NACL_LDFLAGS) \ libtoxcore.la \ $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NACL_LIBS) \ $(WINSOCK2_LIBS) endif diff --git a/toxcore/Makefile.inc b/toxcore/Makefile.inc index 867ad9e4..8912965e 100644 --- a/toxcore/Makefile.inc +++ b/toxcore/Makefile.inc @@ -49,4 +49,5 @@ libtoxcore_la_LDFLAGS = $(TOXCORE_LT_LDFLAGS) \ $(WINSOCK2_LIBS) libtoxcore_la_LIBADD = $(LIBSODIUM_LIBS) \ + $(NACL_OBJECTS) \ $(NAC_LIBS)