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
26 dnl AC_PREFIX_DEFAULT(/usr/local)
28 dnl #############################################################
30 dnl # 0. Checks for compiler, libtool, and command line options.
32 dnl #############################################################
36 AC_PROG_GCC_TRADITIONAL
43 AC_CHECK_PROG(GMAKE, gmake, yes, no)
44 if test $GMAKE = no; then
45 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
47 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
49 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
50 if test -z "$makever"; then
51 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
52 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
55 dnl libltdl is installable
56 AC_LIBLTDL_INSTALLABLE
58 dnl ensure that we're looking for dlopen
61 dnl Figure out how to build shared libraries
64 dnl Put this in later, when all distributed modules use autoconf.
65 dnl AC_ARG_WITH(disablemodulefoo,
66 dnl [ --without-rlm_foo Disables module compilation. Module list:]
67 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
68 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
69 dnl awk '{print " "$0}']))
71 AC_ARG_ENABLE(strict-dependencies,
72 [ --enable-strict-dependencies Fail configure on lack of module dependancy.])
74 AC_ARG_WITH(fooincludedir,
75 [ --with-FOO-include-dir=DIR Dir for includes for FOO, module dependancy.])
77 AC_ARG_WITH(foolibdir,
78 [ --with-FOO-lib-dir=DIR Dir for libraries for FOO, module dependancy.])
80 dnl extra argument: --with-logdir
81 logdir='${localstatedir}/log'
82 AC_MSG_CHECKING(logdir)
84 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log] ],
87 AC_MSG_ERROR(Need logdir)
97 AC_MSG_RESULT($logdir)
99 dnl extra argument: --with-radacctdir
100 radacctdir='${logdir}/radacct'
101 AC_MSG_CHECKING(radacctdir)
102 AC_ARG_WITH(radacctdir,
103 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
106 AC_MSG_ERROR(Need radacctdir)
111 radacctdir="$withval"
116 AC_MSG_RESULT($radacctdir)
118 dnl extra argument: --with-raddbdir
119 raddbdir='${sysconfdir}/raddb'
120 AC_MSG_CHECKING(raddbdir)
121 AC_ARG_WITH(raddbdir,
122 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
125 AC_MSG_ERROR(Need raddbdir)
135 AC_MSG_RESULT($raddbdir)
137 dnl extra argument: --with-dict-nocase
139 AC_ARG_WITH(dict-nocase,
140 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
148 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
149 AC_DEFINE(WITH_DICT_NOCASE)
152 dnl extra argument: --with-ascend-binary
154 AC_ARG_WITH(ascend-binary,
155 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
163 if test "X$ASCEND_BINARY" = "Xyes"; then
164 AC_DEFINE(ASCEND_BINARY)
167 dnl extra argument: --with-threads
170 [ --with-threads Use threads, if available. (default=yes) ],
179 dnl extra argument: --with-thread-pool
181 AC_ARG_WITH(thread-pool,
182 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
192 dnl extra argument: --with-snmp
195 [ --with-snmp Compile in SNMP support. (default=yes)],
206 dnl move these into the mysql configure.in file
207 AC_ARG_WITH(mysql-include-dir,
208 [ --with-mysql-include-dir=DIR Directory where the MySQL includes may be found ],
209 [ mysql_include_dir="$withval" ]
212 AC_ARG_WITH(mysql-lib-dir,
213 [ --with-mysql-lib-dir=DIR Directory where the MySQL libraries may be found ],
214 [ mysql_lib_dir="$withval" ]
217 AC_ARG_WITH(mysql-dir,
218 [ --with-mysql-dir=DIR Base directory where MySQL is installed ],
219 [ mysql_lib_dir="$withval/lib/mysql"
220 mysql_include_dir="$withval/include"
224 AC_ARG_ENABLE(ltdl-install,
225 [ --disable-ltdl-install do not install libltdl])
226 if test x"${enable_ltdl_install+set}" != xset; then
227 enable_ltdl_install=yes
228 ac_configure_args="$ac_configure_args --enable-ltdl-install"
230 AC_CONFIG_SUBDIRS(libltdl)
233 dnl # Allow the user to specify a list of modules to be linked
234 dnl # statically to the server.
237 AC_ARG_WITH(static_modules,
238 [ --with-static-modules=QUOTED-MODULE-LIST],[
239 for i in $withval; do
240 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
245 dnl # Enable developer C compiler warnings
247 AC_ARG_ENABLE(developer,
248 [ --enable-developer Turns on super-duper-extra-compile-warnings
259 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
260 dnl turn on the developer flag when taken from a CVS checkout (not a release)
264 dnl See what include-style is used by the make program.
265 dnl AC_MSG_CHECKING(include style for make)
266 dnl echo "include /dev/null" > testmake.$$
267 dnl echo "all:" >> testmake.$$
268 dnl make -f testmake.$$ >/dev/null 2>&1
277 dnl rm -f testmake.$$
278 dnl AC_MSG_RESULT(" $INCLUDE")
279 dnl AC_SUBST(INCLUDE)
282 dnl #############################################################
284 dnl # 1. Checks for programs
286 dnl #############################################################
288 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
289 if test ! -x $ac_cv_path_PERL; then
290 AC_MSG_ERROR(perl not found - fatal)
292 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
293 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
294 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
296 dnl FIXME This is truly gross.
297 missing_dir=`cd $ac_aux_dir && pwd`
298 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
299 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
300 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
302 AC_PATH_PROG(LOCATE,locate)
303 AC_PATH_PROG(DIRNAME,dirname)
304 AC_PATH_PROG(GREP,grep)
307 dnl # check for AIX, to allow us to use some BSD functions
308 dnl # must be before macros that call the compiler.
312 dnl #############################################################
314 dnl # 2. Checks for libraries
316 dnl #############################################################
318 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
320 if test "$WITH_THREADS" = "yes"; then
321 if test $ac_cv_prog_suncc = "yes"; then
325 AC_CHECK_HEADERS(pthread.h)
327 if test "X$ac_cv_header_pthread_h" = "X"; then
328 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
332 dnl # pthread stuff is usually in -lpthread
334 AC_CHECK_LIB(pthread, pthread_create,
335 PTHREADLIB="-lpthread"
339 dnl # Except for *BSD, where it's in -lc_r,
340 dnl # and where we've got to add extra CFLAGS.
342 if test "X$PTHREADLIB" = "X"; then
344 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
345 AC_CHECK_LIB(c_r, pthread_create,
351 dnl # If we have NO pthread libraries, remove any knowledge of threads.
353 if test "x$PTHREADLIB" = "x"; then
355 ac_cv_header_pthread_h="no"
357 LIBS="$LIBS $PTHREADLIB"
358 CFLAGS="$CFLAGS -D_REENTRANT"
363 dnl # Checks to ensure that the thread pool code can build.
365 if test "$WITH_THREAD_POOL" = "yes"; then
367 dnl # If using thread pools, check that threading is enabled
369 if test "$WITH_THREADS" != "yes"; then
370 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
374 dnl # If using thread pools, check that we have thread libraries
376 if test "X$PTHREADLIB" = "X"; then
377 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
381 dnl # Check for sem_init all by itself
383 AC_CHECK_FUNC(sem_init)
384 if test "X$ac_cv_func_sem_init" = "Xno"; then
387 dnl # If not found, sem_init is in -lposix4 on Solaris
389 AC_CHECK_LIB(posix4, sem_init)
391 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
392 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
398 dnl # Finally, after all of the checks above, we see if
399 dnl # we can REALLY use the thread pools.
401 if test "$WITH_THREAD_POOL" = "yes"; then
402 AC_DEFINE(WITH_THREAD_POOL,1)
406 dnl Check if we need -lsocket
407 AC_CHECK_LIB(socket, getsockname)
409 dnl Check for -lresolv
410 dnl This library may be needed later.
411 AC_CHECK_LIB(resolv, inet_aton)
413 dnl Check if we need -lnsl. Usually if we want to
414 dnl link against -lsocket we need to include -lnsl as well.
415 AC_CHECK_LIB(nsl, inet_ntoa)
417 dnl #############################################################
419 dnl # 3. Checks for header files
421 dnl #############################################################
452 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
453 if test "x$ac_cv_header_regex_h" = "xyes"; then
461 ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
464 AC_SUBST(REGEX_EXTENDED)
467 dnl #############################################################
469 dnl # 4. Checks for typedefs
471 dnl #############################################################
474 dnl # Ensure that these are defined
481 dnl check for socklen_t
482 AC_CHECK_TYPE_INCLUDE([
483 #ifdef HAVE_SYS_TYPES_H
484 #include <sys/types.h>
486 #ifdef HAVE_SYS_SOCKET_H
487 #include <sys/socket.h>
491 dnl check for uint8_t
492 AC_CHECK_TYPE_INCLUDE([
493 #ifdef HAVE_INTTYPES_H
494 #include <inttypes.h>
499 ],uint8_t, unsigned char)
501 dnl check for uint32_t
502 AC_CHECK_TYPE_INCLUDE([
503 #ifdef HAVE_INTTYPES_H
504 #include <inttypes.h>
509 ],uint32_t, unsigned int)
511 dnl #############################################################
513 dnl # 5. Checks for structures and functions
515 dnl #############################################################
534 RADIUSD_NEED_DECLARATIONS( \
547 dnl #############################################################
549 dnl # 6. Checks for compiler characteristics
551 dnl #############################################################
554 dnl # Ensure that these are defined
559 dnl # See if this is OS/2
561 AC_MSG_CHECKING(type of OS)
564 if test "$OS" = "OS/2"; then
572 dnl # Set Default CFLAGS
574 if test "x$GCC" = "xyes"; then
575 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
578 AC_MSG_CHECKING(for developer gcc flags)
579 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
580 devflags="-Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
581 CFLAGS="$CFLAGS $devflags"
582 AC_MSG_RESULT(yes. Using $devflags)
585 CFLAGS="$CFLAGS -DNDEBUG"
589 dnl #############################################################
591 dnl # 7. Checks for library functions
593 dnl #############################################################
595 dnl Check for libcrypt
596 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
597 AC_CHECK_LIB(crypt, crypt,
601 if test "$CRYPTLIB" != ""; then
602 AC_DEFINE(HAVE_CRYPT)
604 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
607 if test "x$WITH_SNMP" = "xyes"; then
616 dnl #############################################################
618 dnl # 8. Checks for system services
620 dnl #############################################################
623 dnl # Figure out where libtool is located,
625 LIBTOOL="`pwd`/libtool"
630 AC_SUBST(top_builddir)
632 dnl #############################################################
634 dnl # Configure in any module directories.
636 dnl #############################################################
639 for foo in `find src/modules -name configure -print`; do
640 bar=`echo $foo | sed 's%/configure$%%g'`
641 mysubdirs="$mysubdirs $bar"
645 dnl # Don't change the variable name here. Autoconf goes bonkers
648 AC_CONFIG_SUBDIRS($mysubdirs)
650 dnl #############################################################
652 dnl # And finally, output the results.
654 dnl #############################################################
657 dnl # Substitute whatever libraries we found to be necessary
661 USE_SHARED_LIBS=$enable_shared
662 AC_SUBST(USE_SHARED_LIBS)
663 USE_STATIC_LIBS=$enable_static
664 AC_SUBST(USE_STATIC_LIBS)
665 AC_SUBST(STATIC_MODULES)
670 ./src/include/build-radpaths-h \
671 ./src/main/checkrad.pl \
674 ./scripts/rc.radiusd \
676 ./scripts/check-radiusd-config \
677 ./scripts/radiusd.cron.daily \
678 ./scripts/radiusd.cron.monthly \
682 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
683 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
684 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
685 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly)])
687 cat >> src/include/autoconf.h <<EOF
689 #define HOSTINFO "$host"