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, second beta, is 0.2
30 dnl #############################################################
32 dnl # 0. Checks for compiler, libtool, and command line options.
34 dnl #############################################################
38 AC_PROG_GCC_TRADITIONAL
45 AC_CHECK_PROG(GMAKE, gmake, yes, no)
46 if test $GMAKE = no; then
47 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
49 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
51 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
52 if test -z "$makever"; then
53 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
54 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
57 dnl libltdl is installable
58 AC_LIBLTDL_INSTALLABLE
60 dnl ensure that we're looking for dlopen
63 dnl Figure out how to build shared libraries
66 dnl Put this in later, when all distributed modules use autoconf.
67 dnl AC_ARG_WITH(disablemodulefoo,
68 dnl [ --without-rlm_foo Disables module compilation. Module list:]
69 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
70 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
71 dnl awk '{print " "$0}']))
73 AC_ARG_ENABLE(strict-dependencies,
74 [ --enable-strict-dependencies Fail configure on lack of module dependancy.])
76 AC_ARG_WITH(fooincludedir,
77 [ --with-FOO-include-dir=DIR Dir for includes for FOO, module dependancy.])
79 AC_ARG_WITH(foolibdir,
80 [ --with-FOO-lib-dir=DIR Dir for libraries for FOO, module dependancy.])
82 dnl extra argument: --with-logdir
83 logdir='${localstatedir}/log/radius'
84 AC_MSG_CHECKING(logdir)
86 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log/radius] ],
89 AC_MSG_ERROR(Need logdir)
99 AC_MSG_RESULT($logdir)
101 dnl extra argument: --with-radacctdir
102 radacctdir='${logdir}/radacct'
103 AC_MSG_CHECKING(radacctdir)
104 AC_ARG_WITH(radacctdir,
105 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
108 AC_MSG_ERROR(Need radacctdir)
113 radacctdir="$withval"
118 AC_MSG_RESULT($radacctdir)
120 dnl extra argument: --with-raddbdir
121 raddbdir='${sysconfdir}/raddb'
122 AC_MSG_CHECKING(raddbdir)
123 AC_ARG_WITH(raddbdir,
124 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
127 AC_MSG_ERROR(Need raddbdir)
137 AC_MSG_RESULT($raddbdir)
139 dnl extra argument: --with-dict-nocase
141 AC_ARG_WITH(dict-nocase,
142 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
150 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
151 AC_DEFINE(WITH_DICT_NOCASE)
154 dnl extra argument: --with-ascend-binary
156 AC_ARG_WITH(ascend-binary,
157 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
165 if test "X$ASCEND_BINARY" = "Xyes"; then
166 AC_DEFINE(ASCEND_BINARY)
169 dnl extra argument: --with-threads
173 [ --with-threads Use threads, if available. (default=yes) ],
183 dnl extra argument: --with-snmp
186 [ --with-snmp Compile in SNMP support. (default=yes)],
195 AC_ARG_ENABLE(ltdl-install,
196 [ --disable-ltdl-install do not install libltdl])
197 if test x"${enable_ltdl_install+set}" != xset; then
198 enable_ltdl_install=yes
199 ac_configure_args="$ac_configure_args --enable-ltdl-install"
201 AC_CONFIG_SUBDIRS(libltdl)
204 dnl # Allow the user to specify a list of modules to be linked
205 dnl # statically to the server.
208 AC_ARG_WITH(static_modules,
209 [ --with-static-modules=QUOTED-MODULE-LIST],[
210 for i in $withval; do
211 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
216 dnl # Enable developer C compiler warnings
218 AC_ARG_ENABLE(developer,
219 [ --enable-developer Turns on flags of interest to developers.],
229 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
230 dnl turn on the developer flag when taken from a CVS checkout (not a release)
235 dnl # These next two arguments don't actually do anything. They're
236 dnl # place holders so that the top-level configure script can tell
237 dnl # the user how to configure lower-level modules
241 dnl # extra argument: --with-rlm-FOO-lib-dir
243 AC_ARG_WITH(rlm-FOO-lib-dir,
244 [ --with-rlm-FOO-lib-dir=DIR Directory to look for library files used by module FOO],
252 dnl # extra argument: --with-rlm-FOO-include-dir
254 AC_ARG_WITH(rlm-FOO-include-dir,
255 [ --with-rlm-FOO-include-dir=DIR Directory to look for include files used by module FOO],
262 dnl See what include-style is used by the make program.
263 dnl AC_MSG_CHECKING(include style for make)
264 dnl echo "include /dev/null" > testmake.$$
265 dnl echo "all:" >> testmake.$$
266 dnl make -f testmake.$$ >/dev/null 2>&1
275 dnl rm -f testmake.$$
276 dnl AC_MSG_RESULT(" $INCLUDE")
277 dnl AC_SUBST(INCLUDE)
280 dnl #############################################################
282 dnl # 1. Checks for programs
284 dnl #############################################################
286 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
287 if test ! -x $ac_cv_path_PERL; then
288 AC_MSG_ERROR(perl not found - fatal)
290 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
291 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
292 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
294 dnl FIXME This is truly gross.
295 missing_dir=`cd $ac_aux_dir && pwd`
296 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
297 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
298 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
300 AC_PATH_PROG(LOCATE,locate)
301 AC_PATH_PROG(DIRNAME,dirname)
302 AC_PATH_PROG(GREP,grep)
305 dnl # check for AIX, to allow us to use some BSD functions
306 dnl # must be before macros that call the compiler.
310 dnl #############################################################
312 dnl # 2. Checks for libraries
314 dnl #############################################################
316 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
318 if test "$WITH_THREADS" = "yes"; then
319 if test $ac_cv_prog_suncc = "yes"; then
323 AC_CHECK_HEADERS(pthread.h)
325 if test "X$ac_cv_header_pthread_h" = "X"; then
326 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
330 dnl # pthread stuff is usually in -lpthread
332 AC_CHECK_LIB(pthread, pthread_join,
333 PTHREADLIB="-lpthread"
336 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols. :\
338 AC_SEARCH_LIBS(sem_init, pthread rt,
340 dnl Er, this usage of $ac_cv_search_sem_init may be unfounded
341 dnl chumminess with the autoconf internals. -chad
342 PTHREADLIB="$PTHREADLIB $ac_cv_search_sem_init"
349 dnl # Except for *BSD, where it's in -lc_r,
350 dnl # and where we've got to add extra CFLAGS.
352 if test "X$PTHREADLIB" = "X"; then
354 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
355 AC_CHECK_LIB(c_r, pthread_create,
360 dnl # Set libs, etc, if we have them.
361 if test "x$PTHREADLIB" != "x"; then
362 LIBS="$LIBS $PTHREADLIB"
363 CFLAGS="$CFLAGS -D_REENTRANT"
368 dnl # If we have NO pthread libraries, remove any knowledge of threads.
370 if test "x$PTHREADLIB" = "x"; then
372 ac_cv_header_pthread_h="no"
377 dnl Check if we need -lsocket
378 AC_CHECK_LIB(socket, getsockname)
380 dnl Check for -lresolv
381 dnl This library may be needed later.
382 AC_CHECK_LIB(resolv, inet_aton)
384 dnl Check if we need -lnsl. Usually if we want to
385 dnl link against -lsocket we need to include -lnsl as well.
386 AC_CHECK_LIB(nsl, inet_ntoa)
388 dnl #############################################################
390 dnl # 3. Checks for header files
392 dnl #############################################################
424 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
425 if test "x$ac_cv_header_regex_h" = "xyes"; then
433 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
436 AC_SUBST(REGEX_EXTENDED)
439 dnl #############################################################
441 dnl # 4. Checks for typedefs
443 dnl #############################################################
446 dnl # Ensure that these are defined
453 dnl check for socklen_t
454 AC_CHECK_TYPE_INCLUDE([
455 #ifdef HAVE_SYS_TYPES_H
456 #include <sys/types.h>
458 #ifdef HAVE_SYS_SOCKET_H
459 #include <sys/socket.h>
463 dnl check for uint8_t
464 AC_CHECK_TYPE_INCLUDE([
465 #ifdef HAVE_INTTYPES_H
466 #include <inttypes.h>
471 ],uint8_t, unsigned char)
473 dnl check for uint32_t
474 AC_CHECK_TYPE_INCLUDE([
475 #ifdef HAVE_INTTYPES_H
476 #include <inttypes.h>
481 ],uint32_t, unsigned int)
483 dnl #############################################################
485 dnl # 5. Checks for structures and functions
487 dnl #############################################################
507 RADIUSD_NEED_DECLARATIONS( \
520 dnl #############################################################
522 dnl # 6. Checks for compiler characteristics
524 dnl #############################################################
527 dnl # Ensure that these are defined
532 dnl # See if this is OS/2
534 AC_MSG_CHECKING(type of OS)
537 if test "$OS" = "OS/2"; then
545 dnl # Set Default CFLAGS
547 if test "x$GCC" = "xyes"; then
548 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
551 AC_MSG_CHECKING(for developer gcc flags)
552 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
553 devflags="-Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
554 CFLAGS="$CFLAGS $devflags"
556 AC_MSG_RESULT(yes. Using $devflags)
559 CFLAGS="$CFLAGS -DNDEBUG"
564 dnl #############################################################
566 dnl # 7. Checks for library functions
568 dnl #############################################################
570 dnl Check for libcrypt
571 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
572 AC_CHECK_LIB(crypt, crypt,
576 if test "$CRYPTLIB" != ""; then
577 AC_DEFINE(HAVE_CRYPT)
579 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
582 if test "x$WITH_SNMP" = "xyes"; then
587 dnl # Check for sem_init all by itself
589 if test "X$ac_cv_func_sem_init" = "Xno"; then
592 dnl # If not found, sem_init is in -lposix4 on Solaris
594 AC_CHECK_LIB(posix4, sem_init)
596 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
597 if test "$WITH_THREAD_POOL" = "yes"; then
598 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
607 dnl #############################################################
609 dnl # 8. Checks for system services
611 dnl #############################################################
614 dnl # Figure out where libtool is located,
616 LIBTOOL="`pwd`/libtool"
621 AC_SUBST(top_builddir)
623 dnl import libtool stuff
626 dnl # Checks to ensure that the thread pool code can build.
628 if test "$WITH_THREAD_POOL" = "yes"; then
630 dnl # If using thread pools, check that threading is enabled
632 if test "$WITH_THREADS" != "yes"; then
633 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
637 dnl # If using thread pools, check that we have thread libraries
639 if test "X$PTHREADLIB" = "X"; then
640 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
644 dnl # Finally, after all of the checks above, we see if
645 dnl # we can REALLY use the thread pools.
647 if test "$WITH_THREAD_POOL" = "yes"; then
648 AC_DEFINE(WITH_THREAD_POOL,1)
652 dnl #############################################################
654 dnl # Configure in any module directories.
656 dnl #############################################################
659 for foo in `find src/modules -name configure -print`; do
660 bar=`echo $foo | sed 's%/configure$%%g'`
661 mysubdirs="$mysubdirs $bar"
665 dnl # Don't change the variable name here. Autoconf goes bonkers
668 AC_CONFIG_SUBDIRS($mysubdirs)
670 dnl #############################################################
672 dnl # And finally, output the results.
674 dnl #############################################################
677 dnl # Substitute whatever libraries we found to be necessary
680 AC_SUBST(INSTALLSTRIP)
682 USE_SHARED_LIBS=$enable_shared
683 AC_SUBST(USE_SHARED_LIBS)
684 USE_STATIC_LIBS=$enable_static
685 AC_SUBST(USE_STATIC_LIBS)
686 AC_SUBST(STATIC_MODULES)
687 AC_SUBST(RADIUSD_VERSION)
692 ./src/include/build-radpaths-h \
693 ./src/main/checkrad.pl \
696 ./scripts/rc.radiusd \
698 ./scripts/check-radiusd-config \
699 ./scripts/radiusd.cron.daily \
700 ./scripts/radiusd.cron.monthly \
704 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
705 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
706 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
707 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly)])
709 cat >> src/include/autoconf.h <<EOF
711 #define HOSTINFO "$host"
712 #define RADIUSD_VERSION "$RADIUSD_VERSION"