Commit c59670db authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #1782 from minrk/configure-with-tweetnacl

fallback on tweetnacl if libsodium is not found and not explicitly requested
parents 135c4112 e8665079
......@@ -274,6 +274,15 @@ src_libzmq_la_CPPFLAGS += ${sodium_CFLAGS}
src_libzmq_la_LIBADD += ${sodium_LIBS}
endif
if USE_TWEETNACL
src_libzmq_la_SOURCES += \
tweetnacl/src/tweetnacl.c \
tweetnacl/contrib/randombytes/devurandom.c
src_libzmq_la_CXXFLAGS += \
-I$(top_builddir)/tweetnacl/contrib/randombytes \
-I$(top_builddir)/tweetnacl/src
endif
if HAVE_PGM
src_libzmq_la_CPPFLAGS += ${pgm_CFLAGS}
src_libzmq_la_LIBADD += ${pgm_LIBS}
......
......@@ -427,13 +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
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
......@@ -446,10 +467,13 @@ if test "x$have_sodium_library" != "xno"; then
CPPFLAGS="$CPPFLAGS -Wno-long-long"
;;
esac
elif test "x$with_tweetnacl" != "xno"; then
AC_DEFINE(HAVE_LIBSODIUM, 1, [Sodium is provided by tweetnacl.])
AC_DEFINE(HAVE_TWEETNACL, 1, [Using tweetnacl.])
fi
AM_CONDITIONAL(HAVE_SODIUM, test "x$have_sodium_library" != "xno")
AM_CONDITIONAL(USE_TWEETNACL, test "x$with_tweetnacl" != "xno")
# build using pgm
have_pgm_library="no"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment