diff mbox series

[v4,2/20] m4: move openssl check to common place

Message ID 1507316415-2144-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v4,1/20] .gitignore: ignore only libtool m4 files | expand

Commit Message

Github ODP bot Oct. 6, 2017, 6:59 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 213 (lumag:plat-def)
 ** https://github.com/Linaro/odp/pull/213
 ** Patch: https://github.com/Linaro/odp/pull/213.patch
 ** Base sha: a63f25ff2994b2df78c24f1f8b63d0e06628eb68
 ** Merge commit sha: d50e2e291ff11c1319e66c699d2f82260d59c383
 **/
 m4/odp_openssl.m4                        | 60 ++++++++++++++++++++++++++++++++
 platform/linux-generic/m4/configure.m4   |  2 +-
 platform/linux-generic/m4/odp_openssl.m4 | 37 --------------------
 3 files changed, 61 insertions(+), 38 deletions(-)
 create mode 100644 m4/odp_openssl.m4
 delete mode 100644 platform/linux-generic/m4/odp_openssl.m4
diff mbox series

Patch

diff --git a/m4/odp_openssl.m4 b/m4/odp_openssl.m4
new file mode 100644
index 000000000..72568a8ae
--- /dev/null
+++ b/m4/odp_openssl.m4
@@ -0,0 +1,60 @@ 
+# ODP_OPENSSL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -----------------------------------------------------
+AC_DEFUN([ODP_OPENSSL],
+[dnl
+AC_ARG_VAR([OPENSSL_CPPFLAGS], [C preprocessor flags for OpenSSL])
+AC_ARG_VAR([OPENSSL_LIBS], [linker flags for OpenSSL crypto library])
+AC_ARG_VAR([OPENSSL_STATIC_LIBS], [static linker flags for OpenSSL crypto library])
+
+##########################################################################
+# Set optional OpenSSL path
+##########################################################################
+AC_ARG_WITH([openssl-path],
+[AC_HELP_STRING([--with-openssl-path=DIR],
+	       [path to openssl libs and headers (use system path if not provided)])],
+[OPENSSL_CPPFLAGS="-I$withval/include"
+OPENSSL_LIBS="-L$withval/lib -lcrypto"],
+[if test "x$ac_cv_env_OPENSSL_LIBS_set" != "xset" ; then
+       OPENSSL_LIBS="-lcrypto"
+fi])
+if test "x$ac_cv_env_OPENSSL_STATIC_LIBS_set" != "xset" ; then
+       OPENSSL_STATIC_LIBS="$OPENSSL_LIBS -ldl"
+fi
+
+##########################################################################
+# Save and set temporary compilation flags
+##########################################################################
+OLD_CPPFLAGS=$CPPFLAGS
+OLD_LIBS=$LIBS
+CPPFLAGS="$OPENSSL_CPPFLAGS $CPPFLAGS"
+LIBS="$OPENSSL_LIBS $LIBS"
+
+##########################################################################
+# Check for OpenSSL availability
+##########################################################################
+odp_openssl_ok=yes
+AC_CHECK_HEADERS([openssl/des.h openssl/rand.h openssl/hmac.h openssl/evp.h], [],
+		 [odp_openssl_ok=no])
+AC_CACHE_CHECK([for EVP_EncryptInit in -lcrypto], [odp_cv_openssl_crypto],
+[AC_LINK_IFELSE([AC_LANG_CALL([], [EVP_EncryptInit])],
+	       [odp_cv_openssl_crypto=yes],
+	       [odp_cv_openssl_crypto=no])])
+if test "x$odp_cv_openssl_crypto" != "xyes" ; then
+	odp_openssl_ok=no
+fi
+
+if test "x$odp_openssl_ok" = "xyes" ; then
+	m4_default([$1], [:])
+else
+	OPENSSL_CPPFLAGS=""
+	OPENSSL_LIBS=""
+	OPENSSL_STATIC_LIBS=""
+	m4_default([$2], [AC_MSG_FAILURE([OpenSSL not found])])
+fi
+
+##########################################################################
+# Restore old saved variables
+##########################################################################
+LIBS=$OLD_LIBS
+CPPFLAGS=$OLD_CPPFLAGS
+]) # ODP_OPENSSL
diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4
index 8e008de44..63540c7eb 100644
--- a/platform/linux-generic/m4/configure.m4
+++ b/platform/linux-generic/m4/configure.m4
@@ -76,7 +76,7 @@  AC_SUBST([ATOMIC_LIBS])
 
 m4_include([platform/linux-generic/m4/odp_pthread.m4])
 m4_include([platform/linux-generic/m4/odp_timer.m4])
-m4_include([platform/linux-generic/m4/odp_openssl.m4])
+ODP_OPENSSL
 m4_include([platform/linux-generic/m4/odp_pcap.m4])
 m4_include([platform/linux-generic/m4/odp_netmap.m4])
 m4_include([platform/linux-generic/m4/odp_dpdk.m4])
diff --git a/platform/linux-generic/m4/odp_openssl.m4 b/platform/linux-generic/m4/odp_openssl.m4
deleted file mode 100644
index 1d520077c..000000000
--- a/platform/linux-generic/m4/odp_openssl.m4
+++ /dev/null
@@ -1,37 +0,0 @@ 
-##########################################################################
-# Set optional OpenSSL path
-##########################################################################
-AC_ARG_WITH([openssl-path],
-AC_HELP_STRING([--with-openssl-path=DIR path to openssl libs and headers],
-               [(or in the default path if not specified).]),
-    [OPENSSL_PATH=$withval
-    OPENSSL_CPPFLAGS="-I$OPENSSL_PATH/include"
-    OPENSSL_LIBS="-L$OPENSSL_PATH/lib"
-    ],[])
-
-##########################################################################
-# Save and set temporary compilation flags
-##########################################################################
-OLD_LDFLAGS=$LDFLAGS
-OLD_CPPFLAGS=$CPPFLAGS
-LIBS="$OPENSSL_LIBS $LIBS"
-CPPFLAGS="$OPENSSL_CPPFLAGS $CPPFLAGS"
-
-##########################################################################
-# Check for OpenSSL availability
-##########################################################################
-AC_CHECK_LIB([crypto], [EVP_EncryptInit], [OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto"
-					   OPENSSL_STATIC_LIBS="$OPENSSL_LIBS -ldl"],
-             [AC_MSG_FAILURE([OpenSSL libraries required])])
-AC_CHECK_HEADERS([openssl/des.h openssl/rand.h openssl/hmac.h openssl/evp.h], [],
-             [AC_MSG_ERROR([OpenSSL headers required])])
-
-AC_SUBST([OPENSSL_CPPFLAGS])
-AC_SUBST([OPENSSL_LIBS])
-AC_SUBST([OPENSSL_STATIC_LIBS])
-
-##########################################################################
-# Restore old saved variables
-##########################################################################
-LIBS=$OLD_LIBS
-CPPFLAGS=$OLD_CPPFLAGS