dnl -------------------------------------------------------- -*- autoconf -*- dnl Copyright 2006 The Apache Software Foundation or its licensors, as dnl applicable. dnl dnl Licensed under the Apache License, Version 2.0 (the "License"); dnl you may not use this file except in compliance with the License. dnl You may obtain a copy of the License at dnl dnl http://www.apache.org/licenses/LICENSE-2.0 dnl dnl Unless required by applicable law or agreed to in writing, software dnl distributed under the License is distributed on an "AS IS" BASIS, dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. dnl See the License for the specific language governing permissions and dnl limitations under the License. dnl dnl SSL autoconf functions dnl dnl Look for OpenSSL libraries and headers dnl AC_DEFUN([BADCA_CHECK_OPENSSL], [ badca_have_openssl=0 mydirs="/usr /usr/local /usr/sfw" AC_ARG_WITH([openssl], [ --with-openssl=DIR specify location of OpenSSL], [ if test "$withval" = "no"; then AC_ERROR("OpenSSL is required for BaDCA") elif test "$withval" = "yes"; then for d in $mydirs; do BADCA_CHECK_OPENSSL_PATH($d) done else BADCA_CHECK_OPENSSL_PATH($withval) fi ], [ for d in $mydirs; do BADCA_CHECK_OPENSSL_PATH($d) if test "$badca_have_openssl" = "1"; then break; fi done ]) if test "$badca_have_openssl" = "1"; then openssl_CPPFLAGS="-I$openssl_DIR/include" AC_SUBST(openssl_CPPFLAGS) openssl_LDFLAGS="-L$openssl_DIR/lib" AC_SUBST(openssl_LDFLAGS) openssl_LIBS="-lssl -lcrypto" AC_SUBST(openssl_LIBS) # These are meant for use in setup.py! openssl_INCDIR="$openssl_DIR/include" AC_SUBST(openssl_INCDIR) openssl_LIBDIR="$openssl_DIR/lib" AC_SUBST(openssl_LIBDIR) openssl_LIBSONLY="'ssl', 'crypto'" AC_SUBST(openssl_LIBSONLY) else AC_ERROR([You MUSThave OpenSSL installed for BaDCA]) fi ] ) dnl Look for OpenSSL libraries and headers... AC_DEFUN([BADCA_CHECK_OPENSSL_PATH], [ openssl_have_headers=0 openssl_have_libs=0 dir=$1 if test -d $1; then AC_MSG_CHECKING([for OpenSSL in $1]) CHECK_OPENSSL("$1") if test "$openssl_have_headers" = "1" && \ test "$openssl_have_libs" = "1"; then AC_MSG_RESULT([yes, in $1]) openssl_DIR=$1 badca_have_openssl=1 else AC_MSG_RESULT([no]) fi else echo "skipping directory $1 as it doesn't exist!" fi ] ) dnl dnl CHECK_OPENSSL dnl Check if we have a valid path by trying to compile and run some dnl test code. dnl This simply sets some variables for the caller to check and act on dnl accordingly. dnl BIGNUM check allows us to check -lcrypto dnl X509 check is for -lssl AC_DEFUN([CHECK_OPENSSL], [ orig_LDFLAGS="$LDFLAGS" orig_CPPFLAGS="$CPPFLAGS" CPPFLAGS="-I$1/include $CPPFLAGS" LDFLAGS="-L$1/lib -lssl -lcrypto $LDFLAGS" # Apparently Solaris doesn't have /usr/sfw (default location for the # OpenSSL install) in it's LD_LIBRARY_PATH so we need to add it # or this will fail! os=`uname -s` if test "$os" = "SunOS"; then LDFLAGS="$LDFLAGS -R$1/lib" fi AC_TRY_RUN([ #include "openssl/x509.h" int main(void) { X509 *cert = NULL; BIGNUM *bn = BN_new(); BN_free(bn); return (0); } ], [ openssl_have_headers=1 openssl_have_libs=1 ], [ openssl_have_headers=0 openssl_have_libs=0 ], [ openssl_have_headers=0 openssl_have_libs=0 ]) LDFLAGS="$orig_LDFLAGS" CPPFLAGS="$orig_CPPFLAGS" ] )