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-dict-nocase
124 AC_ARG_WITH(dict-nocase,
125 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
133 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
134 AC_DEFINE(WITH_DICT_NOCASE)
137 dnl extra argument: --with-attrib-nmc
139 AC_ARG_WITH(attrib-nmc,
140 [ --with-attrib-nmc Include USR-style vendor specific attributes (default=yes)],
148 if test "X$ATTRIB_NMC" = "Xyes"; then
149 AC_DEFINE(ATTRIB_NMC)
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) ],
185 WITH_THREAD_POOL=$withval
189 dnl extra argument: --with-snmp
191 [ --with-snmp Compile in SNMP support. (default=no)],
197 SNMPLIB="-lsnmp -lcrypto"
198 SNMPINC=-I/usr/include/ucd-snmp
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)
214 dnl See what include-style is used by the make program.
215 dnl AC_MSG_CHECKING(include style for make)
216 dnl echo "include /dev/null" > testmake.$$
217 dnl echo "all:" >> testmake.$$
218 dnl make -f testmake.$$ >/dev/null 2>&1
227 dnl rm -f testmake.$$
228 dnl AC_MSG_RESULT(" $INCLUDE")
229 dnl AC_SUBST(INCLUDE)
232 dnl #############################################################
234 dnl # 1. Checks for programs
236 dnl #############################################################
238 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
239 if test ! -x $ac_cv_path_PERL; then
240 AC_MSG_ERROR(perl not found - fatal)
242 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
243 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
244 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
246 dnl FIXME This is truly gross.
247 missing_dir=`cd $ac_aux_dir && pwd`
248 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
249 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
250 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
253 dnl # check for AIX, to allow us to use some BSD functions
254 dnl # must be before macros that call the compiler.
258 dnl #############################################################
260 dnl # 2. Checks for libraries
262 dnl #############################################################
264 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
266 if test "$WITH_THREADS" = "yes"; then
267 if test $ac_cv_prog_suncc = "yes"; then
271 AC_CHECK_HEADERS(pthread.h)
273 if test "X$ac_cv_header_pthread_h" = "X"; then
274 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
278 dnl # pthread stuff is usually in -lpthread
280 AC_CHECK_LIB(pthread, pthread_create,
281 PTHREADLIB="-lpthread"
285 dnl # Except for *BSD, where it's in -lc_r,
286 dnl # and where we've got to add extra CFLAGS.
288 if test "X$PTHREADLIB" = "X"; then
290 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
291 AC_CHECK_LIB(c_r, pthread_create,
297 dnl # If we have NO pthread libraries, remove any knowledge of threads.
299 if test "x$PTHREADLIB" = "x"; then
301 ac_cv_header_pthread_h="no"
303 LIBS="$LIBS $PTHREADLIB"
304 CFLAGS="$CFLAGS -D_REENTRANT"
309 dnl # Checks to ensure that the thread pool code can build.
311 if test "$WITH_THREAD_POOL" = "yes"; then
313 dnl # If using thread pools, check that threading is enabled
315 if test "$WITH_THREADS" != "yes"; then
316 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
320 dnl # If using thread pools, check that we have thread libraries
322 if test "X$PTHREADLIB" = "X"; then
323 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
327 dnl # Check for sem_init all by itself
329 AC_CHECK_FUNC(sem_init)
330 if test "X$ac_cv_func_sem_init" = "Xno"; then
333 dnl # If not found, sem_init is in -lposix4 on Solaris
335 AC_CHECK_LIB(posix4, sem_init)
337 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
338 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
344 dnl # Finally, after all of the checks above, we see if
345 dnl # we can REALLY use the thread pools.
347 if test "$WITH_THREAD_POOL" = "yes"; then
348 AC_DEFINE(WITH_THREAD_POOL,1)
352 dnl Check if we need -lsocket
353 AC_CHECK_LIB(socket, getsockname)
355 dnl Check for -lresolv
356 dnl This library may be needed later.
357 AC_CHECK_LIB(resolv, inet_aton)
359 dnl Check if we need -lnsl. Usually if we want to
360 dnl link against -lsocket we need to include -lnsl as well.
361 AC_CHECK_LIB(nsl, inet_ntoa)
363 dnl #############################################################
365 dnl # 3. Checks for header files
367 dnl #############################################################
394 dnl #############################################################
396 dnl # 4. Checks for typedefs
398 dnl #############################################################
401 dnl # Ensure that these are defined
408 dnl Check for socklen_t
409 AC_CACHE_CHECK(for socklen_t,
412 AC_TRY_COMPILE([#include <sys/types.h>
413 #include <sys/socket.h>],
420 if test "$fr_cv_socklen_t" != "yes"; then
421 AC_DEFINE(socklen_t, int)
424 dnl Check for uint8_t
425 AC_CACHE_CHECK(for uint8_t,
429 #ifdef HAVE_INTTYPES_H
430 #include <inttypes.h>
442 if test "$fr_cv_uint8_t" != "yes"; then
443 AC_DEFINE(uint8_t, unsigned char)
446 dnl Check for uint32_t
447 AC_CACHE_CHECK(for uint32_t,
451 #ifdef HAVE_INTTYPES_H
452 #include <inttypes.h>
464 if test "$fr_cv_uint32_t" != "yes"; then
465 AC_DEFINE(uint32_t, unsigned int)
470 dnl # If we don't have uint32_t, then verify that sizeof(unsigned int)==4
471 dnl # If the integers are NOT 4 octets long, then the previous definition
472 dnl # won't work, and we won't produce correct RADIUS packets.
474 if test "x$UINT32_T_AS_INT" != "x"; then
475 AC_CHECK_SIZEOF(unsigned int, [4])
478 dnl #############################################################
480 dnl # 5. Checks for structures and functions
482 dnl #############################################################
500 RADIUSD_NEED_DECLARATIONS( \
513 dnl #############################################################
515 dnl # 6. Checks for compiler characteristics
517 dnl #############################################################
520 dnl # Ensure that these are defined
525 dnl # See if this is OS/2
527 AC_MSG_CHECKING(type of OS)
530 if test "$OS" = "OS/2"; then
538 dnl # Set Default CFLAGS
540 if test "$GCC" = "yes"; then
541 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
544 dnl #############################################################
546 dnl # 7. Checks for library functions
548 dnl #############################################################
550 dnl Check for libcrypt
551 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
552 AC_CHECK_LIB(crypt, crypt,
556 if test "$CRYPTLIB" != ""; then
557 AC_DEFINE(HAVE_CRYPT)
559 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
562 dnl #############################################################
564 dnl # 8. Checks for system services
566 dnl #############################################################
569 dnl # Figure out where libtool is located,
571 LIBTOOL="`pwd`/libtool"
576 AC_SUBST(top_builddir)
578 dnl #############################################################
580 dnl # And finally, output the results.
582 dnl #############################################################
585 dnl # Substitute whatever libraries we found to be necessary
589 AC_SUBST(INSTALL_PROGRAM)
590 AC_SUBST(INSTALL_DATA)
591 AC_SUBST(INSTALL_SCRIPT)
595 ./src/include/build-radpaths-h \
596 ./src/main/checkrad.pl \
599 ./scripts/rc.radiusd \
601 ./scripts/check-radiusd-config \
605 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
606 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
607 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
608 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config)])