diff mbox

[PATCHv2,2/4] configure: cleanup OpenSSL configuration

Message ID 1417300979-6248-3-git-send-email-anders.roxell@linaro.org
State Accepted
Commit 6bc2edcb08f72f182872604b8ed121c830e734e7
Headers show

Commit Message

Anders Roxell Nov. 29, 2014, 10:42 p.m. UTC
Configure's AC_CHECK_LIBS (using internal compilation checks) doesn't use
AM_*FLAGS, therefore we need to temporarily add these to *FLAGS when running the
checks when we try to compile against packages that are not in default search
paths (--with-*-path=).
We need to reset these temporary settings to not clobber users manually set
*FLAGS when the check is complete.

Always check OpenSSL dependency

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 configure.ac | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 3752f3d..acd0060 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,21 +126,37 @@  if test -z "$DOXYGEN";
 fi
 
 ##########################################################################
-# Check for openssl availability
+# 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
-AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include"
-AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib -lcrypto"
-],[
+    [OPENSSL_PATH=$withval
+    AM_CFLAGS="$AM_CFLAGS -I$OPENSSL_PATH/include"
+    AM_LDFLAGS="$AM_LDFLAGS -L$OPENSSL_PATH/lib"
+    ],[AC_MSG_RESULT([no])])
+
+##########################################################################
+# Save and set temporary compilation flags
+##########################################################################
+OLD_LDFLAGS=$LDFLAGS
+OLD_CFLAGS=$CFLAGS
+LDFLAGS="$AM_LDFLAGS $LDFLAGS"
+CFLAGS="$AM_CFLAGS $CFLAGS"
+
+##########################################################################
+# Check for OpenSSL availability
+##########################################################################
 AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
-             [AC_MSG_FAILURE([can't find openssl crypto lib])])
+             [AC_MSG_FAILURE([OpenSSL libraries required])])
 AC_CHECK_HEADERS([openssl/des.h openssl/rand.h openssl/hmac.h openssl/evp.h], [],
-             [AC_MSG_FAILURE([can't find openssl crypto headers])])
-    ])
+             [AC_MSG_ERROR([OpenSSL headers required])])
+
+##########################################################################
+# Restore old saved variables
+##########################################################################
+LDFLAGS=$OLD_LDFLAGS
+CFLAGS=$OLD_CFLAGS
 
 ##########################################################################
 # Default warning setup