summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 5b01cafbe59155277e8ecf0c449201137c481930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# configure.ac - process this file with autoconf to produce configure
#
# Copyright (C) 2006 Luke Howard
# Copyright (C) 2006 West Consulting
# Copyright (C) 2006-2014 Arthur de Jong
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

AC_PREREQ(2.61)
AC_COPYRIGHT(
[Copyright (C) 2006 Luke Howard
Copyright (C) 2006 West Consulting
Copyright (C) 2006-2014 Arthur de Jong
Copyright (C) 2014 Luke Shumaker

This configure script is derived from configure.ac which is free software;
you can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. See the
configure.ac file for more details.])

# initialize and set version and bugreport address
AC_INIT([parabola-nslcd],
        [0.9.4.1],
        [dev@lists.parabolagnulinux.org],,
        [https://projects.parabola.nu/packages/parabola-nslcd.git/])
RELEASE_MONTH="Sep 2014"
AC_SUBST(RELEASE_MONTH)
AC_CONFIG_SRCDIR([nslcd.h])
AC_CONFIG_MACRO_DIR([m4])

# some initialisation
AC_CANONICAL_TARGET
AC_PREFIX_DEFAULT()
AC_CONFIG_LIBOBJ_DIR([compat])

# display notice and initialize automake
AC_MSG_NOTICE([configuring AC_PACKAGE_TARNAME AC_PACKAGE_VERSION])
AM_INIT_AUTOMAKE([1.11.2 check-news gnu std-options color-tests --warnings=all])

# create a config.h file (Automake will add -DHAVE_CONFIG_H)
AC_CONFIG_HEADERS([config.h])

# check for programs
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_RANLIB
AM_PROG_CC_C_O
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_LN_S
AM_PROG_AR

# checks for tool to convert docbook to man
genman="no"
AC_PATH_PROGS(DOCBOOK2X_MAN, docbook2x-man docbook2man)
AC_MSG_CHECKING([for tool to (re)generate man pages])
if test "x${DOCBOOK2X_MAN}" != x
then
  genman="${DOCBOOK2X_MAN}"
fi
AC_MSG_RESULT($genman)
AM_CONDITIONAL([GENMAN], [test "x${genman}" != "xno"])
if test "x${genman}" = "xno"
then
  AC_MSG_WARN([docbook2x-man not found: not (re)generating man pages])
fi

# check whether to install manual pages
AC_MSG_CHECKING([whether to install man pages])
instman="no"
if [test "x${genman}" != "xno" || ls  "${srcdir}/man/"*.? > /dev/null 2>&1]
then
  instman="yes"
fi
AC_MSG_RESULT($instman)
AM_CONDITIONAL([INSTMAN], [test "x${instman}" != "xno"])
if test "x${instman}" = "xno"
then
  AC_MSG_WARN([not installing man pages (no generator and not pre-generated)])
fi

# check for debugging options
AC_ARG_ENABLE(debug,
              AS_HELP_STRING([--enable-debug],
                             [enable extensive debugging and logging]),
              [if test "x$enableval" != "xno" ; then CFLAGS="-g -DDEBUG $CFLAGS" ; fi])

DESIRED_CFLAGS=""

# check for extra compiler warnings
AC_ARG_ENABLE(warnings,
              AS_HELP_STRING([--enable-warnings],
                             [enable extra compiler warnings (gcc)]),
              [if test "x$enableval" != "no"
               then
                 CFLAGS="$CFLAGS -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Waggregate-return -Wmissing-declarations -Wunused -Wformat=2 -Wswitch-default -Wswitch-enum -Wfloat-equal -Wbad-function-cast -Wredundant-decls"
                 DESIRED_CFLAGS="$DESIRED_CFLAGS -Wextra -Wdeclaration-after-statement -Werror-implicit-function-declaration -Werror=implicit"
               fi])
test_gcc_flag() {
  AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
  $CC -c conftest.c $CFLAGS $@ > /dev/null 2> /dev/null
  ret=$?
  rm -f conftest.o
  return $ret
}
for flag in $DESIRED_CFLAGS
do
  AC_MSG_CHECKING([whether $CC accepts $flag])
  if test_gcc_flag $flag
  then
    CFLAGS="$CFLAGS $flag"
    AC_MSG_RESULT([yes])
  else
    AC_MSG_RESULT([no])
  fi
done

# add --disable-maintainer-mode option
AM_MAINTAINER_MODE([enable])

# check whether the nslcd daemon should be built
AC_MSG_CHECKING([whether to build the nslcd daemon])
AC_ARG_ENABLE(nslcd,
              AS_HELP_STRING([--disable-nslcd],
                             [build the nslcd daemon @<:@enabled@:>@]),,
              [enable_nslcd="yes"])
AC_MSG_RESULT($enable_nslcd)
AM_CONDITIONAL([ENABLE_NSLCD], [test "x$enable_nslcd" = "xyes"])

# check whether configfile options should be checked
AC_MSG_CHECKING([whether to check configfile options])
AC_ARG_ENABLE(configfile_checking,
              AS_HELP_STRING([--disable-configfile-checking],
                             [check configfile options @<:@enabled@:>@]),
              [configfile_checking=$enableval],
              [configfile_checking="yes"])
AC_MSG_RESULT($configfile_checking)
if test "x$configfile_checking" = "xyes"
then
  AC_DEFINE(ENABLE_CONFIGFILE_CHECKING, 1 ,[Whether to check configfile options.])
fi

# check the name of the configuration file
AC_ARG_WITH(nslcd-conf-file,
            AS_HELP_STRING([--with-nslcd-conf-file=PATH],
                           [path to nslcd configuration file @<:@/etc/nslcd.conf@:>@]),
            [ NSLCD_CONF_PATH="$with_nslcd_conf_file" ],
            [ NSLCD_CONF_PATH="/etc/nslcd.conf" ])
AC_DEFINE_UNQUOTED(NSLCD_CONF_PATH, "$NSLCD_CONF_PATH", [Path to nslcd configuration file.])
AC_SUBST(NSLCD_CONF_PATH)

# the SONAME to use for the NSS module
AC_MSG_CHECKING([soname of NSS module])
AC_ARG_WITH(nss-module-soname,
            AS_HELP_STRING([--with-nss-module-soname=SONAME],
                           [soname of NSS module @<:@auto@:>@]),
            [ NSS_MODULE_SONAME="$with_nss_module_soname" ],
            [ NSS_MODULE_SONAME="auto" ])
if test "x$NSS_MODULE_SONAME" = "xauto"
then
  case "$target_os" in
    solaris*) NSS_MODULE_SONAME="nss_ldap.so.1" ;;
    freebsd*|dragonfly*) NSS_MODLULE_SONAME="nss_ldap.so.1" ;;
    *)        NSS_MODULE_SONAME="libnss_ldap.so.2" ;;
  esac
