Release bumped to "gts4".
[tac_plus.git] / configure.in
1 dnl This file writen by Devrim SERAL for tac_plus daemon
2
3 AC_INIT()
4 dnl Check for Host information
5 dnl AC_CANONICAL_HOST()
6 AC_CANONICAL_SYSTEM()
7 AM_INIT_AUTOMAKE(tac_plus, F4.0.3.alpha.8.gts4)
8
9 dnl Checks for programs.
10 AC_PROG_MAKE_SET
11 AC_PROG_CC
12
13 case $host_os in
14         *linux-gnu)
15                 AC_DEFINE(LINUX)
16                 AC_DEFINE(GLIBC)
17                 ;;
18         *solaris)
19                 AC_DEFINE(SOLARIS)
20                 ;;
21         *freebsd)
22                 AC_DEFINE(FREEBSD)
23                 ;;
24         *hpux)
25                 AC_DEFINE(HPUX)
26                 ;;
27         *aix)
28                 AC_DEFINE(AIX)
29                 AC_MSG_WARN([See /usr/lpp/bos/bsdport on your system for details of how to define bsdcc])
30                 # CC="bsdcc"
31                 ;;
32         *mips)
33                 AC_DEFINE(MIPS)
34                 ;;
35         *)
36                 ;;
37 esac
38
39 dnl Devrim Added
40 AM_CONFIG_HEADER(config.h)
41 AM_MAINTAINER_MODE
42
43 if test "x$USE_MAINTAINER_MODE" = "xyes"; then
44         AC_DEFINE(MAINTAINER_MODE)
45 fi
46
47 if test "x$USE_MAINTAINER_MODE" = "xyes" -a "x$GCC" = "xyes"; then
48         CFLAGS="$CFLAGS -ggdb3 -Wall -Wstrict-prototypes -pedantic -Wsign-compare"
49 fi
50
51 # Set these options as otherwise some autoconf tests give different results:
52 final_CFLAGS="$CFLAGS"
53 CFLAGS="$CFLAGS -D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D_BSD_SOURCE=1 -D_OSF_SOURCE=1 -D__EXTENSIONS__=1"
54
55 COND_USE=""
56 AC_SUBST(COND_USE)
57 conf_LDFLAGS=""
58 AC_SUBST(conf_LDFLAGS)
59 conf_LDADD=""
60 AC_SUBST(conf_LDADD)
61
62
63 dnl Checks for libraries.
64 dnl Replace `main' with a function in -lnsl:
65 AC_CHECK_LIB(nsl, main,    [ conf_LDADD="-lnsl    $conf_LDADD" ] )
66 dnl Replace `main' with a function in -log:
67 AC_CHECK_LIB(og, main,     [ conf_LDADD="-log     $conf_LDADD" ] )
68 dnl Replace `main' with a function in -lsocket:
69 AC_CHECK_LIB(socket, main, [ conf_LDADD="-lsocket $conf_LDADD" ] )
70 dnl Check for Crypt function
71 dnl Never use CONF_LDADD here as it is used also for "generate_passwd"
72 AC_CHECK_LIB(crypt, crypt)
73 AC_CHECK_LIB(c,printf)
74
75 dnl Checks for header files.
76 AC_HEADER_STDC
77 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)
78 AC_CHECK_HEADERS(shadow.h,[
79                 if test -f /etc/shadow ; then
80                   AC_DEFINE(SHADOW_PASSWORDS)
81                 fi
82                 ],)
83 dnl Checks for typedefs, structures, and compiler characteristics.
84 AC_C_CONST
85 AC_HEADER_TIME
86
87 dnl Checks for library functions.
88 AC_PROG_GCC_TRADITIONAL
89 AC_FUNC_SETPGRP
90 AC_TYPE_SIGNAL
91 AC_FUNC_VPRINTF
92 AC_FUNC_WAIT3
93 AC_TYPE_SIZE_T
94 AC_CHECK_FUNCS(select socket strcspn strdup strtol siginterrupt)
95 AC_CHECK_SIZEOF(unsigned short,2)
96 AC_CHECK_SIZEOF(unsigned int,4)
97 AC_CHECK_SIZEOF(unsigned long,4)
98
99
100 dnl For PAM support
101 AC_MSG_CHECKING(for PAM support:)
102 echo
103 AC_ARG_WITH(pam,
104         [  --with-pam           With PAM Support   ],,)
105 if test "x$with_pam" = "xyes";then
106         AC_CHECK_LIB(dl, dlopen,     [ conf_LDADD="-ldl  $conf_LDADD" ] )
107         AC_CHECK_LIB(pam, pam_start, [ conf_LDADD="-lpam $conf_LDADD" ] )
108         AC_DEFINE(USE_PAM)
109         COND_USE="$COND_USE "'$(cond_USE_PAM)'
110         AC_MSG_RESULT(Pam support... yes)
111 else
112         AC_MSG_RESULT(Pam support... no)
113 fi
114
115 dnl For LDAP Support
116 AC_MSG_CHECKING(for LDAP support)
117 echo
118 AC_ARG_WITH(ldap,
119         [  --with-ldap          With LDAP Support   ],,)
120
121 if test "x$with_ldap" = "xyes";then
122         dnl Replace `main' with a function in -llber:
123         AC_CHECK_LIB(lber, main,   [ conf_LDADD="-llber   $conf_LDADD"; liblber="-llber" ], [ liblber="" ] )
124         dnl Replace `main' with a function in -lldap:
125         AC_CHECK_LIB(ldap, ldap_simple_bind_s, [ conf_LDADD="-lldap   $conf_LDADD" ],
126                 [
127         AC_CHECK_LIB(ldap, ldap_init,          [ conf_LDADD="-lldap   $conf_LDADD" ],, $liblber)
128                 ], $liblber )
129         AC_DEFINE(USE_LDAP)
130         COND_USE="$COND_USE "'$(cond_USE_LDAP)'
131         AC_MSG_RESULT(LDAP support... yes)
132 else
133         AC_MSG_RESULT(LDAP support... no)
134 fi
135
136 dnl For DB Support
137 AC_MSG_CHECKING(for DB support)
138 echo
139 AC_ARG_WITH(db,
140         [  --with-db            For DB Support   ],,)
141 if test "x$with_db" = "xyes";then
142         AC_DEFINE(DB)
143         AC_DEFINE(DB_NULL)
144         COND_USE="$COND_USE "'$(cond_DB)'
145         COND_USE="$COND_USE "'$(cond_DB_NULL)'
146         AC_MSG_RESULT(DB support... yes)
147 else
148         AC_MSG_RESULT(DB support... no)
149 fi
150
151 dnl For MySQL support
152 if test "x$with_db" = "xyes";then
153
154 echo "Check for MySQL support:"
155
156 AC_ARG_WITH(mysql,
157         [  --with-mysql         With MySQL Support   ],,)
158
159 AC_ARG_WITH(mysql-prefix,
160         [  --with-mysql-prefix=PREFIX  Mysql prefix [default=/usr]],
161         MYSQL_PREFIX=$withval,
162         MYSQL_PREFIX=/usr
163 )
164
165
166 if test "x$with_mysql" = "xyes";then
167
168         conf_LDFLAGS="-L$MYSQL_PREFIX/lib/mysql $conf_LDFLAGS"
169         CPPFLAGS="-I$MYSQL_PREFIX/include/mysql $CPPFLAGS"
170         AC_CHECK_LIB(mysqlclient, mysql_init,
171                         conf_LDADD="-lmysqlclient -lm $conf_LDADD",
172                         AC_MSG_ERROR(*** couldn't find libmysqlclient),
173                         -lm)
174
175         AC_DEFINE(DB_MYSQL)
176         COND_USE="$COND_USE "'$(cond_DB_MYSQL)'
177         AC_MSG_RESULT(Mysql support... yes)
178 else
179         AC_MSG_RESULT(Mysql support... no)
180 fi
181
182 fi
183
184 dnl For PgSQL support
185 if test "x$with_db" = "xyes";then
186
187 echo "Check for PgSQL support:"
188
189 AC_ARG_WITH(pgsql,
190         [  --with-pgsql         With PgSQL Support   ],,)
191
192 AC_ARG_WITH(pgsql-prefix,
193         [  --with-pgsql-prefix=PREFIX  PgSQL prefix [default=/usr]],
194         PGSQL_PREFIX=$withval,
195         PGSQL_PREFIX=/usr
196 )
197
198
199 if test "x$with_pgsql" = "xyes";then
200
201         conf_LDFLAGS="-L$PGSQL_PREFIX/lib/pgsql $conf_LDFLAGS"
202         CPPFLAGS="-I$PGSQL_PREFIX/include/pgsql $CPPFLAGS"
203         AC_CHECK_LIB(pq,PQconnectdb ,
204                         conf_LDADD="-lpq $conf_LDADD",
205                         AC_MSG_ERROR(*** couldn't find libpq))
206
207         AC_DEFINE(DB_PGSQL)
208         COND_USE="$COND_USE "'$(cond_DB_PGSQL)'
209         AC_MSG_RESULT(Pgsql support... yes)
210 else
211         AC_MSG_RESULT(Pgsql support... no)
212 fi
213
214 fi
215
216 dnl Tacuid & tac guid
217
218 AC_ARG_WITH(tacuid,
219                 [  --with-tacuid=ID     If you like to run tac_plus other than root user (no default value) ],,)
220 AC_ARG_WITH(tacgid,
221                 [  --with-tacgid=GID    If you like to run tac_plus other than root group(no default value) ],,)
222
223
224 if (test "x$with_tacuid" != "x" && test "x$with_tacgid" != "x" && test "x$with_tacuid" != "xyes" && test "x$with_tacgid" != "xyes");then
225
226         AC_DEFINE_UNQUOTED(TACPLUS_USERID,  $with_tacuid)
227         AC_DEFINE_UNQUOTED(TACPLUS_GROUPID, $with_tacgid)
228         AC_MSG_RESULT(tacacs+ work with given user and group id)
229 fi
230
231 AC_MSG_CHECKING(whether to enable the maxsess feature)
232 AC_ARG_ENABLE(maxsess,
233               [  --enable-maxsess       Enable maxsess feature ],
234 [
235 if test "$enableval" = "yes";then
236         AC_DEFINE(MAXSESS)
237         AC_MSG_RESULT(yes)
238         COND_USE="$COND_USE "'$(cond_MAXSESS)'
239 else
240         AC_MSG_RESULT(no)
241 fi
242 ],
243 [
244         AC_MSG_RESULT(no)
245 ])
246
247 dnl Enable tacacs.pid file directory
248 AC_ARG_WITH(tacplus_pid,
249         [  --with-tacplus_pid=PREFIX  Tac_plus pid file location [default=/var/run] ],
250         [ pidfile="$withval" ],
251         [ pidfile="" ]
252 )
253 if test "x$pidfile" '!=' "x"; then
254         AC_DEFINE_UNQUOTED(TACPLUS_PIDFILE, "$pidfile/tac_plus.pid")
255 fi
256
257 dnl For libwrap check
258 AC_MSG_CHECKING(whether to enable the libwrap feature)
259 cond=false
260 AC_ARG_WITH(libwrap,
261 [  --with-libwrap[=PATH]   Compile in libwrap (tcp_wrappers) support.],
262 [ case "$withval" in
263   no)
264     AC_MSG_RESULT(no)
265     ;;
266   yes)
267     AC_MSG_RESULT(yes)
268     AC_CHECK_LIB(wrap, request_init, [
269         conf_LDADD="-lwrap $conf_LDADD"
270         cond=true
271         ])
272     ;;
273   *)
274     AC_MSG_RESULT(yes)
275     if test -d "$withval"; then
276         LDFLAGS="-L$withval $LDFLAGS"
277     fi
278     AC_TRY_LINK([ int allow_severity; int deny_severity; ],
279                 [ hosts_access(); ],
280                 [],
281                 [ AC_MSG_ERROR(Could not find the $withval library.  You must first install tcp_wrappers.) ])
282     cond=true
283     ;;
284   esac ],
285   AC_MSG_RESULT(no)
286 )
287 if $cond; then
288         AC_DEFINE(TCPWRAPPER)
289         COND_USE="$COND_USE "'$(cond_TCPWRAPPER)'
290 fi
291
292 dnl For SKEY check
293 AC_MSG_CHECKING(whether to use SKEY security feature)
294 cond=false
295 AC_ARG_WITH(skey,
296 [  --with-skey[=LIBPATH]   Compile with SKEY support (also use -I in CPPFLAGS var).],
297 [ case "$withval" in
298   no)
299     AC_MSG_RESULT(no)
300     ;;
301   yes)
302     AC_MSG_RESULT(yes)
303     cond=true
304     ;;
305   *)
306     AC_MSG_RESULT(yes)
307     if test '!' -f "$withval";then
308         AC_MSG_ERROR([Cannot find $withval library file, you may wish to use LIBS variable instead.])
309     fi
310     conf_LDADD="$withval $conf_LDADD"
311     cond=true
312     ;;
313   esac ],
314   AC_MSG_RESULT(no)
315 )
316 if $cond; then
317         AC_DEFINE(SKEY)
318         COND_USE="$COND_USE "'$(cond_SKEY)'
319 fi
320
321 dnl For MSCHAP and also MSCHAP_DES
322 AC_MSG_CHECKING(whether to compile with Microsoft CHAP)
323 cond=false
324 AC_ARG_WITH(mschap,
325 [  --with-mschap[=des]     Compile with Microsoft CHAP (optionally including MSCHAP_DES).],
326 [ case "$withval" in
327   no)
328     AC_MSG_RESULT(no)
329     ;;
330   yes)
331     AC_MSG_RESULT([yes, without DES])
332     cond=true
333     ;;
334   des)
335     AC_MSG_RESULT([yes, including DES])
336     AC_DEFINE(MSCHAP_DES)
337     cond=true
338     ;;
339   *)
340     AC_MSG_ERROR(Unknown --with-mschap argument $withval, use: no, yes or des)
341     ;;
342   esac ],
343   AC_MSG_RESULT(no)
344 )
345 if $cond; then
346         AC_DEFINE(MSCHAP)
347         COND_USE="$COND_USE "'$(cond_MSCHAP)'
348 fi
349
350 dnl For SunOS encryption compatibility
351 dnl Never use CONF_LDADD here as it is used also for "generate_passwd"
352 AC_MSG_CHECKING(whether to use SunOS encryption compatibility)
353 cond=false
354 AC_ARG_WITH(descrypt,
355 [  --with-descrypt         Be password encryption compatible with SunOS.],
356 [ case "$withval" in
357   no)
358     AC_MSG_RESULT(no)
359     ;;
360   yes)
361     AC_MSG_RESULT(yes)
362     LIBS="-ldescrypt $LIBS"
363     ;;
364   *)
365     AC_MSG_RESULT(yes - $withval)
366     LIBS="$withval $LIBS"
367     ;;
368   esac ],
369   AC_MSG_RESULT(no)
370 )
371
372 AC_ARG_WITH(efence,
373 [  --with-efence           compile with efence support (for debugging)],,[
374         if test "x$USE_MAINTAINER_MODE" = "xyes"; then
375                 with_efence=auto
376         else
377                 with_efence=no
378         fi
379 ])
380 if test "$with_efence" != no; then
381         AC_CHECK_LIB(efence,malloc,,[
382                 if test "$with_efence" = yes; then
383                         AC_MSG_ERROR(Unable to find efence library.)
384                 fi
385                 ])
386 fi
387
388 dnl Check for type in sys/socket.h
389 AC_MSG_CHECKING([for parameter type of 3rd accept() arg])
390 AC_CACHE_VAL(tac_plus_cv_accept_type, [
391         check_ok=false
392         for type in socklen_t size_t int; do
393                 AC_TRY_COMPILE([
394 #include <sys/types.h>
395 #include <sys/socket.h>
396 #if STDC_HEADERS
397 #include <stdlib.h>
398 #include <stddef.h>
399 #endif
400 ],[
401                         return 0;}
402                         int accept(int s, struct sockaddr *addr, ]$type[ *addrlen)
403                         { return 0; }
404                         int discarded_main() {
405 ],
406                         [check_ok=true;break],continue)
407         done
408         if $check_ok
409         then
410                 tac_plus_cv_accept_type=$type
411         else
412                 tac_plus_cv_accept_type=no
413         fi
414         ])
415 if test "x$tac_plus_cv_accept_type" = "xno"
416 then
417         AC_DEFINE(socklen_t,int)
418         AC_MSG_RESULT([failed to detect, will try int])
419 else
420         AC_MSG_RESULT($tac_plus_cv_accept_type)
421         if test "x$tac_plus_cv_accept_type" != "xsocklen_t"
422         then
423                 AC_DEFINE_UNQUOTED(socklen_t,$tac_plus_cv_accept_type)
424         fi
425 fi
426
427 dnl Check for system regex (stolen from "mutt" package)
428 AC_ARG_WITH(included-regex, [  --with-included-regex   Use the included regex library ],
429         [tac_plus_cv_included_regex=yes],
430         [AC_CHECK_FUNCS(regcomp, tac_plus_cv_included_regex=no, tac_plus_cv_included_regex=yes)])
431
432 if test $tac_plus_cv_included_regex = no ; then
433 AC_CACHE_CHECK([whether your system's regexp library is completely broken],
434         [tac_plus_cv_included_regex_broken],
435         AC_TRY_RUN([
436 #ifdef HAVE_UNISTD_H
437 #include <unistd.h>
438 #endif
439 #ifdef HAVE_REGEX_H
440 #include <regex.h>
441 #endif
442 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); }],
443         tac_plus_cv_included_regex_broken=no, tac_plus_cv_included_regex_broken=yes, tac_plus_cv_included_regex_broken=yes))
444         if test $tac_plus_cv_included_regex_broken = yes ; then
445                 echo "Using the included regex instead." >&AC_FD_MSG
446                 tac_plus_cv_included_regex=yes
447         fi
448 fi
449 if test $tac_plus_cv_included_regex = yes; then
450         AC_DEFINE(WITH_INCLUDED_REGEX)
451         COND_USE="$COND_USE "'$(cond_WITH_INCLUDED_REGEX)'
452 fi
453
454 dnl Check for "struct passwd.pw_{age,comment}"
455 dnl Stolen from Julianne Frances Haugh's login replacement.
456 AC_CACHE_CHECK(for pw_age in struct passwd,
457 tac_plus_cv_struct_passwd_pw_age, AC_TRY_COMPILE([#include <pwd.h>],
458 [ struct passwd pw;  pw.pw_age = "" ],
459 tac_plus_cv_struct_passwd_pw_age=yes, tac_plus_cv_struct_passwd_pw_age=no))
460
461 if test "$tac_plus_cv_struct_passwd_pw_age" = "yes"; then
462         AC_DEFINE(HAVE_PASSWD_PW_AGE)
463 fi
464 AC_CACHE_CHECK(for pw_comment in struct passwd,
465 tac_plus_cv_struct_passwd_pw_comment, AC_TRY_COMPILE([#include <pwd.h>],
466 [ struct passwd pw;  pw.pw_comment = "" ],
467 tac_plus_cv_struct_passwd_pw_comment=yes, tac_plus_cv_struct_passwd_pw_comment=no))
468
469 if test "$tac_plus_cv_struct_passwd_pw_comment" = "yes"; then
470         AC_DEFINE(HAVE_PASSWD_PW_COMMENT)
471 fi
472 AC_CACHE_CHECK(for ut_host in struct utmp,
473 tac_plus_cv_struct_utmp_ut_host, AC_TRY_COMPILE([#include <utmp.h>],
474 [ struct utmp ut;  ut.ut_host = "" ],
475 tac_plus_cv_struct_utmp_ut_host=yes, tac_plus_cv_struct_utmp_ut_host=no))
476
477 if test "$tac_plus_cv_struct_utmp_ut_host" = "yes"; then
478         AC_DEFINE(HAVE_UTMP_UT_HOST)
479 fi
480
481 CFLAGS="$final_CFLAGS"
482
483 AC_OUTPUT([
484         Makefile
485         tac_plus.spec
486         ])