| 1 |
dnl |
| 2 |
dnl openssl.m4 -- Find the path to the openssl library. |
| 3 |
dnl |
| 4 |
AC_DEFUN([AM_PATH_OPENSSL], |
| 5 |
[OPENSSL_CFLAGS="" |
| 6 |
OPENSSL_LDFLAGS="" |
| 7 |
OPENSSL_LIBS="" |
| 8 |
|
| 9 |
AC_ARG_WITH([openssl-prefix], [ --with-openssl-prefix=PFX |
| 10 |
Prefix where openssl is installed (optional)], |
| 11 |
openssl_prefix="$withval", openssl_prefix="") |
| 12 |
if test x"$openssl_prefix" = xyes ; then |
| 13 |
openssl_prefix=""; |
| 14 |
fi |
| 15 |
|
| 16 |
AC_MSG_CHECKING([for openssl location]) |
| 17 |
if test x"$openssl_prefix" = x ; then |
| 18 |
openssl_header_found="no" |
| 19 |
for dir in /usr/local /usr ; do |
| 20 |
if test -f "$dir/include/openssl/ssl.h" ; then |
| 21 |
openssl_header_found="yes" |
| 22 |
OPENSSL_CFLAGS="-I$dir/include" |
| 23 |
OPENSSL_LDFLAGS="-L$dir/lib" |
| 24 |
break |
| 25 |
fi |
| 26 |
done |
| 27 |
if test x"$openssl_header_found" = "no" ; then |
| 28 |
AC_MSG_RESULT([no]) |
| 29 |
AC_MSG_ERROR([openssl header file 'openssl/ssl.h' not found.]) |
| 30 |
fi |
| 31 |
AC_MSG_RESULT([$dir]) |
| 32 |
else |
| 33 |
OPENSSL_CFLAGS="-I$openssl_prefix/include" |
| 34 |
OPENSSL_LDFLAGS="-L$openssl_prefix/lib" |
| 35 |
AC_MSG_RESULT([$openssl_prefix]) |
| 36 |
fi |
| 37 |
|
| 38 |
openssl_save_LDFLAGS=$LDFLAGS |
| 39 |
LDFLAGS="$OPENSSL_LDFLAGS $LDFLAGS" |
| 40 |
openssl_save_CFLAGS=$CFLAGS |
| 41 |
CFLAGS="$OPENSSL_CFLAGS $CFLAGS" |
| 42 |
AC_CHECK_LIB([rsaref], [RSAPublicEncrypt], |
| 43 |
[AC_CHECK_LIB([RSAglue], [RSAPublicEncrypt], |
| 44 |
[OPENSSL_LIBS="-lRSAglue -lrsaref"],,[-lrsaref])]) |
| 45 |
AC_CHECK_LIB([crypto], [BIO_new], |
| 46 |
[AC_CHECK_LIB([dl], [DSO_load], |
| 47 |
[OPENSSL_LIBS="-lcrypto -ldl $OPENSSL_LIBS"], |
| 48 |
[OPENSSL_LIBS="-lcrypto $OPENSSL_LIBS"], [-lcrypto $OPENSSL_LIBS])], |
| 49 |
[AC_MSG_ERROR(cannot link with OpenSSL)], [$OPENSSL_LIBS]) |
| 50 |
AC_CHECK_LIB([ssl], [SSL_library_init], |
| 51 |
[OPENSSL_LIBS="-lssl $OPENSSL_LIBS"], |
| 52 |
[AC_MSG_ERROR(cannot link with OpenSSL)], [$OPENSSL_LIBS]) |
| 53 |
LDFLAGS=$openssl_save_LDFLAGS |
| 54 |
CFLAGS=$openssl_save_CFLAGS |
| 55 |
if test x"$OPENSSL_LIBS" = x ; then |
| 56 |
AC_MSG_ERROR([openssl required but not found]) |
| 57 |
else |
| 58 |
OPENSSL_LIBS="$OPENSSL_LDFLAGS $OPENSSL_LIBS" |
| 59 |
fi |
| 60 |
|
| 61 |
AC_SUBST([OPENSSL_CFLAGS]) |
| 62 |
AC_SUBST([OPENSSL_LIBS])]) |
| 63 |
] |