fi
AC_MSG_RESULT($NSS_MODULE_SONAME)
AC_DEFINE_UNQUOTED(NSS_MODULE_SONAME, "$NSS_MODULE_SONAME", [The SONAME of the NSS library module.])
AC_SUBST(NSS_MODULE_SONAME)

AC_MSG_CHECKING([name of NSS module])
AC_ARG_WITH(nss-module-name,
            AS_HELP_STRING([--with-nss-module-name=NAME],
                           [name of NSS module @<:@ldap@:>@]),
            [ NSS_MODULE_NAME="$with_nss_module_name" ],
            [ NSS_MODULE_NAME="ldap" ])
AC_MSG_RESULT($NSS_MODULE_NAME)
AC_DEFINE_UNQUOTED(NSS_MODULE_NAME, "$NSS_MODULE_NAME", [The NAME of the NSS library module.])
AC_SUBST(NSS_MODULE_NAME)

AC_MSG_CHECKING([symbol name of the NSS module version])
AC_ARG_WITH(nss-module-sym-version,
            AS_HELP_STRING([--with-nss-module-sym-version=SYM],
                           [symbol name of the NSS module version @<:@_nss_ldap_version@:>@]),
            [ NSS_MODULE_SYM_VERSION="$with_nss_module_sym_version" ],
            [ NSS_MODULE_SYM_VERSION="_nss_ldap_version" ])
