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, 0.5
28 RADIUSD_MAJOR_VERSION=0
29 RADIUSD_MINOR_VERSION=6
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 AC_CHECK_PROG(GMAKE, gmake, yes, no)
48 if test $GMAKE = no; then
49 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
51 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
53 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
54 if test -z "$makever"; then
55 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
56 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
59 dnl libltdl is installable
60 AC_LIBLTDL_INSTALLABLE
62 dnl ensure that we're looking for dlopen
65 dnl Figure out how to build shared libraries
68 dnl Put this in later, when all distributed modules use autoconf.
69 dnl AC_ARG_WITH(disablemodulefoo,
70 dnl [ --without-rlm_foo Disables module compilation. Module list:]
71 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
72 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
73 dnl awk '{print " "$0}']))
75 AC_ARG_ENABLE(strict-dependencies,
76 [ --enable-strict-dependencies Fail configure on lack of module dependancy.])
78 dnl extra argument: --with-logdir
79 logdir='${localstatedir}/log/radius'
80 AC_MSG_CHECKING(logdir)
82 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log/radius] ],
85 AC_MSG_ERROR(Need logdir)
95 AC_MSG_RESULT($logdir)
97 dnl extra argument: --with-radacctdir
98 radacctdir='${logdir}/radacct'
99 AC_MSG_CHECKING(radacctdir)
100 AC_ARG_WITH(radacctdir,
101 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
104 AC_MSG_ERROR(Need radacctdir)
109 radacctdir="$withval"
114 AC_MSG_RESULT($radacctdir)
116 dnl extra argument: --with-raddbdir
117 raddbdir='${sysconfdir}/raddb'
118 AC_MSG_CHECKING(raddbdir)
119 AC_ARG_WITH(raddbdir,
120 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
123 AC_MSG_ERROR(Need raddbdir)
133 AC_MSG_RESULT($raddbdir)
135 dnl extra argument: --with-dict-nocase
137 AC_ARG_WITH(dict-nocase,
138 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
146 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
147 AC_DEFINE(WITH_DICT_NOCASE)
150 dnl extra argument: --with-ascend-binary
152 AC_ARG_WITH(ascend-binary,
153 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
161 if test "X$ASCEND_BINARY" = "Xyes"; then
162 AC_DEFINE(ASCEND_BINARY)
165 dnl extra argument: --with-threads
169 [ --with-threads Use threads, if available. (default=yes) ],
179 dnl extra argument: --with-snmp
182 [ --with-snmp Compile in SNMP support. (default=yes)],
191 AC_ARG_ENABLE(ltdl-install,
192 [ --disable-ltdl-install do not install libltdl])
193 if test x"${enable_ltdl_install+set}" != xset; then
194 enable_ltdl_install=yes
195 ac_configure_args="$ac_configure_args --enable-ltdl-install"
197 AC_CONFIG_SUBDIRS(libltdl)
200 dnl # Allow the user to specify a list of modules to be linked
201 dnl # statically to the server.
204 AC_ARG_WITH(static_modules,
205 [ --with-static-modules=QUOTED-MODULE-LIST],[
206 for i in $withval; do
207 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
212 dnl # Enable developer C compiler warnings
214 AC_ARG_ENABLE(developer,
215 [ --enable-developer Enables features of interest to developers.],
225 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
226 dnl turn on the developer flag when taken from a CVS checkout (not a release)
230 dnl extra argument: --with-experimental-modules
232 AC_ARG_WITH(experimental-modules,
233 [ --with-experimental-modules Use experimental and unstable modules. (default=no) ],
243 dnl # These next two arguments don't actually do anything. They're
244 dnl # place holders so that the top-level configure script can tell
245 dnl # the user how to configure lower-level modules
249 dnl # extra argument: --with-rlm-FOO-lib-dir
251 AC_ARG_WITH(rlm-FOO-lib-dir,
252 [ --with-rlm-FOO-lib-dir=DIR Directory to look for library files used by module FOO],
260 dnl # extra argument: --with-rlm-FOO-include-dir
262 AC_ARG_WITH(rlm-FOO-include-dir,
263 [ --with-rlm-FOO-include-dir=DIR Directory to look for include files used by module FOO],
270 dnl See what include-style is used by the make program.
271 dnl AC_MSG_CHECKING(include style for make)
272 dnl echo "include /dev/null" > testmake.$$
273 dnl echo "all:" >> testmake.$$
274 dnl make -f testmake.$$ >/dev/null 2>&1
283 dnl rm -f testmake.$$
284 dnl AC_MSG_RESULT(" $INCLUDE")
285 dnl AC_SUBST(INCLUDE)
288 dnl #############################################################
290 dnl # 1. Checks for programs
292 dnl #############################################################
294 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
295 if test ! -x $ac_cv_path_PERL; then
296 AC_MSG_ERROR(perl not found - fatal)
298 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
300 dnl FIXME This is truly gross.
301 missing_dir=`cd $ac_aux_dir && pwd`
302 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
303 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
304 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
306 AC_PATH_PROG(LOCATE,locate)
307 AC_PATH_PROG(DIRNAME,dirname)
308 AC_PATH_PROG(GREP,grep)
311 dnl # check for AIX, to allow us to use some BSD functions
312 dnl # must be before macros that call the compiler.
316 dnl #############################################################
318 dnl # 2. Checks for libraries
320 dnl #############################################################
322 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
324 if test "$WITH_THREADS" = "yes"; then
325 if test $ac_cv_prog_suncc = "yes"; then
329 AC_CHECK_HEADERS(pthread.h)
331 if test "X$ac_cv_header_pthread_h" = "X"; then
332 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
336 dnl # If pthread_create is in the standard libs (e.g. libc),
337 dnl # then don't do anything magical.
339 AC_CHECK_FUNC(pthread_join, PTHREADLIB=" ")
342 dnl # pthread stuff is usually in -lpthread
344 AC_CHECK_LIB(pthread, pthread_join,
345 PTHREADLIB="-lpthread"
348 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols. :\
350 AC_SEARCH_LIBS(sem_init, pthread rt,
352 dnl Er, this usage of $ac_cv_search_sem_init may be unfounded
353 dnl chumminess with the autoconf internals. -chad
354 dnl PTHREADLIB="$PTHREADLIB $ac_cv_search_sem_init"
361 dnl # Except for *BSD, where it's in -lc_r,
362 dnl # and where we've got to add extra CFLAGS.
364 if test "X$PTHREADLIB" = "X"; then
366 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
367 AC_CHECK_LIB(c_r, pthread_create,
372 dnl # Set libs, etc, if we have them.
373 if test "x$PTHREADLIB" != "x"; then
374 LIBS="$LIBS $PTHREADLIB"
375 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
380 dnl # If we have NO pthread libraries, remove any knowledge of threads.
382 if test "x$PTHREADLIB" = "x"; then
384 ac_cv_header_pthread_h="no"
389 dnl Check if we need -lsocket
390 AC_CHECK_LIB(socket, getsockname)
392 dnl Check for -lresolv
393 dnl This library may be needed later.
394 AC_CHECK_LIB(resolv, inet_aton)
396 dnl Check if we need -lnsl. Usually if we want to
397 dnl link against -lsocket we need to include -lnsl as well.
398 AC_CHECK_LIB(nsl, inet_ntoa)
400 dnl #############################################################
402 dnl # 3. Checks for header files
404 dnl #############################################################
441 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
442 if test "x$ac_cv_header_regex_h" = "xyes"; then
450 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
453 AC_SUBST(REGEX_EXTENDED)
456 dnl # other checks which require headers
458 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
463 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
469 dnl #############################################################
471 dnl # 4. Checks for typedefs
473 dnl #############################################################
476 dnl # Ensure that these are defined
483 dnl check for socklen_t
484 AC_CHECK_TYPE_INCLUDE([
485 #ifdef HAVE_SYS_TYPES_H
486 #include <sys/types.h>
488 #ifdef HAVE_SYS_SOCKET_H
489 #include <sys/socket.h>
493 dnl check for uint8_t
494 AC_CHECK_TYPE_INCLUDE([
495 #ifdef HAVE_INTTYPES_H
496 #include <inttypes.h>
501 ],uint8_t, unsigned char)
503 dnl check for uint16_t
504 AC_CHECK_TYPE_INCLUDE([
505 #ifdef HAVE_INTTYPES_H
506 #include <inttypes.h>
511 ],uint16_t, unsigned short)
513 dnl check for uint32_t
514 AC_CHECK_TYPE_INCLUDE([
515 #ifdef HAVE_INTTYPES_H
516 #include <inttypes.h>
521 ],uint32_t, unsigned int)
523 dnl #############################################################
525 dnl # 5. Checks for structures and functions
527 dnl #############################################################
551 RADIUSD_NEED_DECLARATIONS( \
564 dnl # check if we have utmpx.h
565 dnl # if so, check if struct utmpx has entry ut_xtime
566 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
567 if test "x$ac_cv_header_utmpx_h" = "xyes"
569 AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
570 if test "x$ac_cv_type_struct_utmpx_ut_xtime" = "x"
572 AC_DEFINE(ut_xtime,ut_tv.tv_sec)
576 dnl #############################################################
578 dnl # 6. Checks for compiler characteristics
580 dnl #############################################################
583 dnl # Ensure that these are defined
588 dnl # See if this is OS/2
590 AC_MSG_CHECKING(type of OS)
593 if test "$OS" = "OS/2"; then
601 dnl # Set Default CFLAGS
603 if test "x$GCC" = "xyes"; then
604 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
607 AC_MSG_CHECKING(for developer gcc flags)
608 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
609 devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
610 CFLAGS="$CFLAGS $devflags"
612 AC_MSG_RESULT(yes. Using $devflags)
615 CFLAGS="$CFLAGS -DNDEBUG"
620 dnl #############################################################
622 dnl # 7. Checks for library functions
624 dnl #############################################################
626 dnl Check for libcrypt
627 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
628 AC_CHECK_LIB(crypt, crypt,
631 if test "$CRYPTLIB" != ""; then
632 AC_DEFINE(HAVE_CRYPT)
634 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
637 dnl Check for libcipher
638 AC_CHECK_LIB(cipher, setkey,
639 CRYPTLIB="${CRYPTLIB} -lcipher"
643 if test "x$WITH_SNMP" = "xyes"; then
648 dnl # Check for sem_init all by itself
650 if test "X$ac_cv_func_sem_init" = "Xno"; then
653 dnl # If not found, sem_init is in -lposix4 on Solaris
655 AC_CHECK_LIB(posix4, sem_init)
657 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
658 if test "$WITH_THREAD_POOL" = "yes"; then
659 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
666 gethostbyaddrrstyle=""
667 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
668 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
669 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
670 gethostbyaddrrstyle=SYSV
672 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
673 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
674 gethostbyaddrrstyle=GNU
677 AC_TRY_COMPILE([#include <netdb.h>], [ gethostbyaddr(NULL, 0, 0) ], [
678 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
679 gethostbyaddrrstyle=BSD
682 if test "x$gethostbyaddrrstyle" = "x"; then
683 AC_MSG_RESULT([none! It must not exist, here.])
685 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
689 dnl #############################################################
691 dnl # 8. Checks for system services
693 dnl #############################################################
696 dnl # Figure out where libtool is located,
698 LIBTOOL="`pwd`/libtool"
703 AC_SUBST(top_builddir)
705 dnl import libtool stuff
708 dnl # Checks to ensure that the thread pool code can build.
710 if test "$WITH_THREAD_POOL" = "yes"; then
712 dnl # If using thread pools, check that threading is enabled
714 if test "$WITH_THREADS" != "yes"; then
715 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
719 dnl # If using thread pools, check that we have thread libraries
721 if test "X$PTHREADLIB" = "X"; then
722 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
727 dnl #############################################################
729 dnl # Configure in any module directories.
731 dnl #############################################################
734 if test "x$EXPERIMENTAL" = "xyes"; then
735 for foo in `find src/modules -name configure -print`; do
736 bar=`echo $foo | sed 's%/configure$%%g'`
737 mysubdirs="$mysubdirs $bar"
741 dnl # Find 'configure' in ONLY the stable modules
743 for foo in `find \`cat src/modules/stable | sed 's%rlm%src/modules/rlm%g'\` -name configure -print`; do
744 bar=`echo $foo | sed 's%/configure$%%g'`
745 mysubdirs="$mysubdirs $bar"
749 dnl ############################################################
750 dnl # make modules by list
751 dnl #############################################################
753 if test "x$EXPERIMENTAL" = "xyes"; then
754 for foo in `ls src/modules | grep rlm_`; do
755 MODULES="$MODULES $foo"
759 dnl # make ONLY the stable modules
761 for foo in `cat src/modules/stable`; do
762 MODULES="$MODULES $foo"
767 dnl # Don't change the variable name here. Autoconf goes bonkers
770 AC_CONFIG_SUBDIRS($mysubdirs)
773 dnl #############################################################
775 dnl # And finally, output the results.
777 dnl #############################################################
780 dnl # Substitute whatever libraries we found to be necessary
783 AC_SUBST(INSTALLSTRIP)
785 USE_SHARED_LIBS=$enable_shared
786 AC_SUBST(USE_SHARED_LIBS)
787 USE_STATIC_LIBS=$enable_static
788 AC_SUBST(USE_STATIC_LIBS)
789 AC_SUBST(STATIC_MODULES)
790 AC_SUBST(RADIUSD_MAJOR_VERSION)
791 AC_SUBST(RADIUSD_MINOR_VERSION)
792 AC_SUBST(RADIUSD_VERSION)
797 ./src/include/build-radpaths-h \
798 ./src/main/checkrad.pl \
801 ./scripts/rc.radiusd \
803 ./scripts/check-radiusd-config \
804 ./scripts/radiusd.cron.daily \
805 ./scripts/radiusd.cron.monthly \
806 ./scripts/cryptpasswd \
810 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
811 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
812 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
813 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
815 cat >> src/include/autoconf.h <<EOF
817 #define HOSTINFO "$host"
818 #define RADIUSD_VERSION "$RADIUSD_VERSION"