3 # PDNS_CHECK_LIBCRYPTO([action-if-found[, action-if-not-found]])
7 # Look for OpenSSL's libcrypto in a number of default spots, or in a
8 # user-selected spot (via --with-libcrypto). Sets
10 # LIBCRYPTO_INCLUDES to the include directives required
11 # LIBCRYPTO_LIBS to the -l directives required
12 # LIBCRYPTO_LDFLAGS to the -L or -R flags required
14 # and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately
16 # This macro sets LIBCRYPTO_INCLUDES such that source files should use the
17 # openssl/ directory in include directives:
19 # #include <openssl/hmac.h>
23 # Taken and modified from AX_CHECK_OPENSSL by:
24 # Copyright (c) 2009,2010 Zmanda Inc. <http://www.zmanda.com/>
25 # Copyright (c) 2009,2010 Dustin J. Mitchell <dustin@zmanda.com>
27 # Copying and distribution of this file, with or without modification, are
28 # permitted in any medium without royalty provided the copyright notice
29 # and this notice are preserved. This file is offered as-is, without any
34 AU_ALIAS([CHECK_LIBCRYPTO], [PDNS_CHECK_LIBCRYPTO])
35 AC_DEFUN([PDNS_CHECK_LIBCRYPTO], [
37 AC_ARG_WITH([libcrypto],
38 [AS_HELP_STRING([--with-libcrypto=DIR],
39 [root of the OpenSSL directory])],
42 "" | y | ye | yes | n | no)
43 AC_MSG_ERROR([Invalid --with-libcrypto value])
49 # if pkg-config is installed and openssl has installed a .pc file,
50 # then use that information and don't search ssldirs
51 AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
52 if test x"$PKG_CONFIG" != x""; then
53 LIBCRYPTO_LDFLAGS=`$PKG_CONFIG libcrypto --libs-only-L 2>/dev/null`
55 LIBCRYPTO_LIBS=`$PKG_CONFIG libcrypto --libs-only-l 2>/dev/null`
56 LIBCRYPTO_INCLUDES=`$PKG_CONFIG libcrypto --cflags-only-I 2>/dev/null`
61 # no such luck; use some default ssldirs
63 ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
69 # note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
70 # an 'openssl' subdirectory
74 for ssldir in $ssldirs; do
75 AC_MSG_CHECKING([for openssl/crypto.h in $ssldir])
76 if test -f "$ssldir/include/openssl/crypto.h"; then
77 LIBCRYPTO_INCLUDES="-I$ssldir/include"
78 LIBCRYPTO_LDFLAGS="-L$ssldir/lib"
79 LIBCRYPTO_LIBS="-lcrypto"
88 # if the file wasn't found, well, go ahead and try the link anyway -- maybe
92 # try the preprocessor and linker with our new flags,
93 # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
95 AC_MSG_CHECKING([whether compiling and linking against OpenSSL's libcrypto works])
96 echo "Trying link with LIBCRYPTO_LDFLAGS=$LIBCRYPTO_LDFLAGS;" \
97 "LIBCRYPTO_LIBS=$LIBCRYPTO_LIBS; LIBCRYPTO_INCLUDES=$LIBCRYPTO_INCLUDES" >&AS_MESSAGE_LOG_FD
100 save_LDFLAGS="$LDFLAGS"
101 save_CPPFLAGS="$CPPFLAGS"
102 LDFLAGS="$LDFLAGS $LIBCRYPTO_LDFLAGS"
103 LIBS="$LIBCRYPTO_LIBS $LIBS"
104 CPPFLAGS="$LIBCRYPTO_INCLUDES $CPPFLAGS"
106 [AC_LANG_PROGRAM([#include <openssl/crypto.h>], [ERR_load_CRYPTO_strings()])],
114 CPPFLAGS="$save_CPPFLAGS"
115 LDFLAGS="$save_LDFLAGS"
118 AC_SUBST([LIBCRYPTO_INCLUDES])
119 AC_SUBST([LIBCRYPTO_LIBS])
120 AC_SUBST([LIBCRYPTO_LDFLAGS])