xref: /PHP-5.4/ext/ldap/config.m4 (revision a286fa35)
1dnl
2dnl $Id$
3dnl
4
5AC_DEFUN([PHP_LDAP_CHECKS], [
6  if test -f $1/include/ldap.h; then
7    LDAP_DIR=$1
8    LDAP_INCDIR=$1/include
9    LDAP_LIBDIR=$1/$PHP_LIBDIR
10  elif test -f $1/include/umich-ldap/ldap.h; then
11    LDAP_DIR=$1
12    LDAP_INCDIR=$1/include/umich-ldap
13    LDAP_LIBDIR=$1/$PHP_LIBDIR
14  elif test -f $1/ldap/public/ldap.h; then
15    LDAP_DIR=$1
16    LDAP_INCDIR=$1/ldap/public
17    LDAP_LIBDIR=$1/$PHP_LIBDIR
18  fi
19])
20
21AC_DEFUN([PHP_LDAP_SASL_CHECKS], [
22  if test "$1" = "yes"; then
23    SEARCH_DIRS="/usr/local /usr"
24  else
25    SEARCH_DIRS=$1
26  fi
27
28  for i in $SEARCH_DIRS; do
29    if test -f $i/include/sasl/sasl.h; then
30      LDAP_SASL_DIR=$i
31      AC_DEFINE(HAVE_LDAP_SASL_SASL_H,1,[ ])
32      break
33    elif test -f $i/include/sasl.h; then
34      LDAP_SASL_DIR=$i
35      AC_DEFINE(HAVE_LDAP_SASL_H,1,[ ])
36      break
37    fi
38  done
39
40  if test "$LDAP_SASL_DIR"; then
41    LDAP_SASL_INCDIR=$LDAP_SASL_DIR/include
42    LDAP_SASL_LIBDIR=$LDAP_SASL_DIR/$PHP_LIBDIR
43  else
44    AC_MSG_ERROR([sasl.h not found!])
45  fi
46
47  if test "$PHP_LDAP_SASL" = "yes"; then
48    SASL_LIB="-lsasl2"
49  else
50    SASL_LIB="-L$LDAP_SASL_LIBDIR -lsasl2"
51  fi
52
53  PHP_CHECK_LIBRARY(sasl2, sasl_version,
54  [
55    PHP_ADD_INCLUDE($LDAP_SASL_INCDIR)
56    PHP_ADD_LIBRARY_WITH_PATH(sasl2, $LDAP_SASL_LIBDIR, LDAP_SHARED_LIBADD)
57    AC_DEFINE(HAVE_LDAP_SASL, 1, [LDAP SASL support])
58  ], [
59    AC_MSG_ERROR([LDAP SASL check failed. Please check config.log for more information.])
60  ], [
61    $LDAP_SHARED_LIBADD $SASL_LIB
62  ])
63])
64
65PHP_ARG_WITH(ldap,for LDAP support,
66[  --with-ldap[=DIR]       Include LDAP support])
67
68PHP_ARG_WITH(ldap-sasl,for LDAP Cyrus SASL support,
69[  --with-ldap-sasl[=DIR]    LDAP: Include Cyrus SASL support], no, no)
70
71if test "$PHP_LDAP" != "no"; then
72
73  PHP_NEW_EXTENSION(ldap, ldap.c, $ext_shared,,-DLDAP_DEPRECATED=1)
74
75  if test "$PHP_LDAP" = "yes"; then
76    for i in /usr/local /usr; do
77      PHP_LDAP_CHECKS($i)
78    done
79  else
80    PHP_LDAP_CHECKS($PHP_LDAP)
81  fi
82
83  if test -z "$LDAP_DIR"; then
84    AC_MSG_ERROR(Cannot find ldap.h)
85  fi
86
87  dnl The Linux version of the SDK need -lpthread
88  dnl I have tested Solaris, and it doesn't, but others may.  Add
89  dnl these here if necessary.   -RL
90  dnl Is this really necessary? -Troels Arvin
91
92  if test `uname` = "Linux"; then
93    LDAP_PTHREAD=pthread
94  else
95    LDAP_PTHREAD=
96  fi
97
98  if test -f $LDAP_LIBDIR/liblber.a || test -f $LDAP_LIBDIR/liblber.$SHLIB_SUFFIX_NAME; then
99    PHP_ADD_LIBRARY_WITH_PATH(lber, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
100    PHP_ADD_LIBRARY_WITH_PATH(ldap, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
101
102  elif test -f $LDAP_LIBDIR/libldap.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/libldap.$SHLIB_SUFFIX_NAME.3 || test -f $LDAP_LIBDIR/libldap.3.dylib; then
103    PHP_ADD_LIBRARY_WITH_PATH(ldap, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
104
105  elif test -f $LDAP_LIBDIR/libssldap50.$SHLIB_SUFFIX_NAME; then
106    if test -n "$LDAP_PTHREAD"; then
107      PHP_ADD_LIBRARY($LDAP_PTHREAD)
108    fi
109    PHP_ADD_LIBRARY_WITH_PATH(nspr4, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
110    PHP_ADD_LIBRARY_WITH_PATH(plc4, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
111    PHP_ADD_LIBRARY_WITH_PATH(plds4, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
112    PHP_ADD_LIBRARY_WITH_PATH(ssldap50, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
113    PHP_ADD_LIBRARY_WITH_PATH(ldap50, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
114    PHP_ADD_LIBRARY_WITH_PATH(prldap50, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
115    PHP_ADD_LIBRARY_WITH_PATH(ssl3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
116    AC_DEFINE(HAVE_NSLDAP,1,[ ])
117
118  elif test -f $LDAP_LIBDIR/libldapssl41.$SHLIB_SUFFIX_NAME; then
119    if test -n "$LDAP_PTHREAD"; then
120      PHP_ADD_LIBRARY($LDAP_PTHREAD)
121    fi
122    PHP_ADD_LIBRARY_WITH_PATH(nspr3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
123    PHP_ADD_LIBRARY_WITH_PATH(plc3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
124    PHP_ADD_LIBRARY_WITH_PATH(plds3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
125    PHP_ADD_LIBRARY_WITH_PATH(ldapssl41, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
126    AC_DEFINE(HAVE_NSLDAP,1,[ ])
127
128  elif test -f $LDAP_LIBDIR/libldapssl30.$SHLIB_SUFFIX_NAME; then
129    if test -n "$LDAP_PTHREAD"; then
130      PHP_ADD_LIBRARY($LDAP_PTHREAD)
131    fi
132    PHP_ADD_LIBRARY_WITH_PATH(ldapssl30, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
133    AC_DEFINE(HAVE_NSLDAP,1,[ ])
134
135  elif test -f $LDAP_LIBDIR/libldap30.$SHLIB_SUFFIX_NAME; then
136    if test -n "$LDAP_PTHREAD"; then
137      PHP_ADD_LIBRARY($LDAP_PTHREAD)
138    fi
139    PHP_ADD_LIBRARY_WITH_PATH(ldap30, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
140    AC_DEFINE(HAVE_NSLDAP,1,[ ])
141
142  elif test -f $LDAP_LIBDIR/libumich_ldap.$SHLIB_SUFFIX_NAME; then
143    PHP_ADD_LIBRARY_WITH_PATH(umich_lber, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
144    PHP_ADD_LIBRARY_WITH_PATH(umich_ldap, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
145
146  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME; then
147    PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
148    AC_DEFINE(HAVE_ORALDAP,1,[ ])
149    if test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
150      AC_DEFINE(HAVE_ORALDAP_10,1,[ ])
151    fi
152  else
153    AC_MSG_ERROR(Cannot find ldap libraries in $LDAP_LIBDIR.)
154  fi
155
156  PHP_ADD_INCLUDE($LDAP_INCDIR)
157  PHP_SUBST(LDAP_SHARED_LIBADD)
158  AC_DEFINE(HAVE_LDAP,1,[ ])
159
160  dnl Save original values
161  _SAVE_CPPFLAGS=$CPPFLAGS
162  _SAVE_LIBS=$LIBS
163  CPPFLAGS="$CPPFLAGS -I$LDAP_INCDIR"
164  LIBS="$LIBS $LDAP_SHARED_LIBADD"
165
166  dnl Check for 3 arg ldap_set_rebind_proc
167  AC_CACHE_CHECK([for 3 arg ldap_set_rebind_proc], ac_cv_3arg_setrebindproc,
168  [AC_TRY_COMPILE([#include <ldap.h>], [ldap_set_rebind_proc(0,0,0)],
169  ac_cv_3arg_setrebindproc=yes, ac_cv_3arg_setrebindproc=no)])
170  if test "$ac_cv_3arg_setrebindproc" = yes; then
171    AC_DEFINE(HAVE_3ARG_SETREBINDPROC,1,[Whether 3 arg set_rebind_proc()])
172  fi
173
174  dnl Solaris 2.8 claims to be 2004 API, but doesn't have
175  dnl ldap_parse_reference() nor ldap_start_tls_s()
176  AC_CHECK_FUNCS([ldap_parse_result ldap_parse_reference ldap_start_tls_s])
177
178  dnl
179  dnl SASL check
180  dnl
181  if test "$PHP_LDAP_SASL" != "no"; then
182    PHP_LDAP_SASL_CHECKS([$PHP_LDAP_SASL])
183  fi
184
185  dnl
186  dnl Sanity check
187  dnl
188  AC_CHECK_FUNC(ldap_bind_s, [], [
189    AC_MSG_ERROR([LDAP build check failed. Please check config.log for more information.])
190  ])
191
192  dnl Restore original values
193  CPPFLAGS=$_SAVE_CPPFLAGS
194  LIBS=$_SAVE_LIBS
195fi
196