1AC_DEFUN([PHP_LDAP_CHECKS], [ 2 if test -f $1/include/ldap.h; then 3 LDAP_DIR=$1 4 LDAP_INCDIR=$1/include 5 LDAP_LIBDIR=$1/$PHP_LIBDIR 6 elif test -f $1/ldap/public/ldap.h; then 7 LDAP_DIR=$1 8 LDAP_INCDIR=$1/ldap/public 9 LDAP_LIBDIR=$1/$PHP_LIBDIR 10 else 11 dnl Note that Oracle Instant Client lacks LDAP features implemented in PHP 12 dnl ldap extension and cannot be built. Use OpenLDAP on Solaris. 13 dnl See: https://github.com/php/php-src/issues/15051 14 15 dnl Find Oracle Instant Client RPM header location corresponding to the 16 dnl given lib path e.g. for --with-ldap=/usr/lib/oracle/12.1/client64/lib 17 AC_CHECK_SIZEOF([long]) 18 AC_MSG_CHECKING([if we're at 64-bit platform]) 19 AS_IF([test "$ac_cv_sizeof_long" -eq 4],[ 20 AC_MSG_RESULT([no]) 21 PHP_OCI8_IC_LIBDIR_SUFFIX="" 22 ],[ 23 AC_MSG_RESULT([yes]) 24 PHP_OCI8_IC_LIBDIR_SUFFIX=64 25 ]) 26 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 43PHP_ARG_WITH([ldap], 44 [for LDAP support], 45 [AS_HELP_STRING([[--with-ldap[=DIR]]], 46 [Include LDAP support])]) 47 48PHP_ARG_WITH([ldap-sasl], 49 [whether to build with LDAP Cyrus SASL support], 50 [AS_HELP_STRING([--with-ldap-sasl], 51 [LDAP: Build with Cyrus SASL support])], 52 [no], 53 [no]) 54 55if test "$PHP_LDAP" != "no"; then 56 PHP_NEW_EXTENSION([ldap], 57 [ldap.c], 58 [$ext_shared],, 59 [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) 60 61 AS_VAR_IF([PHP_LDAP], [yes], [ 62 for i in /usr/local /usr; do 63 PHP_LDAP_CHECKS([$i]) 64 done 65 ], [PHP_LDAP_CHECKS([$PHP_LDAP])]) 66 67 AS_VAR_IF([LDAP_DIR],, [AC_MSG_ERROR([Cannot find ldap.h])]) 68 69 dnl -pc removal is a hack for clang 70 MACHINE_INCLUDES=$($CC -dumpmachine | $SED 's/-pc//') 71 72 AH_TEMPLATE([HAVE_ORALDAP], 73 [Define to 1 if the ldap extension uses the Oracle Instant Client.]) 74 75 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 76 PHP_ADD_LIBRARY_WITH_PATH([lber], [$LDAP_LIBDIR], [LDAP_SHARED_LIBADD]) 77 PHP_ADD_LIBRARY_WITH_PATH([ldap], [$LDAP_LIBDIR], [LDAP_SHARED_LIBADD]) 78 79 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 80 PHP_ADD_LIBRARY_WITH_PATH([ldap], [$LDAP_LIBDIR], [LDAP_SHARED_LIBADD]) 81 82 elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.12.1 || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libclntsh.$SHLIB_SUFFIX_NAME.12.1; then 83 PHP_ADD_LIBRARY_WITH_PATH([clntsh], [$LDAP_LIBDIR], [LDAP_SHARED_LIBADD]) 84 AC_DEFINE([HAVE_ORALDAP], [1]) 85 86 elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME.11.1 || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libclntsh.$SHLIB_SUFFIX_NAME.11.1; then 87 PHP_ADD_LIBRARY_WITH_PATH([clntsh], [$LDAP_LIBDIR], [LDAP_SHARED_LIBADD]) 88 AC_DEFINE([HAVE_ORALDAP], [1]) 89 90 elif test -f $LDAP_LIBDIR/libclntsh.$SHLIB_SUFFIX_NAME || test -f $LDAP_LIBDIR/$MACHINE_INCLUDES/libclntsh.$SHLIB_SUFFIX_NAME; then 91 PHP_ADD_LIBRARY_WITH_PATH([clntsh], [$LDAP_LIBDIR], [LDAP_SHARED_LIBADD]) 92 AC_DEFINE([HAVE_ORALDAP], [1]) 93 94 else 95 AC_MSG_ERROR([Cannot find ldap libraries in $LDAP_LIBDIR.]) 96 fi 97 98 PHP_ADD_INCLUDE([$LDAP_INCDIR]) 99 PHP_SUBST([LDAP_SHARED_LIBADD]) 100 AC_DEFINE([HAVE_LDAP], [1], 101 [Define to 1 if the PHP extension 'ldap' is available.]) 102 103 dnl Save original values 104 _SAVE_CPPFLAGS=$CPPFLAGS 105 _SAVE_LIBS=$LIBS 106 CPPFLAGS="$CPPFLAGS -I$LDAP_INCDIR" 107 LIBS="$LIBS $LDAP_SHARED_LIBADD" 108 109 dnl Check for 3 arg ldap_set_rebind_proc 110 AC_CACHE_CHECK([for 3 arg ldap_set_rebind_proc], 111 [php_cv_have_3arg_setrebindproc], 112 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <ldap.h>], 113 [ldap_set_rebind_proc(0,0,0)])], 114 [php_cv_have_3arg_setrebindproc=yes], 115 [php_cv_have_3arg_setrebindproc=no])]) 116 AS_VAR_IF([php_cv_have_3arg_setrebindproc], [yes], 117 [AC_DEFINE([HAVE_3ARG_SETREBINDPROC], [1], 118 [Define to 1 if 'ldap_set_rebind_proc' has 3 arguments.])]) 119 120 dnl Solaris 2.8 claims to be 2004 API, but doesn't have ldap_parse_reference() 121 dnl nor ldap_start_tls_s() 122 AC_CHECK_FUNCS(m4_normalize([ 123 ldap_control_find 124 ldap_extended_operation 125 ldap_extended_operation_s 126 ldap_parse_extended_result 127 ldap_parse_reference 128 ldap_parse_result 129 ldap_passwd 130 ldap_refresh_s 131 ldap_start_tls_s 132 ldap_whoami_s 133 ])) 134 135 dnl SASL check 136 AS_VAR_IF([PHP_LDAP_SASL], [no],, [ 137 PKG_CHECK_MODULES([SASL], [libsasl2]) 138 PHP_EVAL_INCLINE([$SASL_CFLAGS]) 139 PHP_EVAL_LIBLINE([$SASL_LIBS], [LDAP_SHARED_LIBADD]) 140 AC_DEFINE([HAVE_LDAP_SASL], [1], 141 [Define to 1 if the ldap extension has SASL support enabled.]) 142 ]) 143 144 dnl Sanity check 145 AC_CHECK_FUNC([ldap_sasl_bind_s],, 146 [AC_CHECK_FUNC([ldap_simple_bind_s],, 147 [AC_MSG_ERROR([LDAP library build check failed.])])]) 148 149 dnl Restore original values 150 CPPFLAGS=$_SAVE_CPPFLAGS 151 LIBS=$_SAVE_LIBS 152fi 153