From ecdcf551737c390e4b98316754c23b37d4ad8ad4 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 14 Jan 2019 21:53:12 +0000 Subject: [PATCH] Add -pthread to pkgconfig's Libs.private if enabled Allows static builds to correctly inherit the pthread dependency when used with pkg-config --static --libs libsodium AC_SUBST doesn't require explicit values Regen autoconf Fixes #800 --- Makefile.in | 5 +- builds/Makefile.in | 1 + configure | 78 ++++++++++++++++++++++++++++++- configure.ac | 5 +- contrib/Makefile.in | 1 + dist-build/Makefile.in | 1 + libsodium-uninstalled.pc.in | 1 + libsodium.pc.in | 1 + msvc-scripts/Makefile.in | 1 + src/Makefile.in | 1 + src/libsodium/Makefile.in | 1 + src/libsodium/include/Makefile.in | 1 + test/Makefile.in | 1 + test/default/Makefile.in | 1 + 14 files changed, 96 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 9d48fe27..034a35a3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -207,7 +207,9 @@ am__DIST_COMMON = $(srcdir)/Makefile.in \ $(top_srcdir)/src/libsodium/include/sodium/version.h.in \ AUTHORS ChangeLog THANKS build-aux/compile \ build-aux/config.guess build-aux/config.sub \ - build-aux/install-sh build-aux/ltmain.sh build-aux/missing + build-aux/install-sh build-aux/ltmain.sh build-aux/missing \ + compile config.guess config.sub depcomp install-sh ltmain.sh \ + missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) @@ -336,6 +338,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/builds/Makefile.in b/builds/Makefile.in index a140757b..ea45ecb1 100644 --- a/builds/Makefile.in +++ b/builds/Makefile.in @@ -214,6 +214,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/configure b/configure index 0d59f16b..ce9205ab 100755 --- a/configure +++ b/configure @@ -704,6 +704,7 @@ VALGRIND_ENABLED VALGRIND_ENABLED_FALSE VALGRIND_ENABLED_TRUE VALGRIND +PKGCONFIG_LIBS_PRIVATE SAFECODE_HOME PTHREAD_CFLAGS PTHREAD_LIBS @@ -3275,7 +3276,7 @@ fi SODIUM_LIBRARY_VERSION_MAJOR=10 SODIUM_LIBRARY_VERSION_MINOR=2 -DLL_VERSION=8 +DLL_VERSION=23 SODIUM_LIBRARY_VERSION=25:0:2 # | | | # +------+ | +---+ @@ -3295,6 +3296,7 @@ SODIUM_LIBRARY_VERSION=25:0:2 LX_CFLAGS=${CFLAGS-NONE} +PKGCONFIG_LIBS_PRIVATE="" if pwd | fgrep ' ' > /dev/null 2>&1; then : @@ -5463,6 +5465,7 @@ $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h with_threads="yes" LIBS="$PTHREAD_LIBS $LIBS" + PKGCONFIG_LIBS_PRIVATE="$PTHREAD_LIBS $PTHREAD_CFLAGS $PKGCONFIG_LIBS_PRIVATE" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC" : @@ -5745,6 +5748,78 @@ else : fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -ftree-vectorize" >&5 +$as_echo_n "checking whether C compiler accepts -ftree-vectorize... " >&6; } +if ${ax_cv_check_cflags___ftree_vectorize+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -ftree-vectorize" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ax_cv_check_cflags___ftree_vectorize=yes +else + ax_cv_check_cflags___ftree_vectorize=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___ftree_vectorize" >&5 +$as_echo "$ax_cv_check_cflags___ftree_vectorize" >&6; } +if test "x$ax_cv_check_cflags___ftree_vectorize" = xyes; then : + CFLAGS="$CFLAGS -ftree-vectorize" +else + : +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -ftree-slp-vectorize" >&5 +$as_echo_n "checking whether C compiler accepts -ftree-slp-vectorize... " >&6; } +if ${ax_cv_check_cflags___ftree_slp_vectorize+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -ftree-slp-vectorize" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ax_cv_check_cflags___ftree_slp_vectorize=yes +else + ax_cv_check_cflags___ftree_slp_vectorize=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS=$ax_check_save_flags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___ftree_slp_vectorize" >&5 +$as_echo "$ax_cv_check_cflags___ftree_slp_vectorize" >&6; } +if test "x$ax_cv_check_cflags___ftree_slp_vectorize" = xyes; then : + CFLAGS="$CFLAGS -ftree-slp-vectorize" +else + : +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fomit-frame-pointer" >&5 $as_echo_n "checking whether C compiler accepts -fomit-frame-pointer... " >&6; } if ${ax_cv_check_cflags___fomit_frame_pointer+:} false; then : @@ -5826,6 +5901,7 @@ fi + # Check whether --enable-valgrind was given. if test "${enable_valgrind+set}" = set; then : enableval=$enable_valgrind; enable_valgrind=$enableval diff --git a/configure.ac b/configure.ac index 28eeb5dd..02619d4a 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,7 @@ AC_SUBST(DLL_VERSION) AC_LANG_ASSERT(C) LX_CFLAGS=${CFLAGS-NONE} +PKGCONFIG_LIBS_PRIVATE="" dnl Path check @@ -127,6 +128,7 @@ AS_IF([test "x$withval" = "xyes"], [ AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files]) with_threads="yes" LIBS="$PTHREAD_LIBS $LIBS" + PKGCONFIG_LIBS_PRIVATE="$PTHREAD_LIBS $PTHREAD_CFLAGS $PKGCONFIG_LIBS_PRIVATE" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC"]) ], [with_threads="no"]) @@ -192,7 +194,8 @@ AC_ARG_ENABLE(opt, ]) ]) -AC_SUBST([MAINT]) +AC_SUBST(MAINT) +AC_SUBST(PKGCONFIG_LIBS_PRIVATE) AX_VALGRIND_CHECK diff --git a/contrib/Makefile.in b/contrib/Makefile.in index 0ee01446..08ce51d5 100644 --- a/contrib/Makefile.in +++ b/contrib/Makefile.in @@ -214,6 +214,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/dist-build/Makefile.in b/dist-build/Makefile.in index 881c44fa..052987b6 100644 --- a/dist-build/Makefile.in +++ b/dist-build/Makefile.in @@ -214,6 +214,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/libsodium-uninstalled.pc.in b/libsodium-uninstalled.pc.in index 3d502308..068a9c6b 100644 --- a/libsodium-uninstalled.pc.in +++ b/libsodium-uninstalled.pc.in @@ -3,4 +3,5 @@ Version: @PACKAGE_VERSION@ Description: A modern and easy-to-use crypto library Libs: -L${pcfiledir}/src/libsodium -lsodium +Libs.private: @PKGCONFIG_LIBS_PRIVATE@ Cflags: -I${pcfiledir}/src/libsodium/include -I@top_srcdir@/src/libsodium/include -I@top_srcdir@/src/libsodium/include/sodium diff --git a/libsodium.pc.in b/libsodium.pc.in index 19b3c1af..6c2b43aa 100644 --- a/libsodium.pc.in +++ b/libsodium.pc.in @@ -8,4 +8,5 @@ Version: @PACKAGE_VERSION@ Description: A modern and easy-to-use crypto library Libs: -L${libdir} -lsodium +Libs.private: @PKGCONFIG_LIBS_PRIVATE@ Cflags: -I${includedir} diff --git a/msvc-scripts/Makefile.in b/msvc-scripts/Makefile.in index f1f08897..210acdf7 100644 --- a/msvc-scripts/Makefile.in +++ b/msvc-scripts/Makefile.in @@ -214,6 +214,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/src/Makefile.in b/src/Makefile.in index a4d6091e..d243b0df 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -274,6 +274,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/src/libsodium/Makefile.in b/src/libsodium/Makefile.in index c4884aa6..d19d385b 100644 --- a/src/libsodium/Makefile.in +++ b/src/libsodium/Makefile.in @@ -834,6 +834,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/src/libsodium/include/Makefile.in b/src/libsodium/include/Makefile.in index e7a87234..f6e421b6 100644 --- a/src/libsodium/include/Makefile.in +++ b/src/libsodium/include/Makefile.in @@ -306,6 +306,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/test/Makefile.in b/test/Makefile.in index 4fcf9de3..803acc6c 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -274,6 +274,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ diff --git a/test/default/Makefile.in b/test/default/Makefile.in index 4b4f3628..4c5027e7 100644 --- a/test/default/Makefile.in +++ b/test/default/Makefile.in @@ -804,6 +804,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PKGCONFIG_LIBS_PRIVATE = @PKGCONFIG_LIBS_PRIVATE@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@