1 dnl #############################################################
3 dnl # For information about autoconf, see:
5 dnl # http://www.primate.wisc.edu/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 ensure that we're looking for dlopen
57 dnl Figure out how to build shared libraries
60 dnl extra argument: --with-logdir
61 logdir='${localstatedir}/log'
62 AC_MSG_CHECKING(logdir)
64 [ --with-logdir=DIR Directory for logfiles [LOCALSTATEDIR/log] ],
67 AC_MSG_ERROR(Need logdir)
77 AC_MSG_RESULT($logdir)
79 dnl extra argument: --with-radacctdir
80 radacctdir='${logdir}/radacct'
81 AC_MSG_CHECKING(radacctdir)
82 AC_ARG_WITH(radacctdir,
83 [ --with-radacctdir=PATH Directory for detail files [LOGDIR/radacct] ],
86 AC_MSG_ERROR(Need radacctdir)
96 AC_MSG_RESULT($radacctdir)
98 dnl extra argument: --with-raddbdir
99 raddbdir='${sysconfdir}/raddb'
100 AC_MSG_CHECKING(raddbdir)
101 AC_ARG_WITH(raddbdir,
102 [ --with-raddbdir=DIR Directory for config files [SYSCONFDIR/raddb] ],
105 AC_MSG_ERROR(Need raddbdir)
115 AC_MSG_RESULT($raddbdir)
117 dnl extra argument: --with-dbm
121 [ --with-dbm Compile in DBM support],
132 dnl extra argument: --with-ndbm
134 [ --with-ndbm Compile in NDBM support],
148 dnl extra argument: --with-ascend-hack
149 AC_ARG_WITH(ascend-hack,
150 [ --with-ascend-hack Include Ascend hacks],
155 AC_DEFINE(WITH_ASCEND_HACK)
156 dnl if they haven't said to use it, do so.
157 if test "${with_ascend_cpl+set}" != "set"; then
163 dnl extra argument: --with-ascend-cpl=N
164 AC_ARG_WITH(ascend-cpl,
165 [ --with-ascend-cpl=N Set Ascend Channels Per Line to N [23] ],
168 AC_DEFINE_UNQUOTED(ASCEND_CHANNELS_PER_LINE, $withval)
172 dnl extra argument: --with-ntdomain-hack
173 AC_ARG_WITH(ntdomain-hack,
174 [ --with-ntdomain-hack Include NT Domain hack],
179 AC_DEFINE(WITH_NTDOMAIN_HACK)
183 dnl extra argument: --with-spcj-hack
184 AC_ARG_WITH(spcj-hack,
185 [ --with-spcj-hack Include Specialix Jetstream hacks],
190 AC_DEFINE(WITH_SPECIALIX_JETSTREAM_HACK)
194 dnl extra argument: --with-dict-nocase
195 AC_ARG_WITH(dict-nocase,
196 [ --with-dict-nocase Make dictionary case-independant],
201 AC_DEFINE(WITH_DICT_NOCASE)
205 dnl extra argument: --with-attrib-nmc
207 AC_ARG_WITH(attrib-nmc,
208 [ --with-attrib-nmc Include USR-style vendor specific attributes (default=yes)],
209 [ ATTRIB_NMC=$withval
214 AC_DEFINE(ATTRIB_NMC)
217 dnl if they haven't said to use it, do so.
218 if test "$ATTRIB_NMC" = "";then
219 AC_DEFINE(ATTRIB_NMC)
222 dnl extra argument: --with-ascend-binary
224 AC_ARG_WITH(ascend-binary,
225 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
226 [ ASCEND_BINARY=$withval
231 AC_DEFINE(ASCEND_BINARY)
234 dnl if they haven't said to use it, do so.
235 if test "X$ASCEND_BINARY" = "X";then
236 AC_DEFINE(ASCEND_BINARY)
239 dnl extra argument: --with-threads
242 [ --with-threads Use threads, if available. (default=yes) ],
245 WITH_THREADS=$withval
249 dnl extra argument: --with-thread-pool
251 AC_ARG_WITH(thread-pool,
252 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
255 WITH_THREAD_POOL=$withval
259 dnl See what include-style is used by the make program.
260 dnl AC_MSG_CHECKING(include style for make)
261 dnl echo "include /dev/null" > testmake.$$
262 dnl echo "all:" >> testmake.$$
263 dnl make -f testmake.$$ >/dev/null 2>&1
272 dnl rm -f testmake.$$
273 dnl AC_MSG_RESULT(" $INCLUDE")
274 dnl AC_SUBST(INCLUDE)
277 dnl #############################################################
279 dnl # 1. Checks for programs
281 dnl #############################################################
283 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
284 if test ! -x $ac_cv_path_PERL; then
285 AC_MSG_ERROR(perl not found - fatal)
287 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
288 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
289 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
292 dnl # check for AIX, to allow us to use some BSD functions
293 dnl # must be before macros that call the compiler.
297 dnl #############################################################
299 dnl # 2. Checks for libraries
301 dnl #############################################################
303 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
305 if test "$WITH_THREADS" = "yes"; then
306 AC_CHECK_HEADERS(pthread.h)
307 AC_CHECK_LIB(pthread, pthread_create,
308 PTHREADLIB="-lpthread"
310 if test "X$PTHREADLIB" = "X"; then
311 AC_CHECK_LIB(c_r, pthread_create,
318 if test "$WITH_THREAD_POOL" = "yes"; then
319 dnl If using thread pools, check that threading is enabled
320 if test "$WITH_THREADS" != "yes"; then
321 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
324 dnl If using thread pools, check that we have thread libraries
325 if test "X$PTHREADLIB" = "X"; then
326 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
329 AC_DEFINE(WITH_THREAD_POOL,1)
332 dnl Check for -lsocket
333 AC_CHECK_LIB(socket, getsockname,
338 dnl Check for -lresolv
339 dnl This library may be needed later.
340 AC_CHECK_LIB(resolv, inet_aton)
342 dnl Check for -lnsl. We don't need yp_all, but usually if we want to
343 dnl link against -lsocket we need to include -lnsl as well.
344 AC_CHECK_LIB(nsl, yp_all,
349 dnl #############################################################
351 dnl # 3. Checks for header files
353 dnl #############################################################
376 dnl #############################################################
378 dnl # 4. Checks for typedefs
380 dnl #############################################################
383 dnl # Ensure that these are defined
390 dnl Check for socklen_t
391 AC_CACHE_CHECK(for socklen_t,
394 AC_TRY_COMPILE([#include <sys/types.h>
395 #include <sys/socket.h>],
397 AC_DEFINE(HAVE_SOCKLEN_T) fr_cv_socklen_t=yes,
402 dnl Check for uint8_t
403 AC_CACHE_CHECK(for uint8_t,
407 #ifdef HAVE_INTTYPES_H
408 #include <inttypes.h>
420 if test "$fr_cv_uint8_t" != "yes"; then
421 AC_DEFINE(uint8_t, unsigned char)
424 dnl Check for uint32_t
425 AC_CACHE_CHECK(for uint32_t,
429 #ifdef HAVE_INTTYPES_H
430 #include <inttypes.h>
442 if test "$fr_cv_uint32_t" != "yes"; then
443 AC_DEFINE(uint32_t, unsigned int)
448 dnl # If we don't have uint32_t, then verify that sizeof(unsigned int)==4
449 dnl # If the integers are NOT 4 octets long, then the previous definition
450 dnl # won't work, and we won't produce correct RADIUS packets.
452 if test "x$UINT32_T_AS_INT" != "x"; then
453 AC_CHECK_SIZEOF(unsigned int, [4])
456 dnl #############################################################
458 dnl # 5. Checks for structures and functions
460 dnl #############################################################
476 RADIUSD_NEED_DECLARATIONS( \
489 dnl #############################################################
491 dnl # 6. Checks for compiler characteristics
493 dnl #############################################################
496 dnl # Ensure that these are defined
501 dnl # See if this is OS/2
503 AC_MSG_CHECKING(type of OS)
506 if test "$OS" = "OS/2"; then
514 dnl # Set Default CFLAGS
516 if test "$GCC" = "yes"; then
517 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
520 dnl #############################################################
522 dnl # 7. Checks for library functions
524 dnl #############################################################
526 dnl Check for libcrypt
527 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
528 AC_CHECK_LIB(crypt, crypt,
532 if test "$CRYPTLIB" != ""; then
533 AC_DEFINE(HAVE_CRYPT)
535 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
538 dnl ***********************
539 dnl This next bit is stolen from glib, and modified to work for FreeRADIUS.
540 dnl ***********************
544 MODULE_HAVE_DLERROR=0
546 dnl *** dlopen() and dlsym() in system libraries
547 if test -z "$DYNAMIC_MODULES"; then
548 AC_CHECK_FUNC(dlopen,
550 [ DYNAMIC_MODULES=DYNAMIC_MODULES_DL HAVE_DLOPEN=1 ]
555 dnl *** dlopen() and dlsym() in libdl
556 if test -z "$DYNAMIC_MODULES"; then
557 AC_CHECK_LIB(dl, dlopen,
558 AC_CHECK_LIB(dl, dlsym,
560 [ DYNAMIC_MODULES=DYNAMIC_MODULES_DL HAVE_DLOPEN=1 ]
565 dnl *** shl_load() in libdld (HP-UX)
566 if test -z "$DYNAMIC_MODULES"; then
567 AC_MSG_CHECKING(how to export all symbols)
568 SAVED_LDFLAGS=$LDFLAGS
570 LDFLAGS="$LDFLAGS -Wl,-E"
571 AC_TRY_LINK(,[ return 0; ],
572 [ MODULE_LDFLAGS="-Wl,-E" ],[
573 LDFLAGS="$SAVED_LDFLAGS -bexpall"
574 AC_TRY_LINK(,[ return 0; ],
575 MODULE_LDFLAGS="-bexpall",
580 LDFLAGS=$SAVED_LDFLAGS
581 AC_MSG_RESULT($MODULE_LDFLAGS)
583 AC_CHECK_LIB(dld, shl_load,
585 DYNAMIC_MODULES=DYNAMIC_MODULES_DLD
589 dnl *** additional checks for DYNAMIC_MODULES_DL
590 if test "$DYNAMIC_MODULES" = "DYNAMIC_MODULES_DL"; then
592 dnl *** check whether we need preceeding underscores
593 AC_MSG_CHECKING(for preceeding underscore in symbols)
594 AC_CACHE_VAL(rlm_cv_uscore,[
597 int rlm_underscore_test (void) { return 42; }
599 void *f1 = (void*)0, *f2 = (void*)0, *handle;
600 handle = dlopen ((void*)0, 0);
602 f1 = dlsym (handle, "rlm_underscore_test");
603 f2 = dlsym (handle, "_rlm_underscore_test");
604 } return (!f2 || f1);
610 rm -f plugin.c plugin.o plugin.lo
612 AC_MSG_RESULT($rlm_cv_uscore)
613 if test "x$rlm_cv_uscore" = "xyes"; then
614 AC_DEFINE(MODULE_NEED_USCORE)
617 LDFLAGS="$LDFLAGS_orig"
618 dnl *** check for having dlerror()
619 AC_CHECK_FUNC(dlerror,
620 MODULE_HAVE_DLERROR=1,
621 MODULE_HAVE_DLERROR=0)
623 dnl *** done, have e got an implementation?
624 if test -z "$DYNAMIC_MODULES"; then
628 AC_SUBST(DYNAMIC_MODULES)
629 AC_DEFINE(HAVE_DLOPEN)
630 AC_SUBST(MODULE_LIBS)
631 AC_SUBST(MODULE_CFLAGS)
632 AC_SUBST(MODULE_LDFLAGS)
633 AC_SUBST(MODULE_HAVE_DLERROR)
635 dnl #############################################################
637 dnl # 8. Checks for system services
639 dnl #############################################################
642 dnl # Figure out where libtool is located,
644 LIBTOOL="`pwd`/libtool"
647 dnl #############################################################
649 dnl # And finally, output the results.
651 dnl #############################################################
654 dnl # Substitute whatever libraries we found to be necessary
660 ./src/include/build-radpaths-h \
661 ./src/main/checkrad.pl \
664 ./scripts/rc.radiusd \
668 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
669 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
670 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])