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-dict-nocase
123 AC_ARG_WITH(dict-nocase,
124 [ --with-dict-nocase Make dictionary case-independant (default=yes)],
132 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
133 AC_DEFINE(WITH_DICT_NOCASE)
136 dnl extra argument: --with-attrib-nmc
138 AC_ARG_WITH(attrib-nmc,
139 [ --with-attrib-nmc Include USR-style vendor specific attributes (default=yes)],
147 if test "X$ATTRIB_NMC" = "Xyes"; then
148 AC_DEFINE(ATTRIB_NMC)
151 dnl extra argument: --with-ascend-binary
153 AC_ARG_WITH(ascend-binary,
154 [ --with-ascend-binary Include support for Ascend binary filter attributes (default=yes)],
162 if test "X$ASCEND_BINARY" = "Xyes"; then
163 AC_DEFINE(ASCEND_BINARY)
166 dnl extra argument: --with-threads
169 [ --with-threads Use threads, if available. (default=yes) ],
178 dnl extra argument: --with-thread-pool
180 AC_ARG_WITH(thread-pool,
181 [ --with-thread-pool Use a pool of threads for high-load systems. (default=no) ],
184 WITH_THREAD_POOL=$withval
188 dnl extra argument: --with-snmp
190 [ --with-snmp Compile in SNMP support. (default=no)],
196 SNMPLIB="-lsnmp -lcrypto"
197 SNMPINC=-I/usr/include/ucd-snmp
205 AC_ARG_ENABLE(ltdl-install,
206 [ --disable-ltdl-install do not install libltdl])
207 if test x"${enable_ltdl_install+set}" != xset; then
208 enable_ltdl_install=yes
209 ac_configure_args="$ac_configure_args --enable-ltdl-install"
211 AC_CONFIG_SUBDIRS(libltdl)
213 dnl See what include-style is used by the make program.
214 dnl AC_MSG_CHECKING(include style for make)
215 dnl echo "include /dev/null" > testmake.$$
216 dnl echo "all:" >> testmake.$$
217 dnl make -f testmake.$$ >/dev/null 2>&1
226 dnl rm -f testmake.$$
227 dnl AC_MSG_RESULT(" $INCLUDE")
228 dnl AC_SUBST(INCLUDE)
231 dnl #############################################################
233 dnl # 1. Checks for programs
235 dnl #############################################################
237 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
238 if test ! -x $ac_cv_path_PERL; then
239 AC_MSG_ERROR(perl not found - fatal)
241 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
242 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
243 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
245 dnl FIXME This is truly gross.
246 missing_dir=`cd $ac_aux_dir && pwd`
247 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
248 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
249 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
252 dnl # check for AIX, to allow us to use some BSD functions
253 dnl # must be before macros that call the compiler.
257 dnl #############################################################
259 dnl # 2. Checks for libraries
261 dnl #############################################################
263 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
265 if test "$WITH_THREADS" = "yes"; then
266 if test $ac_cv_prog_suncc = "yes"; then
270 AC_CHECK_HEADERS(pthread.h)
272 if test "X$ac_cv_header_pthread_h" = "X"; then
273 AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
277 dnl # pthread stuff is usually in -lpthread
279 AC_CHECK_LIB(pthread, pthread_create,
280 PTHREADLIB="-lpthread"
284 dnl # Except for *BSD, where it's in -lc_r,
285 dnl # and where we've got to add extra CFLAGS.
287 if test "X$PTHREADLIB" = "X"; then
289 CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
290 AC_CHECK_LIB(c_r, pthread_create,
296 dnl # If we have NO pthread libraries, remove any knowledge of threads.
298 if test "x$PTHREADLIB" = "x"; then
300 ac_cv_header_pthread_h="no"
302 LIBS="$LIBS $PTHREADLIB"
303 CFLAGS="$CFLAGS -D_REENTRANT"
308 dnl # Checks to ensure that the thread pool code can build.
310 if test "$WITH_THREAD_POOL" = "yes"; then
312 dnl # If using thread pools, check that threading is enabled
314 if test "$WITH_THREADS" != "yes"; then
315 AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
319 dnl # If using thread pools, check that we have thread libraries
321 if test "X$PTHREADLIB" = "X"; then
322 AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
326 dnl # Check for sem_init all by itself
328 AC_CHECK_FUNC(sem_init)
329 if test "X$ac_cv_func_sem_init" = "Xno"; then
332 dnl # If not found, sem_init is in -lposix4 on Solaris
334 AC_CHECK_LIB(posix4, sem_init)
336 if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
337 AC_MSG_WARN(You do not have posix semaphores. Disabling thread pools)
343 dnl # Finally, after all of the checks above, we see if
344 dnl # we can REALLY use the thread pools.
346 if test "$WITH_THREAD_POOL" = "yes"; then
347 AC_DEFINE(WITH_THREAD_POOL,1)
351 dnl Check if we need -lsocket
352 AC_CHECK_LIB(socket, getsockname)
354 dnl Check for -lresolv
355 dnl This library may be needed later.
356 AC_CHECK_LIB(resolv, inet_aton)
358 dnl Check if we need -lnsl. Usually if we want to
359 dnl link against -lsocket we need to include -lnsl as well.
360 AC_CHECK_LIB(nsl, inet_ntoa)
362 dnl #############################################################
364 dnl # 3. Checks for header files
366 dnl #############################################################
393 dnl #############################################################
395 dnl # 4. Checks for typedefs
397 dnl #############################################################
400 dnl # Ensure that these are defined
407 dnl Check for socklen_t
408 AC_CACHE_CHECK(for socklen_t,
411 AC_TRY_COMPILE([#include <sys/types.h>
412 #include <sys/socket.h>],
419 if test "$fr_cv_socklen_t" != "yes"; then
420 AC_DEFINE(socklen_t, int)
423 dnl Check for uint8_t
424 AC_CACHE_CHECK(for uint8_t,
428 #ifdef HAVE_INTTYPES_H
429 #include <inttypes.h>
441 if test "$fr_cv_uint8_t" != "yes"; then
442 AC_DEFINE(uint8_t, unsigned char)
445 dnl Check for uint32_t
446 AC_CACHE_CHECK(for uint32_t,
450 #ifdef HAVE_INTTYPES_H
451 #include <inttypes.h>
463 if test "$fr_cv_uint32_t" != "yes"; then
464 AC_DEFINE(uint32_t, unsigned int)
469 dnl # If we don't have uint32_t, then verify that sizeof(unsigned int)==4
470 dnl # If the integers are NOT 4 octets long, then the previous definition
471 dnl # won't work, and we won't produce correct RADIUS packets.
473 if test "x$UINT32_T_AS_INT" != "x"; then
474 AC_CHECK_SIZEOF(unsigned int, [4])
477 dnl #############################################################
479 dnl # 5. Checks for structures and functions
481 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
591 ./src/include/build-radpaths-h \
592 ./src/main/checkrad.pl \
595 ./scripts/rc.radiusd \
597 ./scripts/check-radiusd-config \
601 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
602 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
603 AC_OUTPUT_COMMANDS([(cd ./src/main && chmod +x checkrad.pl radlast radtest)])
604 AC_OUTPUT_COMMANDS([(cd ./scripts && chmod +x rc.radiusd radwatch check-radiusd-config)])