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 extra argument: --with-logdir
65 logdir='${localstatedir}/log'
66 AC_MSG_CHECKING(logdir)
68 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log] ],
71 AC_MSG_ERROR(Need logdir)
81 AC_MSG_RESULT($logdir)
83 dnl extra argument: --with-radacctdir
84 radacctdir='${logdir}/radacct'
85 AC_MSG_CHECKING(radacctdir)
86 AC_ARG_WITH(radacctdir,
87 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
90 AC_MSG_ERROR(Need radacctdir)
100 AC_MSG_RESULT($radacctdir)
102 dnl extra argument: --with-raddbdir
103 raddbdir='${sysconfdir}/raddb'
104 AC_MSG_CHECKING(raddbdir)
105 AC_ARG_WITH(raddbdir,
106 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
109 AC_MSG_ERROR(Need raddbdir)
119 AC_MSG_RESULT($raddbdir)
121 dnl extra argument: --with-dbm
125 [ --with-dbm Compile in DBM support],
136 dnl extra argument: --with-ndbm
138 [ --with-ndbm Compile in NDBM support],
152 dnl extra argument: --with-ascend-hack
153 AC_ARG_WITH(ascend-hack,
154 [ --with-ascend-hack Include Ascend hacks],
159 AC_DEFINE(WITH_ASCEND_HACK)
160 dnl if they haven't said to use it, do so.
161 if test "${with_ascend_cpl+set}" != "set"; then
167 dnl extra argument: --with-ascend-cpl=N
168 AC_ARG_WITH(ascend-cpl,
169 [ --with-ascend-cpl=N Set Ascend Channels Per Line to N [23] ],
172 AC_DEFINE_UNQUOTED(ASCEND_CHANNELS_PER_LINE, $withval)
176 dnl extra argument: --with-ntdomain-hack
177 AC_ARG_WITH(ntdomain-hack,
178 [ --with-ntdomain-hack Include NT Domain hack],
183 AC_DEFINE(WITH_NTDOMAIN_HACK)
187 dnl extra argument: --with-spcj-hack
188 AC_ARG_WITH(spcj-hack,
189 [ --with-spcj-hack Include Specialix Jetstream hacks],
194 AC_DEFINE(WITH_SPECIALIX_JETSTREAM_HACK)
198 dnl extra argument: --with-dict-nocase
200 AC_ARG_WITH(dict-nocase,
201 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
209 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
210 AC_DEFINE(WITH_DICT_NOCASE)
213 dnl extra argument: --with-attrib-nmc
215 AC_ARG_WITH(attrib-nmc,
216 [ --with-attrib-nmc Include USR-style vendor specific attributes (default=yes)],
224 if test "X$ATTRIB_NMC" = "Xyes"; then
225 AC_DEFINE(ATTRIB_NMC)
228 dnl extra argument: --with-ascend-binary
230 AC_ARG_WITH(ascend-binary,
231 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
239 if test "X$ASCEND_BINARY" = "Xyes"; then
240 AC_DEFINE(ASCEND_BINARY)
243 dnl extra argument: --with-threads
246 [ --with-threads Use threads, if available. (default=yes) ],
255 dnl extra argument: --with-thread-pool
257 AC_ARG_WITH(thread-pool,
258 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
261 WITH_THREAD_POOL=$withval
265 dnl extra argument: --with-snmp
267 [ --with-snmp Compile in SNMP support. (default=no)],
273 SNMPLIB="-lsnmp -lcrypto"
274 SNMPINC=-I/usr/include/ucd-snmp
278 dnl extra argument: --with-usercollide
279 AC_ARG_WITH(usercollide,
280 [ --with-usercollide Compile in user collision code. (default=no)],
285 AC_DEFINE(WITH_USERCOLLIDE)
294 AC_ARG_ENABLE(ltdl-install,
295 [ --disable-ltdl-install do not install libltdl])
296 if test x"${enable_ltdl_install+set}" != xset; then
297 enable_ltdl_install=yes
298 ac_configure_args="$ac_configure_args --enable-ltdl-install"
300 AC_CONFIG_SUBDIRS(libltdl)
302 dnl See what include-style is used by the make program.
303 dnl AC_MSG_CHECKING(include style for make)
304 dnl echo "include /dev/null" > testmake.$$
305 dnl echo "all:" >> testmake.$$
306 dnl make -f testmake.$$ >/dev/null 2>&1
315 dnl rm -f testmake.$$
316 dnl AC_MSG_RESULT(" $INCLUDE")
317 dnl AC_SUBST(INCLUDE)
320 dnl #############################################################
322 dnl # 1. Checks for programs
324 dnl #############################################################
326 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
327 if test ! -x $ac_cv_path_PERL; then
328 AC_MSG_ERROR(perl not found - fatal)
330 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
331 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
332 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
334 dnl FIXME This is truly gross.
335 missing_dir=`cd $ac_aux_dir && pwd`
336 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
337 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
338 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
341 dnl # check for AIX, to allow us to use some BSD functions
342 dnl # must be before macros that call the compiler.
346 dnl #############################################################
348 dnl # 2. Checks for libraries
350 dnl #############################################################
352 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
354 if test "$WITH_THREADS" = "yes"; then
355 if test $ac_cv_prog_suncc = "yes"; then
359 AC_CHECK_HEADERS(pthread.h)
361 if test "X$ac_cv_header_pthread_h" = "X"; then
362 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
366 dnl # pthread stuff is usually in -lpthread
368 AC_CHECK_LIB(pthread, pthread_create,
369 PTHREADLIB="-lpthread"
373 dnl # Except for *BSD, where it's in -lc_r,
374 dnl # and where we've got to add extra CFLAGS.
376 if test "X$PTHREADLIB" = "X"; then
378 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
379 AC_CHECK_LIB(c_r, pthread_create,
383 LIBS="$LIBS $PTHREADLIB"
384 CFLAGS="$CFLAGS -D_REENTRANT"
388 dnl # Checks to ensure that the thread pool code can build.
390 if test "$WITH_THREAD_POOL" = "yes"; then
392 dnl # If using thread pools, check that threading is enabled
394 if test "$WITH_THREADS" != "yes"; then
395 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
399 dnl # If using thread pools, check that we have thread libraries
401 if test "X$PTHREADLIB" = "X"; then
402 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
406 dnl # Check for sem_init all by itself
408 AC_CHECK_FUNC(sem_init)
409 if test "X$ac_cv_func_sem_init" = "Xno"; then
412 dnl # If not found, sem_init is in -lposix4 on Solaris
414 AC_CHECK_LIB(posix4, sem_init)
416 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
417 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
423 dnl # Finally, after all of the checks above, we see if
424 dnl # we can REALLY use the thread pools.
426 if test "$WITH_THREAD_POOL" = "yes"; then
427 AC_DEFINE(WITH_THREAD_POOL,1)
431 dnl Check if we need -lsocket
432 AC_CHECK_LIB(socket, getsockname)
434 dnl Check for -lresolv
435 dnl This library may be needed later.
436 AC_CHECK_LIB(resolv, inet_aton)
438 dnl Check if we need -lnsl. Usually if we want to
439 dnl link against -lsocket we need to include -lnsl as well.
440 AC_CHECK_LIB(nsl, inet_ntoa)
442 dnl #############################################################
444 dnl # 3. Checks for header files
446 dnl #############################################################
473 dnl #############################################################
475 dnl # 4. Checks for typedefs
477 dnl #############################################################
480 dnl # Ensure that these are defined
487 dnl Check for socklen_t
488 AC_CACHE_CHECK(for socklen_t,
491 AC_TRY_COMPILE([#include <sys/types.h>
492 #include <sys/socket.h>],
499 if test "$fr_cv_socklen_t" != "yes"; then
500 AC_DEFINE(socklen_t, int)
503 dnl Check for uint8_t
504 AC_CACHE_CHECK(for uint8_t,
508 #ifdef HAVE_INTTYPES_H
509 #include <inttypes.h>
521 if test "$fr_cv_uint8_t" != "yes"; then
522 AC_DEFINE(uint8_t, unsigned char)
525 dnl Check for uint32_t
526 AC_CACHE_CHECK(for uint32_t,
530 #ifdef HAVE_INTTYPES_H
531 #include <inttypes.h>
543 if test "$fr_cv_uint32_t" != "yes"; then
544 AC_DEFINE(uint32_t, unsigned int)
549 dnl # If we don't have uint32_t, then verify that sizeof(unsigned int)==4
550 dnl # If the integers are NOT 4 octets long, then the previous definition
551 dnl # won't work, and we won't produce correct RADIUS packets.
553 if test "x$UINT32_T_AS_INT" != "x"; then
554 AC_CHECK_SIZEOF(unsigned int, [4])
557 dnl #############################################################
559 dnl # 5. Checks for structures and functions
561 dnl #############################################################
579 RADIUSD_NEED_DECLARATIONS( \
592 dnl #############################################################
594 dnl # 6. Checks for compiler characteristics
596 dnl #############################################################
599 dnl # Ensure that these are defined
604 dnl # See if this is OS/2
606 AC_MSG_CHECKING(type of OS)
609 if test "$OS" = "OS/2"; then
617 dnl # Set Default CFLAGS
619 if test "$GCC" = "yes"; then
620 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
623 dnl #############################################################
625 dnl # 7. Checks for library functions
627 dnl #############################################################
629 dnl Check for libcrypt
630 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
631 AC_CHECK_LIB(crypt, crypt,
635 if test "$CRYPTLIB" != ""; then
636 AC_DEFINE(HAVE_CRYPT)
638 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
641 dnl #############################################################
643 dnl # 8. Checks for system services
645 dnl #############################################################
648 dnl # Figure out where libtool is located,
650 LIBTOOL="`pwd`/libtool"
655 AC_SUBST(top_builddir)
657 dnl #############################################################
659 dnl # And finally, output the results.
661 dnl #############################################################
664 dnl # Substitute whatever libraries we found to be necessary
670 ./src/include/build-radpaths-h \
671 ./src/main/checkrad.pl \
674 ./scripts/rc.radiusd \
676 ./scripts/check-radiusd-config \
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)])