]> git.sur5r.net Git - openldap/blob - contrib/slapd-modules/nssov/nss-ldapd/configure.ac
ITS#5801
[openldap] / contrib / slapd-modules / nssov / nss-ldapd / configure.ac
1 # configure.ac - process this file with autoconf to produce configure
2 #
3 # Copyright (C) 2006 Luke Howard
4 # Copyright (C) 2006 West Consulting
5 # Copyright (C) 2006, 2007, 2008 Arthur de Jong
6 #
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
11 #
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301 USA
21
22 AC_PREREQ(2.59)
23 AC_COPYRIGHT(
24 [Copyright (C) 2006 Luke Howard
25 Copyright (C) 2006 West Consulting
26 Copyright (C) 2006, 2007, 2008 Arthur de Jong
27
28 This configure script is derived from configure.ac which is free software;
29 you can redistribute it and/or modify it under the terms of the GNU Lesser
30 General Public License as published by the Free Software Foundation; either
31 version 2.1 of the License, or (at your option) any later version. See the
32 configure.ac file for more details.])
33
34 # initialize and set version and bugreport address
35 AC_INIT([nss-ldapd],[0.6.2],[arthur@ch.tudelft.nl])
36 RELEASE_MONTH="May 2008"
37 AC_SUBST(RELEASE_MONTH)
38 AC_CONFIG_SRCDIR([nslcd.h])
39
40 AC_CANONICAL_TARGET
41 AC_PREFIX_DEFAULT()
42
43 # display notice and initialize automake
44 AC_MSG_NOTICE([configuring AC_PACKAGE_TARNAME AC_PACKAGE_VERSION])
45 AM_INIT_AUTOMAKE(AC_PACKAGE_TARNAME,AC_PACKAGE_VERSION)
46
47 # create a config.h file (Automake will add -DHAVE_CONFIG_H)
48 AC_CONFIG_HEADERS([config.h])
49
50 # check for programs
51 AC_PROG_CC
52 AC_PROG_CPP
53 AC_PROG_INSTALL
54 AC_PROG_RANLIB
55 AM_PROG_CC_C_O
56 AC_USE_SYSTEM_EXTENSIONS
57
58 # checks for tool to convert docbook to man
59 AC_PATH_PROGS(DOCBOOK2X_MAN, docbook2x-man)
60 if test "x${DOCBOOK2X_MAN}" = x
61 then
62   AC_MSG_WARN([docbook2x-man not found: not generating man pages])
63 fi
64 AM_CONDITIONAL([GENMAN], [test "x${DOCBOOK2X_MAN}" != x])
65
66 # start with default options
67 nss_ldap_so_LIBS=
68 nslcd_LIBS=
69
70 # check for debugging options
71 AC_ARG_ENABLE(debug,
72               AS_HELP_STRING([--enable-debug],
73                              [enable extensive debugging and logging]),
74               [if test "x$enableval" != "xno" ; then CFLAGS="-g -DDEBUG $CFLAGS" ; fi])
75
76 DESIRED_CFLAGS=""
77
78 # check for extra compiler warnings
79 AC_ARG_ENABLE(warnings,
80               AS_HELP_STRING([--enable-warnings],
81                              [enable extra compiler warnings (gcc)]),
82               [if test "x$enableval" != "no"
83                then
84                  CFLAGS="$CFLAGS -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Waggregate-return -Wmissing-declarations -Wunused -Wformat=2 -Wswitch-default -Wswitch-enum -Wfloat-equal -Wbad-function-cast -Wunreachable-code -Wredundant-decls"
85                  DESIRED_CFLAGS="$DESIRED_CFLAGS -Wextra -Wdeclaration-after-statement -Werror-implicit-function-declaration"
86                fi])
87
88 test_gcc_flag() {
89   AC_LANG_CONFTEST([int main() {}])
90   $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
91   ret=$?
92   rm -f conftest.o
93   return $ret
94 }
95
96 for flag in $DESIRED_CFLAGS
97 do
98   AC_MSG_CHECKING([whether $CC accepts $flag])
99   if test_gcc_flag $flag
100   then
101     CFLAGS="$CFLAGS $flag"
102     AC_MSG_RESULT([yes])
103   else
104     AC_MSG_RESULT([no])
105   fi
106 done
107
108 AC_ARG_WITH(ldap-lib,
109             AS_HELP_STRING([--with-ldap-lib=TYPE],
110                            [select ldap library (auto|netscape5|netscape4|netscape3|umich|openldap) @<:@auto@:>@]))
111 if test -z "$with_ldap_lib"
112 then
113   with_ldap_lib=auto
114 fi
115
116 AC_ARG_WITH(ldap-conf-file,
117             AS_HELP_STRING([--with-ldap-conf-file=PATH],
118                            [path to LDAP configuration file @<:@/etc/nss-ldapd.conf@:>@]),
119             [ NSS_LDAP_PATH_CONF="$with_ldap_conf_file" ],
120             [ NSS_LDAP_PATH_CONF="/etc/nss-ldapd.conf" ])
121 AC_DEFINE_UNQUOTED(NSS_LDAP_PATH_CONF,"$NSS_LDAP_PATH_CONF",[Path to LDAP configuration file.])
122 AC_SUBST(NSS_LDAP_PATH_CONF)
123
124 AC_ARG_WITH(nslcd-pidfile,
125             AS_HELP_STRING([--with-nslcd-pidfile=PATH],
126                            [path to pidfile @<:@/var/run/nslcd/nslcd.pid@:>@]),
127             [ NSLCD_PIDFILE="$with_nslcd_pidfile" ],
128             [ NSLCD_PIDFILE="/var/run/nslcd/nslcd.pid" ])
129 AC_DEFINE_UNQUOTED(NSLCD_PIDFILE,"$NSLCD_PIDFILE",[The location of the pidfile used for checking availability of the nslcd.])
130 AC_SUBST(NSLCD_PIDFILE)
131
132 AC_ARG_WITH(nslcd-socket,
133             AS_HELP_STRING([--with-nslcd-socket=PATH],
134                            [path to socket @<:@/var/run/nslcd/socket@:>@]),
135             [ NSLCD_SOCKET="$with_nslcd_socket" ],
136             [ NSLCD_SOCKET="/var/run/nslcd/socket" ])
137 AC_DEFINE_UNQUOTED(NSLCD_SOCKET,"$NSLCD_SOCKET",[The location of the socket used for communicating.])
138 AC_SUBST(NSLCD_SOCKET)
139
140 # checks for availability of header files
141 AC_CHECK_HEADERS(lber.h)
142 AC_CHECK_HEADERS(ldap.h,,AC_MSG_ERROR([could not locate <ldap.h>]),[
143     #if HAVE_LBER_H
144     #include <lber.h>
145     #endif
146     ])
147 AC_CHECK_HEADERS(ldap_ssl.h)
148 AC_CHECK_HEADERS(nss.h)
149 AC_CHECK_HEADERS(pthread.h)
150 AC_CHECK_HEADERS(shadow.h)
151 AC_CHECK_HEADERS(aliases.h)
152 AC_CHECK_HEADERS(netinet/ether.h)
153 AC_CHECK_HEADERS(ctype.h)
154 AC_CHECK_HEADERS(getopt.h)
155 AC_CHECK_HEADERS(sys/un.h)
156 AC_CHECK_HEADERS(sasl.h sasl/sasl.h)
157 AC_CHECK_HEADERS(strings.h)
158 AC_CHECK_HEADERS(gssldap.h)
159 AC_CHECK_HEADERS(gsssasl.h)
160 AC_CHECK_HEADERS(gssapi/gssapi_krb5.h gssapi.h)
161 AC_CHECK_HEADERS(grp.h)
162 AC_CHECK_HEADERS(sys/socket.h)
163 AC_CHECK_HEADERS(sys/ucred.h)
164 AC_CHECK_HEADERS(ucred.h)
165
166 # set up directory with compatibility replacement files
167 AC_CONFIG_LIBOBJ_DIR([compat])
168
169 # checks for availability of system libraries for nslcd
170 save_LIBS="$LIBS"
171 LIBS="$nslcd_LIBS"
172 AC_SEARCH_LIBS(gethostbyname,nsl socket)
173 AC_SEARCH_LIBS(socket,socket)
174 #AC_CHECK_LIB(resolv,main)
175 nslcd_LIBS="$LIBS"
176 LIBS="$save_LIBS"
177
178 # check for availability of system libraries for nss part
179 save_LIBS="$LIBS"
180 LIBS="$nss_ldap_so_LIBS"
181 AC_SEARCH_LIBS(socket,socket)
182 nss_ldap_so_LIBS="$LIBS"
183 LIBS="$save_LIBS"
184
185 # TODO: simplify the above since we need a correct LIBS for the following
186 #       tests
187
188 # checks for availability of functions
189 AC_CHECK_FUNCS(sigaction)
190 AC_CHECK_FUNCS(snprintf)
191 AC_CHECK_FUNCS(gethostbyname)
192 AC_CHECK_FUNCS(setgroups)
193 AC_CHECK_FUNCS(getpeereid)
194 AC_CHECK_FUNCS(getpeerucred)
195 AC_CHECK_FUNCS(__nss_configure_lookup)
196
197
198 # replace getopt_long() function if it is not on the system
199 AC_REPLACE_FUNCS(getopt_long)
200 # replace daemon() function if it is not on the system
201 AC_SEARCH_LIBS(daemon,bsd)
202 AC_REPLACE_FUNCS(daemon)
203 # replace ether_ntoa_r() and ether_aton_r() if they are not found
204 AC_CHECK_FUNCS(ether_aton_r ether_ntoa_r,,[AC_CHECK_FUNCS(ether_aton ether_ntoa)
205                                            AC_LIBOBJ(ether)])
206
207 # checks for types
208 AC_C_CONST
209 AC_TYPE_SIGNAL
210 AC_TYPE_MODE_T
211 AC_TYPE_SIZE_T
212 AC_TYPE_UID_T
213
214 # check for support for the __thread keyword
215 AC_CACHE_CHECK([whether $CC supports '__thread'], [mn_cv_c___thread_supported],
216                [AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[static __thread i;]], []),
217                        [mn_cv_c___thread_supported=yes],
218                        [mn_cv_c___thread_supported=no])])
219 if test $mn_cv_c___thread_supported != yes
220 then
221   AC_MSG_WARN([$CC does not support '__thread' keyword])
222   AC_DEFINE(__thread,,[Define to empty if compiler does not support `__thread' keyword.])
223 fi
224
225 # check for support for the struct ether_addr structure
226 AC_CHECK_TYPE(struct ether_addr,
227     AC_DEFINE(HAVE_STRUCT_ETHER_ADDR,1,[Define to 1 if you have a `struct ether_addr' definition.]),,[
228     #include <sys/socket.h>
229     #include <net/if.h>
230     #include <netinet/in.h>
231     #include <netinet/if_ether.h>])
232
233 # check to see if socklen_t is defined
234 AC_CHECK_TYPE(socklen_t,,
235     AC_DEFINE(socklen_t,size_t,[Define to `size_t' if not defined elswhere.]),[
236     #include <sys/types.h>
237     #include <sys/socket.h>])
238
239 # check to see if struct sockaddr_storage is defined
240 AC_CHECK_TYPE(struct sockaddr_storage,,
241     AC_DEFINE(sockaddr_storage,sockaddr_in,[Define to `sockaddr_in' if not defined elsewhere.]),[
242     #include <sys/types.h>
243     #include <sys/socket.h>])
244
245 # check for support for the struct ucred structure
246 AC_CHECK_TYPE(struct ucred,
247     AC_DEFINE(HAVE_STRUCT_UCRED,1,[Define to 1 if you have a `struct ucred' definition.]),,[
248     #include <sys/socket.h>
249     #include <sys/un.h>
250     #include <sys/types.h>])
251
252 AC_CHECK_TYPE(sasl_interact_t,
253     AC_DEFINE(HAVE_SASL_INTERACT_T,1,[Define to 1 if you have a `sasl_interact_t' definition.]))
254
255 # checks for LDAP library
256 save_LIBS="$LIBS"
257 LIBS="$nslcd_LIBS"
258 save_CFLAGS="$CFLAGS"
259
260 # check threading stuff
261 ACX_PTHREAD(,AC_MSG_ERROR([no support for pthreads]))
262 AC_CHECK_FUNCS(pthread_atfork)
263
264 LIBS="$PTHREAD_LIBS $LIBS"
265 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
266
267 AC_CHECK_LIB(gssapi, gss_krb5_ccache_name,[LIBS="-lgssapi $LIBS" found_gssapi_lib=yes],,$LIBS)
268 if test -z "$found_gssapi_lib"
269 then
270   AC_CHECK_LIB(gssapi_krb5, gss_krb5_ccache_name,[LIBS="-lgssapi_krb5 $LIBS"],,$LIBS)
271 fi
272
273 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = umich -o $with_ldap_lib = openldap \)
274 then
275   AC_SEARCH_LIBS(ldap_search_ext,[ldap_r ldap],found_ldap_lib=yes,,)
276 fi
277 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape5 \)
278 then
279   AC_CHECK_LIB(ldap50, main, LIBS="-lldap50 -lssldap50 -lssl3 -lnss3 -lnspr4 -lprldap50 -lplc4 -lplds4 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
280 fi
281 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape4 \)
282 then
283   AC_CHECK_LIB(ldapssl41, main, LIBS="-lldapssl41 -lplc3 -lplds3 -lnspr3 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
284   if test -z "$found_ldap_lib"
285   then
286     AC_CHECK_LIB(ldapssl40, main, LIBS="-lldapssl40 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
287   fi
288   if test -z "$found_ldap_lib"
289   then
290     AC_CHECK_LIB(ldap41, main, LIBS="-lldap41 $LIBS" found_ldap_lib=yes need_pthread=no,,)
291   fi
292   if test -z "$found_ldap_lib"
293   then
294     AC_CHECK_LIB(ldap40, main, LIBS="-lldap40 $LIBS" found_ldap_lib=yes need_pthread=no,,)
295   fi
296 fi
297 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape3 \)
298 then
299   AC_CHECK_LIB(ldapssl30, main, LIBS="-lldapssl30 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
300 fi
301 if test -z "$found_ldap_lib"
302 then
303   AC_MSG_ERROR(could not locate a valid LDAP library)
304 fi
305 if test "$need_pthread" = "yes"
306 then
307   AC_CHECK_LIB(pthread, main)
308 fi
309 AC_CHECK_LIB(gssldap, ldap_gss_bind,[LIBS="-lgssldap $LIBS"],,$LIBS)
310 AC_CHECK_LIB(sasl2, sasl_client_init)
311
312 AC_CHECK_FUNCS(sasl_auxprop_request)
313 AC_CHECK_FUNCS(gss_krb5_ccache_name)
314 AC_CHECK_FUNCS(ldap_parse_result ldap_memfree ldap_controls_free ldap_control_free)
315 AC_CHECK_FUNCS(ldap_explode_dn ldap_explode_rdn ldap_set_option ldap_get_option)
316 AC_CHECK_FUNCS(ldap_abandon ldap_simple_bind_s ldap_unbind ldap_set_rebind_proc)
317 AC_CHECK_FUNCS(ldap_sasl_interactive_bind_s ldap_initialize ldap_search_ext)
318 AC_CHECK_FUNCS(ldap_create_control)
319 AC_CHECK_FUNCS(ldap_domain2hostlist ldap_domain2dn)
320 AC_CHECK_FUNCS(ldap_get_values ldap_value_free ldap_get_dn)
321 AC_CHECK_FUNCS(ldap_err2string ldap_msgfree ldap_result)
322
323 # replace ldap_create_page_control() and ldap_parse_page_control()
324 AC_CHECK_FUNCS(ldap_create_page_control ldap_parse_page_control,,[AC_LIBOBJ(pagectrl)])
325
326 # check the number of arguments that ldap_set_rebind_proc() uses
327 AC_CACHE_CHECK(
328     [number of arguments to ldap_set_rebind_proc],
329     nss_ldapd_cv_ldap_set_rebind_proc,
330     [AC_COMPILE_IFELSE(
331         [AC_LANG_PROGRAM([[
332             #include <lber.h>
333             #include <ldap.h>]],
334             [[ldap_set_rebind_proc(0, 0, 0);]])],
335         [nss_ldapd_cv_ldap_set_rebind_proc=3],
336         [nss_ldapd_cv_ldap_set_rebind_proc=2]) ])
337 AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS,$nss_ldapd_cv_ldap_set_rebind_proc,
338                    [Define to the number of arguments to ldap_set_rebindproc.])
339
340 CFLAGS="$save_CFLAGS"
341 nslcd_LIBS="$LIBS"
342 LIBS="$save_LIBS"
343
344 AC_SUBST(nss_ldap_so_LIBS)
345 AC_SUBST(nslcd_LIBS)
346
347 # generate files
348 AC_CONFIG_FILES([Makefile compat/Makefile common/Makefile
349                  nss/Makefile nslcd/Makefile man/Makefile tests/Makefile])
350 AC_OUTPUT