fallback on tweetnacl if libsodium is not found and not explicitly requested

This commit is contained in:
Min RK 2016-02-08 11:58:30 +01:00
parent 2902fd60b9
commit e86650794f

View File

@ -427,19 +427,34 @@ fi
have_sodium_library="no"
AC_ARG_WITH([libsodium], [AS_HELP_STRING([--with-libsodium],
[require libzmq build with libsodium crypto library. Requires pkg-config [default=yes]])],
[require libzmq build with libsodium crypto library. Requires pkg-config [default=check]])],
[require_libsodium_ext=$withval],
[require_libsodium_ext=yes])
[require_libsodium_ext=check])
AC_ARG_WITH([tweetnacl], [AS_HELP_STRING([--with-tweetnacl],
[build libzmq with bundled tweetnacl crypto library [default=no]])],
[require_libsodium_ext=no
with_tweetnacl=yes],
[with_tweetnacl=no])
with_tweetnacl=yes
AC_MSG_CHECKING(for sodium)
AC_MSG_RESULT(tweetnacl)],
[with_tweetnacl=check])
# conditionally require libsodium package
if test "x$require_libsodium_ext" != "xno"; then
PKG_CHECK_MODULES([sodium], [libsodium], [have_sodium_library="yes"])
PKG_CHECK_MODULES([sodium], [libsodium],
[
have_sodium_library=yes
with_tweetnacl=no
],
[
if test "x$require_libsodium_ext" == "xyes"; then
AC_MSG_ERROR(libsodium has been requested but not found)
else
AC_MSG_RESULT([ libsodium not found, using tweetnacl])
have_sodium_library=no
with_tweetnacl=yes
fi
])
fi
if test "x$have_sodium_library" != "xno"; then
@ -453,7 +468,6 @@ if test "x$have_sodium_library" != "xno"; then
;;
esac
elif test "x$with_tweetnacl" != "xno"; then
echo "using tweetnacl"
AC_DEFINE(HAVE_LIBSODIUM, 1, [Sodium is provided by tweetnacl.])
AC_DEFINE(HAVE_TWEETNACL, 1, [Using tweetnacl.])
fi