1 dnl #############################################################
3 dnl # For information about autoconf, see:
5 dnl # http://www.gnu.org/software/autoconf/
7 dnl # The recommended order is:
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...])
21 dnl #############################################################
23 AC_INIT(src/main/radiusd.c)
24 AC_CONFIG_HEADER(src/include/autoconf.h)
25 AC_REVISION($Revision$)dnl
27 dnl # The version of the software
28 RADIUSD_MAJOR_VERSION=0
29 RADIUSD_MINOR_VERSION=7-pre
30 RADIUSD_VERSION="${RADIUSD_MAJOR_VERSION}.${RADIUSD_MINOR_VERSION}"
32 dnl #############################################################
34 dnl # 0. Checks for compiler, libtool, and command line options.
36 dnl #############################################################
40 AC_PROG_GCC_TRADITIONAL
47 dnl # check for AIX, to allow us to use some BSD functions
48 dnl # must be before macros that call the compiler.
53 AC_CHECK_PROG(GMAKE, gmake, yes, no)
54 if test $GMAKE = no; then
55 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
57 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
59 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
60 if test -z "$makever"; then
61 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
62 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
65 dnl libltdl is installable
66 AC_LIBLTDL_INSTALLABLE
68 dnl use system-wide libtool, if it exists
69 AC_ARG_WITH(system-libtool,
70 [ --with-system-libtool try to use libtool installed in your system [default=use our own]],
71 [ AC_PATH_PROG(LIBTOOL, libtool,,$PATH:/usr/local/bin) ],
73 LIBTOOL="`pwd`/libtool"
75 dnl ensure that we're looking for dlopen
78 dnl Figure out how to build shared libraries
83 dnl Put this in later, when all distributed modules use autoconf.
84 dnl AC_ARG_WITH(disablemodulefoo,
85 dnl [ --without-rlm_foo Disables module compilation. Module list:]
86 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
87 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
88 dnl awk '{print " "$0}']))
90 AC_ARG_ENABLE(strict-dependencies,
91 [ --enable-strict-dependencies Fail configure on lack of module dependancy.])
93 dnl extra argument: --with-logdir
94 logdir='${localstatedir}/log/radius'
95 AC_MSG_CHECKING(logdir)
97 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log/radius] ],
100 AC_MSG_ERROR(Need logdir)
110 AC_MSG_RESULT($logdir)
112 dnl extra argument: --with-radacctdir
113 radacctdir='${logdir}/radacct'
114 AC_MSG_CHECKING(radacctdir)
115 AC_ARG_WITH(radacctdir,
116 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
119 AC_MSG_ERROR(Need radacctdir)
124 radacctdir="$withval"
129 AC_MSG_RESULT($radacctdir)
131 dnl extra argument: --with-raddbdir
132 raddbdir='${sysconfdir}/raddb'
133 AC_MSG_CHECKING(raddbdir)
134 AC_ARG_WITH(raddbdir,
135 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
138 AC_MSG_ERROR(Need raddbdir)
148 AC_MSG_RESULT($raddbdir)
150 dnl extra argument: --with-dict-nocase
152 AC_ARG_WITH(dict-nocase,
153 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
161 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
162 AC_DEFINE(WITH_DICT_NOCASE)
165 dnl extra argument: --with-ascend-binary
167 AC_ARG_WITH(ascend-binary,
168 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
176 if test "X$ASCEND_BINARY" = "Xyes"; then
177 AC_DEFINE(ASCEND_BINARY)
180 dnl extra argument: --with-threads
183 [ --with-threads Use threads, if available. (default=yes) ],
192 dnl extra argument: --with-snmp
195 [ --with-snmp Compile in SNMP support. (default=yes)],
204 dnl AC_ARG_ENABLE(ltdl-install,
205 dnl [ --disable-ltdl-install do not install libltdl])
206 dnl if test x"${enable_ltdl_install+set}" != xset; then
207 dnl enable_ltdl_install=yes
208 dnl ac_configure_args="$ac_configure_args --enable-ltdl-install"
210 dnl AC_CONFIG_SUBDIRS(libltdl)
213 dnl # Allow the user to specify a list of modules to be linked
214 dnl # statically to the server.
217 AC_ARG_WITH(static_modules,
218 [ --with-static-modules=QUOTED-MODULE-LIST],[
219 for i in $withval; do
220 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
225 dnl # Enable developer C compiler warnings
227 AC_ARG_ENABLE(developer,
228 [ --enable-developer Enables features of interest to developers.],
238 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
239 dnl turn on the developer flag when taken from a CVS checkout (not a release)
243 dnl extra argument: --with-experimental-modules
245 AC_ARG_WITH(experimental-modules,
246 [ --with-experimental-modules Use experimental and unstable modules. (default=no) ],
256 dnl # These next two arguments don't actually do anything. They're
257 dnl # place holders so that the top-level configure script can tell
258 dnl # the user how to configure lower-level modules
262 dnl # extra argument: --with-rlm-FOO-lib-dir
264 AC_ARG_WITH(rlm-FOO-lib-dir,
265 [ --with-rlm-FOO-lib-dir=DIR Directory to look for library files used by module FOO],
273 dnl # extra argument: --with-rlm-FOO-include-dir
275 AC_ARG_WITH(rlm-FOO-include-dir,
276 [ --with-rlm-FOO-include-dir=DIR Directory to look for include files used by module FOO],
283 dnl See what include-style is used by the make program.
284 dnl AC_MSG_CHECKING(include style for make)
285 dnl echo "include /dev/null" > testmake.$$
286 dnl echo "all:" >> testmake.$$
287 dnl make -f testmake.$$ >/dev/null 2>&1
296 dnl rm -f testmake.$$
297 dnl AC_MSG_RESULT(" $INCLUDE")
298 dnl AC_SUBST(INCLUDE)
301 dnl #############################################################
303 dnl # 1. Checks for programs
305 dnl #############################################################
308 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
309 if test "x$ac_cv_path_PERL" = "x"; then
310 AC_MSG_WARN(perl not found - Simultaneous-Use and checkrad.pl may not work)
312 AC_PATH_PROG(SNMPGET, snmpget)
313 if test "x$ac_cv_path_SNMPGET" = "x"; then
314 AC_MSG_WARN(snmpget not found - Simultaneous-Use and checkrad.pl may not work)
317 AC_PATH_PROG(SNMPWALK, snmpwalk)
318 if test "x$ac_cv_path_SNMPWALK" = "x"; then
319 AC_MSG_WARN(snmpwalk not found - Simultaneous-Use and checkrad.pl may not work)
322 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
324 dnl FIXME This is truly gross.
325 missing_dir=`cd $ac_aux_dir && pwd`
326 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
327 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
328 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
330 AC_PATH_PROG(LOCATE,locate)
331 AC_PATH_PROG(DIRNAME,dirname)
332 AC_PATH_PROG(GREP,grep)
334 dnl #############################################################
336 dnl # 2. Checks for libraries
338 dnl #############################################################
340 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
342 if test "x$WITH_THREADS" = "xyes"; then
343 if test $ac_cv_prog_suncc = "yes"; then
347 AC_CHECK_HEADERS(pthread.h)
349 if test "X$ac_cv_header_pthread_h" = "X"; then
350 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
355 dnl # pthread stuff is usually in -lpthread
357 AC_SEARCH_LIBS(pthread_create, pthread,
358 [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" ],
361 dnl # Except for *BSD, where it's in -lc_r,
362 dnl # and where we've got to add extra CFLAGS.
364 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
365 AC_CHECK_LIB(c_r, pthread_create
366 [CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"]
373 dnl # If we have NO pthread libraries, remove any knowledge of threads.
375 if test "x$WITH_THREADS" != "xyes"; then
377 ac_cv_header_pthread_h="no"
381 dnl # We need sem_init() and friends, as they're the friendliest
382 dnl # semaphore functions for threading.
384 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
385 dnl # Some systems have them in -lsem
386 dnl # Solaris has them in -lposix4
388 AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt,
390 [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)]
394 dnl Check if we need -lsocket
395 AC_CHECK_LIB(socket, getsockname)
397 dnl Check for -lresolv
398 dnl This library may be needed later.
399 AC_CHECK_LIB(resolv, inet_aton)
401 dnl Check if we need -lnsl. Usually if we want to
402 dnl link against -lsocket we need to include -lnsl as well.
403 AC_CHECK_LIB(nsl, inet_ntoa)
405 dnl #############################################################
407 dnl # 3. Checks for header files
409 dnl #############################################################
448 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
449 if test "x$ac_cv_header_regex_h" = "xyes"; then
457 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
460 AC_SUBST(REGEX_EXTENDED)
463 dnl # other checks which require headers
465 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
470 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
476 dnl #############################################################
478 dnl # 4. Checks for typedefs
480 dnl #############################################################
483 dnl # Ensure that these are defined
490 dnl check for socklen_t
491 AC_CHECK_TYPE_INCLUDE([
492 #ifdef HAVE_SYS_TYPES_H
493 #include <sys/types.h>
495 #ifdef HAVE_SYS_SOCKET_H
496 #include <sys/socket.h>
500 dnl check for uint8_t
501 AC_CHECK_TYPE_INCLUDE([
502 #ifdef HAVE_INTTYPES_H
503 #include <inttypes.h>
508 ],uint8_t, unsigned char)
510 dnl check for uint16_t
511 AC_CHECK_TYPE_INCLUDE([
512 #ifdef HAVE_INTTYPES_H
513 #include <inttypes.h>
518 ],uint16_t, unsigned short)
520 dnl check for uint32_t
521 AC_CHECK_TYPE_INCLUDE([
522 #ifdef HAVE_INTTYPES_H
523 #include <inttypes.h>
528 ],uint32_t, unsigned int)
530 dnl #############################################################
532 dnl # 5. Checks for structures and functions
534 dnl #############################################################
557 RADIUSD_NEED_DECLARATIONS( \
570 dnl # check if we have utmpx.h
571 dnl # if so, check if struct utmpx has entry ut_xtime
572 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
573 if test "x$ac_cv_header_utmpx_h" = "xyes"
575 AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
576 if test "x$ac_cv_type_struct_utmpx_ut_xtime" = "x"
578 AC_DEFINE(ut_xtime,ut_tv.tv_sec)
582 dnl #############################################################
584 dnl # 6. Checks for compiler characteristics
586 dnl #############################################################
589 dnl # Ensure that these are defined
594 dnl # See if this is OS/2
596 AC_MSG_CHECKING(type of OS)
599 if test "$OS" = "OS/2"; then
607 dnl # Set Default CFLAGS
609 if test "x$GCC" = "xyes"; then
610 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
613 AC_MSG_CHECKING(for developer gcc flags)
614 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
615 devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
616 CFLAGS="$CFLAGS $devflags"
618 AC_MSG_RESULT(yes. Using $devflags)
621 CFLAGS="$CFLAGS -DNDEBUG"
626 dnl #############################################################
628 dnl # 7. Checks for library functions
630 dnl #############################################################
632 dnl Check for libcrypt
633 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
634 AC_CHECK_LIB(crypt, crypt,
637 if test "$CRYPTLIB" != ""; then
638 AC_DEFINE(HAVE_CRYPT)
640 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
643 dnl Check for libcipher
644 AC_CHECK_LIB(cipher, setkey,
645 CRYPTLIB="${CRYPTLIB} -lcipher"
649 if test "x$WITH_SNMP" = "xyes"; then
653 gethostbyaddrrstyle=""
654 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
655 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
656 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
657 gethostbyaddrrstyle=SYSV
659 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
660 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
661 gethostbyaddrrstyle=GNU
664 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr(NULL, 0, 0) ], [
665 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
666 gethostbyaddrrstyle=BSD
669 if test "x$gethostbyaddrrstyle" = "x"; then
670 AC_MSG_RESULT([none! It must not exist, here.])
672 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
676 dnl #############################################################
678 dnl # 8. Checks for system services
680 dnl #############################################################
683 dnl # Figure out where libtool is located,
686 AC_MSG_RESULT([top_builddir=$top_builddir])
687 AC_SUBST(top_builddir)
692 dnl # Work around stupid autoconf crap
694 if test "x$INCLTDL" != "x";then
695 INCLTDL='-I${top_builddir}/''libltdl'
698 dnl import libtool stuff
700 dnl #############################################################
702 dnl # Configure in any module directories.
704 dnl #############################################################
707 if test "x$EXPERIMENTAL" = "xyes"; then
708 for foo in `find src/modules -name configure -print`; do
709 bar=`echo $foo | sed 's%/configure$%%g'`
710 mysubdirs="$mysubdirs $bar"
714 dnl # Find 'configure' in ONLY the stable modules
716 for foo in `find \`cat src/modules/stable | sed 's%rlm%src/modules/rlm%g'\` -name configure -print`; do
717 bar=`echo $foo | sed 's%/configure$%%g'`
718 mysubdirs="$mysubdirs $bar"
722 dnl ############################################################
723 dnl # make modules by list
724 dnl #############################################################
726 if test "x$EXPERIMENTAL" = "xyes"; then
727 for foo in `ls src/modules | grep rlm_`; do
728 MODULES="$MODULES $foo"
732 dnl # make ONLY the stable modules
734 for foo in `cat src/modules/stable`; do
735 MODULES="$MODULES $foo"
740 dnl # Don't change the variable name here. Autoconf goes bonkers
743 AC_CONFIG_SUBDIRS($mysubdirs)
746 dnl #############################################################
748 dnl # And finally, output the results.
750 dnl #############################################################
753 dnl # Substitute whatever libraries we found to be necessary
756 AC_SUBST(INSTALLSTRIP)
758 USE_SHARED_LIBS=$enable_shared
759 AC_SUBST(USE_SHARED_LIBS)
760 USE_STATIC_LIBS=$enable_static
761 AC_SUBST(USE_STATIC_LIBS)
762 AC_SUBST(STATIC_MODULES)
763 AC_SUBST(RADIUSD_MAJOR_VERSION)
764 AC_SUBST(RADIUSD_MINOR_VERSION)
765 AC_SUBST(RADIUSD_VERSION)
770 ./src/include/build-radpaths-h \
771 ./src/main/Makefile \
772 ./src/main/checkrad.pl \
775 ./scripts/rc.radiusd \
777 ./scripts/check-radiusd-config \
778 ./scripts/radiusd.cron.daily \
779 ./scripts/radiusd.cron.monthly \
780 ./scripts/cryptpasswd \
784 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
785 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
786 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
787 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
789 cat >> src/include/autoconf.h <<EOF
791 #define HOSTINFO "$host"
792 #define RADIUSD_VERSION "$RADIUSD_VERSION"