Release bumped to "gts4".
[tac_plus.git] / configure.in
index 6b3eb13..0b8fd72 100644 (file)
 dnl This file writen by Devrim SERAL for tac_plus daemon
 
 AC_INIT()
+dnl Check for Host information
+dnl AC_CANONICAL_HOST()
+AC_CANONICAL_SYSTEM()
+AM_INIT_AUTOMAKE(tac_plus, F4.0.3.alpha.8.gts4)
 
 dnl Checks for programs.
 AC_PROG_MAKE_SET
 AC_PROG_CC
 
-dnl Check for Host information
-dnl AC_CANONICAL_HOST()
-AC_CANONICAL_SYSTEM()
-
-case $host_os in 
+case $host_os in
        *linux-gnu)
-       OS="-DLINUX -DGLIBC"
-       ;;
+               AC_DEFINE(LINUX)
+               AC_DEFINE(GLIBC)
+               ;;
        *solaris)
-       OS="-DSOLARIS"
-       ;;
+               AC_DEFINE(SOLARIS)
+               ;;
        *freebsd)
-       OS="-DFREEBSD"
-       ;;
+               AC_DEFINE(FREEBSD)
+               ;;
        *hpux)
-       OS="-DHPUX"
-       ;;
+               AC_DEFINE(HPUX)
+               ;;
        *aix)
-       OS="-DAIX"
-       ;;
+               AC_DEFINE(AIX)
+               AC_MSG_WARN([See /usr/lpp/bos/bsdport on your system for details of how to define bsdcc])
+               # CC="bsdcc"
+               ;;
+       *mips)
+               AC_DEFINE(MIPS)
+               ;;
        *)
-       ;;
+               ;;
 esac
-       
+
+dnl Devrim Added
+AM_CONFIG_HEADER(config.h)
+AM_MAINTAINER_MODE
+
+if test "x$USE_MAINTAINER_MODE" = "xyes"; then
+       AC_DEFINE(MAINTAINER_MODE)
+fi
+
+if test "x$USE_MAINTAINER_MODE" = "xyes" -a "x$GCC" = "xyes"; then
+       CFLAGS="$CFLAGS -ggdb3 -Wall -Wstrict-prototypes -pedantic -Wsign-compare"
+fi
+
+# Set these options as otherwise some autoconf tests give different results:
+final_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D_BSD_SOURCE=1 -D_OSF_SOURCE=1 -D__EXTENSIONS__=1"
+
+COND_USE=""
+AC_SUBST(COND_USE)
+conf_LDFLAGS=""
+AC_SUBST(conf_LDFLAGS)
+conf_LDADD=""
+AC_SUBST(conf_LDADD)
+
+
 dnl Checks for libraries.
 dnl Replace `main' with a function in -lnsl:
-AC_CHECK_LIB(nsl, main)
+AC_CHECK_LIB(nsl, main,    [ conf_LDADD="-lnsl    $conf_LDADD" ] )
 dnl Replace `main' with a function in -log:
