]> arthur.barton.de Git - netatalk.git/blob - macros/ssl-check.m4
9fa7b3729b008ad7390a0babe7e7282961f1b25d
[netatalk.git] / macros / ssl-check.m4
1 dnl $Id: ssl-check.m4,v 1.9 2003-06-08 16:04:49 srittau Exp $
2 dnl Autoconf macro to check for SSL or OpenSSL
3
4 AC_DEFUN([AC_PATH_GCRYPT], [
5
6         GCRYPT_CFLAGS=""
7         GCRYPT_LIBS=""
8
9         search="yes"
10         errifnotfound="no"
11
12         AC_ARG_ENABLE(libgcrypt, [  --disable-gcrypt        disable compilation with libgcrypt], [
13                 if test "x$enableval" != "xdisable"; then
14                         errifnotfound="yes"
15                 else
16                         search="no"
17                 fi
18         ])
19
20         GCRYPT_CONFIG=""
21         if test "x$search" == "xyes"; then
22                 AC_PATH_PROG([GCRYPT_CONFIG], [libgcrypt-config], [no])
23
24                 if test "x$GCRYPT_CONFIG" == "xno"; then
25                         if test "x$errifnotfound" == "xyes"; then
26                                 AC_MSG_ERROR([libgcrypt-config not found])
27                         fi
28                 else
29                         GCRYPT_CFLAGS="`$GCRYPT_CONFIG --cflags`"
30                         GCRYPT_LIBS="`$GCRYPT_CONFIG --libs`"
31                 fi
32         fi
33
34         AC_SUBST(GCRYPT_CFLAGS)
35         AC_SUBST(GCRYPT_LIBS)
36         AM_CONDITIONAL(HAVE_GCRYPT, test -n "$GCRYPT_CONFIG")
37 ])
38
39 AC_DEFUN([AC_PATH_SSL], [
40         AC_ARG_WITH(ssl-dir, [  --with-ssl-dir=PATH     specify path to OpenSSL installation (must contain
41                           lib and include dirs)],
42                 [
43                         if test "x$withval" = "xno"; then
44                                 tryssl=no
45                         elif test "x$withval" = "xyes"; then
46                                 tryssl=yes
47                                 tryssldir=
48                         else
49                                 dnl FIXME: should only try in $withval
50                                 tryssl=yes
51                                 tryssldir="$withval"
52                         fi
53                 ], [tryssl=yes]
54         )
55
56         SSL_CFLAGS=""
57         SSL_LIBS=""
58         compile_ssl=no
59
60         if test "$tryssl" = "yes"; then
61                 AC_MSG_CHECKING([for SSL])
62                 for ssldir in "" $tryssldir /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl /usr/local/ssl ; do
63                         if test -f "$ssldir/include/openssl/cast.h" ; then
64                                 SSL_CFLAGS="$SSL_CFLAGS -I$ssldir/include -I$ssldir/include/openssl"
65                                 SSL_LIBS="$SSL_LIBS -L$ssldir/lib -L$ssldir -lcrypto"
66                                 if test "x$need_dash_r" = "xyes"; then
67                                         SSL_LIBS="$SSL_LIBS -R$ssldir/lib -R$ssldir"
68                                 fi
69                                 AC_MSG_RESULT([$ssldir (enabling RANDNUM and DHX support)])
70
71 dnl FIXME: The following looks crude and probably doesn't work properly.
72                                 dnl Check for the crypto library:
73                                 AC_CHECK_LIB(crypto, main)
74                                 dnl Check for "DES" library (for SSLeay, not openssl):
75                                 AC_CHECK_LIB(des, main)
76
77                                 AC_DEFINE(OPENSSL_DHX,  1, [Define if the OpenSSL DHX modules should be built])
78                                 AC_DEFINE(UAM_DHX,      1, [Define if the DHX UAM modules should be compiled])
79                                 compile_ssl=yes
80                                 break
81                         fi
82                 done
83                 if test "x$compile_ssl" = "xno"; then
84                         AC_MSG_RESULT([no])
85                 fi
86         fi
87         AC_SUBST(SSL_CFLAGS)
88         AC_SUBST(SSL_LIBS)
89 ])