AC_MSG_RESULT($NSS_MODULE_SYM_VERSION)
AC_DEFINE_UNQUOTED(NSS_MODULE_SYM_VERSION, "$NSS_MODULE_SYM_VERSION", [The symbol name of the NSS library module version.])
AC_SUBST(NSS_MODULE_SYM_VERSION)

AC_MSG_CHECKING([symbol name of the NSS module enable flag])
AC_ARG_WITH(nss-module-sym-enablelookups,
            AS_HELP_STRING([--with-nss-module-sym-enablelookups=SYM],
                           [symbol name of the NSS module enable flag @<:@_nss_ldap_version@:>@]),
            [ NSS_MODULE_SYM_ENABLELOOKUPS="$with_nss_module_sym_enablelookups" ],
            [ NSS_MODULE_SYM_ENABLELOOKUPS="_nss_ldap_enablelookups" ])
AC_MSG_RESULT($NSS_MODULE_SYM_ENABLELOOKUPS)
AC_DEFINE_UNQUOTED(NSS_MODULE_SYM_ENABLELOOKUPS, "$NSS_MODULE_SYM_ENABLELOOKUPS", [The symbol name of the NSS library module enable flag.])
AC_SUBST(NSS_MODULE_SYM_ENABLELOOKUPS)

# checks for availability of header files
AC_CHECK_HEADERS([ctype.h strings.h pthread.h pthread_np.h fcntl.h limits.h])
AC_CHECK_HEADERS([nss.h nss_common.h grp.h shadow.h aliases.h netdb.h rpc/rpcent.h])
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h])
AC_CHECK_HEADERS([nsswitch.h nss_dbdefs.h])
AC_CHECK_HEADERS([sys/socket.h sys/un.h sys/ucred.h ucred.h sys/param.h sys/time.h])
AC_CHECK_HEADERS([getopt.h syslog.h stddef.h])

# other general checks
AC_C_INLINE
AC_C_CONST

# checks for availability of common functions
AC_CHECK_FUNCS([sigaction snprintf])
AC_SEARCH_LIBS(socket, socket)
AC_CHECK_FUNCS([strcasecmp strncasecmp strchr strcspn strspn strtol strtoul strtoull strndup])
AC_CHECK_FUNCS([malloc realloc atexit])
AC_FUNC_FORK
AC_CHECK_FUNCS(__assert_fail)
AC_SEARCH_LIBS(clock_gettime, rt)
AC_CHECK_FUNCS([setusershell getusershell endusershell getgrouplist])
AC_CHECK_DECLS([setusershell, getusershell, endusershell])

# checks for types
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_TYPE_PID_T
AC_TYPE_INT32_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long int)
AC_CHECK_SIZEOF(unsigned long long int)
AC_CHECK_SIZEOF(uid_t)
AC_CHECK_SIZEOF(gid_t)
AX_TLS()

