GSS_S_PROMPTING_NEEDED is a bit
[cyrus-sasl.git] / cmulocal / libssl.m4
1 dnl libssl.m4--Ssl libraries and includes
2 dnl Derrick Brashear
3 dnl from KTH kafs and Arla
4 dnl $Id: libssl.m4,v 1.10 2005/04/26 19:14:08 shadow Exp $
5
6 AC_DEFUN([CMU_LIBSSL_INC_WHERE1], [
7 saved_CPPFLAGS=$CPPFLAGS
8 CPPFLAGS="$saved_CPPFLAGS -I$1"
9 CMU_CHECK_HEADER_NOCACHE(openssl/ssl.h,
10 ac_cv_found_libssl_inc=yes,
11 ac_cv_found_libssl_inc=no)
12 CPPFLAGS=$saved_CPPFLAGS
13 ])
14
15 AC_DEFUN([CMU_LIBSSL_INC_WHERE], [
16    for i in $1; do
17       AC_MSG_CHECKING(for libssl headers in $i)
18       CMU_LIBSSL_INC_WHERE1($i)
19       CMU_TEST_INCPATH($i, ssl)
20       if test "$ac_cv_found_libssl_inc" = "yes"; then
21         ac_cv_libssl_where_inc=$i
22         AC_MSG_RESULT(found)
23         break
24       else
25         AC_MSG_RESULT(not found)
26       fi
27     done
28 ])
29
30 AC_DEFUN([CMU_LIBSSL_LIB_WHERE1], [
31 saved_LIBS=$LIBS
32 LIBS="$saved_LIBS -L$1 -lssl -lcrypto $LIB_SOCKET"
33 AC_TRY_LINK(,
34 [SSL_write();],
35 [ac_cv_found_ssl_lib=yes],
36 ac_cv_found_ssl_lib=no)
37 LIBS=$saved_LIBS
38 ])
39
40 AC_DEFUN([CMU_LIBSSL_LIB_WHERE], [
41    for i in $1; do
42       AC_MSG_CHECKING(for libssl libraries in $i)
43       CMU_LIBSSL_LIB_WHERE1($i)
44       dnl deal with false positives from implicit link paths
45       CMU_TEST_LIBPATH($i, ssl)
46       if test "$ac_cv_found_ssl_lib" = "yes" ; then
47         ac_cv_libssl_where_lib=$i
48         AC_MSG_RESULT(found)
49         break
50       else
51         AC_MSG_RESULT(not found)
52       fi
53     done
54 ])
55
56 AC_DEFUN([CMU_LIBSSL], [
57 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
58 AC_REQUIRE([CMU_SOCKETS])
59 AC_ARG_WITH(libssl,
60         [  --with-libssl=PREFIX      Compile with Libssl support],
61         [if test "X$with_libssl" = "X"; then
62                 with_libssl=yes
63         fi])
64 AC_ARG_WITH(libssl-lib,
65         [  --with-libssl-lib=dir     use libssl libraries in dir],
66         [if test "$withval" = "yes" -o "$withval" = "no"; then
67                 AC_MSG_ERROR([No argument for --with-libssl-lib])
68         fi])
69 AC_ARG_WITH(libssl-include,
70         [  --with-libssl-include=dir use libssl headers in dir],
71         [if test "$withval" = "yes" -o "$withval" = "no"; then
72                 AC_MSG_ERROR([No argument for --with-libssl-include])
73         fi])
74
75         if test "X$with_libssl" != "X"; then
76           if test "$with_libssl" != "yes" -a "$with_libssl" != no; then
77             ac_cv_libssl_where_lib=$with_libssl/$CMU_LIB_SUBDIR
78             ac_cv_libssl_where_inc=$with_libssl/include
79           fi
80         fi
81
82         if test "$with_libssl" != "no"; then 
83           if test "X$with_libssl_lib" != "X"; then
84             ac_cv_libssl_where_lib=$with_libssl_lib
85           fi
86           if test "X$ac_cv_libssl_where_lib" = "X"; then
87             CMU_LIBSSL_LIB_WHERE(/usr/local/$CMU_LIB_SUBDIR/openssl /usr/$CMU_LIB_SUBDIR/openssl /usr/local/$CMU_LIB_SUBDIR /usr/$CMU_LIB_SUBDIR)
88           fi
89
90           if test "X$with_libssl_include" != "X"; then
91             ac_cv_libssl_where_inc=$with_libssl_include
92           fi
93           if test "X$ac_cv_libssl_where_inc" = "X"; then
94             CMU_LIBSSL_INC_WHERE(/usr/local/include /usr/include)
95           fi
96         fi
97
98         AC_MSG_CHECKING(whether to include libssl)
99         if test "X$ac_cv_libssl_where_lib" = "X" -a "X$ac_cv_libssl_where_inc" = "X"; then
100           ac_cv_found_libssl=no
101           AC_MSG_RESULT(no)
102         else
103           ac_cv_found_libssl=yes
104           AC_MSG_RESULT(yes)
105           LIBSSL_INC_DIR=$ac_cv_libssl_where_inc
106           LIBSSL_LIB_DIR=$ac_cv_libssl_where_lib
107           LIBSSL_INC_FLAGS="-I${LIBSSL_INC_DIR}"
108           LIBSSL_LIB_FLAGS="-L${LIBSSL_LIB_DIR} -lssl -lcrypto"
109           if test "X$RPATH" = "X"; then
110                 RPATH=""
111           fi
112           case "${host}" in
113             *-*-linux*)
114               if test "X$RPATH" = "X"; then
115                 RPATH="-Wl,-rpath,${LIBSSL_LIB_DIR}"
116               else 
117                 RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
118               fi
119               ;;
120             *-*-hpux*)
121               if test "X$RPATH" = "X"; then
122                 RPATH="-Wl,+b${LIBSSL_LIB_DIR}"
123               else 
124                 RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
125               fi
126               ;;
127             *-*-irix*)
128               if test "X$RPATH" = "X"; then
129                 RPATH="-Wl,-rpath,${LIBSSL_LIB_DIR}"
130               else 
131                 RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
132               fi
133               ;;
134             *-*-solaris2*)
135               if test "$ac_cv_prog_gcc" = yes; then
136                 if test "X$RPATH" = "X"; then
137                   RPATH="-Wl,-R${LIBSSL_LIB_DIR}"
138                 else 
139                   RPATH="${RPATH}:${LIBSSL_LIB_DIR}"
140                 fi
141               else
142                 RPATH="${RPATH} -R${LIBSSL_LIB_DIR}"
143               fi
144               ;;
145           esac
146           AC_SUBST(RPATH)
147         fi
148         AC_SUBST(LIBSSL_INC_DIR)
149         AC_SUBST(LIBSSL_LIB_DIR)
150         AC_SUBST(LIBSSL_INC_FLAGS)
151         AC_SUBST(LIBSSL_LIB_FLAGS)
152         ])
153