Use AC_CHECK_LIB for ssl and crypto
diff --git a/Makefile.am b/Makefile.am
index 1f0302b..0983f68 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,12 +61,12 @@
ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/udp-transport.h ndn-cpp/transport/udp-transport.cpp ndn-cpp/transport/udp-transport.hpp
bin_test_encode_decode_interest_SOURCES = tests/test-encode-decode-interest.cpp
-bin_test_encode_decode_interest_LDADD = $(OPENSSL_LIBS) libndn-cpp.la libndn-c.la
+bin_test_encode_decode_interest_LDADD = libndn-cpp.la libndn-c.la
bin_test_encode_decode_data_SOURCES = tests/test-encode-decode-data.cpp
-bin_test_encode_decode_data_LDADD = $(OPENSSL_LIBS) libndn-cpp.la libndn-c.la
+bin_test_encode_decode_data_LDADD = libndn-cpp.la libndn-c.la
bin_test_get_async_SOURCES = tests/test-get-async.cpp
-bin_test_get_async_LDADD = $(OPENSSL_LIBS) libndn-cpp.la libndn-c.la
+bin_test_get_async_LDADD = libndn-cpp.la libndn-c.la
dist_noinst_SCRIPTS = autogen.sh
diff --git a/Makefile.in b/Makefile.in
index 5c9df2a..249a344 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -166,19 +166,16 @@
tests/test-encode-decode-data.$(OBJEXT)
bin_test_encode_decode_data_OBJECTS = \
$(am_bin_test_encode_decode_data_OBJECTS)
-am__DEPENDENCIES_1 =
-bin_test_encode_decode_data_DEPENDENCIES = $(am__DEPENDENCIES_1) \
- libndn-cpp.la libndn-c.la
+bin_test_encode_decode_data_DEPENDENCIES = libndn-cpp.la libndn-c.la
am_bin_test_encode_decode_interest_OBJECTS = \
tests/test-encode-decode-interest.$(OBJEXT)
bin_test_encode_decode_interest_OBJECTS = \
$(am_bin_test_encode_decode_interest_OBJECTS)
-bin_test_encode_decode_interest_DEPENDENCIES = $(am__DEPENDENCIES_1) \
- libndn-cpp.la libndn-c.la
+bin_test_encode_decode_interest_DEPENDENCIES = libndn-cpp.la \
+ libndn-c.la
am_bin_test_get_async_OBJECTS = tests/test-get-async.$(OBJEXT)
bin_test_get_async_OBJECTS = $(am_bin_test_get_async_OBJECTS)
-bin_test_get_async_DEPENDENCIES = $(am__DEPENDENCIES_1) libndn-cpp.la \
- libndn-c.la
+bin_test_get_async_DEPENDENCIES = libndn-cpp.la libndn-c.la
SCRIPTS = $(dist_noinst_SCRIPTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -360,9 +357,6 @@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
-OPENSSL_INCLUDES = @OPENSSL_INCLUDES@
-OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@
-OPENSSL_LIBS = @OPENSSL_LIBS@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
@@ -373,7 +367,6 @@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
-PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -508,11 +501,11 @@
ndn-cpp/c/transport/socket-transport.h ndn-cpp/c/transport/udp-transport.h ndn-cpp/transport/udp-transport.cpp ndn-cpp/transport/udp-transport.hpp
bin_test_encode_decode_interest_SOURCES = tests/test-encode-decode-interest.cpp
-bin_test_encode_decode_interest_LDADD = $(OPENSSL_LIBS) libndn-cpp.la libndn-c.la
+bin_test_encode_decode_interest_LDADD = libndn-cpp.la libndn-c.la
bin_test_encode_decode_data_SOURCES = tests/test-encode-decode-data.cpp
-bin_test_encode_decode_data_LDADD = $(OPENSSL_LIBS) libndn-cpp.la libndn-c.la
+bin_test_encode_decode_data_LDADD = libndn-cpp.la libndn-c.la
bin_test_get_async_SOURCES = tests/test-get-async.cpp
-bin_test_get_async_LDADD = $(OPENSSL_LIBS) libndn-cpp.la libndn-c.la
+bin_test_get_async_LDADD = libndn-cpp.la libndn-c.la
dist_noinst_SCRIPTS = autogen.sh
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
diff --git a/config.h.in b/config.h.in
index eec5492..b91c0cf 100644
--- a/config.h.in
+++ b/config.h.in
@@ -12,6 +12,12 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
+/* Define to 1 if you have the `crypto' library (-lcrypto). */
+#undef HAVE_LIBCRYPTO
+
+/* Define to 1 if you have the `ssl' library (-lssl). */
+#undef HAVE_LIBSSL
+
/* 1 if have memcmp in memory.h. */
#undef HAVE_MEMCMP
diff --git a/configure b/configure
index d786058..4a4e0e9 100755
--- a/configure
+++ b/configure
@@ -678,10 +678,6 @@
DX_DOCDIR
DX_CONFIG
DX_PROJECT
-OPENSSL_LDFLAGS
-OPENSSL_LIBS
-OPENSSL_INCLUDES
-PKG_CONFIG
HAVE_CXX11
CXXCPP
am__fastdepCXX_FALSE
@@ -818,7 +814,6 @@
with_gnu_ld
with_sysroot
enable_libtool_lock
-with_openssl
enable_doxygen_doc
enable_doxygen_dot
enable_doxygen_man
@@ -1496,7 +1491,6 @@
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
- --with-openssl=DIR root of the OpenSSL directory
Some influential environment variables:
CC C compiler command
@@ -15516,156 +15510,105 @@
fi
-
- found=false
-
-# Check whether --with-openssl was given.
-if test "${with_openssl+set}" = set; then :
- withval=$with_openssl;
- case "$withval" in
- "" | y | ye | yes | n | no)
- as_fn_error $? "Invalid --with-openssl value" "$LINENO" 5
- ;;
- *) ssldirs="$withval"
- ;;
- esac
-
-else
-
- # if pkg-config is installed and openssl has installed a .pc file,
- # then use that information and don't search ssldirs
- # Extract the first word of "pkg-config", so it can be a program name with args.
-set dummy pkg-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_PKG_CONFIG+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5
+$as_echo_n "checking for SSL_library_init in -lssl... " >&6; }
+if ${ac_cv_lib_ssl_SSL_library_init+:} false; then :
$as_echo_n "(cached) " >&6
else
- case $PKG_CONFIG in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-fi
-PKG_CONFIG=$ac_cv_path_PKG_CONFIG
-if test -n "$PKG_CONFIG"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
-$as_echo "$PKG_CONFIG" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- if test x"$PKG_CONFIG" != x""; then
- OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
- if test $? = 0; then
- OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
- OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
- found=true
- fi
- fi
-
- # no such luck; use some default ssldirs
- if ! $found; then
- ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
- fi
-
-
-fi
-
-
-
- # note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
- # an 'openssl' subdirectory
-
- if ! $found; then
- OPENSSL_INCLUDES=
- for ssldir in $ssldirs; do
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl/ssl.h in $ssldir" >&5
-$as_echo_n "checking for openssl/ssl.h in $ssldir... " >&6; }
- if test -f "$ssldir/include/openssl/ssl.h"; then
- OPENSSL_INCLUDES="-I$ssldir/include"
- OPENSSL_LDFLAGS="-L$ssldir/lib"
- OPENSSL_LIBS="-lssl -lcrypto"
- found=true
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- break
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- fi
- done
-
- # if the file wasn't found, well, go ahead and try the link anyway -- maybe
- # it will just work!
- fi
-
- # try the preprocessor and linker with our new flags,
- # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling and linking against OpenSSL works" >&5
-$as_echo_n "checking whether compiling and linking against OpenSSL works... " >&6; }
- echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
- "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&5
-
- save_LIBS="$LIBS"
- save_LDFLAGS="$LDFLAGS"
- save_CPPFLAGS="$CPPFLAGS"
- LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
- LIBS="$OPENSSL_LIBS $LIBS"
- CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lssl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include <openssl/ssl.h>
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char SSL_library_init ();
int
main ()
{
-SSL_new(NULL)
+return SSL_library_init ();
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-
-
+ ac_cv_lib_ssl_SSL_library_init=yes
else
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-
+ ac_cv_lib_ssl_SSL_library_init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5
+$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; }
+if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBSSL 1
+_ACEOF
+ LIBS="-lssl $LIBS"
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "can't find openssl ssl lib
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_EncryptInit in -lcrypto" >&5
+$as_echo_n "checking for EVP_EncryptInit in -lcrypto... " >&6; }
+if ${ac_cv_lib_crypto_EVP_EncryptInit+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char EVP_EncryptInit ();
+int
+main ()
+{
+return EVP_EncryptInit ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ ac_cv_lib_crypto_EVP_EncryptInit=yes
+else
+ ac_cv_lib_crypto_EVP_EncryptInit=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_EncryptInit" >&5
+$as_echo "$ac_cv_lib_crypto_EVP_EncryptInit" >&6; }
+if test "x$ac_cv_lib_crypto_EVP_EncryptInit" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBCRYPTO 1
+_ACEOF
+
+ LIBS="-lcrypto $LIBS"
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "can't find openssl crypto lib
+See \`config.log' for more details" "$LINENO" 5; }
+fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for std::shared_ptr" >&5
diff --git a/configure.ac b/configure.ac
index 4bcfd0f..5cfd9ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,10 @@
AC_LANG([C++])
AX_CXX_COMPILE_STDCXX_11(, optional)
-AX_CHECK_OPENSSL
+AC_CHECK_LIB([ssl], [SSL_library_init], [],
+ [AC_MSG_FAILURE([can't find openssl ssl lib])])
+AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
+ [AC_MSG_FAILURE([can't find openssl crypto lib])])
AC_MSG_CHECKING([for std::shared_ptr])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(