1 dnl This should be processed after a new module is added!
3 dnl #############################################################
5 dnl # For information about autoconf, see:
7 dnl # http://www.gnu.org/software/autoconf/
9 dnl # The recommended order is:
12 dnl # 0. checks for compiler, libtool, and command line options
13 dnl # 1. checks for programs
14 dnl # 2. checks for libraries
15 dnl # 3. checks for header files
16 dnl # 4. checks for typedefs
17 dnl # 5. checks for structures and functions
18 dnl # 6. checks for compiler characteristics
19 dnl # 7. checks for library functions
20 dnl # 8. checks for system services
21 dnl # AC_OUTPUT([file...])
23 dnl #############################################################
25 AC_INIT(src/main/radiusd.c)
26 AC_CONFIG_HEADER(src/include/autoconf.h)
27 AC_REVISION($Revision$)dnl
28 dnl AC_PREFIX_DEFAULT(/usr/local)
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(rlm-best-guess,
74 [ --enable-rlm-best-guess Try to build all, but don't fail when lacking
76 if test x"${enable_rlm_best_guess+set}" = xset; then
77 enable_rlm_best_guess=yes
78 ac_configure_args="$ac_configure_args --enable-rlm-best-guess"
81 AC_ARG_WITH(fooincludedir,
82 [ --with-FOO-include-dir=DIR Dir for includes for FOO, module dependancy.])
84 AC_ARG_WITH(foolibdir,
85 [ --with-FOO-lib-dir=DIR Dir for libraries for FOO, module dependancy.])
87 dnl extra argument: --with-logdir
88 logdir='${localstatedir}/log'
89 AC_MSG_CHECKING(logdir)
91 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log] ],
94 AC_MSG_ERROR(Need logdir)
104 AC_MSG_RESULT($logdir)
106 dnl extra argument: --with-radacctdir
107 radacctdir='${logdir}/radacct'
108 AC_MSG_CHECKING(radacctdir)
109 AC_ARG_WITH(radacctdir,
110 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
113 AC_MSG_ERROR(Need radacctdir)
118 radacctdir="$withval"
123 AC_MSG_RESULT($radacctdir)
125 dnl extra argument: --with-raddbdir
126 raddbdir='${sysconfdir}/raddb'
127 AC_MSG_CHECKING(raddbdir)
128 AC_ARG_WITH(raddbdir,
129 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
132 AC_MSG_ERROR(Need raddbdir)
142 AC_MSG_RESULT($raddbdir)
144 dnl extra argument: --with-dict-nocase
146 AC_ARG_WITH(dict-nocase,
147 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
155 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
156 AC_DEFINE(WITH_DICT_NOCASE)
159 dnl extra argument: --with-ascend-binary
161 AC_ARG_WITH(ascend-binary,
162 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
170 if test "X$ASCEND_BINARY" = "Xyes"; then
171 AC_DEFINE(ASCEND_BINARY)
174 dnl extra argument: --with-threads
177 [ --with-threads Use threads, if available. (default=yes) ],
186 dnl extra argument: --with-thread-pool
188 AC_ARG_WITH(thread-pool,
189 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
199 dnl extra argument: --with-snmp
202 [ --with-snmp Compile in SNMP support. (default=yes)],
213 dnl move these into the mysql configure.in file
214 AC_ARG_WITH(mysql-include-dir,
215 [ --with-mysql-include-dir=DIR Directory where the MySQL includes may be found ],
216 [ mysql_include_dir="$withval" ]
219 AC_ARG_WITH(mysql-lib-dir,
220 [ --with-mysql-lib-dir=DIR Directory where the MySQL libraries may be found ],
221 [ mysql_lib_dir="$withval" ]
224 AC_ARG_WITH(mysql-dir,
225 [ --with-mysql-dir=DIR Base directory where MySQL is installed ],
226 [ mysql_lib_dir="$withval/lib/mysql"
227 mysql_include_dir="$withval/include"
231 AC_ARG_ENABLE(ltdl-install,
232 [ --disable-ltdl-install do not install libltdl])
233 if test x"${enable_ltdl_install+set}" != xset; then
234 enable_ltdl_install=yes
235 ac_configure_args="$ac_configure_args --enable-ltdl-install"
237 AC_CONFIG_SUBDIRS(libltdl)
240 dnl # Allow the user to specify a list of modules to be linked
241 dnl # statically to the server.
244 AC_ARG_WITH(static_modules,
245 [ --with-static-modules=QUOTED-MODULE-LIST],[
246 for i in $withval; do
247 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
252 dnl # Enable developer C compiler warnings
254 AC_ARG_ENABLE(developer,
255 [ --enable-developer Turns on super-duper-extra-compile-warnings
266 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
267 dnl turn on the developer flag when taken from a CVS checkout (not a release)
271 dnl See what include-style is used by the make program.
272 dnl AC_MSG_CHECKING(include style for make)
273 dnl echo "include /dev/null" > testmake.$$
274 dnl echo "all:" >> testmake.$$
275 dnl make -f testmake.$$ >/dev/null 2>&1
284 dnl rm -f testmake.$$
285 dnl AC_MSG_RESULT(" $INCLUDE")
286 dnl AC_SUBST(INCLUDE)
289 dnl #############################################################
291 dnl # 1. Checks for programs
293 dnl #############################################################
295 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
296 if test ! -x $ac_cv_path_PERL; then
297 AC_MSG_ERROR(perl not found - fatal)
299 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
300 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
301 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
303 dnl FIXME This is truly gross.
304 missing_dir=`cd $ac_aux_dir && pwd`
305 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
306 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
307 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
310 dnl # check for AIX, to allow us to use some BSD functions
311 dnl # must be before macros that call the compiler.
315 dnl #############################################################
317 dnl # 2. Checks for libraries
319 dnl #############################################################
321 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
323 if test "$WITH_THREADS" = "yes"; then
324 if test $ac_cv_prog_suncc = "yes"; then
328 AC_CHECK_HEADERS(pthread.h)
330 if test "X$ac_cv_header_pthread_h" = "X"; then
331 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
335 dnl # pthread stuff is usually in -lpthread
337 AC_CHECK_LIB(pthread, pthread_create,
338 PTHREADLIB="-lpthread"
342 dnl # Except for *BSD, where it's in -lc_r,
343 dnl # and where we've got to add extra CFLAGS.
345 if test "X$PTHREADLIB" = "X"; then
347 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
348 AC_CHECK_LIB(c_r, pthread_create,
354 dnl # If we have NO pthread libraries, remove any knowledge of threads.
356 if test "x$PTHREADLIB" = "x"; then
358 ac_cv_header_pthread_h="no"
360 LIBS="$LIBS $PTHREADLIB"
361 CFLAGS="$CFLAGS -D_REENTRANT"
366 dnl # Checks to ensure that the thread pool code can build.
368 if test "$WITH_THREAD_POOL" = "yes"; then
370 dnl # If using thread pools, check that threading is enabled
372 if test "$WITH_THREADS" != "yes"; then
373 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
377 dnl # If using thread pools, check that we have thread libraries
379 if test "X$PTHREADLIB" = "X"; then
380 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
384 dnl # Check for sem_init all by itself
386 AC_CHECK_FUNC(sem_init)
387 if test "X$ac_cv_func_sem_init" = "Xno"; then
390 dnl # If not found, sem_init is in -lposix4 on Solaris
392 AC_CHECK_LIB(posix4, sem_init)
394 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
395 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
401 dnl # Finally, after all of the checks above, we see if
402 dnl # we can REALLY use the thread pools.
404 if test "$WITH_THREAD_POOL" = "yes"; then
405 AC_DEFINE(WITH_THREAD_POOL,1)
409 dnl Check if we need -lsocket
410 AC_CHECK_LIB(socket, getsockname)
412 dnl Check for -lresolv
413 dnl This library may be needed later.
414 AC_CHECK_LIB(resolv, inet_aton)
416 dnl Check if we need -lnsl. Usually if we want to
417 dnl link against -lsocket we need to include -lnsl as well.
418 AC_CHECK_LIB(nsl, inet_ntoa)
420 dnl #############################################################
422 dnl # 3. Checks for header files
424 dnl #############################################################
455 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
456 if test "x$ac_cv_header_regex_h" = "xyes"; then
464 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
467 AC_SUBST(REGEX_EXTENDED)
470 dnl #############################################################
472 dnl # 4. Checks for typedefs
474 dnl #############################################################
477 dnl # Ensure that these are defined
484 dnl check for socklen_t
485 AC_CHECK_TYPE_INCLUDE([
486 #ifdef HAVE_SYS_TYPES_H
487 #include <sys/types.h>
489 #ifdef HAVE_SYS_SOCKET_H
490 #include <sys/socket.h>
494 dnl check for uint8_t
495 AC_CHECK_TYPE_INCLUDE([
496 #ifdef HAVE_INTTYPES_H
497 #include <inttypes.h>
502 ],uint8_t, unsigned char)
504 dnl check for uint32_t
505 AC_CHECK_TYPE_INCLUDE([
506 #ifdef HAVE_INTTYPES_H
507 #include <inttypes.h>
512 ],uint32_t, unsigned int)
514 dnl #############################################################
516 dnl # 5. Checks for structures and functions
518 dnl #############################################################
537 RADIUSD_NEED_DECLARATIONS( \
550 dnl #############################################################
552 dnl # 6. Checks for compiler characteristics
554 dnl #############################################################
557 dnl # Ensure that these are defined
562 dnl # See if this is OS/2
564 AC_MSG_CHECKING(type of OS)
567 if test "$OS" = "OS/2"; then
575 dnl # Set Default CFLAGS
577 if test "x$GCC" = "xyes"; then
578 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
581 AC_MSG_CHECKING(for developer gcc flags)
582 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
583 devflags="-Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
584 CFLAGS="$CFLAGS $devflags"
585 AC_MSG_RESULT(yes. Using $devflags)
588 CFLAGS="$CFLAGS -DNDEBUG"
592 dnl #############################################################
594 dnl # 7. Checks for library functions
596 dnl #############################################################
598 dnl Check for libcrypt
599 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
600 AC_CHECK_LIB(crypt, crypt,
604 if test "$CRYPTLIB" != ""; then
605 AC_DEFINE(HAVE_CRYPT)
607 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
610 if test "x$WITH_SNMP" = "xyes"; then
619 dnl #############################################################
621 dnl # 8. Checks for system services
623 dnl #############################################################
626 dnl # Figure out where libtool is located,
628 LIBTOOL="`pwd`/libtool"
633 AC_SUBST(top_builddir)
635 dnl #############################################################
637 dnl # Configure in any module directories.
639 dnl #############################################################
641 dnl This 'echo' is a way to get 'find' output on one line. (Make sure that -n
642 dnl works, or the 'sed's at configure-time will fail! Presumably, if you have
643 dnl autoconf, you have a decent echo. :/ Maybe.)
644 dnl Someone suggest a nicer way to do this!
645 AC_CONFIG_SUBDIRS(esyscmd(echo -n `find src/modules -name configure -print |sed 's%configure$%%'`))
647 dnl #############################################################
649 dnl # And finally, output the results.
651 dnl #############################################################
654 dnl # Substitute whatever libraries we found to be necessary
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)
666 ./src/include/build-radpaths-h \
667 ./src/main/checkrad.pl \
670 ./scripts/rc.radiusd \
672 ./scripts/check-radiusd-config \
673 ./scripts/radiusd.cron.daily \
674 ./scripts/radiusd.cron.monthly \
678 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
679 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
680 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
681 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly)])
683 cat >> src/include/autoconf.h <<EOF
685 #define HOSTINFO "$host"