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