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
44 AC_CHECK_PROG(GMAKE, gmake, yes, no)
45 if test $GMAKE = no; then
46 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
48 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
50 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
51 if test -z "$makever"; then
52 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
53 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
56 dnl libltdl is installable
57 AC_LIBLTDL_INSTALLABLE
59 dnl ensure that we're looking for dlopen
62 dnl Figure out how to build shared libraries
65 dnl extra argument: --with-logdir
66 logdir='${localstatedir}/log'
67 AC_MSG_CHECKING(logdir)
69 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log] ],
72 AC_MSG_ERROR(Need logdir)
82 AC_MSG_RESULT($logdir)
84 dnl extra argument: --with-radacctdir
85 radacctdir='${logdir}/radacct'
86 AC_MSG_CHECKING(radacctdir)
87 AC_ARG_WITH(radacctdir,
88 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
91 AC_MSG_ERROR(Need radacctdir)
101 AC_MSG_RESULT($radacctdir)
103 dnl extra argument: --with-raddbdir
104 raddbdir='${sysconfdir}/raddb'
105 AC_MSG_CHECKING(raddbdir)
106 AC_ARG_WITH(raddbdir,
107 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
110 AC_MSG_ERROR(Need raddbdir)
120 AC_MSG_RESULT($raddbdir)
122 dnl extra argument: --with-dbm
126 [ --with-dbm Compile in DBM support],
137 dnl extra argument: --with-ndbm
139 [ --with-ndbm Compile in NDBM support],
153 dnl extra argument: --with-ascend-hack
154 AC_ARG_WITH(ascend-hack,
155 [ --with-ascend-hack Include Ascend hacks],
160 AC_DEFINE(WITH_ASCEND_HACK)
161 dnl if they haven't said to use it, do so.
162 if test "${with_ascend_cpl+set}" != "set"; then
168 dnl extra argument: --with-ascend-cpl=N
169 AC_ARG_WITH(ascend-cpl,
170 [ --with-ascend-cpl=N Set Ascend Channels Per Line to N [23] ],
173 AC_DEFINE_UNQUOTED(ASCEND_CHANNELS_PER_LINE, $withval)
177 dnl extra argument: --with-ntdomain-hack
178 AC_ARG_WITH(ntdomain-hack,
179 [ --with-ntdomain-hack Include NT Domain hack],
184 AC_DEFINE(WITH_NTDOMAIN_HACK)
188 dnl extra argument: --with-spcj-hack
189 AC_ARG_WITH(spcj-hack,
190 [ --with-spcj-hack Include Specialix Jetstream hacks],
195 AC_DEFINE(WITH_SPECIALIX_JETSTREAM_HACK)
199 dnl extra argument: --with-dict-nocase
201 AC_ARG_WITH(dict-nocase,
202 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
210 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
211 AC_DEFINE(WITH_DICT_NOCASE)
214 dnl extra argument: --with-attrib-nmc
216 AC_ARG_WITH(attrib-nmc,
217 [ --with-attrib-nmc Include USR-style vendor specific attributes (default=yes)],
225 if test "X$ATTRIB_NMC" = "Xyes"; then
226 AC_DEFINE(ATTRIB_NMC)
229 dnl extra argument: --with-ascend-binary
231 AC_ARG_WITH(ascend-binary,
232 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
240 if test "X$ASCEND_BINARY" = "Xyes"; then
241 AC_DEFINE(ASCEND_BINARY)
244 dnl extra argument: --with-threads
247 [ --with-threads Use threads, if available. (default=yes) ],
256 dnl extra argument: --with-thread-pool
258 AC_ARG_WITH(thread-pool,
259 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
262 WITH_THREAD_POOL=$withval
266 dnl extra argument: --with-snmp
268 [ --with-snmp Compile in SNMP support. (default=no)],
274 SNMPLIB="-lsnmp -lcrypto"
275 SNMPINC=-I/usr/include/ucd-snmp
283 AC_ARG_ENABLE(ltdl-install,
284 [ --disable-ltdl-install do not install libltdl])
285 if test x"${enable_ltdl_install+set}" != xset; then
286 enable_ltdl_install=yes
287 ac_configure_args="$ac_configure_args --enable-ltdl-install"
289 AC_CONFIG_SUBDIRS(libltdl)
291 dnl See what include-style is used by the make program.
292 dnl AC_MSG_CHECKING(include style for make)
293 dnl echo "include /dev/null" > testmake.$$
294 dnl echo "all:" >> testmake.$$
295 dnl make -f testmake.$$ >/dev/null 2>&1
304 dnl rm -f testmake.$$
305 dnl AC_MSG_RESULT(" $INCLUDE")
306 dnl AC_SUBST(INCLUDE)
309 dnl #############################################################
311 dnl # 1. Checks for programs
313 dnl #############################################################
315 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
316 if test ! -x $ac_cv_path_PERL; then
317 AC_MSG_ERROR(perl not found - fatal)
319 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
320 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
321 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
323 dnl FIXME This is truly gross.
324 missing_dir=`cd $ac_aux_dir && pwd`
325 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
326 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
327 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
330 dnl # check for AIX, to allow us to use some BSD functions
331 dnl # must be before macros that call the compiler.
335 dnl #############################################################
337 dnl # 2. Checks for libraries
339 dnl #############################################################
341 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
343 if test "$WITH_THREADS" = "yes"; then
344 if test $ac_cv_prog_suncc = "yes"; then
348 AC_CHECK_HEADERS(pthread.h)
350 if test "X$ac_cv_header_pthread_h" = "X"; then
351 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
355 dnl # pthread stuff is usually in -lpthread
357 AC_CHECK_LIB(pthread, pthread_create,
358 PTHREADLIB="-lpthread"
362 dnl # Except for *BSD, where it's in -lc_r,
363 dnl # and where we've got to add extra CFLAGS.
365 if test "X$PTHREADLIB" = "X"; then
367 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
368 AC_CHECK_LIB(c_r, pthread_create,
372 LIBS="$LIBS $PTHREADLIB"
373 CFLAGS="$CFLAGS -D_REENTRANT"
377 dnl # Checks to ensure that the thread pool code can build.
379 if test "$WITH_THREAD_POOL" = "yes"; then
381 dnl # If using thread pools, check that threading is enabled
383 if test "$WITH_THREADS" != "yes"; then
384 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
388 dnl # If using thread pools, check that we have thread libraries
390 if test "X$PTHREADLIB" = "X"; then
391 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
395 dnl # Check for sem_init all by itself
397 AC_CHECK_FUNC(sem_init)
398 if test "X$ac_cv_func_sem_init" = "Xno"; then
401 dnl # If not found, sem_init is in -lposix4 on Solaris
403 AC_CHECK_LIB(posix4, sem_init)
405 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
406 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
412 dnl # Finally, after all of the checks above, we see if
413 dnl # we can REALLY use the thread pools.
415 if test "$WITH_THREAD_POOL" = "yes"; then
416 AC_DEFINE(WITH_THREAD_POOL,1)
420 dnl Check if we need -lsocket
421 AC_CHECK_LIB(socket, getsockname)
423 dnl Check for -lresolv
424 dnl This library may be needed later.
425 AC_CHECK_LIB(resolv, inet_aton)
427 dnl Check if we need -lnsl. Usually if we want to
428 dnl link against -lsocket we need to include -lnsl as well.
429 AC_CHECK_LIB(nsl, inet_ntoa)
431 dnl #############################################################
433 dnl # 3. Checks for header files
435 dnl #############################################################
462 dnl #############################################################
464 dnl # 4. Checks for typedefs
466 dnl #############################################################
469 dnl # Ensure that these are defined
476 dnl Check for socklen_t
477 AC_CACHE_CHECK(for socklen_t,
480 AC_TRY_COMPILE([#include <sys/types.h>
481 #include <sys/socket.h>],
488 if test "$fr_cv_socklen_t" != "yes"; then
489 AC_DEFINE(socklen_t, int)
492 dnl Check for uint8_t
493 AC_CACHE_CHECK(for uint8_t,
497 #ifdef HAVE_INTTYPES_H
498 #include <inttypes.h>
510 if test "$fr_cv_uint8_t" != "yes"; then
511 AC_DEFINE(uint8_t, unsigned char)
514 dnl Check for uint32_t
515 AC_CACHE_CHECK(for uint32_t,
519 #ifdef HAVE_INTTYPES_H
520 #include <inttypes.h>
532 if test "$fr_cv_uint32_t" != "yes"; then
533 AC_DEFINE(uint32_t, unsigned int)
538 dnl # If we don't have uint32_t, then verify that sizeof(unsigned int)==4
539 dnl # If the integers are NOT 4 octets long, then the previous definition
540 dnl # won't work, and we won't produce correct RADIUS packets.
542 if test "x$UINT32_T_AS_INT" != "x"; then
543 AC_CHECK_SIZEOF(unsigned int, [4])
546 dnl #############################################################
548 dnl # 5. Checks for structures and functions
550 dnl #############################################################
568 RADIUSD_NEED_DECLARATIONS( \
581 dnl #############################################################
583 dnl # 6. Checks for compiler characteristics
585 dnl #############################################################
588 dnl # Ensure that these are defined
593 dnl # See if this is OS/2
595 AC_MSG_CHECKING(type of OS)
598 if test "$OS" = "OS/2"; then
606 dnl # Set Default CFLAGS
608 if test "$GCC" = "yes"; then
609 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
612 dnl #############################################################
614 dnl # 7. Checks for library functions
616 dnl #############################################################
618 dnl Check for libcrypt
619 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
620 AC_CHECK_LIB(crypt, crypt,
624 if test "$CRYPTLIB" != ""; then
625 AC_DEFINE(HAVE_CRYPT)
627 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
630 dnl #############################################################
632 dnl # 8. Checks for system services
634 dnl #############################################################
637 dnl # Figure out where libtool is located,
639 LIBTOOL="`pwd`/libtool"
644 AC_SUBST(top_builddir)
646 dnl #############################################################
648 dnl # And finally, output the results.
650 dnl #############################################################
653 dnl # Substitute whatever libraries we found to be necessary
657 AC_SUBST(INSTALL_PROGRAM)
658 AC_SUBST(INSTALL_DATA)
659 AC_SUBST(INSTALL_SCRIPT)
663 ./src/include/build-radpaths-h \
664 ./src/main/checkrad.pl \
667 ./scripts/rc.radiusd \
669 ./scripts/check-radiusd-config \
673 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
674 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
675 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
676 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config)])