1AC_INIT(pam_ldap.c)
2AC_CANONICAL_SYSTEM
3AC_PREFIX_DEFAULT()
4
5AM_INIT_AUTOMAKE(pam_ldap, 185)
6AM_CONFIG_HEADER(config.h)
7
8AC_PROG_CC
9AC_PROG_CPP
10AC_PROG_INSTALL
11
12AC_ARG_ENABLE(ypldapd, [  --enable-ypldapd        enable PADL ypldapd specific features], [AC_DEFINE(YPLDAPD)])
13AC_ARG_ENABLE(ssl, [  --disable-ssl           disable SSL/TSL support])
14AC_ARG_WITH(ldap-lib, [  --with-ldap-lib=type    select ldap library [auto|netscape5|netscape4|netscape3|umich|openldap]])
15AC_ARG_WITH(ldap-dir, [  --with-ldap-dir=DIR     base directory of ldap SDK])
16AC_ARG_WITH(ldap-conf-file, [  --with-ldap-conf-file     path to LDAP configuration file], [AC_DEFINE_UNQUOTED(PAM_LDAP_PATH_CONF, "$with_ldap_conf_file")])
17AC_ARG_WITH(ldap-secret-file, [  --with-ldap-secret-file   path to LDAP root secret file], [AC_DEFINE_UNQUOTED(PAM_LDAP_PATH_ROOTPASSWD, "$with_ldap_secret_file")])
18
19if test "$ac_cv_prog_gcc" = "yes"; then CFLAGS="$CFLAGS -Wall -fPIC"; fi
20
21dnl This is needed for the native Solaris LDAP SDK
22CPPFLAGS="$CPPFLAGS -DLDAP_REFERRALS -DLDAP_DEPRECATED"
23
24case "$target_os" in
25freebsd*) CPPFLAGS="$CPPFLAGS -DPIC -D_REENTRANT" ;;
26aix*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
27*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
28esac
29
30case "$target_os" in
31aix*) if test "$ac_cv_prog_gcc" = "yes"; then
32    pam_ldap_so_LD="/usr/ccs/bin/ld"
33  fi
34  LDFLAGS="$LDFLAGS -Wl,-brtl"
35  pam_ldap_so_LDFLAGS="-bM:SRE -bnoentry -bE:\$(srcdir)/exports.aix -brtl -lc"
36  TARGET_OS="AIX" ;;
37darwin*) pam_ldap_so_LDFLAGS="-bundle" ;;
38hpux*) pam_ldap_so_LD="/bin/ld"
39  pam_ldap_so_LDFLAGS="-b -dynamic -G `cat exports.hpux`"
40  TARGET_OS="HPUX" ;;
41solaris*) pam_ldap_so_LD="/usr/ccs/bin/ld"
42  pam_ldap_so_LDFLAGS="-B dynamic -M \$(srcdir)/exports.solaris -G -B group -lc" ;;
43linux*) pam_ldap_so_LDFLAGS="-shared -Wl,-Bdynamic -Wl,--version-script,\$(srcdir)/exports.linux" ;;
44*) pam_ldap_so_LDFLAGS="-shared" ;;
45esac
46
47AC_SUBST(pam_ldap_so_LD)
48AC_SUBST(pam_ldap_so_LDFLAGS)
49
50AM_CONDITIONAL(USE_NATIVE_LINKER, test -n "$pam_ldap_so_LD")
51AM_CONDITIONAL(EXTENSION_SO, test "$target_os" = "linux" -o "$target_os" = "linux-gnu")
52AM_CONDITIONAL(EXTENSION_1, test "$TARGET_OS" = "HPUX")
53
54if test -n "$with_ldap_dir"; then
55  CPPFLAGS="$CPPFLAGS -I$with_ldap_dir/include"
56  LDFLAGS="$LDFLAGS -L$with_ldap_dir/lib"
57  case "$target_os" in
58  aix*) LDFLAGS="$LDFLAGS -Wl,-blibpath:$with_ldap_dir/lib"
59    pam_ldap_so_LDFLAGS="$pam_ldap_so_LDFLAGS -L$with_ldap_dir/lib -blibpath:$with_ldap_dir/lib" ;;
60  hpux*) LDFLAGS="$LDFLAGS -Wl,+b$with_ldap_dir/lib"
61    pam_ldap_so_LDFLAGS="$pam_ldap_so_LDFLAGS -L$with_ldap_dir/lib +b$with_ldap_dir/lib" ;;
62  solaris*) LDFLAGS="$LDFLAGS -R$with_ldap_dir/lib"
63    pam_ldap_so_LDFLAGS="$pam_ldap_so_LDFLAGS -L$with_ldap_dir/lib -R$with_ldap_dir/lib" ;;
64  *) LDFLAGS="$LDFLAGS -Wl,-rpath,$with_ldap_dir/lib" ;;
65  esac
66fi
67
68AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h security/pam_modules.h)
69AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h pam/pam_modules.h)
70AC_CHECK_HEADERS(des.h crypt.h)
71AC_CHECK_HEADERS(lber.h)
72AC_CHECK_HEADERS(ldap.h, , AC_MSG_ERROR(could not locate <ldap.h>))
73AC_CHECK_HEADERS(ldap_ssl.h)
74AC_CHECK_HEADERS(sasl/sasl.h)
75AC_CHECK_HEADERS(sasl.h)
76
77AC_CHECK_LIB(dl, main)
78AC_CHECK_LIB(pam, main)
79dnl AC_CHECK_LIB(pthread, main)
80AC_CHECK_LIB(resolv, main)
81AC_CHECK_LIB(crypt, main)
82AC_CHECK_LIB(nsl, main)
83
84AC_CHECK_FUNCS(gethostbyname)
85if test "$ac_cv_func_gethostbyname" = "no"; then
86  unset ac_cv_func_gethostbyname
87  AC_CHECK_LIB(nsl, main)
88  AC_CHECK_FUNCS(gethostbyname)
89fi
90
91
92dnl check which ldap library we have
93if test -z "$with_ldap_lib"; then
94  with_ldap_lib=auto
95fi
96
97if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = umich -o $with_ldap_lib = openldap \); then
98  AC_CHECK_LIB(lber, main)
99  AC_CHECK_LIB(ldap, main, LIBS="-lldap $LIBS" found_ldap_lib=yes)
100fi
101
102if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape5 \); then
103  AC_CHECK_LIB(ldap50, main, LIBS="-lldap50 -lssldap50 -lssl3 -lnss3 -lnspr4 -lprldap50 -lplc4 -lplds4 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
104fi
105if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape4 \); then
106  AC_CHECK_LIB(ldapssl41, main, LIBS="-lldapssl41 -lplc3 -lplds3 -lnspr3 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
107  if test -z "$found_ldap_lib"; then
108    AC_CHECK_LIB(ldapssl40, main, LIBS="-lldapssl40 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
109  fi
110  if test -z "$found_ldap_lib"; then
111    AC_CHECK_LIB(ldap41, main, LIBS="-lldap41 $LIBS" found_ldap_lib=yes need_pthread=no,,)
112  fi
113  if test -z "$found_ldap_lib"; then
114    AC_CHECK_LIB(ldap40, main, LIBS="-lldap40 $LIBS" found_ldap_lib=yes need_pthread=no,,)
115  fi
116fi
117if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape3 \); then
118  AC_CHECK_LIB(ldapssl30, main, LIBS="-lldapssl30 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
119fi
120
121if test -z "$found_ldap_lib"; then
122  AC_MSG_ERROR(could not locate a valid LDAP library)
123fi
124
125if test "$need_pthread" = "yes"; then
126  AC_CHECK_LIB(pthread, main)
127fi
128
129AC_CHECK_FUNCS(ldap_init ldap_get_lderrno ldap_set_lderrno ldap_parse_result ldap_memfree ldap_controls_free ldap_set_option ldap_get_option)
130if test "$enable_ssl" \!= "no"; then
131  AC_CHECK_FUNCS(ldapssl_init ldap_start_tls_s ldap_pvt_tls_set_option)
132fi
133AC_CHECK_FUNCS(ldap_initialize)
134AC_CHECK_FUNCS(ldap_sasl_bind ldap_sasl_interactive_bind_s)
135AC_CHECK_FUNCS(gethostbyname_r)
136
137if test "$ac_cv_func_gethostbyname_r" = "yes"; then
138AC_CACHE_CHECK(whether gethostbyname_r takes 6 arguments, xad_cv_gethostbyname_r_args, [
139AC_TRY_COMPILE([
140#include <netdb.h>], [gethostbyname_r(0, 0, 0, 0, 0, 0);], [xad_cv_gethostbyname_r_args=6], [
141	AC_TRY_COMPILE([
142		#include <netdb.h>],
143		[gethostbyname_r(0, 0, 0, 0, 0);], [xad_cv_gethostbyname_r_args=5], [xad_cv_gethostbyname_r_args=3]
144)]) ])
145AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_ARGS, $xad_cv_gethostbyname_r_args)
146fi
147
148AC_CHECK_FUNCS(ldap_set_rebind_proc)
149AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, pam_ldap_cv_ldap_set_rebind_proc, [
150AC_TRY_COMPILE([
151#include <lber.h>
152#include <ldap.h>], [ldap_set_rebind_proc(0, 0, 0);], [pam_ldap_cv_ldap_set_rebind_proc=3], [pam_ldap_cv_ldap_set_rebind_proc=2]) ])
153AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $pam_ldap_cv_ldap_set_rebind_proc)
154
155AC_OUTPUT(Makefile)
156