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, first beta, is 0.1
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
172 [ --with-threads Use threads, if available. (default=yes) ],
181 dnl extra argument: --with-thread-pool
183 AC_ARG_WITH(thread-pool,
184 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
194 dnl extra argument: --with-snmp
197 [ --with-snmp Compile in SNMP support. (default=yes)],
206 AC_ARG_ENABLE(ltdl-install,
207 [ --disable-ltdl-install do not install libltdl])
208 if test x"${enable_ltdl_install+set}" != xset; then
209 enable_ltdl_install=yes
210 ac_configure_args="$ac_configure_args --enable-ltdl-install"
212 AC_CONFIG_SUBDIRS(libltdl)
215 dnl # Allow the user to specify a list of modules to be linked
216 dnl # statically to the server.
219 AC_ARG_WITH(static_modules,
220 [ --with-static-modules=QUOTED-MODULE-LIST],[
221 for i in $withval; do
222 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
227 dnl # Enable developer C compiler warnings
229 AC_ARG_ENABLE(developer,
230 [ --enable-developer Turns on flags of interest to developers.],
240 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
241 dnl turn on the developer flag when taken from a CVS checkout (not a release)
245 dnl See what include-style is used by the make program.
246 dnl AC_MSG_CHECKING(include style for make)
247 dnl echo "include /dev/null" > testmake.$$
248 dnl echo "all:" >> testmake.$$
249 dnl make -f testmake.$$ >/dev/null 2>&1
258 dnl rm -f testmake.$$
259 dnl AC_MSG_RESULT(" $INCLUDE")
260 dnl AC_SUBST(INCLUDE)
263 dnl #############################################################
265 dnl # 1. Checks for programs
267 dnl #############################################################
269 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
270 if test ! -x $ac_cv_path_PERL; then
271 AC_MSG_ERROR(perl not found - fatal)
273 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
274 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
275 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
277 dnl FIXME This is truly gross.
278 missing_dir=`cd $ac_aux_dir && pwd`
279 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
280 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
281 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
283 AC_PATH_PROG(LOCATE,locate)
284 AC_PATH_PROG(DIRNAME,dirname)
285 AC_PATH_PROG(GREP,grep)
288 dnl # check for AIX, to allow us to use some BSD functions
289 dnl # must be before macros that call the compiler.
293 dnl #############################################################
295 dnl # 2. Checks for libraries
297 dnl #############################################################
299 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
301 if test "$WITH_THREADS" = "yes"; then
302 if test $ac_cv_prog_suncc = "yes"; then
306 AC_CHECK_HEADERS(pthread.h)
308 if test "X$ac_cv_header_pthread_h" = "X"; then
309 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
313 dnl # pthread stuff is usually in -lpthread
315 AC_CHECK_LIB(pthread, pthread_join,
316 PTHREADLIB="-lpthread"
319 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols. :\
321 AC_SEARCH_LIBS(sem_init, pthread rt,
323 dnl Er, this usage of $ac_cv_search_sem_init may be unfounded
324 dnl chumminess with the autoconf internals. -chad
325 PTHREADLIB="$PTHREADLIB $ac_cv_search_sem_init"
332 dnl # Except for *BSD, where it's in -lc_r,
333 dnl # and where we've got to add extra CFLAGS.
335 if test "X$PTHREADLIB" = "X"; then
337 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
338 AC_CHECK_LIB(c_r, pthread_create,
344 dnl # If we have NO pthread libraries, remove any knowledge of threads.
346 if test "x$PTHREADLIB" = "x"; then
348 ac_cv_header_pthread_h="no"
350 LIBS="$LIBS $PTHREADLIB"
351 CFLAGS="$CFLAGS -D_REENTRANT"
355 dnl Check if we need -lsocket
356 AC_CHECK_LIB(socket, getsockname)
358 dnl Check for -lresolv
359 dnl This library may be needed later.
360 AC_CHECK_LIB(resolv, inet_aton)
362 dnl Check if we need -lnsl. Usually if we want to
363 dnl link against -lsocket we need to include -lnsl as well.
364 AC_CHECK_LIB(nsl, inet_ntoa)
366 dnl #############################################################
368 dnl # 3. Checks for header files
370 dnl #############################################################
402 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
403 if test "x$ac_cv_header_regex_h" = "xyes"; then
411 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
414 AC_SUBST(REGEX_EXTENDED)
417 dnl #############################################################
419 dnl # 4. Checks for typedefs
421 dnl #############################################################
424 dnl # Ensure that these are defined
431 dnl check for socklen_t
432 AC_CHECK_TYPE_INCLUDE([
433 #ifdef HAVE_SYS_TYPES_H
434 #include <sys/types.h>
436 #ifdef HAVE_SYS_SOCKET_H
437 #include <sys/socket.h>
441 dnl check for uint8_t
442 AC_CHECK_TYPE_INCLUDE([
443 #ifdef HAVE_INTTYPES_H
444 #include <inttypes.h>
449 ],uint8_t, unsigned char)
451 dnl check for uint32_t
452 AC_CHECK_TYPE_INCLUDE([
453 #ifdef HAVE_INTTYPES_H
454 #include <inttypes.h>
459 ],uint32_t, unsigned int)
461 dnl #############################################################
463 dnl # 5. Checks for structures and functions
465 dnl #############################################################
485 RADIUSD_NEED_DECLARATIONS( \
498 dnl #############################################################
500 dnl # 6. Checks for compiler characteristics
502 dnl #############################################################
505 dnl # Ensure that these are defined
510 dnl # See if this is OS/2
512 AC_MSG_CHECKING(type of OS)
515 if test "$OS" = "OS/2"; then
523 dnl # Set Default CFLAGS
525 if test "x$GCC" = "xyes"; then
526 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
529 AC_MSG_CHECKING(for developer gcc flags)
530 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
531 devflags="-Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
532 CFLAGS="$CFLAGS $devflags"
534 AC_MSG_RESULT(yes. Using $devflags)
537 CFLAGS="$CFLAGS -DNDEBUG"
542 dnl #############################################################
544 dnl # 7. Checks for library functions
546 dnl #############################################################
548 dnl Check for libcrypt
549 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
550 AC_CHECK_LIB(crypt, crypt,
554 if test "$CRYPTLIB" != ""; then
555 AC_DEFINE(HAVE_CRYPT)
557 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
560 if test "x$WITH_SNMP" = "xyes"; then
565 dnl # Check for sem_init all by itself
567 if test "X$ac_cv_func_sem_init" = "Xno"; then
570 dnl # If not found, sem_init is in -lposix4 on Solaris
572 AC_CHECK_LIB(posix4, sem_init)
574 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
575 if test "$WITH_THREAD_POOL" = "yes"; then
576 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
585 dnl #############################################################
587 dnl # 8. Checks for system services
589 dnl #############################################################
592 dnl # Figure out where libtool is located,
594 LIBTOOL="`pwd`/libtool"
599 AC_SUBST(top_builddir)
602 dnl # Checks to ensure that the thread pool code can build.
604 if test "$WITH_THREAD_POOL" = "yes"; then
606 dnl # If using thread pools, check that threading is enabled
608 if test "$WITH_THREADS" != "yes"; then
609 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
613 dnl # If using thread pools, check that we have thread libraries
615 if test "X$PTHREADLIB" = "X"; then
616 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
620 dnl # Finally, after all of the checks above, we see if
621 dnl # we can REALLY use the thread pools.
623 if test "$WITH_THREAD_POOL" = "yes"; then
624 AC_DEFINE(WITH_THREAD_POOL,1)
628 dnl #############################################################
630 dnl # Configure in any module directories.
632 dnl #############################################################
635 for foo in `find src/modules -name configure -print`; do
636 bar=`echo $foo | sed 's%/configure$%%g'`
637 mysubdirs="$mysubdirs $bar"
641 dnl # Don't change the variable name here. Autoconf goes bonkers
644 AC_CONFIG_SUBDIRS($mysubdirs)
646 dnl #############################################################
648 dnl # And finally, output the results.
650 dnl #############################################################
653 dnl # Substitute whatever libraries we found to be necessary
656 AC_SUBST(INSTALLSTRIP)
658 USE_SHARED_LIBS=$enable_shared
659 AC_SUBST(USE_SHARED_LIBS)
660 USE_STATIC_LIBS=$enable_static
661 AC_SUBST(USE_STATIC_LIBS)
662 AC_SUBST(STATIC_MODULES)
663 AC_SUBST(RADIUSD_VERSION)
668 ./src/include/build-radpaths-h \
669 ./src/main/checkrad.pl \
672 ./scripts/rc.radiusd \
674 ./scripts/check-radiusd-config \
675 ./scripts/radiusd.cron.daily \
676 ./scripts/radiusd.cron.monthly \
680 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
681 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
682 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
683 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly)])
685 cat >> src/include/autoconf.h <<EOF
687 #define HOSTINFO "$host"
688 #define RADIUSD_VERSION "$RADIUSD_VERSION"