Start integrating new build system with "configure"
[freeradius.git] / src / modules / rlm_ldap / configure.in
1 AC_PREREQ([2.53])
2 AC_INIT(rlm_ldap.c)
3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_ldap])
5
6 fail=
7 SMART_LIBS=
8 SMART_CLFAGS=
9 if test x$with_[]modname != xno; then
10
11         dnl ############################################################
12         dnl # Check for compiler
13         dnl ############################################################
14         AC_PROG_CC
15
16         dnl ############################################################
17         dnl # Check for command line options
18         dnl ############################################################
19
20         dnl extra argument: --with-rlm-ldap-lib-dir
21         rlm_ldap_lib_dir=
22         AC_ARG_WITH(rlm-ldap-lib-dir,
23         [  --with-rlm-ldap-lib-dir=DIR       directory for LDAP library files []],
24         [ case "$withval" in
25             no)
26                 AC_MSG_ERROR(Need rlm-ldap-lib-dir)
27                 ;;
28             yes)
29                 ;;
30             *)
31                 rlm_ldap_lib_dir="$withval"
32                 ;;
33           esac ]
34         )
35
36         dnl extra argument: --with-rlm-ldap-include-dir
37         rlm_ldap_include_dir=
38         AC_ARG_WITH(rlm-ldap-include-dir,
39         [  --with-rlm-ldap-include-dir=DIR   directory for LDAP include files []],
40         [ case "$withval" in
41             no)
42                 AC_MSG_ERROR(Need rlm-ldap-include-dir)
43                 ;;
44             yes)
45                 ;;
46             *)
47                 rlm_ldap_include_dir="$withval"
48                 ;;
49           esac ]
50         )
51
52         dnl extra argument: --enable-shared --disable-shared
53         AC_ENABLE_SHARED
54
55         dnl OpenLDAP doesn't provide an autoconf test for their libldap,
56         dnl and we can't reasonably check for all the dependancies for
57         dnl every version and every set of options.
58         if test "x$enable_shared" = "xno"; then
59                 AC_MSG_WARN(Static linking with libldap will probably result in unresolved symbols.)
60         fi
61
62         dnl extra argument: --with-threads
63         rlm_ldap_with_threads=yes
64         AC_ARG_WITH(threads,
65         [  --with-threads          use threads, if available. (default=yes) ],
66         [ case "$withval" in
67             no)
68                 rlm_ldap_with_threads=no
69                 ;;
70             *)
71                 ;;
72             esac ])
73
74         dnl ############################################################
75         dnl # Check for libraries
76         dnl ############################################################
77
78         dnl pthread stuff is usually in -lpthread
79         dnl or in -lc_r, on *BSD
80         if test "x$rlm_ldap_with_threads" = "xyes"; then
81             AC_CHECK_LIB(pthread, pthread_create,
82                          [ LIBS="-lpthread $LIBS" ],
83                          AC_CHECK_LIB(c_r, pthread_create,
84                                       [ LIBS="-lc_r $LIBS" ],
85                                       [ rlm_ldap_with_threads="no" ]
86                                       )
87                          )
88         fi
89
90         dnl Try only "-lldap_r" or "-lldap"
91         dnl Static linking will probably not work, but nobody ever
92         dnl complained about it.
93         smart_try_dir=$rlm_ldap_lib_dir
94         if test "x$rlm_ldap_with_threads" = "xyes"; then
95             FR_SMART_CHECK_LIB(ldap_r, ldap_init)
96             if test "x$ac_cv_lib_ldap_r_ldap_init" != "xyes"; then
97                 fail="$fail libldap_r"
98             fi
99         else
100             FR_SMART_CHECK_LIB(ldap, ldap_init)
101             if test "x$ac_cv_lib_ldap_ldap_init" != "xyes"; then
102                 fail="$fail libldap"
103             fi
104         fi
105
106         dnl ############################################################
107         dnl # Check for header files
108         dnl ############################################################
109
110         smart_try_dir=$rlm_ldap_include_dir
111         FR_SMART_CHECK_INCLUDE(ldap.h)
112         if test "$ac_cv_header_ldap_h" != "yes"; then
113           fail="$fail ldap.h"
114         fi
115
116         dnl ############################################################
117         dnl # Check for library functions
118         dnl ############################################################
119
120         if test "x$fail" = "x"; then
121             AC_CHECK_FUNC(ldap_start_tls_s,
122                 [ SMART_CFLAGS="$SMART_CFLAGS -DHAVE_LDAP_START_TLS" ])
123             AC_CHECK_FUNC(ldap_initialize,
124                 [ SMART_CFLAGS="$SMART_CFLAGS -DHAVE_LDAP_INITIALIZE" ])
125             AC_CHECK_FUNC(ldap_int_tls_config,
126                 [ SMART_CFLAGS="$SMART_CFLAGS -DHAVE_LDAP_INT_TLS_CONFIG" ])
127
128
129         AC_CHECK_FUNCS(ldap_set_rebind_proc)
130         AC_CACHE_CHECK(whether ldap_set_rebind_proc takes 3 arguments, ac_cv_ldap_set_rebind_proc, [
131         AC_TRY_COMPILE([
132         #include <lber.h>
133         #include <ldap.h>], [ldap_set_rebind_proc(0, 0, 0);],
134           [ac_cv_ldap_set_rebind_proc=3],
135           [ac_cv_ldap_set_rebind_proc=2]) ])
136         fi
137
138         targetname=modname
139 else
140         targetname=
141         echo \*\*\* module modname is disabled.
142 fi
143
144 if test x"$fail" != x""; then
145         if test x"${enable_strict_dependencies}" = x"yes"; then
146                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
147         else
148                 AC_MSG_WARN([silently not building ]modname[.])
149                 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.])
150                 if test x"$headersuggestion" != x; then
151                         AC_MSG_WARN([$headersuggestion])
152                 fi
153                 if test x"$libsuggestion" != x; then
154                         AC_MSG_WARN([$libsuggestion])
155                 fi
156                 targetname=""
157         fi
158 fi
159
160 dnl extra argument: --with-edir
161 dnl If using Novell eDirectory, enable UP and Novell specific code
162 WITH_EDIRECTORY=no
163 AC_ARG_WITH(edir,
164 [  --with-edir             enable Novell eDirectory integration.  (default=no) ],
165 [ case "$withval" in
166     yes)
167         SMART_CFLAGS="$SMART_CFLAGS -DNOVELL_UNIVERSAL_PASSWORD -DNOVELL"
168         edir="edir_ldapext.c"
169         ;;
170     *)
171         ;;
172   esac ]
173 )
174
175 ldap_ldflags=$SMART_LIBS
176 ldap_cflags="$SMART_CFLAGS -DLDAP_DEPRECATED -DLDAP_SET_REBIND_PROC_ARGS=$ac_cv_ldap_set_rebind_proc"
177 AC_SUBST(edir)
178 AC_SUBST(ldap_ldflags)
179 AC_SUBST(ldap_cflags)
180 AC_SUBST(targetname)
181 AC_OUTPUT(Makefile)
182 AC_OUTPUT(all.mk)