# check for support for the struct ether_addr structure
AC_CHECK_TYPES(struct ether_addr,,, [
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <net/if.h>
    #include <netinet/in.h>
    #include <netinet/if_ether.h>
    #ifdef HAVE_NETINET_ETHER_H
    #include <netinet/ether.h>
    #endif])

# check for ether_aton and ether_ntoa functions
AC_CHECK_FUNCS(ether_aton ether_ntoa ether_aton_r ether_ntoa_r)
AC_CHECK_DECLS([ether_aton, ether_ntoa],,, [
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <net/if.h>
    #include <netinet/in.h>
    #include <netinet/if_ether.h>
    #ifdef HAVE_NETINET_ETHER_H
    #include <netinet/ether.h>
    #endif])

# check to see if socklen_t is defined
AC_CHECK_TYPE(socklen_t,,
    AC_DEFINE(socklen_t, size_t, [Define to `size_t' if not defined elswhere.]), [
    #include <sys/types.h>
    #include <sys/socket.h>])

# check the return type of setnetgrent()
AC_CACHE_CHECK(
    [return type of setnetgrent],
    nss_pam_ldapd_cv_setnetgrent_type,
    [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM([[
            #include <netdb.h>
            ]], [[
            return setnetgrent(0);
            ]])],
        [nss_pam_ldapd_cv_setnetgrent_type=int],
        [nss_pam_ldapd_cv_setnetgrent_type=void]) ])
if test "x$nss_pam_ldapd_cv_setnetgrent_type" = "xvoid"
then
  AC_DEFINE(SETNETGRENT_RETURNS_VOID, 1,
            [Define to 1 if setnetgrent() returns void.])
fi

# nslcd daemon-specific tests
if test "x$enable_nslcd" = "xyes"
then
  # save CFLAGS and LIBS to restore later
  nslcd_save_CFLAGS="$CFLAGS"
  nslcd_save_LIBS="$LIBS"

  AC_CHECK_HEADERS(regex.h)

  # checks for availability of system libraries for nslcd
  AC_SEARCH_LIBS(gethostbyname, nsl socket)
  AC_SEARCH_LIBS(hstrerror, resolv)
  AC_SEARCH_LIBS(dlopen, dl)
  AC_SEARCH_LIBS(yaml_parser_initialize, yaml)
  AC_SEARCH_LIBS(crypt_r, crypt)

  # check for availability of sytemd socket activation
  AC_SEARCH_LIBS(sd_listen_fds, systemd)


  # check for availability of functions
  AC_CHECK_FUNCS(initgroups setgroups execvp execvpe)
  AC_CHECK_FUNCS(getpeereid)
  AC_CHECK_FUNCS(getpeerucred)
  AC_CHECK_FUNCS(__nss_configure_lookup)
  AC_CHECK_FUNCS(getenv putenv clearenv)
  AC_CHECK_FUNCS(dlopen dlsym dlerror)
  AC_CHECK_FUNCS(regcomp regexec regerror)

  # replace some functions if they are not on the system
  AC_REPLACE_FUNCS(getopt_long)
  AC_REPLACE_FUNCS(strndup)

  # check to see if struct sockaddr_storage is defined
  AC_CHECK_TYPE(struct sockaddr_storage,,
      AC_DEFINE(sockaddr_storage, sockaddr_in, [Define to `sockaddr_in' if not defined elsewhere.]), [
      #include <sys/types.h>
      #include <sys/socket.h>])

  # check for support for the struct ucred structure
  AC_CHECK_TYPE(struct ucred,
      AC_DEFINE(HAVE_STRUCT_UCRED, 1, [Define to 1 if you have a `struct ucred' definition.]),, [
      #include <sys/socket.h>
      #include <sys/un.h>
      #include <sys/types.h>])

  # check threading stuff
  AX_PTHREAD(, AC_MSG_ERROR([no support for pthreads]))
  pthread_save_CFLAGS="$CFLAGS"
  pthread_save_LIBS="$LIBS"
  CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
  LIBS="$LIBS $PTHREAD_LIBS"
  AC_CHECK_FUNCS([pthread_mutex_lock pthread_join pthread_timedjoin_np pthread_atfork])
  CFLAGS="$pthread_save_CFLAGS"
  LIBS="$pthread_save_LIBS"

  # save nslcd LIBS and CFLAGS and restore originals
  nslcd_CFLAGS="$CFLAGS"
  nslcd_LIBS="$LIBS"
  CFLAGS="$nslcd_save_CFLAGS"
  LIBS="$nslcd_save_LIBS"

  AC_SUBST(nslcd_LIBS)
fi

# generate files
AC_CONFIG_FILES([
	Makefile
	compat/Makefile
	common/Makefile
	nslcd/Makefile
	tests/Makefile
	man/Makefile
	man/nslcd.8.xml
	man/nslcd.conf.5.xml
	])
AC_OUTPUT