-AC_CHECK_LIB(og, main)
-dnl Replace `main' with a function in -lldap:
-AC_CHECK_LIB(ldap, main)
-dnl Replace `main' with a function in -llber:
-AC_CHECK_LIB(lber, main)
+AC_CHECK_LIB(og, main,     [ conf_LDADD="-log     $conf_LDADD" ] )
 dnl Replace `main' with a function in -lsocket:
-AC_CHECK_LIB(socket, main)
+AC_CHECK_LIB(socket, main, [ conf_LDADD="-lsocket $conf_LDADD" ] )
 dnl Check for Crypt function
+dnl Never use CONF_LDADD here as it is used also for "generate_passwd"
 AC_CHECK_LIB(crypt, crypt)
 AC_CHECK_LIB(c,printf)
 
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(fcntl.h malloc.h strings.h sys/file.h sys/ioctl.h sys/time.h syslog.h sys/syslog.h unistd.h regex.h sys/param.h)
+AC_CHECK_HEADERS(shadow.h,[
+               if test -f /etc/shadow ; then
+                 AC_DEFINE(SHADOW_PASSWORDS)
+               fi
+               ],)
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_HEADER_TIME
+
+dnl Checks for library functions.
+AC_PROG_GCC_TRADITIONAL
+AC_FUNC_SETPGRP
+AC_TYPE_SIGNAL
+AC_FUNC_VPRINTF
+AC_FUNC_WAIT3
+AC_TYPE_SIZE_T
+AC_CHECK_FUNCS(select socket strcspn strdup strtol siginterrupt)
+AC_CHECK_SIZEOF(unsigned short,2)
+AC_CHECK_SIZEOF(unsigned int,4)
+AC_CHECK_SIZEOF(unsigned long,4)
 
-dnl Devrim Added 
-AC_CONFIG_HEADER(config.h)
 
 dnl For PAM support
 AC_MSG_CHECKING(for PAM support:)
@@ -55,9 +103,10 @@ echo
 AC_ARG_WITH(pam,
        [  --with-pam           With PAM Support   ],,)
 if test "x$with_pam" = "xyes";then
-       AC_CHECK_LIB(dl, dlopen)
-       AC_CHECK_LIB(pam, pam_start)
-       DEFINES="-DUSE_PAM $DEFINES";
+       AC_CHECK_LIB(dl, dlopen,     [ conf_LDADD="-ldl  $conf_LDADD" ] )
+       AC_CHECK_LIB(pam, pam_start, [ conf_LDADD="-lpam $conf_LDADD" ] )
+       AC_DEFINE(USE_PAM)
+       COND_USE="$COND_USE "'$(cond_USE_PAM)'
         AC_MSG_RESULT(Pam support... yes)
 else
         AC_MSG_RESULT(Pam support... no)
@@ -70,22 +119,30 @@ AC_ARG_WITH(ldap,
         [  --with-ldap         With LDAP Support   ],,)
 
 if test "x$with_ldap" = "xyes";then
-   AC_CHECK_LIB(ldap, ldap_simple_bind_s)
-   AC_CHECK_LIB(ldap, ldap_init)
-   DEFINES="-DUSE_LDAP $DEFINES"
-        AC_MSG_RESULT(LDAP support... yes)
+       dnl Replace `main' with a function in -llber:
+       AC_CHECK_LIB(lber, main,   [ conf_LDADD="-llber   $conf_LDADD"; liblber="-llber" ], [ liblber="" ] )
+       dnl Replace `main' with a function in -lldap:
+       AC_CHECK_LIB(ldap, ldap_simple_bind_s, [ conf_LDADD="-lldap   $conf_LDADD" ],
+               [
+       AC_CHECK_LIB(ldap, ldap_init,          [ conf_LDADD="-lldap   $conf_LDADD" ],, $liblber)
+               ], $liblber )
+       AC_DEFINE(USE_LDAP)
+       COND_USE="$COND_USE "'$(cond_USE_LDAP)'
+       AC_MSG_RESULT(LDAP support... yes)
 else
-        AC_MSG_RESULT(LDAP support... no)
+       AC_MSG_RESULT(LDAP support... no)
 fi
 
 dnl For DB Support
 AC_MSG_CHECKING(for DB support)
-echo 
+echo
 AC_ARG_WITH(db,
         [  --with-db           For DB Support   ],,)
 if test "x$with_db" = "xyes";then
-       DB="$DB -DDB -DDB_NULL" 
+       AC_DEFINE(DB)
+       AC_DEFINE(DB_NULL)
+       COND_USE="$COND_USE "'$(cond_DB)'
+       COND_USE="$COND_USE "'$(cond_DB_NULL)'
        AC_MSG_RESULT(DB support... yes)
 else
        AC_MSG_RESULT(DB support... no)
@@ -107,15 +164,16 @@ AC_ARG_WITH(mysql-prefix,
 
 
 if test "x$with_mysql" = "xyes";then
-       
-       LDFLAGS="-L$MYSQL_PREFIX/lib/mysql $LDFLAGS"
-        LDFLAGS="-I$MYSQL_PREFIX/include/mysql $LDFLAGS"
+
+       conf_LDFLAGS="-L$MYSQL_PREFIX/lib/mysql $conf_LDFLAGS"
+        CPPFLAGS="-I$MYSQL_PREFIX/include/mysql $CPPFLAGS"
         AC_CHECK_LIB(mysqlclient, mysql_init,
-                        LIBS="-lmysqlclient -lm $LIBS",
+                        conf_LDADD="-lmysqlclient -lm $conf_LDADD",
                         AC_MSG_ERROR(*** couldn't find libmysqlclient),
                         -lm)
 
-       DB="$DB -DDB_MYSQL";
+       AC_DEFINE(DB_MYSQL)
+       COND_USE="$COND_USE "'$(cond_DB_MYSQL)'
         AC_MSG_RESULT(Mysql support... yes)
 else
         AC_MSG_RESULT(Mysql support... no)
@@ -139,14 +197,15 @@ AC_ARG_WITH(pgsql-prefix,
 
 
 if test "x$with_pgsql" = "xyes";then
-       
-       LDFLAGS="-L$PGSQL_PREFIX/lib/pgsql $LDFLAGS"
-        LDFLAGS="-I$PGSQL_PREFIX/include/pgsql $LDFLAGS"
+
+       conf_LDFLAGS="-L$PGSQL_PREFIX/lib/pgsql $conf_LDFLAGS"
+        CPPFLAGS="-I$PGSQL_PREFIX/include/pgsql $CPPFLAGS"
         AC_CHECK_LIB(pq,PQconnectdb ,
-                        LIBS="-lpq $LIBS",
+                        conf_LDADD="-lpq $conf_LDADD",
                         AC_MSG_ERROR(*** couldn't find libpq))
 
-       DB="$DB -DDB_PGSQL";
+       AC_DEFINE(DB_PGSQL)
+       COND_USE="$COND_USE "'$(cond_DB_PGSQL)'
         AC_MSG_RESULT(Pgsql support... yes)
 else
         AC_MSG_RESULT(Pgsql support... no)
@@ -154,7 +213,7 @@ fi
 
 fi
 
-dnl Tacuid & tac guid 
+dnl Tacuid & tac guid
 
 AC_ARG_WITH(tacuid,
                [  --with-tacuid=ID     If you like to run tac_plus other than root user (no default value) ],,)
@@ -164,8 +223,9 @@ AC_ARG_WITH(tacgid,
 
 if (test "x$with_tacuid" != "x" && test "x$with_tacgid" != "x" && test "x$with_tacuid" != "xyes" && test "x$with_tacgid" != "xyes");then
 
-       DEFINES="-DTACPLUS_USERID=$with_tacuid -DTACPLUS_GROUPID=$with_tacgid $DEFINES";        
-       AC_MSG_RESULT(tacacs+ work with given user and group id) 
+       AC_DEFINE_UNQUOTED(TACPLUS_USERID,  $with_tacuid)
+       AC_DEFINE_UNQUOTED(TACPLUS_GROUPID, $with_tacgid)
+       AC_MSG_RESULT(tacacs+ work with given user and group id)
 fi
 
 AC_MSG_CHECKING(whether to enable the maxsess feature)
@@ -173,9 +233,10 @@ AC_ARG_ENABLE(maxsess,
               [  --enable-maxsess      Enable maxsess feature ],
 [
 if test "$enableval" = "yes";then
-       DEFINES="-DMAXSESS $DEFINES";
+       AC_DEFINE(MAXSESS)
        AC_MSG_RESULT(yes)
-else 
+       COND_USE="$COND_USE "'$(cond_MAXSESS)'
+else
        AC_MSG_RESULT(no)
 fi
 ],
@@ -183,17 +244,19 @@ fi
        AC_MSG_RESULT(no)
 ])
 
-dnl Enable tacacs.pid file directory 
-
+dnl Enable tacacs.pid file directory
 AC_ARG_WITH(tacplus_pid,
         [  --with-tacplus_pid=PREFIX  Tac_plus pid file location [default=/var/run] ],
-        PIDFILE="-DTACPLUS_PIDFILE=\\\"$withval/tac_plus.pid\\\"",
-        PIDFILE="-DTACPLUS_PIDFILE=\\\"/var/run/tac_plus.pid\\\""
+       [ pidfile="$withval" ],
+       [ pidfile="" ]
 )
+if test "x$pidfile" '!=' "x"; then
+       AC_DEFINE_UNQUOTED(TACPLUS_PIDFILE, "$pidfile/tac_plus.pid")
+fi
 
 dnl For libwrap check
-AC_MSG_CHECKING(whether to enable the libwrap feture)
-
+AC_MSG_CHECKING(whether to enable the libwrap feature)
+cond=false
 AC_ARG_WITH(libwrap,
 [  --with-libwrap[=PATH]   Compile in libwrap (tcp_wrappers) support.],
 [ case "$withval" in
@@ -203,48 +266,221 @@ AC_ARG_WITH(libwrap,
   yes)
     AC_MSG_RESULT(yes)
     AC_CHECK_LIB(wrap, request_init, [
-        LIBS="-lwrap $LIBS"
-        DEFINES="-DTCPWRAPPER $DEFINES"])
+        conf_LDADD="-lwrap $conf_LDADD"
+       cond=true
+       ])
     ;;
   *)
     AC_MSG_RESULT(yes)
     if test -d "$withval"; then
         LDFLAGS="-L$withval $LDFLAGS"
-       DEFINES="-DTCPWRAPPER $DEFINES"
     fi
     AC_TRY_LINK([ int allow_severity; int deny_severity; ],
                 [ hosts_access(); ],
                 [],
                 [ AC_MSG_ERROR(Could not find the $withval library.  You must first install tcp_wrappers.) ])
+    cond=true
     ;;
   esac ],
   AC_MSG_RESULT(no)
 )
+if $cond; then
+       AC_DEFINE(TCPWRAPPER)
+       COND_USE="$COND_USE "'$(cond_TCPWRAPPER)'
+fi
 
-dnl insert defines to Makefile 
-AC_SUBST(DEFINES)
-AC_SUBST(PIDFILE)
-AC_SUBST(DB)
-AC_SUBST(OS)
+dnl For SKEY check
+AC_MSG_CHECKING(whether to use SKEY security feature)
+cond=false
+AC_ARG_WITH(skey,
+[  --with-skey[=LIBPATH]   Compile with SKEY support (also use -I in CPPFLAGS var).],
+[ case "$withval" in
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  yes)
+    AC_MSG_RESULT(yes)
+    cond=true
+    ;;
+  *)
+    AC_MSG_RESULT(yes)
+    if test '!' -f "$withval";then
+       AC_MSG_ERROR([Cannot find $withval library file, you may wish to use LIBS variable instead.])
+    fi
+    conf_LDADD="$withval $conf_LDADD"
+    cond=true
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
+if $cond; then
+       AC_DEFINE(SKEY)
+       COND_USE="$COND_USE "'$(cond_SKEY)'
+fi
 
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS(fcntl.h malloc.h strings.h sys/file.h sys/ioctl.h sys/time.h syslog.h unistd.h)
-AC_CHECK_HEADERS(shadow.h,[
-               if test -f /etc/shadow ; then
-                 AC_DEFINE(SHADOW_PASSWORDS)           
-               fi 
-               ],)
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_HEADER_TIME
+dnl For MSCHAP and also MSCHAP_DES
+AC_MSG_CHECKING(whether to compile with Microsoft CHAP)
+cond=false
+AC_ARG_WITH(mschap,
+[  --with-mschap[=des]     Compile with Microsoft CHAP (optionally including MSCHAP_DES).],
+[ case "$withval" in
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  yes)
+    AC_MSG_RESULT([yes, without DES])
+    cond=true
+    ;;
+  des)
+    AC_MSG_RESULT([yes, including DES])
+    AC_DEFINE(MSCHAP_DES)
+    cond=true
+    ;;
+  *)
+    AC_MSG_ERROR(Unknown --with-mschap argument $withval, use: no, yes or des)
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
+if $cond; then
+       AC_DEFINE(MSCHAP)
+       COND_USE="$COND_USE "'$(cond_MSCHAP)'
+fi
 
-dnl Checks for library functions.
-AC_PROG_GCC_TRADITIONAL
-AC_FUNC_SETPGRP
-AC_TYPE_SIGNAL
-AC_FUNC_VPRINTF
-AC_FUNC_WAIT3
-AC_CHECK_FUNCS(regcomp select socket strcspn strdup strtol)
+dnl For SunOS encryption compatibility
+dnl Never use CONF_LDADD here as it is used also for "generate_passwd"
+AC_MSG_CHECKING(whether to use SunOS encryption compatibility)
+cond=false
+AC_ARG_WITH(descrypt,
+[  --with-descrypt         Be password encryption compatible with SunOS.],
+[ case "$withval" in
+  no)
+    AC_MSG_RESULT(no)
+    ;;
+  yes)
+    AC_MSG_RESULT(yes)
+    LIBS="-ldescrypt $LIBS"
+    ;;
+  *)
+    AC_MSG_RESULT(yes - $withval)
+    LIBS="$withval $LIBS"
+    ;;
+  esac ],
+  AC_MSG_RESULT(no)
+)
+
+AC_ARG_WITH(efence,
+[  --with-efence           compile with efence support (for debugging)],,[
+       if test "x$USE_MAINTAINER_MODE" = "xyes"; then
+               with_efence=auto
+       else
+               with_efence=no
+       fi
+])
+if test "$with_efence" != no; then
+       AC_CHECK_LIB(efence,malloc,,[
+               if test "$with_efence" = yes; then
+                       AC_MSG_ERROR(Unable to find efence library.)
+               fi
+               ])
+fi
+
+dnl Check for type in sys/socket.h
+AC_MSG_CHECKING([for parameter type of 3rd accept() arg])
+AC_CACHE_VAL(tac_plus_cv_accept_type, [
+       check_ok=false
+       for type in socklen_t size_t int; do
+               AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+],[
+                       return 0;}
+                       int accept(int s, struct sockaddr *addr, ]$type[ *addrlen)
+                       { return 0; }
+                       int discarded_main() {
+],
+                       [check_ok=true;break],continue)
+       done
+       if $check_ok
+       then
+               tac_plus_cv_accept_type=$type
+       else
+               tac_plus_cv_accept_type=no
+       fi
+       ])
+if test "x$tac_plus_cv_accept_type" = "xno"
+then
+       AC_DEFINE(socklen_t,int)
+       AC_MSG_RESULT([failed to detect, will try int])
+else
+       AC_MSG_RESULT($tac_plus_cv_accept_type)
+       if test "x$tac_plus_cv_accept_type" != "xsocklen_t"
+       then
+               AC_DEFINE_UNQUOTED(socklen_t,$tac_plus_cv_accept_type)
+       fi
+fi
+
+dnl Check for system regex (stolen from "mutt" package)
+AC_ARG_WITH(included-regex, [  --with-included-regex   Use the included regex library ],
+       [tac_plus_cv_included_regex=yes],
+       [AC_CHECK_FUNCS(regcomp, tac_plus_cv_included_regex=no, tac_plus_cv_included_regex=yes)])
+
+if test $tac_plus_cv_included_regex = no ; then
+AC_CACHE_CHECK([whether your system's regexp library is completely broken],
+       [tac_plus_cv_included_regex_broken],
+       AC_TRY_RUN([
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
+main() { regex_t blah ; regmatch_t p; p.rm_eo = p.rm_eo; return regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0); }],
+       tac_plus_cv_included_regex_broken=no, tac_plus_cv_included_regex_broken=yes, tac_plus_cv_included_regex_broken=yes))
+       if test $tac_plus_cv_included_regex_broken = yes ; then
+               echo "Using the included regex instead." >&AC_FD_MSG
+               tac_plus_cv_included_regex=yes
+       fi
+fi
+if test $tac_plus_cv_included_regex = yes; then
+       AC_DEFINE(WITH_INCLUDED_REGEX)
+       COND_USE="$COND_USE "'$(cond_WITH_INCLUDED_REGEX)'
+fi
+
+dnl Check for "struct passwd.pw_{age,comment}"
+dnl Stolen from Julianne Frances Haugh's login replacement.
+AC_CACHE_CHECK(for pw_age in struct passwd,
+tac_plus_cv_struct_passwd_pw_age, AC_TRY_COMPILE([#include <pwd.h>],
+[ struct passwd pw;  pw.pw_age = "" ],
+tac_plus_cv_struct_passwd_pw_age=yes, tac_plus_cv_struct_passwd_pw_age=no))
+
+if test "$tac_plus_cv_struct_passwd_pw_age" = "yes"; then
+       AC_DEFINE(HAVE_PASSWD_PW_AGE)
+fi
+AC_CACHE_CHECK(for pw_comment in struct passwd,
+tac_plus_cv_struct_passwd_pw_comment, AC_TRY_COMPILE([#include <pwd.h>],
+[ struct passwd pw;  pw.pw_comment = "" ],
+tac_plus_cv_struct_passwd_pw_comment=yes, tac_plus_cv_struct_passwd_pw_comment=no))
+
+if test "$tac_plus_cv_struct_passwd_pw_comment" = "yes"; then
+       AC_DEFINE(HAVE_PASSWD_PW_COMMENT)
+fi
+AC_CACHE_CHECK(for ut_host in struct utmp,
+tac_plus_cv_struct_utmp_ut_host, AC_TRY_COMPILE([#include <utmp.h>],
+[ struct utmp ut;  ut.ut_host = "" ],
+tac_plus_cv_struct_utmp_ut_host=yes, tac_plus_cv_struct_utmp_ut_host=no))
+
+if test "$tac_plus_cv_struct_utmp_ut_host" = "yes"; then
+       AC_DEFINE(HAVE_UTMP_UT_HOST)
+fi
+
+CFLAGS="$final_CFLAGS"
 
-AC_OUTPUT(Makefile,echo timestamp > stamp-h)
+AC_OUTPUT([
+       Makefile
+       tac_plus.spec
+       ])