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
42 AC_CHECK_PROG(GMAKE, gmake, yes, no)
43 if test $GMAKE = no; then
44 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
46 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
48 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
49 if test -z "$makever"; then
50 AC_MSG_ERROR(GNU Make is not installed. Please download and install it
51 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
54 dnl libltdl is installable
55 AC_LIBLTDL_INSTALLABLE
57 dnl ensure that we're looking for dlopen
60 dnl Figure out how to build shared libraries
63 dnl extra argument: --with-logdir
64 logdir='${localstatedir}/log'
65 AC_MSG_CHECKING(logdir)
67 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log] ],
70 AC_MSG_ERROR(Need logdir)
80 AC_MSG_RESULT($logdir)
82 dnl extra argument: --with-radacctdir
83 radacctdir='${logdir}/radacct'
84 AC_MSG_CHECKING(radacctdir)
85 AC_ARG_WITH(radacctdir,
86 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
89 AC_MSG_ERROR(Need radacctdir)
99 AC_MSG_RESULT($radacctdir)
101 dnl extra argument: --with-raddbdir
102 raddbdir='${sysconfdir}/raddb'
103 AC_MSG_CHECKING(raddbdir)
104 AC_ARG_WITH(raddbdir,
105 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
108 AC_MSG_ERROR(Need raddbdir)
118 AC_MSG_RESULT($raddbdir)
120 dnl extra argument: --with-dbm
124 [ --with-dbm Compile in DBM support],
135 dnl extra argument: --with-ndbm
137 [ --with-ndbm Compile in NDBM support],
151 dnl extra argument: --with-ascend-hack
152 AC_ARG_WITH(ascend-hack,
153 [ --with-ascend-hack Include Ascend hacks],
158 AC_DEFINE(WITH_ASCEND_HACK)
159 dnl if they haven't said to use it, do so.
160 if test "${with_ascend_cpl+set}" != "set"; then
166 dnl extra argument: --with-ascend-cpl=N
167 AC_ARG_WITH(ascend-cpl,
168 [ --with-ascend-cpl=N Set Ascend Channels Per Line to N [23] ],
171 AC_DEFINE_UNQUOTED(ASCEND_CHANNELS_PER_LINE, $withval)
175 dnl extra argument: --with-ntdomain-hack
176 AC_ARG_WITH(ntdomain-hack,
177 [ --with-ntdomain-hack Include NT Domain hack],
182 AC_DEFINE(WITH_NTDOMAIN_HACK)
186 dnl extra argument: --with-spcj-hack
187 AC_ARG_WITH(spcj-hack,
188 [ --with-spcj-hack Include Specialix Jetstream hacks],
193 AC_DEFINE(WITH_SPECIALIX_JETSTREAM_HACK)
197 dnl extra argument: --with-dict-nocase
199 AC_ARG_WITH(dict-nocase,
200 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
208 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
209 AC_DEFINE(WITH_DICT_NOCASE)
212 dnl extra argument: --with-attrib-nmc
214 AC_ARG_WITH(attrib-nmc,
215 [ --with-attrib-nmc Include USR-style vendor specific attributes (default=yes)],
223 if test "X$ATTRIB_NMC" = "Xyes"; then
224 AC_DEFINE(ATTRIB_NMC)
227 dnl extra argument: --with-ascend-binary
229 AC_ARG_WITH(ascend-binary,
230 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
238 if test "X$ASCEND_BINARY" = "Xyes"; then
239 AC_DEFINE(ASCEND_BINARY)
242 dnl extra argument: --with-threads
245 [ --with-threads Use threads, if available. (default=yes) ],
254 dnl extra argument: --with-thread-pool
256 AC_ARG_WITH(thread-pool,
257 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
260 WITH_THREAD_POOL=$withval
264 AC_ARG_ENABLE(ltdl-install,
265 [ --disable-ltdl-install do not install libltdl])
266 if test x"${enable_ltdl_install+set}" != xset; then
267 enable_ltdl_install=yes
268 ac_configure_args="$ac_configure_args --enable-ltdl-install"
270 AC_CONFIG_SUBDIRS(src/libltdl)
272 dnl See what include-style is used by the make program.
273 dnl AC_MSG_CHECKING(include style for make)
274 dnl echo "include /dev/null" > testmake.$$
275 dnl echo "all:" >> testmake.$$
276 dnl make -f testmake.$$ >/dev/null 2>&1
285 dnl rm -f testmake.$$
286 dnl AC_MSG_RESULT(" $INCLUDE")
287 dnl AC_SUBST(INCLUDE)
290 dnl #############################################################
292 dnl # 1. Checks for programs
294 dnl #############################################################
296 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
297 if test ! -x $ac_cv_path_PERL; then
298 AC_MSG_ERROR(perl not found - fatal)
300 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
301 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
302 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
304 dnl FIXME This is truly gross.
305 missing_dir=`cd $ac_aux_dir && pwd`
306 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
307 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
308 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
311 dnl # check for AIX, to allow us to use some BSD functions
312 dnl # must be before macros that call the compiler.
316 dnl #############################################################
318 dnl # 2. Checks for libraries
320 dnl #############################################################
322 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
324 if test "$WITH_THREADS" = "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,
349 LIBS="$LIBS $PTHREADLIB"
350 CFLAGS="$CFLAGS -D_REENTRANT"
354 dnl # Checks to ensure that the thread pool code can build.
356 if test "$WITH_THREAD_POOL" = "yes"; then
358 dnl # If using thread pools, check that threading is enabled
360 if test "$WITH_THREADS" != "yes"; then
361 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
365 dnl # If using thread pools, check that we have thread libraries
367 if test "X$PTHREADLIB" = "X"; then
368 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
372 dnl # Check for sem_init all by itself
374 AC_CHECK_FUNC(sem_init)
375 if test "X$ac_cv_func_sem_init" = "Xno"; then
378 dnl # If not found, sem_init is in -lposix4 on Solaris
380 AC_CHECK_LIB(posix4, sem_init)
382 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
383 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
389 dnl # Finally, after all of the checks above, we see if
390 dnl # we can REALLY use the thread pools.
392 if test "$WITH_THREAD_POOL" = "yes"; then
393 AC_DEFINE(WITH_THREAD_POOL,1)
397 dnl Check if we need -lsocket
398 AC_CHECK_LIB(socket, getsockname)
400 dnl Check for -lresolv
401 dnl This library may be needed later.
402 AC_CHECK_LIB(resolv, inet_aton)
404 dnl Check if we need -lnsl. Usually if we want to
405 dnl link against -lsocket we need to include -lnsl as well.
406 AC_CHECK_LIB(nsl, inet_ntoa)
408 dnl #############################################################
410 dnl # 3. Checks for header files
412 dnl #############################################################
438 dnl #############################################################
440 dnl # 4. Checks for typedefs
442 dnl #############################################################
445 dnl # Ensure that these are defined
452 dnl Check for socklen_t
453 AC_CACHE_CHECK(for socklen_t,
456 AC_TRY_COMPILE([#include <sys/types.h>
457 #include <sys/socket.h>],
464 if test "$fr_cv_socklen_t" != "yes"; then
465 AC_DEFINE(socklen_t, int)
468 dnl Check for uint8_t
469 AC_CACHE_CHECK(for uint8_t,
473 #ifdef HAVE_INTTYPES_H
474 #include <inttypes.h>
486 if test "$fr_cv_uint8_t" != "yes"; then
487 AC_DEFINE(uint8_t, unsigned char)
490 dnl Check for uint32_t
491 AC_CACHE_CHECK(for uint32_t,
495 #ifdef HAVE_INTTYPES_H
496 #include <inttypes.h>
508 if test "$fr_cv_uint32_t" != "yes"; then
509 AC_DEFINE(uint32_t, unsigned int)
514 dnl # If we don't have uint32_t, then verify that sizeof(unsigned int)==4
515 dnl # If the integers are NOT 4 octets long, then the previous definition
516 dnl # won't work, and we won't produce correct RADIUS packets.
518 if test "x$UINT32_T_AS_INT" != "x"; then
519 AC_CHECK_SIZEOF(unsigned int, [4])
522 dnl #############################################################
524 dnl # 5. Checks for structures and functions
526 dnl #############################################################
544 RADIUSD_NEED_DECLARATIONS( \
557 dnl #############################################################
559 dnl # 6. Checks for compiler characteristics
561 dnl #############################################################
564 dnl # Ensure that these are defined
569 dnl # See if this is OS/2
571 AC_MSG_CHECKING(type of OS)
574 if test "$OS" = "OS/2"; then
582 dnl # Set Default CFLAGS
584 if test "$GCC" = "yes"; then
585 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
588 dnl #############################################################
590 dnl # 7. Checks for library functions
592 dnl #############################################################
594 dnl Check for libcrypt
595 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
596 AC_CHECK_LIB(crypt, crypt,
600 if test "$CRYPTLIB" != ""; then
601 AC_DEFINE(HAVE_CRYPT)
603 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
606 dnl #############################################################
608 dnl # 8. Checks for system services
610 dnl #############################################################
613 dnl # Figure out where libtool is located,
615 LIBTOOL="`pwd`/libtool"
620 dnl #############################################################
622 dnl # And finally, output the results.
624 dnl #############################################################
627 dnl # Substitute whatever libraries we found to be necessary
633 ./src/include/build-radpaths-h \
634 ./src/main/checkrad.pl \
637 ./scripts/rc.radiusd \
639 ./scripts/check-radiusd-config \
643 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
644 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
645 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
646 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config)])