+dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
+dnl values.
+dnl
+dnl Parameters:
+dnl $1 = option name
+dnl $2 = help-string
+dnl $3 = action to perform if option is not default
+dnl $4 = action if perform if option is default
+dnl $5 = default option value (either 'yes' or 'no')
+AC_DEFUN([CF_ARG_OPTION],
+[AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
+ if test "$enableval" != "$5" ; then
+ifelse($3,,[ :]dnl
+,[ $3]) ifelse($4,,,[
+ else
+ $4])
+ fi],[enableval=$5 ifelse($4,,,[
+ $4
+])dnl
+ ])])dnl
+dnl
+dnl Allow user to disable a normally-on option.
+dnl
+dnl AC_DEFUN([CF_ARG_DISABLE],[CF_ARG_OPTION($1,[$2 (default: on)],[$3],[$4],yes))dnl
+dnl
+dnl
dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
dnl Reported by Keith Bostic.
-dnl
AC_DEFUN([CF_SYS_ERRLIST],
[
AC_MSG_CHECKING([declaration of sys_errlist])
dnl that causes an "internal 2K buffer" error on HPUX when run
dnl with /bin/sh. Autoconf 2.10 seems to be okay.
AC_CONFIG_AUX_DIR(etc)
-AC_PREFIX_DEFAULT(/usr/local)
AC_CONFIG_HEADER(include/portable.h)dnl
+dnl
+dnl Start Args
+AC_MSG_CHECKING(arguments)
+
+dnl server options
+CF_ARG_OPTION(ldapd,[ --enable-ldapd enable building ldapd],[
+ BUILD_LDAPD=yes],[BUILD_LDAPD=no],no)dnl
+CF_ARG_OPTION(slapd,[ --enable-slapd enable building slapd],[
+ BUILD_SLAPD=no],[BUILD_SLAPD=yes],yes)dnl
+CF_ARG_OPTION(slurpd,[ --enable-slurpd enable building slurpd],[
+ BUILD_SLURPD=no],[BUILD_SLURPD=yes],yes)dnl
+
+dnl Backend options
+CF_ARG_OPTION(ldbm,[ --enable-ldbm enable ldbm backend],[
+ BUILD_LDBM=no],[BUILD_LDBM=yes],yes)dnl
+CF_ARG_OPTION(passwd,[ --enable-passwd enable passwd backend],[
+ BUILD_PASSWD=no],[BUILD_PASSWD=yes],yes)dnl
+CF_ARG_OPTION(shell,[ --enable-shell enable shell backend],[
+ BUILD_SHELL=no],[BUILD_SHELL=yes],yes)dnl
+
+AC_ARG_WITH(ndbm,[ --with-ndbm use NDB for LDBM backend],[
+ opt_ndbm=yes],[opt_ndbm=no])
+AC_ARG_WITH(gdbm,[ --with-gdbm use GDBM for LDBM backend],[
+ opt_gdbm=yes],[opt_gdbm=no])
+AC_ARG_WITH(dbhash,[ --with-dbhash use Berkeley DB Hash for LDBM backend],[
+ opt_dbhash=yes],[opt_dbhash=no])
+AC_ARG_WITH(dbbtree,[ --with-dbbtree use Berkeley DB Btrees for LDBM backend],[
+ opt_dbbtree=yes],[opt_dbbtree=no])
+
+AC_MSG_RESULT(done)
+
+AC_MSG_CHECKING(LDBM preference)
+ldbm_prefer=any
+
+if test "$opt_ndbm" = yes ; then
+ ldbm_prefer=ndbm
+fi
+if test "$opt_gdbm" = yes ; then
+ ldbm_prefer=gdbm
+fi
+if test "$opt_dbhash" = yes ; then
+ ldbm_prefer=dbhash
+fi
+if test "$opt_dbbtree" = yes ; then
+ ldbm_prefer=dbbtree
+fi
+AC_MSG_RESULT($ldbm_prefer)
+
+if test "$BUILD_SLAPD" != "yes" ; then
+ BUILD_SLURPD="no"
+ BUILD_LDBM="no"
+ BUILD_PASSWD="no"
+ BUILD_SHELL="no"
+ ldbm_prefer="none"
+fi
+
+AC_SUBST(BUILD_LDAPD)
+AC_SUBST(BUILD_SLAPD)
+AC_SUBST(BUILD_SLURPD)
+
+AC_SUBST(BUILD_LDBM)
+AC_SUBST(BUILD_PASSWD)
+AC_SUBST(BUILD_SHELL)
+
+dnl End Args
dnl Checks for programs.
AC_PROG_CC
+AC_PROG_GCC_TRADITIONAL
+
AC_PROG_LN_S
-AC_PROG_MAKE_SET
+AC_PROG_INSTALL
AC_PROG_RANLIB
+AC_PROG_MAKE_SET
-# FreeBSD (and others) have crypt(3) in -lcrypt
-AC_CHECK_LIB(crypt, crypt)
+AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
+ $PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:etc)
+AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi,
+ $PATH:/usr/ucb)
+AC_PATH_PROG(FINGER, finger, /usr/ucb/finger,
+ $PATH:/usr/ucb)
+
+ldbm_use="none"
+LIBDB=""
+
+if test "$BUILD_LDBM" = "yes" ; then
+ if test $ldbm_prefer = any -o $ldbm_prefer = dbbtree \
+ -o $ldbm_prefer = dbhash ; then
+ AC_CHECK_FUNC(dbopen,[
+ ldbm_use=$ldbm_prefer
+ ldbm_prefer=found],[
+ AC_CHECK_LIB(db,dbopen,[
+ ldbm_use=$ldbm_prefer
+ ldbm_prefer=found
+ LIBDB="-ldb"
+ ])
+ ])
+
+ if test $ldbm_prefer = found ; then
+ if test $ldbm_use = dbbhash ; then
+ AC_DEFINE(LDBM_USE_DBHASH,1)
+ else
+ AC_DEFINE(LDBM_USE_DBBTREE,1)
+ fi
+ fi
+ fi
+ if test $ldbm_prefer = any -o $ldbm_prefer = gdbm ; then
+ AC_CHECK_LIB(gdbm, gdbm_open,[
+ ldbm_use=$ldbm_prefer
+ ldbm_prefer=found
+ LIBDB="-lgdbm"
+ AC_DEFINE(LDBM_USE_GDBM,1)
+ ])
+ fi
+ if test $ldbm_prefer = any -o $ldbm_prefer = ndbm ; then
+ AC_CHECK_LIB(dbm,dbm_open,[
+ ldbm_use=$ldbm_prefer
+ ldbm_prefer=found
+ LIBDB="-ldbm"
+ AC_DEFINE(LDBM_USE_NDBM,1)
+ ])
+ fi
+
+ if test $ldbm_prefer != found ; then
+ AC_MSG_ERROR(could not find suitable db for $ldbm_prefer backend)
+ fi
+fi
+
+AC_SUBST(LIBDB)
+
+# ud needs termcap (should insert check here)
+LIBTERMCAP="-ltermcap"
+AC_SUBST(LIBTERMCAP)
# FreeBSD has obsoleted re_comp(3) from -lc, needs -lcompat
AC_CHECK_LIB(compat, re_comp)
+# FreeBSD (and others) have crypt(3) in -lcrypt
+LIBCRYPT=
+AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT), [
+ AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"
+ AC_DEFINE(HAVE_CRYPT)])
+])
+AC_SUBST(LIBCRYPT)
+
dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_STRUCT_TM
dnl Checks for library functions.
-AC_PROG_GCC_TRADITIONAL
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
strtoul \
)
-AC_ARG_PROGRAM
-
# Check Configuration
CF_SYS_ERRLIST
-
AC_OUTPUT( \
include/ldapconfig.h \
include/Makefile:etc/top.mk:include/Makefile.in \
libraries/libldif/Makefile:etc/top.mk:libraries/libldif/Makefile.in:etc/lib.mk \
libraries/liblthread/Makefile:etc/top.mk:libraries/liblthread/Makefile.in:etc/lib.mk \
servers/Makefile:etc/top.mk:servers/Makefile.in:etc/dir.mk \
-servers/ldapd/Makefile:etc/top.mk:servers/ldapd/Makefile.in:etc/rules.mk \
-servers/slapd/Makefile:etc/top.mk:servers/slapd/Makefile.in:etc/rules.mk \
+servers/ldapd/Makefile:etc/top.mk:servers/ldapd/Makefile.in:etc/srv.mk \
+servers/slapd/Makefile:etc/top.mk:servers/slapd/Makefile.in:etc/srv.mk \
servers/slapd/back-ldbm/Makefile:etc/top.mk:servers/slapd/back-ldbm/Makefile.in:etc/rules.mk \
servers/slapd/back-passwd/Makefile:etc/top.mk:servers/slapd/back-passwd/Makefile.in:etc/rules.mk \
servers/slapd/back-shell/Makefile:etc/top.mk:servers/slapd/back-shell/Makefile.in:etc/rules.mk \
servers/slapd/tools/Makefile:etc/top.mk:servers/slapd/tools/Makefile.in:etc/rules.mk \
servers/slapd/shell-backends/Makefile:etc/top.mk:servers/slapd/shell-backends/Makefile.in:etc/rules.mk \
-servers/slurpd/Makefile:etc/top.mk:servers/slurpd/Makefile.in:etc/rules.mk \
+servers/slurpd/Makefile:etc/top.mk:servers/slurpd/Makefile.in:etc/srv.mk \
Makefile:etc/top.mk:Makefile.in:etc/dir.mk, \
[date > stamp-h])
+++ /dev/null
-/* include/portable.h. Generated automatically by configure. */
-/* include/portable.h.in. Generated automatically from configure.in by autoheader. */
-/*
- * Copyright (c) 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#ifndef _LDAP_PORTABLE_H
-#define _LDAP_PORTABLE_H
-
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef gid_t */
-
-/* Define if you don't have vprintf but do have _doprnt. */
-/* #undef HAVE_DOPRNT */
-
-/* Define if your struct stat has st_blksize. */
-#define HAVE_ST_BLKSIZE 1
-
-/* Define if you have the strftime function. */
-#define HAVE_STRFTIME 1
-
-/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define if you have the vprintf function. */
-#define HAVE_VPRINTF 1
-
-/* Define if you have the wait3 system call. */
-#define HAVE_WAIT3 1
-
-/* Define to `long' if <sys/types.h> doesn't define. */
-/* #undef off_t */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef pid_t */
-
-/* Define as the return type of signal handlers (int or void). */
-#define RETSIGTYPE void
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if you can safely include both <sys/time.h> and <time.h>. */
-#define TIME_WITH_SYS_TIME 1
-
-/* Define if your <sys/time.h> declares struct tm. */
-/* #undef TM_IN_SYS_TIME */
-
-/* Define to `int' if <sys/types.h> doesn't define. */
-/* #undef uid_t */
-
-/* define this if sys_errlist is not defined in stdio.h or errno.h */
-/* #undef DECL_SYS_ERRLIST */
-
-/* Define if you have the gethostname function. */
-#define HAVE_GETHOSTNAME 1
-
-/* Define if you have the gettimeofday function. */
-#define HAVE_GETTIMEOFDAY 1
-
-/* Define if you have the mktime function. */
-#define HAVE_MKTIME 1
-
-/* Define if you have the select function. */
-#define HAVE_SELECT 1
-
-/* Define if you have the socket function. */
-#define HAVE_SOCKET 1
-
-/* Define if you have the strdup function. */
-#define HAVE_STRDUP 1
-
-/* Define if you have the strerror function. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the strstr function. */
-#define HAVE_STRSTR 1
-
-/* Define if you have the strtod function. */
-#define HAVE_STRTOD 1
-
-/* Define if you have the strtol function. */
-#define HAVE_STRTOL 1
-
-/* Define if you have the strtoul function. */
-#define HAVE_STRTOUL 1
-
-/* Define if you have the <dirent.h> header file. */
-#define HAVE_DIRENT_H 1
-
-/* Define if you have the <fcntl.h> header file. */
-#define HAVE_FCNTL_H 1
-
-/* Define if you have the <limits.h> header file. */
-#define HAVE_LIMITS_H 1
-
-/* Define if you have the <malloc.h> header file. */
-/* #undef HAVE_MALLOC_H */
-
-/* Define if you have the <ndir.h> header file. */
-/* #undef HAVE_NDIR_H */
-
-/* Define if you have the <sgtty.h> header file. */
-#define HAVE_SGTTY_H 1
-
-/* Define if you have the <sys/dir.h> header file. */
-/* #undef HAVE_SYS_DIR_H */
-
-/* Define if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
-
-/* Define if you have the <sys/ioctl.h> header file. */
-#define HAVE_SYS_IOCTL_H 1
-
-/* Define if you have the <sys/ndir.h> header file. */
-/* #undef HAVE_SYS_NDIR_H */
-
-/* Define if you have the <sys/time.h> header file. */
-#define HAVE_SYS_TIME_H 1
-
-/* Define if you have the <syslog.h> header file. */
-#define HAVE_SYSLOG_H 1
-
-/* Define if you have the <termio.h> header file. */
-/* #undef HAVE_TERMIO_H */
-
-/* Define if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Define if you have the compat library (-lcompat). */
-#define HAVE_LIBCOMPAT 1
-
-/* Define if you have the crypt library (-lcrypt). */
-#define HAVE_LIBCRYPT 1
-
-
-#include "bridge.h"
-#endif /* _LDAP_PORTABLE_H */