Allow experimental modules to be explicitly enabled
[freeradius.git] / configure.in
1 dnl #############################################################
2 dnl #
3 dnl #  For information about autoconf, see:
4 dnl #
5 dnl #  http://www.gnu.org/software/autoconf/
6 dnl #  
7 dnl #  The recommended order is:
8 dnl #
9 dnl #  AC_INIT(file)
10 dnl #  0. checks for compiler, libtool, and command line options
11 dnl #  1. checks for programs
12 dnl #  2. checks for libraries
13 dnl #  3. checks for header files
14 dnl #  4. checks for typedefs
15 dnl #  5. checks for structures and functions
16 dnl #  6. checks for compiler characteristics
17 dnl #  7. checks for library functions
18 dnl #  8. checks for system services
19 dnl #  AC_OUTPUT([file...])
20 dnl #
21 dnl #############################################################
22
23 AC_INIT(src/main/radiusd.c)
24 AC_CONFIG_HEADER(src/include/autoconf.h)
25 AC_REVISION($Revision$)dnl
26
27 dnl # The version of the software
28 RADIUSD_MAJOR_VERSION=1
29 RADIUSD_MINOR_VERSION=1.1
30 RADIUSD_VERSION="${RADIUSD_MAJOR_VERSION}.${RADIUSD_MINOR_VERSION}"
31
32 dnl #############################################################
33 dnl #
34 dnl #  0. Checks for compiler, libtool, and command line options.
35 dnl #
36 dnl #############################################################
37
38 dnl Check for GNU cc
39 AC_PROG_CC
40
41 dnl #
42 dnl # check for AIX, to allow us to use some BSD functions
43 dnl # must be before macros that call the compiler.
44 dnl #
45 AC_AIX
46
47 AC_PROG_GCC_TRADITIONAL
48 AC_PROG_CC_SUNPRO
49 AC_PROG_RANLIB
50
51 abs_top_builddir=`pwd`
52 AC_SUBST(abs_top_builddir)
53
54 dnl # autoconf 2.50 and later
55 dnl # AC_SYS_LARGEFILE
56
57 PACKAGE=freeradius
58
59 dnl # check for system bytesex
60 dnl # AC_DEFINES WORDS_BIGENDIAN
61 AC_C_BIGENDIAN
62
63 dnl Find GNU Make.
64 AC_CHECK_PROG(GMAKE, gmake, yes, no)
65 if test $GMAKE = no; then
66   AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
67 else
68   AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
69 fi
70 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
71 if test -z "$makever"; then
72   AC_MSG_ERROR(GNU Make is not installed.  Please download and install it
73                 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
74 fi
75
76 dnl libltdl is installable
77 AC_LIBLTDL_INSTALLABLE
78
79 dnl use system-wide libtool, if it exists
80 AC_ARG_WITH(system-libtool, 
81 [  --with-system-libtool              try to use libtool installed in your system [default=use our own]],
82 [ AC_PATH_PROG(LIBTOOL, libtool,,$PATH:/usr/local/bin) ],
83 [
84   LIBTOOL="`pwd`/libtool"
85   AC_SUBST(LIBTOOL)
86   dnl ensure that we're looking for dlopen
87   AC_LIBTOOL_DLOPEN
88
89   dnl Figure out how to build shared libraries
90   AC_PROG_LIBTOOL
91 ])
92
93
94 dnl Put this in later, when all distributed modules use autoconf.
95 dnl AC_ARG_WITH(disablemodulefoo,
96 dnl [  --without-rlm_foo       Disables module compilation.  Module list:]
97 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
98 dnl     sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
99 dnl     awk '{print "                            "$0}']))
100
101 AC_ARG_ENABLE(strict-dependencies,
102 [  --enable-strict-dependencies  Fail configure on lack of module dependancy.])
103
104 dnl extra argument: --with-logdir
105 logdir='${localstatedir}/log/radius'
106 AC_MSG_CHECKING(logdir)
107 AC_ARG_WITH(logdir,
108 [  --with-logdir=DIR       Directory for logfiles [LOCALSTATEDIR/log/radius] ],
109 [ case "$withval" in
110     no)
111         AC_MSG_ERROR(Need logdir)
112         ;;
113     yes)
114         ;;
115     *)
116         logdir="$withval"
117         ;;
118   esac ]
119 )
120 AC_SUBST(logdir)
121 AC_MSG_RESULT($logdir)
122
123 dnl extra argument: --with-radacctdir
124 radacctdir='${logdir}/radacct'
125 AC_MSG_CHECKING(radacctdir)
126 AC_ARG_WITH(radacctdir,
127 [  --with-radacctdir=PATH  Directory for detail files [LOGDIR/radacct] ],
128 [ case "$withval" in
129     no)
130         AC_MSG_ERROR(Need radacctdir)
131         ;;
132     yes)
133         ;;
134     *)
135         radacctdir="$withval"
136         ;;
137   esac ]
138 )
139 AC_SUBST(radacctdir)
140 AC_MSG_RESULT($radacctdir)
141
142 dnl extra argument: --with-raddbdir
143 raddbdir='${sysconfdir}/raddb'
144 AC_MSG_CHECKING(raddbdir)
145 AC_ARG_WITH(raddbdir,
146 [  --with-raddbdir=DIR     Directory for config files [SYSCONFDIR/raddb] ],
147 [ case "$withval" in
148     no)
149         AC_MSG_ERROR(Need raddbdir)
150         ;;
151     yes)
152         ;;
153     *)
154         raddbdir="$withval"
155         ;;
156   esac ]
157 )
158 AC_SUBST(raddbdir)
159 AC_MSG_RESULT($raddbdir)
160
161 dnl extra argument: --with-ascend-binary
162 ASCEND_BINARY=yes
163 AC_ARG_WITH(ascend-binary,
164 [  --with-ascend-binary    Include support for Ascend binary filter attributes (default=yes)],
165 [ case "$withval" in
166     yes)
167         ;;
168     *)
169         ASCEND_BINARY=""
170   esac ]
171 )
172 if test "X$ASCEND_BINARY" = "Xyes"; then
173   AC_DEFINE(ASCEND_BINARY)
174 fi
175
176 dnl extra argument: --with-threads
177 WITH_THREADS=yes
178 AC_ARG_WITH(threads,
179 [  --with-threads          Use threads, if available.  (default=yes) ],
180 [ case "$withval" in
181     yes)
182         ;;
183     *)
184         WITH_THREADS=""
185   esac ]
186 )
187
188 dnl extra argument: --with-snmp
189 WITH_SNMP=yes
190 AC_ARG_WITH(snmp,
191 [  --with-snmp             Compile in SNMP support. (default=yes)],
192 [ case "$withval" in
193     yes)
194         ;;
195     *)
196         WITH_SNMP=no
197   esac ]
198 )
199
200 dnl extra argument: --with-large-files
201 rad_enable_largefiles=no
202 AC_ARG_WITH(large-files,
203 [  --with-large-files      Compile in large (2G+) file support. (default=no)],
204 [ case "$withval" in
205     yes)
206         rad_enable_largefiles=yes
207         ;;
208     *)
209         ;;
210   esac ]
211 )
212
213
214 dnl AC_ARG_ENABLE(ltdl-install,
215 dnl [  --disable-ltdl-install  do not install libltdl])
216 dnl if test x"${enable_ltdl_install+set}" != xset; then
217 dnl   enable_ltdl_install=yes
218 dnl   ac_configure_args="$ac_configure_args --enable-ltdl-install"
219 dnl fi
220 dnl AC_CONFIG_SUBDIRS(libltdl)
221
222 dnl #
223 dnl #  Allow the user to specify a list of modules to be linked
224 dnl #  statically to the server.
225 dnl #
226 STATIC_MODULES=
227 AC_ARG_WITH(static_modules,
228 [  --with-static-modules=QUOTED-MODULE-LIST],[
229   for i in $withval; do
230     STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
231   done
232 ])
233
234 MODULES=
235 AC_ARG_WITH(modules,
236 [ --with-modules=QUOTED-MODULE-LIST],[
237  for i in $withval; do
238    MODULES="$MODULES $i"
239  done
240 ])
241
242 dnl #
243 dnl #  Enable developer C compiler warnings
244 dnl #
245 AC_ARG_ENABLE(developer,
246 [  --enable-developer               Enables features of interest to developers.],
247 [ case "$enableval" in
248     no)
249         developer=no
250         ;;
251     *)
252         developer=yes
253   esac ]
254 )
255
256 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
257   dnl turn on the developer flag when taken from a CVS checkout (not a release)
258   developer="yes"
259 fi
260
261 dnl extra argument: --with-experimental-modules
262 EXPERIMENTAL=
263 AC_ARG_WITH(experimental-modules,
264 [  --with-experimental-modules      Use experimental and unstable modules. (default=no) ],
265 [ case "$withval" in
266     yes)
267         EXPERIMENTAL=yes
268         ;;
269     *)
270   esac ]
271 )
272
273 dnl #
274 dnl # extra argument: --with-openssl-includes=dir
275 dnl #
276 OPENSSL_INCLUDE_DIR=
277 AC_ARG_WITH(openssl-includes,
278 [  --with-openssl-includes=DIR      Directory to look for OpenSSL include files],
279 [ case "$withval" in
280     *) OPENSSL_INCLUDE_DIR="$withval"
281         ;;
282   esac ]
283 )
284
285 dnl #
286 dnl # extra argument: --with-openssl-libraries=dir
287 dnl #
288 OPENSSL_LIB_DIR=
289 AC_ARG_WITH(openssl-libraries,
290 [  --with-openssl-libraries=DIR     Directory to look for OpenSSL library files],
291 [ case "$withval" in
292     *) OPENSSL_LIB_DIR="$withval"
293         ;;
294   esac ]
295 )
296
297 dnl #
298 dnl #  These next two arguments don't actually do anything.  They're
299 dnl #  place holders so that the top-level configure script can tell
300 dnl #  the user how to configure lower-level modules
301 dnl #
302
303 dnl #
304 dnl # extra argument: --with-rlm-FOO-lib-dir
305 dnl #
306 AC_ARG_WITH(rlm-FOO-lib-dir,
307 [  --with-rlm-FOO-lib-dir=DIR       Directory to look for library files used by module FOO],
308 [ case "$withval" in
309     *)
310         ;;
311   esac ]
312 )
313
314 dnl #
315 dnl # extra argument: --with-rlm-FOO-include-dir
316 dnl #
317 AC_ARG_WITH(rlm-FOO-include-dir,
318 [  --with-rlm-FOO-include-dir=DIR   Directory to look for include files used by module FOO],
319 [ case "$withval" in
320     *)
321         ;;
322   esac ]
323 )
324
325 dnl See what include-style is used by the make program.
326 dnl AC_MSG_CHECKING(include style for make)
327 dnl echo "include /dev/null" > testmake.$$
328 dnl echo "all:" >> testmake.$$
329 dnl make -f testmake.$$ >/dev/null 2>&1
330 dnl if test $? = 0
331 dnl then
332 dnl     INCLUDE=include
333 dnl     IQUOTE=
334 dnl else
335 dnl     INCLUDE=.include
336 dnl     IQUOTE='"'
337 dnl fi
338 dnl rm -f testmake.$$
339 dnl AC_MSG_RESULT(" $INCLUDE")
340 dnl AC_SUBST(INCLUDE)
341 dnl AC_SUBST(IQUOTE)
342
343 dnl extra argument: --with-udpfromto
344 WITH_UDPFROMTO=no
345 AC_ARG_WITH(udpfromto,
346 [  --with-udpfromto        Compile in UDPFROMTO support. (default=no)],
347 [ case "$withval" in
348     yes)
349         WITH_UDPFROMTO=yes
350         ;;
351     *)
352         WITH_UDPFROMTO=no
353   esac ]
354 )
355
356 if test "x$WITH_UDPFROMTO" = "xyes"; then
357         AC_DEFINE(WITH_UDPFROMTO)
358 fi
359
360 dnl extra argument: --with-edir
361 dnl If using Novell eDirectory, enable UP and Novell specific code
362 AC_ARG_WITH(edir,
363 [  --with-edir             Enable Novell eDirectory integration.  (default=no) ] , [] )
364
365 dnl #############################################################
366 dnl #
367 dnl #  1. Checks for programs
368 dnl #
369 dnl #############################################################
370
371 CHECKRAD=checkrad.pl
372 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
373 if test "x$ac_cv_path_PERL" = "x"; then
374   AC_MSG_WARN(perl not found - Simultaneous-Use and checkrad.pl may not work)
375 fi
376 AC_PATH_PROG(SNMPGET, snmpget)
377 if test "x$ac_cv_path_SNMPGET" = "x"; then
378   AC_MSG_WARN(snmpget not found - Simultaneous-Use and checkrad.pl may not work)
379 fi
380
381 AC_PATH_PROG(SNMPWALK, snmpwalk)
382 if test "x$ac_cv_path_SNMPWALK" = "x"; then
383   AC_MSG_WARN(snmpwalk not found - Simultaneous-Use and checkrad.pl may not work)
384 fi
385
386 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
387
388 dnl FIXME This is truly gross.
389 missing_dir=`cd $ac_aux_dir && pwd`
390 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
391 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
392 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
393
394 AC_PATH_PROG(LOCATE,locate)
395 AC_PATH_PROG(DIRNAME,dirname)
396 AC_PATH_PROG(GREP,grep)
397
398 dnl #############################################################
399 dnl #
400 dnl #  2. Checks for libraries
401 dnl #
402 dnl #############################################################
403
404 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
405 old_CFLAGS=$CFLAGS
406 if test "x$WITH_THREADS" = "xyes"; then 
407   if test $ac_cv_prog_suncc = "yes"; then
408     CFLAGS="$CFLAGS -mt"
409   fi
410
411   AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
412
413 dnl # 
414 dnl # pthread stuff is usually in -lpthread
415 dnl # or in -lc_r, on *BSD
416 dnl # 
417 dnl # On Some systems, we need extra pre-processor flags, to get them to
418 dnl # to do the threading properly.
419 dnl # 
420   AC_CHECK_LIB(pthread, pthread_create,
421                 [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
422                   LIBS="$LIBS -lpthread" ],
423                 AC_CHECK_LIB(c_r, pthread_create,
424                             [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
425                             [ WITH_THREADS="no" ]
426                             )
427                 )
428 fi
429
430 dnl # 
431 dnl # If we have NO pthread libraries, remove any knowledge of threads.
432 dnl # 
433 if test "x$WITH_THREADS" != "xyes"; then
434   CFLAGS=$old_CFLAGS
435   ac_cv_header_pthread_h="no"
436   WITH_THREADS=no
437 else
438   dnl #
439   dnl #  We need sem_init() and friends, as they're the friendliest
440   dnl #  semaphore functions for threading.
441   dnl #
442   dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
443   dnl # Some systems have them in -lsem
444   dnl # Solaris has them in -lposix4
445
446   AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt,
447         [],
448         [AC_MSG_ERROR(-lsem not found.  You may want to download it from ftp://ftp.to.gd-es.com/pub/BSDI/libsem.tar.bz2 or ftp://ftp.freeradius.org/pub/radius/contrib/libsem.tar.gz)]
449    )
450 fi
451
452 dnl Check if we need -lsocket
453 AC_CHECK_LIB(socket, getsockname)
454
455 dnl Check for -lresolv
456 dnl This library may be needed later.
457 AC_CHECK_LIB(resolv, inet_aton)
458
459 dnl Check if we need -lnsl. Usually if we want to
460 dnl link against -lsocket we need to include -lnsl as well.
461 AC_CHECK_LIB(nsl, inet_ntoa)
462
463 dnl Check for OpenSSL libraries.
464 OPENSSL_LIBS=
465 old_LIBS=$LIBS
466 if test "x$OPENSSL_LIB_DIR" != "x"; then
467     LIBS="-L$OPENSSL_LIB_DIR $LIBS"
468 fi
469 AC_CHECK_LIB(crypto, DH_new,
470     [
471         AC_DEFINE(HAVE_LIBCRYPTO, 1,
472             [Define to 1 if you have the `crypto' library (-lcrypto).])
473         AC_CHECK_LIB(ssl, SSL_new,
474             [
475                 AC_DEFINE(HAVE_LIBSSL, 1,
476                     [Define to 1 if you have the `ssl' library (-lssl).])
477                 if test "x$OPENSSL_LIB_DIR" != "x"; then
478                     OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
479                 fi
480                 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
481             ], [])
482     ], [])
483 LIBS=$old_LIBS
484
485 dnl #############################################################
486 dnl #
487 dnl #  3. Checks for header files
488 dnl #
489 dnl #############################################################
490
491 dnl #
492 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
493 dnl # getopt will be #included, but won't link.  <sigh>
494 dnl # 
495 dnl # 
496 case "$host" in
497 *-interix*)
498         CFLAGS="$CFLAGS -D_ALL_SOURCE"
499         ;;
500 *-darwin*)
501         CFLAGS="$CFLAGS -DDARWIN"
502         ;;
503 esac
504
505 AC_HEADER_DIRENT
506 AC_HEADER_STDC
507 AC_HEADER_TIME
508 AC_HEADER_SYS_WAIT
509
510 AC_CHECK_HEADERS( \
511         unistd.h \
512         crypt.h \
513         errno.h \
514         resource.h \
515         getopt.h \
516         malloc.h \
517         utmp.h \
518         utmpx.h \
519         signal.h \
520         sys/select.h \
521         syslog.h \
522         inttypes.h \
523         stdint.h \
524         stdio.h \
525         netdb.h \
526         semaphore.h \
527         arpa/inet.h \
528         netinet/in.h \
529         sys/types.h \
530         sys/socket.h \
531         sys/time.h \
532         sys/wait.h \
533         sys/security.h \
534         fcntl.h \
535         sys/fcntl.h \
536         sys/stat.h \
537         prot.h \
538         sia.h \
539         siad.h
540 )
541
542 REGEX=no
543 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
544 if test "x$ac_cv_header_regex_h" = "xyes"; then
545   REGEX_EXTENDED=no
546   REGEX=yes
547   AC_EGREP_CPP(yes,
548     [#include <regex.h>
549      #ifdef REG_EXTENDED
550        yes
551      #endif
552      ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
553 fi
554 AC_SUBST(REGEX)
555 AC_SUBST(REGEX_EXTENDED)
556
557 dnl #
558 dnl #  other checks which require headers
559 dnl #
560 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
561 then
562   AC_DEFINE(OSFC2)
563 fi
564
565 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
566 then
567   AC_DEFINE(OSFSIA)
568 fi
569
570 dnl Check for OpenSSL includes.
571 OPENSSL_INCLUDE="-DNO_OPENSSL"
572 if test "x$OPENSSL_LIBS" = "x"; then
573     AC_MSG_WARN([skipping test for openssl/ssl.h])
574 else
575     old_CPPFLAGS=$CPPFLAGS
576     if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
577         CPPFLAGS="$CPPFLAGS -I$OPENSSL_INCLUDE_DIR"
578     fi
579     dnl # stupid RedHat shit
580     CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
581     AC_CHECK_HEADERS( \
582         openssl/ssl.h \
583         openssl/crypto.h \
584         openssl/err.h \
585         openssl/engine.h,
586         [],
587         OPENSSL_LIBS=
588     )
589     if test "x$OPENSSL_LIBS" != "x"; then
590         AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
591         AC_EGREP_CPP(yes,
592             [#include <openssl/crypto.h>
593              #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
594              yes
595              #endif
596             ], goodssl="yes")
597         if test "x$goodssl" != "xyes"; then
598             AC_MSG_RESULT(no)
599             OPENSSL_LIBS=
600         else
601             AC_MSG_RESULT(yes)
602             if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
603                 OPENSSL_INCLUDE="-I$OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
604             else
605                 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
606             fi
607         fi
608     fi
609     CPPFLAGS=$old_CPPFLAGS
610 fi
611 AC_SUBST(OPENSSL_INCLUDE)
612 AC_SUBST(OPENSSL_LIBS)
613 export OPENSSL_LIBS
614
615 dnl #############################################################
616 dnl #
617 dnl #  4. Checks for typedefs
618 dnl #
619 dnl #############################################################
620
621 dnl #
622 dnl # Ensure that these are defined
623 dnl #
624 AC_TYPE_OFF_T 
625 AC_TYPE_PID_T
626 AC_TYPE_SIZE_T
627 AC_TYPE_UID_T
628
629 dnl check for socklen_t
630 AC_CHECK_TYPE_INCLUDE([
631 #ifdef HAVE_SYS_TYPES_H
632 #include <sys/types.h>
633 #endif
634 #ifdef HAVE_SYS_SOCKET_H
635 #include <sys/socket.h>
636 #endif
637 ],socklen_t, int)
638
639 dnl check for uint8_t
640 AC_CHECK_TYPE_INCLUDE([
641 #ifdef HAVE_INTTYPES_H
642 #include <inttypes.h>
643 #endif
644 #ifdef HAVE_STDINT_H
645 #include <stdint.h>
646 #endif
647 ],uint8_t, unsigned char)
648
649 dnl check for uint16_t
650 AC_CHECK_TYPE_INCLUDE([
651 #ifdef HAVE_INTTYPES_H
652 #include <inttypes.h>
653 #endif
654 #ifdef HAVE_STDINT_H
655 #include <stdint.h>
656 #endif
657 ],uint16_t, unsigned short)
658
659 dnl check for uint32_t
660 AC_CHECK_TYPE_INCLUDE([
661 #ifdef HAVE_INTTYPES_H
662 #include <inttypes.h>
663 #endif
664 #ifdef HAVE_STDINT_H
665 #include <stdint.h>
666 #endif
667 ],uint32_t, unsigned int)
668
669 dnl #############################################################
670 dnl #
671 dnl #  5. Checks for structures and functions
672 dnl #
673 dnl #############################################################
674 AC_CHECK_FUNCS( \
675         getopt_long \
676         lockf \
677         strsignal \
678         sigaction \
679         sigprocmask \
680         pthread_sigmask \
681         snprintf \
682         vsnprintf \
683         setsid \
684         strncasecmp \
685         strcasecmp \
686         localtime_r \
687         ctime_r \
688         gmtime_r \
689         strsep \
690         inet_aton \
691         inet_pton \
692         inet_ntop \
693         gethostname \
694         setlinebuf \
695         setvbuf \
696         getusershell \
697         initgroups \
698         closefrom
699 )
700 RADIUSD_NEED_DECLARATIONS( \
701         crypt \
702         strncasecmp \
703         strcasecmp \
704         inet_aton \
705         gethostname \
706         setlinebuf \
707         getusershell \
708         endusershell
709 )
710
711 AC_TYPE_SIGNAL
712
713 dnl # check if we have utmpx.h
714 dnl # if so, check if struct utmpx has entry ut_xtime
715 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
716 if test "x$ac_cv_header_utmpx_h" = "xyes"
717 then
718  AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
719  if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"
720  then
721    AC_DEFINE(ut_xtime,ut_tv.tv_sec)
722  fi
723 fi
724
725 dnl # struct ip_pktinfo
726 AC_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
727 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"
728 then
729         AC_DEFINE(HAVE_IP_PKTINFO)
730 fi
731
732 dnl #############################################################
733 dnl #
734 dnl #  6. Checks for compiler characteristics
735 dnl #
736 dnl #############################################################
737
738 dnl #
739 dnl # Ensure that these are defined
740 dnl #
741 AC_C_CONST 
742
743 dnl #
744 dnl # See if this is OS/2
745 dnl #
746 AC_MSG_CHECKING(type of OS)
747 OS=`uname -s`
748 AC_MSG_RESULT($OS)
749 if test "$OS" = "OS/2"; then
750         LIBPREFIX=
751 else
752         LIBPREFIX=lib
753 fi
754 AC_SUBST(LIBPREFIX)
755
756 dnl #
757 dnl # Set Default CFLAGS
758 dnl #
759 if test "x$GCC" = "xyes"; then
760     CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
761 fi
762
763 AC_MSG_CHECKING(for developer gcc flags)
764 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
765   devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -W -Wredundant-decls -Wundef"
766   CFLAGS="$CFLAGS $devflags"
767   INSTALLSTRIP=""
768   AC_MSG_RESULT(yes.  Using $devflags)
769 else
770   devflags=""
771   CFLAGS="$CFLAGS -DNDEBUG"
772   INSTALLSTRIP="-s"
773   AC_MSG_RESULT(no.)
774 fi
775
776 dnl #############################################################
777 dnl #
778 dnl #  7. Checks for library functions
779 dnl #
780 dnl #############################################################
781
782 dnl Check for libcrypt
783 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
784 AC_CHECK_LIB(crypt, crypt,
785   CRYPTLIB="-lcrypt"
786 )
787 if test "$CRYPTLIB" != ""; then
788   AC_DEFINE(HAVE_CRYPT)
789 else
790   AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
791 fi
792
793 dnl Check for libcipher
794 AC_CHECK_LIB(cipher, setkey,
795    CRYPTLIB="${CRYPTLIB} -lcipher"
796 )
797 AC_SUBST(CRYPTLIB)
798
799 if test "x$WITH_SNMP" = "xyes"; then
800   SNMP_CHECKS
801 fi
802
803 dnl Check the style of gethostbyaddr, in order of preference
804 dnl GNU (_r eight args)
805 dnl SYSV (_r six args)
806 dnl BSD (three args, may not be thread safe)
807 dnl Tru64 has BSD version, but it is thread safe
808 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
809 dnl We need #stdio.h to define NULL on FreeBSD (at least)
810 gethostbyaddrrstyle=""
811 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
812 case "$host" in
813 *-freebsd*)
814         AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
815         gethostbyaddrrstyle=BSD
816         AC_MSG_WARN([FreeBSD overridden to BSD-style])
817         ;;
818 esac
819 if test "x$gethostbyaddrrstyle" = "x"; then
820         AC_TRY_LINK([
821 #include <stdio.h>
822 #include <netdb.h>
823 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
824         AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
825         gethostbyaddrrstyle=GNU
826 ])
827 fi
828 if test "x$gethostbyaddrrstyle" = "x"; then
829         AC_TRY_LINK([
830 #include <stdio.h>
831 #include <netdb.h>
832 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
833                 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
834                 gethostbyaddrrstyle=SYSV
835         ])
836 fi
837 if test "x$gethostbyaddrrstyle" = "x"; then
838         AC_TRY_LINK([
839 #include <stdio.h>
840 #include <netdb.h>
841 ], [ gethostbyaddr(NULL, 0, 0)  ], [
842                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
843                 gethostbyaddrrstyle=BSD
844         ])
845 fi
846
847 if test "x$gethostbyaddrrstyle" = "x"; then
848         AC_MSG_RESULT([none!  It must not exist, here.])
849 else
850         AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
851 fi
852
853 if test "x$gethostbyaddrrstyle" = "xBSD"; then
854         AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
855 fi
856
857 dnl Check the style of gethostbyname, in order of preference
858 dnl GNU (_r seven args)
859 dnl SYSV (_r five args)
860 dnl BSD (two args, may not be thread safe)
861 dnl Tru64 has BSD version, but it _is_ thread safe
862 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
863 dnl We need #stdio.h to define NULL on FreeBSD (at least)
864 gethostbynamerstyle=""
865 AC_MSG_CHECKING([gethostbyname_r() syntax])
866 AC_TRY_LINK([
867 #include <stdio.h>
868 #include <netdb.h>
869 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ], [
870         AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE)
871         gethostbynamerstyle=GNU
872 ])
873 if test "x$gethostbynamerstyle" = "x"; then
874         AC_TRY_LINK([
875 #include <stdio.h>
876 #include <netdb.h>
877 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] , [
878                 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE)
879                 gethostbynamerstyle=SYSV
880         ])
881 fi
882 if test "x$gethostbynamerstyle" = "x"; then
883         AC_TRY_LINK([
884 #include <stdio.h>
885 #include <netdb.h>
886 ], [ gethostbyname(NULL)  ], [
887                 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE)
888                 gethostbynamerstyle=BSD
889         ])
890 fi
891
892 if test "x$gethostbynamerstyle" = "x"; then
893         AC_MSG_RESULT([none!  It must not exist, here.])
894 else
895         AC_MSG_RESULT([${gethostbynamerstyle}-style])
896 fi
897
898 if test "x$gethostbynamerstyle" = "xBSD"; then
899         AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
900 fi
901
902 dnl check for non-posix solaris ctime_r (extra buflen int arg)
903 ctimerstyle=""
904 AC_MSG_CHECKING([ctime_r() syntax])
905 AC_TRY_LINK([
906 #include <time.h>
907 ], [ ctime_r(NULL, NULL, 0) ], [
908         AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE)
909         ctimerstyle="SOLARIS"
910 ])
911 if test "x$ctimerstyle" = "x"; then
912         AC_TRY_LINK([
913 #include <time.h>
914 ], [ ctime_r(NULL, NULL) ], [
915                 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE)
916                 ctimerstyle="POSIX"
917         ])
918 fi
919
920 if test "x$ctimerstyle" = "x"; then
921         AC_MSG_RESULT([none!  It must not exist, here.])
922 else
923         AC_MSG_RESULT([${ctimerstyle}-style])
924 fi
925
926
927 dnl If configuring with large file support, determine the right flags to
928 dnl use based on the platform.  This is the wrong approach; autoconf 2.50
929 dnl comes with a macro that takes the right approach.  But this works well
930 dnl enough until we switch to autoconf 2.50 or later.
931 if test x"$rad_enable_largefiles" = xyes ; then
932     AC_MSG_CHECKING(for largefile linkage)
933     case "$host" in
934     *-aix4.[01]*)
935         AC_MSG_RESULT(no)
936         AC_MSG_ERROR([AIX before 4.2 does not support large files])
937         ;;
938     *-aix4*)
939         AC_MSG_RESULT(ok)
940         LFS_CFLAGS="-D_LARGE_FILES"
941         LFS_LDFLAGS=""
942         LFS_LIBS=""
943         ;;
944     *-hpux*)
945         AC_MSG_RESULT(ok)
946         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
947         LFS_LDFLAGS=""
948         LFS_LIBS=""
949         ;;
950     *-irix*)
951         AC_MSG_RESULT(no)
952         AC_MSG_ERROR([Large files not supported on this platform])
953         ;;
954     *-linux*)
955         AC_MSG_RESULT(maybe)
956         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
957         LFS_LDFLAGS=""
958         LFS_LIBS=""
959         AC_DEFINE([_GNU_SOURCE], 1,
960                   [Some versions of glibc need this defined for pread/pwrite.])
961         ;;
962     *-solaris*)
963         AC_MSG_RESULT(ok)
964         AC_PATH_PROG(GETCONF, getconf)
965         if test -z "$GETCONF" ; then
966             AC_MSG_ERROR([getconf required to configure large file support])
967         fi
968         LFS_CFLAGS=`$GETCONF LFS_CFLAGS`
969         LFS_LDFLAGS=`$GETCONF LFS_LDFLAGS`
970         LFS_LIBS=`$GETCONF LFS_LIBS`
971         ;;
972     *)
973         AC_MSG_RESULT(maybe)
974         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
975         LFS_LDFLAGS=""
976         LFS_LIBS=""
977         ;;
978     esac
979     AC_SUBST(LFS_CFLAGS)
980     AC_SUBST(LFS_LDFLAGS)
981     AC_SUBST(LFS_LIBS)
982 fi
983
984 AC_SUBST(HOSTINFO, $host)
985
986 dnl #############################################################
987 dnl #
988 dnl #  8. Checks for system services
989 dnl #
990 dnl #############################################################
991
992 dnl #
993 dnl # Figure out where libtool is located,
994 dnl #
995 top_builddir=`pwd`
996 export top_builddir
997 AC_MSG_RESULT([top_builddir=$top_builddir])
998 dnl # AC_SUBST(top_builddir)
999 AC_SUBST(LIBLTDL)
1000 AC_SUBST(INCLTDL)
1001
1002 dnl #
1003 dnl #  Work around stupid autoconf crap
1004 dnl #
1005 if test "x$INCLTDL" != "x";then
1006   INCLTDL='-I${top_builddir}/''libltdl'
1007 fi
1008
1009 dnl import libtool stuff
1010
1011 dnl #############################################################
1012 dnl #
1013 dnl #  Configure in any module directories.
1014 dnl #
1015 dnl #############################################################
1016
1017 mysubdirs=
1018 if test "x$EXPERIMENTAL" = "xyes"; then
1019   bar=`ls -1 src/modules/rlm_*/configure | sed 's%/configure%%'`
1020   dnl # get rid of LF's.
1021   mysubdirs=`echo $bar`
1022 else
1023   dnl # 
1024   dnl # Find 'configure' in ONLY the stable modules
1025   dnl # 
1026   for bar in `cat src/modules/stable`; do
1027     if test -f src/modules/$bar/configure; then
1028       mysubdirs="$mysubdirs src/modules/$bar"
1029     fi
1030   done
1031 fi
1032
1033 dnl ############################################################
1034 dnl # make modules by list
1035 dnl #############################################################
1036 if test "x$EXPERIMENTAL" = "xyes"; then
1037   for foo in `ls -1 src/modules | grep rlm_`; do
1038     MODULES="$MODULES $foo"
1039   done
1040 else
1041    dnl #
1042    dnl # make ONLY the stable modules
1043    dnl #
1044    for foo in `cat src/modules/stable`; do
1045     MODULES="$MODULES $foo"
1046    done
1047 fi
1048
1049 dnl #
1050 dnl #  Don't change the variable name here.  Autoconf goes bonkers
1051 dnl #  if you do.
1052 dnl #
1053 AC_CONFIG_SUBDIRS($mysubdirs)
1054 AC_SUBST(MODULES)
1055
1056 dnl #############################################################
1057 dnl #
1058 dnl #  And finally, output the results.
1059 dnl #
1060 dnl #############################################################
1061
1062 dnl #
1063 dnl #  Substitute whatever libraries we found to be necessary
1064 dnl #
1065 AC_SUBST(LIBS)
1066 AC_SUBST(INSTALLSTRIP)
1067
1068 USE_SHARED_LIBS=$enable_shared
1069 AC_SUBST(USE_SHARED_LIBS)
1070 USE_STATIC_LIBS=$enable_static
1071 AC_SUBST(USE_STATIC_LIBS)
1072 AC_SUBST(STATIC_MODULES)
1073 AC_SUBST(RADIUSD_MAJOR_VERSION)
1074 AC_SUBST(RADIUSD_MINOR_VERSION)
1075 AC_SUBST(RADIUSD_VERSION)
1076 export CFLAGS LIBS
1077
1078 AC_OUTPUT(\
1079         ./Make.inc \
1080         ./src/include/build-radpaths-h \
1081         ./src/main/Makefile \
1082         ./src/main/checkrad.pl \
1083         ./src/main/radlast \
1084         ./src/main/radtest \
1085         ./scripts/rc.radiusd \
1086         ./scripts/radwatch \
1087         ./scripts/check-radiusd-config \
1088         ./scripts/radiusd.cron.daily \
1089         ./scripts/radiusd.cron.monthly \
1090         ./scripts/cryptpasswd \
1091         ./raddb/dictionary \
1092         ./raddb/radiusd.conf
1093 )
1094
1095 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
1096 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
1097 AC_OUTPUT_COMMANDS([(cd ./src/main   && chmod +x checkrad.pl radlast radtest)])
1098 AC_OUTPUT_COMMANDS([(cd ./scripts    && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])