xref: /PHP-7.1/ext/ldap/config.m4 (revision 80003345)
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  else
19
20    dnl Find Oracle Instant Client RPM header location corresponding to the given lib path e.g. for --with-ldap=/usr/lib/oracle/12.1/client64/lib
21    AC_CHECK_SIZEOF(long int, 4)
22    if test "$ac_cv_sizeof_long_int" = "4"; then
23      PHP_OCI8_IC_LIBDIR_SUFFIX=""
24    else
25      PHP_OCI8_IC_LIBDIR_SUFFIX=64
26    fi
27    OCISDKRPMINC=`echo "$1" | $SED -e 's!^/usr/lib/oracle/\(.*\)/client\('${PHP_OCI8_IC_LIBDIR_SUFFIX}'\)*/lib[/]*$!/usr/include/oracle/\1/client\2!'`
28
29    dnl Check for Oracle Instant Client RPM install
30    if test -f $OCISDKRPMINC/ldap.h; then
31      LDAP_DIR=$1
32      LDAP_INCDIR=$OCISDKRPMINC
33      LDAP_LIBDIR=$1
34    dnl Check for Oracle Instant Client ZIP install
35    elif test -f $1/sdk/include/ldap.h; then
36      LDAP_DIR=$1
37      LDAP_INCDIR=$1/sdk/include
38      LDAP_LIBDIR=$1
39    fi
40  fi
41])
42
43AC_DEFUN([PHP_LDAP_SASL_CHECKS], [
44  if test "$1" = "yes"; then
45    SEARCH_DIRS="/usr/local /usr"
46  else
47    SEARCH_DIRS=$1
48  fi
49
50  for i in $SEARCH_DIRS; do
51    if test -f $i/include/sasl/sasl.h; then
52      LDAP_SASL_DIR=$i
53      AC_DEFINE(HAVE_LDAP_SASL_SASL_H,1,[ ])
54      break
55    elif test -f $i/include/sasl.h; then
56      LDAP_SASL_DIR=$i
57      AC_DEFINE(HAVE_LDAP_SASL_H,1,[ ])
58      break
59    fi
60  done
61
62  if test "$LDAP_SASL_DIR"; then
63    LDAP_SASL_INCDIR=$LDAP_SASL_DIR/include
64    LDAP_SASL_LIBDIR=$LDAP_SASL_DIR/$PHP_LIBDIR
65  else
66    AC_MSG_ERROR([sasl.h not found!])
67  fi
68
69  if test "$PHP_LDAP_SASL" = "yes"; then
70    SASL_LIB="-lsasl2"
71  else
72    SASL_LIB="-L$LDAP_SASL_LIBDIR -lsasl2"
73  fi
74
75  PHP_CHECK_LIBRARY(sasl2, sasl_version,
76  [
77    PHP_ADD_INCLUDE($LDAP_SASL_INCDIR)
78    PHP_ADD_LIBRARY_WITH_PATH(sasl2, $LDAP_SASL_LIBDIR, LDAP_SHARED_LIBADD)
79    AC_DEFINE(HAVE_LDAP_SASL, 1, [LDAP SASL support])
80  ], [
81    AC_MSG_ERROR([LDAP SASL check failed. Please check config.log for more information.])
82  ], [
83    $LDAP_SHARED_LIBADD $SASL_LIB
84  ])
85])
86
87PHP_ARG_WITH(ldap,for LDAP support,
88[  --with-ldap[=DIR]         Include LDAP support])
89
90PHP_ARG_WITH(ldap-sasl,for LDAP Cyrus SASL support,
91[  --with-ldap-sasl[=DIR]    LDAP: Include Cyrus SASL support], no, no)
92
93if test "$PHP_LDAP" != "no"; then
94
95  PHP_NEW_EXTENSION(ldap, ldap.c, $ext_shared,,-DLDAP_DEPRECATED=1)
96
97  if test "$PHP_LDAP" = "yes"; then
98    for i in /usr/local /usr; do
99      PHP_LDAP_CHECKS($i)
100    done
101  else
102    PHP_LDAP_CHECKS($PHP_LDAP)
103  fi
104
105  if test -z "$LDAP_DIR"; then
106    AC_MSG_ERROR(Cannot find ldap.h)
107  fi
108
109  dnl The Linux version of the SDK need -lpthread
110  dnl I have tested Solaris, and it doesn't, but others may.  Add
111  dnl these here if necessary.   -RL
112  dnl Is this really necessary? -Troels Arvin
113
114  if test `uname` = "Linux"; then
115    LDAP_PTHREAD=pthread
116  else
117    LDAP_PTHREAD=
118  fi
119
120  MACHINE_INCLUDES=$($CC -dumpmachine)
121
122  if test -f $LDAP_LIBDIR/liblber.a || test -f $LDAP_LIBDIR/liblber.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/liblber.a || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/liblber.$SHLIB_SUFFIX_NAME; then
123    PHP_ADD_LIBRARY_WITH_PATH(lber, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
124    PHP_ADD_LIBRARY_WITH_PATH(ldap, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
125
126  elif test -f $LDAP_LIBDIR/libldap.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/libldap.$SHLIB_SUFFIX_NAME.3 || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libldap.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libldap.$SHLIB_SUFFIX_NAME.3 || test -f $LDAP_LIBDIR/libldap.3.dylib; then
127    PHP_ADD_LIBRARY_WITH_PATH(ldap, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
128
129  elif test -f $LDAP_LIBDIR/libssldap50.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libssldap50.$SHLIB_SUFFIX_NAME; then
130    if test -n "$LDAP_PTHREAD"; then
131      PHP_ADD_LIBRARY($LDAP_PTHREAD)
132    fi
133    PHP_ADD_LIBRARY_WITH_PATH(nspr4, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
134    PHP_ADD_LIBRARY_WITH_PATH(plc4, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
135    PHP_ADD_LIBRARY_WITH_PATH(plds4, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
136    PHP_ADD_LIBRARY_WITH_PATH(ssldap50, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
137    PHP_ADD_LIBRARY_WITH_PATH(ldap50, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
138    PHP_ADD_LIBRARY_WITH_PATH(prldap50, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
139    PHP_ADD_LIBRARY_WITH_PATH(ssl3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
140    AC_DEFINE(HAVE_NSLDAP,1,[ ])
141
142  elif test -f $LDAP_LIBDIR/libldapssl41.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libldapssl41.$SHLIB_SUFFIX_NAME; then
143    if test -n "$LDAP_PTHREAD"; then
144      PHP_ADD_LIBRARY($LDAP_PTHREAD)
145    fi
146    PHP_ADD_LIBRARY_WITH_PATH(nspr3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
147    PHP_ADD_LIBRARY_WITH_PATH(plc3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
148    PHP_ADD_LIBRARY_WITH_PATH(plds3, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
149    PHP_ADD_LIBRARY_WITH_PATH(ldapssl41, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
150    AC_DEFINE(HAVE_NSLDAP,1,[ ])
151
152  elif test -f $LDAP_LIBDIR/libldapssl30.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libldapssl30.$SHLIB_SUFFIX_NAME; then
153    if test -n "$LDAP_PTHREAD"; then
154      PHP_ADD_LIBRARY($LDAP_PTHREAD)
155    fi
156    PHP_ADD_LIBRARY_WITH_PATH(ldapssl30, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
157    AC_DEFINE(HAVE_NSLDAP,1,[ ])
158
159  elif test -f $LDAP_LIBDIR/libldap30.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libldap30.$SHLIB_SUFFIX_NAME; then
160    if test -n "$LDAP_PTHREAD"; then
161      PHP_ADD_LIBRARY($LDAP_PTHREAD)
162    fi
163    PHP_ADD_LIBRARY_WITH_PATH(ldap30, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
164    AC_DEFINE(HAVE_NSLDAP,1,[ ])
165
166  elif test -f $LDAP_LIBDIR/libumich_ldap.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libumich_ldap.$SHLIB_SUFFIX_NAME; then
167    PHP_ADD_LIBRARY_WITH_PATH(umich_lber, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
168    PHP_ADD_LIBRARY_WITH_PATH(umich_ldap, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
169
170  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.12.1 || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libclntsh.$SHLIB_SUFFIX_NAME.12.1; then
171    PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
172    AC_DEFINE(HAVE_ORALDAP,1,[ ])
173    AC_DEFINE(HAVE_ORALDAP_12,1,[ ])
174
175  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.11.1 || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libclntsh.$SHLIB_SUFFIX_NAME.11.1; then
176    PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
177    AC_DEFINE(HAVE_ORALDAP,1,[ ])
178    AC_DEFINE(HAVE_ORALDAP_11,1,[ ])
179
180  elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libclntsh.$SHLIB_SUFFIX_NAME; then
181     PHP_ADD_LIBRARY_WITH_PATH(clntsh, $LDAP_LIBDIR, LDAP_SHARED_LIBADD)
182     AC_DEFINE(HAVE_ORALDAP,1,[ ])
183     AC_DEFINE(HAVE_ORALDAP_10,1,[ ])
184
185  else
186    AC_MSG_ERROR(Cannot find ldap libraries in $LDAP_LIBDIR.)
187  fi
188
189  PHP_ADD_INCLUDE($LDAP_INCDIR)
190  PHP_SUBST(LDAP_SHARED_LIBADD)
191  AC_DEFINE(HAVE_LDAP,1,[ ])
192
193  dnl Save original values
194  _SAVE_CPPFLAGS=$CPPFLAGS
195  _SAVE_LIBS=$LIBS
196  CPPFLAGS="$CPPFLAGS -I$LDAP_INCDIR"
197  LIBS="$LIBS $LDAP_SHARED_LIBADD"
198
199  dnl Check for 3 arg ldap_set_rebind_proc
200  AC_CACHE_CHECK([for 3 arg ldap_set_rebind_proc], ac_cv_3arg_setrebindproc,
201  [AC_TRY_COMPILE([#include <ldap.h>], [ldap_set_rebind_proc(0,0,0)],
202  ac_cv_3arg_setrebindproc=yes, ac_cv_3arg_setrebindproc=no)])
203  if test "$ac_cv_3arg_setrebindproc" = yes; then
204    AC_DEFINE(HAVE_3ARG_SETREBINDPROC,1,[Whether 3 arg set_rebind_proc()])
205  fi
206
207  dnl Solaris 2.8 claims to be 2004 API, but doesn't have
208  dnl ldap_parse_reference() nor ldap_start_tls_s()
209  AC_CHECK_FUNCS([ldap_parse_result ldap_parse_reference ldap_start_tls_s ldap_control_find])
210
211  dnl
212  dnl SASL check
213  dnl
214  if test "$PHP_LDAP_SASL" != "no"; then
215    PHP_LDAP_SASL_CHECKS([$PHP_LDAP_SASL])
216  fi
217
218  dnl
219  dnl Sanity check
220  dnl
221  AC_CHECK_FUNC(ldap_bind_s, [], [
222    AC_MSG_ERROR([LDAP build check failed. Please check config.log for more information.])
223  ])
224
225  dnl Restore original values
226  CPPFLAGS=$_SAVE_CPPFLAGS
227  LIBS=$_SAVE_LIBS
228fi
229