fc9447e965c7f8cf2111126d4eda846df4f57ccf
[tclink.git] / config.m4
1 dnl $Id: config.m4,v 2.00 2001/07/26
2 AC_DEFUN(SSL_LIB_CHK,[if ((test -r $i$1/libssl.so) || (test -r $i$1/libssl.dylib) || test -n "`ls $i$1/libssl.so* 2>/dev/null`"); then SSL_DIR=$i;])
3
4 PHP_ARG_WITH(tclink,for TCLink support,
5 [  --with-tclink[=DIR]    Include TCLink support.  DIR is the TCLink
6                           base install directory, defaults to ../C.
7                           Set DIR to "shared" to build as a dl, or "shared,DIR" 
8                           to build as a dl and still specify DIR.])
9
10 PHP_ARG_WITH(ssl,for TCLink SSL  support,
11 [  --with-ssl[=DIR]       Include TCLink SSL support.  DIR is the SSL
12                           library directory, which defaults to /usr/lib.])
13
14 PHP_ARG_WITH(ca-path,for CA path,
15 [  --with-ca-path[=DIR]     ca-bundle file or CA directory])
16
17 if test "$PHP_TCLINK" != "no"; then
18   AC_DEFINE(HAVE_TCLINK,1,[ ])
19   PHP_EXTENSION(tclink,$ext_shared)
20 fi
21
22 dnl Need to have a way to sepcify the include dir as well
23 if test "$PHP_SSL" != "no"; then
24   for i in /lib /usr/local/lib /usr/lib $PHP_SSL; do
25       SSL_LIB_CHK(/)
26     fi
27   done
28   if test -z "$SSL_DIR"; then
29     AC_MSG_ERROR(Cannot find libssl.so. Please specify the installation path for SSL)
30   fi
31
32   AC_DEFINE(HAVE_SSL,1,[ ])
33
34 fi
35
36 if test "$PHP_CA_PATH" != "no"; then
37         if test "$PHP_CA_PATH" != "yes"; then
38                 AC_MSG_NOTICE([User specified CA path: $PHP_CA_PATH])
39                 TCLINK_CA_PATH="$PHP_CA_PATH"
40         fi
41 fi
42 if test -z "$TCLINK_CA_PATH"; then
43     OPENSSL_CA_PATH=`openssl version -d | sed 's/[[^"]]*"\(.*\)"/\1/'`    # grab whatever between the double quotes 
44     if test -n "$OPENSSL_CA_PATH"; then
45         OPENSSL_CA_PATH="$OPENSSL_CA_PATH/certs"
46         AC_MSG_NOTICE([Openssl CA path: $OPENSSL_CA_PATH])
47         
48         for item in \
49             "$OPENSSL_CA_PATH/ca-bundle.crt" \
50             "$OPENSSL_CA_PATH/ca-certificates.crt" \
51             "$OPENSSL_CA_PATH/ca-bundle.trust.crt" \
52             "$OPENSSL_CA_PATH/tls-ca-bundle.pem" \
53             "$OPENSSL_CA_PATH"
54         do
55                         AC_MSG_NOTICE([Checking '$item'])
56             if test -f $item || test -d $item; then
57                 AC_MSG_NOTICE([Found '$item'])
58                 TCLINK_CA_PATH=$item
59                 break
60             fi
61         done
62     fi  
63 fi
64 if test -z "$TCLINK_CA_PATH"; then
65         AC_MSG_NOTICE([Search from known locations])
66         for item in \
67             "/etc/pki/tls/certs/ca-bundle.crt" \
68             "/etc/ssl/certs/ca-certificates.crt" \
69             "/etc/pki/tls/certs/ca-bundle.trust.crt" \
70             "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" \
71             "/etc/ssl/certs"
72         do
73             AC_MSG_NOTICE([Checking '$item'])
74                         if test -f $item || test -d $item; then
75                 AC_MSG_NOTICE([Found '$item'])
76                 TCLINK_CA_PATH=$item
77                 break
78             fi 
79         done 
80 fi
81 if test -z "$TCLINK_CA_PATH"; then
82     AC_MSG_ERROR([Cannot determine CA path. Please use --with-ca-path=<path> to specify ca-bundle file or CA directory.])
83 fi
84
85 TCLINK_SHARED_LIBADD="-lssl -lcrypto -L$SSL_DIR";
86 CFLAGS="-I$SSL_DIR/../include"
87 TCLINK_VERSION="4.2.1-PHP-`uname -sm | tr ' ' -`"
88 AC_DEFINE_UNQUOTED([TCLINK_VERSION], "$TCLINK_VERSION", [TCLink version string.])
89
90 AC_MSG_NOTICE([CA path: $TCLINK_CA_PATH])
91 AC_DEFINE_UNQUOTED([TCLINK_CA_PATH], "$TCLINK_CA_PATH", [CA path])
92
93 PHP_SUBST(TCLINK_INCLUDE)
94 PHP_SUBST(TCLINK_SHARED_LIBADD)
95