1 # configure.ac - process this file with autoconf to produce configure
3 # Copyright (C) 2006 Luke Howard
4 # Copyright (C) 2006 West Consulting
5 # Copyright (C) 2006, 2007, 2008 Arthur de Jong
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.
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.
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
24 [Copyright (C) 2006 Luke Howard
25 Copyright (C) 2006 West Consulting
26 Copyright (C) 2006, 2007, 2008 Arthur de Jong
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.])
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])
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)
47 # create a config.h file (Automake will add -DHAVE_CONFIG_H)
48 AC_CONFIG_HEADERS([config.h])
56 AC_USE_SYSTEM_EXTENSIONS
58 # checks for tool to convert docbook to man
59 AC_PATH_PROGS(DOCBOOK2X_MAN, docbook2x-man)
60 if test "x${DOCBOOK2X_MAN}" = x
62 AC_MSG_WARN([docbook2x-man not found: not generating man pages])
64 AM_CONDITIONAL([GENMAN], [test "x${DOCBOOK2X_MAN}" != x])
66 # start with default options
70 # check for debugging options
72 AS_HELP_STRING([--enable-debug],
73 [enable extensive debugging and logging]),
74 [if test "x$enableval" != "xno" ; then CFLAGS="-g -DDEBUG $CFLAGS" ; fi])
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"
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"
89 AC_LANG_CONFTEST([int main() {}])
90 $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
96 for flag in $DESIRED_CFLAGS
98 AC_MSG_CHECKING([whether $CC accepts $flag])
99 if test_gcc_flag $flag
101 CFLAGS="$CFLAGS $flag"
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"
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)
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)
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)
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>]),[
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)
166 # set up directory with compatibility replacement files
167 AC_CONFIG_LIBOBJ_DIR([compat])
169 # checks for availability of system libraries for nslcd
172 AC_SEARCH_LIBS(gethostbyname,nsl socket)
173 AC_SEARCH_LIBS(socket,socket)
174 #AC_CHECK_LIB(resolv,main)
178 # check for availability of system libraries for nss part
180 LIBS="$nss_ldap_so_LIBS"
181 AC_SEARCH_LIBS(socket,socket)
182 nss_ldap_so_LIBS="$LIBS"
185 # TODO: simplify the above since we need a correct LIBS for the following
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)
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)
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
221 AC_MSG_WARN([$CC does not support '__thread' keyword])
222 AC_DEFINE(__thread,,[Define to empty if compiler does not support `__thread' keyword.])
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>
230 #include <netinet/in.h>
231 #include <netinet/if_ether.h>])
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>])
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>])
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>
250 #include <sys/types.h>])
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.]))
255 # checks for LDAP library
258 save_CFLAGS="$CFLAGS"
260 # check threading stuff
261 ACX_PTHREAD(,AC_MSG_ERROR([no support for pthreads]))
262 AC_CHECK_FUNCS(pthread_atfork)
264 LIBS="$PTHREAD_LIBS $LIBS"
265 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
267 AC_CHECK_LIB(gssapi, gss_krb5_ccache_name,[LIBS="-lgssapi $LIBS" found_gssapi_lib=yes],,$LIBS)
268 if test -z "$found_gssapi_lib"
270 AC_CHECK_LIB(gssapi_krb5, gss_krb5_ccache_name,[LIBS="-lgssapi_krb5 $LIBS"],,$LIBS)
273 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = umich -o $with_ldap_lib = openldap \)
275 AC_SEARCH_LIBS(ldap_search_ext,[ldap_r ldap],found_ldap_lib=yes,,)
277 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape5 \)
279 AC_CHECK_LIB(ldap50, main, LIBS="-lldap50 -lssldap50 -lssl3 -lnss3 -lnspr4 -lprldap50 -lplc4 -lplds4 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
281 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape4 \)
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"
286 AC_CHECK_LIB(ldapssl40, main, LIBS="-lldapssl40 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
288 if test -z "$found_ldap_lib"
290 AC_CHECK_LIB(ldap41, main, LIBS="-lldap41 $LIBS" found_ldap_lib=yes need_pthread=no,,)
292 if test -z "$found_ldap_lib"
294 AC_CHECK_LIB(ldap40, main, LIBS="-lldap40 $LIBS" found_ldap_lib=yes need_pthread=no,,)
297 if test -z "$found_ldap_lib" -a \( $with_ldap_lib = auto -o $with_ldap_lib = netscape3 \)
299 AC_CHECK_LIB(ldapssl30, main, LIBS="-lldapssl30 $LIBS" found_ldap_lib=yes need_pthread=yes,, -lpthread)
301 if test -z "$found_ldap_lib"
303 AC_MSG_ERROR(could not locate a valid LDAP library)
305 if test "$need_pthread" = "yes"
307 AC_CHECK_LIB(pthread, main)
309 AC_CHECK_LIB(gssldap, ldap_gss_bind,[LIBS="-lgssldap $LIBS"],,$LIBS)
310 AC_CHECK_LIB(sasl2, sasl_client_init)
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)
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)])
326 # check the number of arguments that ldap_set_rebind_proc() uses
328 [number of arguments to ldap_set_rebind_proc],
329 nss_ldapd_cv_ldap_set_rebind_proc,
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.])
340 CFLAGS="$save_CFLAGS"
344 AC_SUBST(nss_ldap_so_LIBS)
348 AC_CONFIG_FILES([Makefile compat/Makefile common/Makefile
349 nss/Makefile nslcd/Makefile man/Makefile tests/Makefile])