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 #############################################################
24 export CFLAGS LIBS LDFLAGS CPPFLAGS
26 AC_INIT([freeradius],[$]Id[$],[http://bugs.freeradius.org],,[http://www.freeradius.org])
27 AC_CONFIG_SRCDIR([src/main/radiusd.c])
28 AC_CONFIG_HEADER([src/include/autoconf.h])
29 m4_include([m4/ax_cc.m4])
31 dnl #############################################################
33 dnl # Custom hackery to discover version at configure time
35 dnl #############################################################
37 RADIUSD_MAJOR_VERSION=`cat VERSION | sed 's/\..*//'`
38 RADIUSD_MINOR_VERSION=`cat VERSION | sed 's/^[[^\.]]*\.//' | sed 's/\..*$//'`
39 RADIUSD_INCRM_VERSION=`cat VERSION | sed 's/^.*\..*\.//' | sed 's/[[\.-]].*$//'`
41 RADIUSD_VERSION=`echo | awk -v major="$RADIUSD_MAJOR_VERSION" \
42 -v minor="$RADIUSD_MINOR_VERSION" \
43 -v incrm="$RADIUSD_INCRM_VERSION" \
44 '{ printf "%02i%02i%02i", major, minor, incrm }'`
47 dnl # Still useful for custom builds
49 RADIUSD_VERSION_STRING=`cat VERSION`
52 dnl # Add definitions to Make.inc as it's used by various build targets
54 AC_SUBST([RADIUSD_VERSION_STRING])
57 dnl # Add definitions to autoconf.h, so that the headers that we install
58 dnl # contain the version number of the server.
60 AC_DEFINE_UNQUOTED([RADIUSD_VERSION], [${RADIUSD_VERSION}], [Version integer in format <ma><ma><mi><mi><in><in>])
61 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_STRING], ["${RADIUSD_VERSION_STRING}"], [Raw version string from VERSION file])
63 dnl #############################################################
65 dnl # Override some of the default autoconf variables such as
66 dnl # CFLAGS if were building in developer mode
68 dnl #############################################################
71 dnl # Enable developer features like debugging symbols.
72 dnl # These checks must be done before expanding the AC_PROG_CC
73 dnl # and AC_PROG_CXX macros.
75 AC_ARG_ENABLE(developer,
76 [ --enable-developer enables features of interest to developers.],
77 [ case "$enableval" in
87 dnl # Turn on the developer flag when taken from a git checkout (not a release)
89 if test -d $srcdir/.git; then
90 if test "x$developer" != "xno"; then
91 AC_MSG_NOTICE([found .git directory, enabling developer build implicitly, disable with --disable-developer])
97 dnl # Autoconf sets -O2 and -g by default, but this is a PITA for debugging
98 dnl # so we remove the defaults if were building in developer mode, and set
99 dnl # -g3 so nice things like macro values are included. Other arguments are
100 dnl # added later when we know what compiler were using.
102 if test "x$developer" = "xyes"; then
106 dnl #############################################################
108 dnl # 0. Checks for compiler, libtool, and command line options.
110 dnl #############################################################
113 dnl # Get system information
118 dnl # As of OSX 10.9 (Mavericks), /usr is no longer populated with the
119 dnl # standard set of headers and libraries, instead were meant to use
120 dnl # one of the SDKs which contains system headers and libraries for
121 dnl # different versions of OSX and iOS.
126 dnl # The version of GCC apple ships with Mavericks works out of the
127 dnl # box, and presumably selects the highest version SDK for OSX.
129 AC_MSG_CHECKING([if cc is apple llvm])
130 if ! $CC --version 2>&1 | grep -I 'Apple LLVM' > /dev/null; then
132 AC_CHECK_PROG(SW_VERS, sw_vers, yes, no)
133 AC_CHECK_PROG(XCODEBUILD, xcodebuild, yes, no)
135 if test "x$SW_VERS" = "xyes" && test "x$XCODEBUILD" = "xyes"; then
136 AC_MSG_NOTICE([determining OSX SDK path])
137 osx_sdk_path=$(xcodebuild -version -sdk macosx$(sw_vers -productVersion | egrep -o '^[[0-9]]+\.[[0-9]]+') Path)
138 AC_MSG_RESULT([$osx_sdk_path])
141 dnl # We need to export these, else the child configure scripts all fail
142 dnl # their compiler checks.
144 export CFLAGS="$CFLAGS --sysroot=$osx_sdk_path"
145 export CPPFLAGS="$CPPFLAGS --sysroot=$osx_sdk_path"
146 export LDFLAGS="$LDFLAGS -L$osx_sdk_path/usr/lib/"
147 DARWIN_CFLAGS="--sysroot=$osx_sdk_path"
148 AC_SUBST(DARWIN_CFLAGS)
157 dnl # Check for GNU cc
163 dnl # check for AIX, to allow us to use some BSD functions
164 dnl # must be before macros that call the compiler.
168 AC_PROG_GCC_TRADITIONAL
173 dnl # Definitive check for whether the compiler is clang
176 if test "x$ax_cv_cc_clang" = "xyes"; then
177 AC_SUBST(clang_path, "$CC")
179 AC_SUBST(clang_path, "")
184 dnl # Set Default CFLAGS for GCC compatible compilers
186 if test "x$GCC" = "xyes"; then
187 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
191 dnl # -Qunused-arguments means the compiler won't complain about unsupported arguments
193 AX_CC_QUNUSED_ARGUMENTS_FLAG
194 if test "x$ax_cv_cc_qunused_arguments_flag" = "xyes"; then
195 CFLAGS="$CFLAGS -Qunused-arguments"
196 LDFLAGS="$LDFLAGS -Qunused-arguments"
200 dnl # Compile in large (2G+) file support.
205 dnl # check for system bytesex
206 dnl # AC_DEFINES WORDS_BIGENDIAN
209 [AC_DEFINE(BIG_ENDIAN, 1, [Define if your processor stores words with the most significant byte first])],
210 [AC_DEFINE(LITTLE_ENDIAN, 1, [Define if your processor stores words with the least significant byte first])]
216 AC_CHECK_PROG(GMAKE, gmake, yes, no)
217 if test $GMAKE = no; then
218 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
220 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
222 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
223 if test -z "$makever"; then
224 AC_MSG_ERROR([GNU Make is not installed. Please download and install it from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.])
228 dnl # autoconf explicitly sets MAKEFLAGS and MFLAGS to '' even though we
229 dnl # didn't tell it to, so we have to use FR_MAKEFLAGS.
231 dnl # determine the number of cores available and set the number of build
232 dnl # processes appropriately.
236 dnl # Temporarily disabled because test and installation targets do not
237 dnl # have dependencies set up correctly for multiple build processes.
238 dnl if test "x$ax_cv_system_cores" != "x"; then
239 dnl : ${FR_MAKEFLAGS=-j$ax_cv_system_cores}
241 AC_SUBST(FR_MAKEFLAGS)
244 dnl # See if we have Git.
246 AC_CHECK_PROG(GIT, git, yes, no)
248 dnl Put this in later, when all distributed modules use autoconf.
249 dnl AC_ARG_WITH(disablemodulefoo,
250 dnl [ --without-rlm_foo Disables module compilation. Module list:]
251 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
252 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
253 dnl awk '{print " "$0}']))
255 AC_ARG_ENABLE(strict-dependencies,
256 [ --enable-strict-dependencies fail configure on lack of module dependancy.])
258 AC_ARG_ENABLE(werror,
259 [ --enable-werror causes the build to fail if any warnings are generated.],
260 [ case "$enableval" in
270 dnl # extra argument: --with-docdir
272 docdir='${datadir}/doc/freeradius'
273 AC_MSG_CHECKING([docdir])
275 [ --with-docdir=DIR directory for documentation [DATADIR/doc/freeradius] ],
282 [[\\/$]]* | ?:[[\\/]]* )
286 AC_MSG_ERROR([expected an absolute directory name for --with-docdir: $withval])
291 AC_MSG_RESULT($docdir)
292 if test "x$docdir" = xno; then
293 AC_MSG_WARN([Documentation files will NOT be installed.])
297 dnl # extra argument: --with-logdir
299 logdir='${localstatedir}/log/radius'
300 AC_MSG_CHECKING(logdir)
302 [ --with-logdir=DIR directory for logfiles [LOCALSTATEDIR/log/radius] ],
305 AC_MSG_ERROR([Need logdir])
309 [[\\/$]]* | ?:[[\\/]]* )
313 AC_MSG_ERROR([expected an absolute directory name for --with-logdir: $withval])
318 AC_MSG_RESULT($logdir)
321 dnl # extra argument: --with-radacctdir
323 radacctdir='${logdir}/radacct'
324 AC_MSG_CHECKING(radacctdir)
325 AC_ARG_WITH(radacctdir,
326 [ --with-radacctdir=DIR directory for detail files [LOGDIR/radacct] ],
329 AC_MSG_ERROR([Need radacctdir])
333 [[\\/$]]* | ?:[[\\/]]* )
334 radacctdir="$withval"
337 AC_MSG_ERROR([expected an absolute directory name for --with-radacctdir: $withval])
342 AC_MSG_RESULT($radacctdir)
345 dnl # extra argument: --with-raddbdir
347 raddbdir='${sysconfdir}/raddb'
348 AC_MSG_CHECKING(raddbdir)
349 AC_ARG_WITH(raddbdir,
350 [ --with-raddbdir=DIR directory for config files [SYSCONFDIR/raddb] ],
353 AC_MSG_ERROR([Need raddbdir])
357 [[\\/$]]* | ?:[[\\/]]* )
361 AC_MSG_ERROR([expected an absolute directory name for --with-raddbdir: $withval])
366 AC_MSG_RESULT($raddbdir)
369 dnl # extra argument: --with-dictdir
371 dictdir='${datarootdir}/freeradius'
372 AC_MSG_CHECKING(dictdir)
374 [ --with-dictdir=DIR directory for dictionary files [DATAROOTDIR/freeradius] ],
377 AC_MSG_ERROR([Need dictdir])
381 [[\\/$]]* | ?:[[\\/]]* )
385 AC_MSG_ERROR([expected an absolute directory name for --with-dictdir: $withval])
390 AC_MSG_RESULT($dictdir)
392 modconfdir='${raddbdir}/mods-config'
396 dnl # extra argument: --with-ascend-binary
398 WITH_ASCEND_BINARY=yes
399 AC_ARG_WITH(ascend-binary,
400 [ --with-ascend-binary include support for Ascend binary filter attributes (default=yes)],
405 WITH_ASCEND_BINARY=no
408 if test "x$WITH_ASCEND_BINARY" = "xyes"; then
409 AC_DEFINE(WITH_ASCEND_BINARY, [1], [include support for Ascend binary filter attributes])
413 dnl # extra argument: --with-threads
417 [ --with-threads use threads, if available. (default=yes) ],
427 dnl # extra argument: --with-tcp
431 [ --with-tcp compile in TCP support. (default=yes)],
439 if test "x$WITH_TCP" = "xyes"; then
440 AC_DEFINE(WITH_TCP, [1], [define if you want TCP support (For RADSec et al)])
444 dnl # extra argument: --with-vmps
448 [ --with-vmps compile in VMPS support. (default=yes)],
456 if test "x$WITH_VMPS" = "xyes"; then
457 AC_DEFINE(WITH_VMPS, [1], [define if you want VMPS support])
461 dnl # extra argument: --with-dhcp
465 [ --with-dhcp compile in DHCP support. (default=yes)],
473 if test "x$WITH_DHCP" = "xyes"; then
474 AC_DEFINE(WITH_DHCP, [1], [define if you want DHCP support])
478 dnl # Allow the user to specify a list of modules to be linked
479 dnl # statically to the server.
482 AC_ARG_WITH(static_modules,
483 [ --with-static-modules=QUOTED-MODULE-LIST],[
484 for i in $withval; do
485 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
490 AC_ARG_WITH(shared-libs,
491 [ --with-shared-libs build dynamic libraries and link against them. (default=yes)],
502 [ --with-modules=QUOTED-MODULE-LIST],[
503 for i in $withval; do
504 MODULES="$MODULES $i"
509 dnl # extra argument: --with-experimental-modules
512 AC_ARG_WITH(experimental-modules,
513 [ --with-experimental-modules use experimental and unstable modules. (default=no, unless --enable-developer=yes) ],
526 dnl # extra argument: --with-udpfromto
529 AC_ARG_WITH(udpfromto,
530 [ --with-udpfromto compile in UDPFROMTO support. (default=yes)],
540 if test "x$WITH_UDPFROMTO" = "xyes"; then
541 AC_DEFINE(WITH_UDPFROMTO, [], [define if you want udpfromto])
545 dnl # extra argument: --with-openssl
549 [ --with-openssl use OpenSSL. (default=yes)],
561 dnl # extra argument: --with-openssl-includes=dir
564 AC_ARG_WITH(openssl-includes,
565 [ --with-openssl-includes=DIR directory to look for OpenSSL include files in],
567 *) OPENSSL_INCLUDE_DIR="$withval"
573 dnl # extra argument: --with-openssl-libraries=dir
576 AC_ARG_WITH(openssl-libraries,
577 [ --with-openssl-libraries=DIR directory to look for OpenSSL library files in],
579 *) OPENSSL_LIB_DIR="$withval"
585 dnl # These next two arguments don't actually do anything. They're
586 dnl # place holders so that the top-level configure script can tell
587 dnl # the user how to configure lower-level modules
591 dnl # extra argument: --with-rlm-FOO-lib-dir
593 AC_ARG_WITH(rlm-FOO-lib-dir,
594 [ --with-rlm-FOO-lib-dir=DIR directory to look for library files used by module FOO in],
602 dnl # extra argument: --with-rlm-FOO-include-dir
604 AC_ARG_WITH(rlm-FOO-include-dir,
605 [ --with-rlm-FOO-include-dir=DIR directory to look for include files used by module FOO in],
612 dnl #############################################################
614 dnl # 1. Checks for programs
616 dnl #############################################################
619 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
620 if test "x$ac_cv_path_PERL" = "x"; then
621 AC_MSG_WARN([perl not found - Simultaneous-Use and checkrad may not work])
623 AC_PATH_PROG(SNMPGET, snmpget)
624 if test "x$ac_cv_path_SNMPGET" = "x"; then
625 AC_MSG_WARN([snmpget not found - Simultaneous-Use and checkrad may not work])
628 AC_PATH_PROG(SNMPWALK, snmpwalk)
629 if test "x$ac_cv_path_SNMPWALK" = "x"; then
630 AC_MSG_WARN([snmpwalk not found - Simultaneous-Use and checkrad may not work])
633 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
636 dnl # FIXME This is truly gross.
638 missing_dir=`cd $ac_aux_dir && pwd`
639 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
640 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
641 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
643 AC_PATH_PROG(LOCATE,locate)
644 AC_PATH_PROG(DIRNAME,dirname)
645 AC_PATH_PROG(GREP,grep)
647 dnl #############################################################
649 dnl # 2. Checks for libraries
651 dnl #############################################################
654 dnl # If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
657 if test "x$WITH_THREADS" = "xyes"; then
658 if test $ac_cv_prog_suncc = "yes"; then
662 AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
665 dnl # pthread stuff is usually in -lpthread
666 dnl # or in -lc_r, on *BSD
668 dnl # On Some systems, we need extra pre-processor flags, to get them to
669 dnl # to do the threading properly.
671 AC_CHECK_LIB(pthread, pthread_create,
673 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
674 LIBS="-lpthread $LIBS"
677 AC_CHECK_LIB(c_r, pthread_create,
678 [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
679 [ WITH_THREADS="no" ]
686 dnl # If we have NO pthread libraries, remove any knowledge of threads.
688 if test "x$WITH_THREADS" != "xyes"; then
690 ac_cv_header_pthread_h="no"
694 dnl # We need sem_init() and friends, as they're the friendliest
695 dnl # semaphore functions for threading.
697 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
698 dnl # Some systems have them in -lsem
699 dnl # Solaris has them in -lposix4
700 dnl # NetBSD has them in -lsemaphore
703 AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt semaphore,
705 [AC_MSG_ERROR([[-lsem not found. You may want to download it from ftp://ftp.to.gd-es.com/pub/BSDI/libsem.tar.bz2 or ftp://ftp.freeradius.org/pub/radius/contrib/libsem.tar.gz]])]
709 if test "x$WITH_THREADS" = "xyes"; then
710 AC_DEFINE(WITH_THREADS, [1], [define if you want thread support])
714 dnl # Check if we need -lsocket
716 AC_CHECK_LIB(dl, dlopen)
719 dnl # Check if we need -lsocket
721 AC_CHECK_LIB(socket, getsockname)
724 dnl # Check for -lresolv
725 dnl # This library may be needed later.
727 AC_CHECK_LIB(resolv, inet_aton)
730 dnl # Check if we need -lnsl. Usually if we want to
731 dnl # link against -lsocket we need to include -lnsl as well.
733 AC_CHECK_LIB(nsl, inet_ntoa)
734 AC_CHECK_LIB(ws2_32, htonl)
737 dnl # Check the pcap library for the RADIUS sniffer.
739 smart_try_dir="$pcap_lib_dir"
740 FR_SMART_CHECK_LIB(pcap, pcap_open_live)
741 if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes"; then
742 AC_MSG_WARN([pcap library not found. Use --with-pcap-lib-dir=<path>.])
743 AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer and ARP listener.])
745 PCAP_LIBS="${smart_lib}"
747 AC_DEFINE(HAVE_LIBPCAP, 1,
748 [Define to 1 if you have the `pcap' library (-lpcap).]
754 dnl #############################################################
756 dnl # 3. Checks for header files
758 dnl #############################################################
761 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
762 dnl # getopt will be #included, but won't link. <sigh>
767 CFLAGS="$CFLAGS -D_ALL_SOURCE"
770 CFLAGS="$CFLAGS -DDARWIN"
771 LIBS="-framework DirectoryService $LIBS"
824 dnl # FreeBSD requires sys/socket.h before net/if.h
826 AC_CHECK_HEADERS(net/if.h, [], [],
828 #ifdef HAVE_SYS_SOCKET_H
829 # include <sys/socket.h>
834 dnl # other checks which require headers
836 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
838 AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
841 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
843 AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
847 dnl # Were we told to use OpenSSL, if we were and we find an error, call AC_MSG_FAILURE and exit
849 if test "x$WITH_OPENSSL" = xyes; then
851 old_LDFLAGS="$LDFLAGS"
853 OPENSSL_INCLUDE="-DNO_OPENSSL"
855 if test "x$OPENSSL_LIB_DIR" != "x"; then
856 LDFLAGS="-L$OPENSSL_LIB_DIR $LDFLAGS"
860 dnl # Check we can link to libssl
862 AC_CHECK_LIB(crypto, DH_new,
864 LIBS="-lcrypto $LIBS"
865 AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
866 AC_CHECK_LIB(ssl, SSL_new,
868 AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl).])
869 if test "x$OPENSSL_LIB_DIR" != "x"; then
870 OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
872 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
875 AC_MSG_FAILURE([failed linking to libssl])
883 dnl # Check we can find required headers
885 old_CPPFLAGS=$CPPFLAGS
887 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
888 CPPFLAGS="-isystem $OPENSSL_INCLUDE_DIR $CPPFLAGS"
889 CFLAGS="-isystem $OPENSSL_INCLUDE_DIR $CFLAGS"
893 dnl # Stupid RedHat shit
895 CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
908 AC_MSG_FAILURE([failed locating OpenSSL headers])
912 AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
914 [#include <openssl/crypto.h>
915 #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
924 AC_MSG_FAILURE([OpenSSL version too old])
928 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
929 OPENSSL_INCLUDE="-isystem $OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
931 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
935 dnl # Now check that the header versions match the library
937 AC_MSG_CHECKING([OpenSSL library and header version consistency])
942 #include <openssl/opensslv.h>
943 #include <openssl/crypto.h>
946 if (SSLeay() == OPENSSL_VERSION_NUMBER) {
949 printf("library: %lx header: %lx... ", (unsigned long) SSLeay(), (unsigned long) OPENSSL_VERSION_NUMBER);
959 AC_MSG_FAILURE([OpenSSL library version does not match header version])
963 if test "x$OPENSSL_LIBS" = x; then
965 LDFLAGS="$old_LDFLAGS"
967 if test "x$OPENSSL_INCLUDE" = x; then
968 CPPFLAGS=$old_CPPFLAGS
973 AC_SUBST(OPENSSL_INCLUDE)
974 AC_SUBST(OPENSSL_LIBS)
978 dnl # Check the pcap includes for the RADIUS sniffer.
980 if test "x$PCAP_LIBS" = x; then
981 AC_MSG_NOTICE([skipping test for pcap.h.])
983 smart_try_dir="$pcap_include_dir"
984 FR_SMART_CHECK_INCLUDE([pcap.h])
985 if test "x$ac_cv_header_pcap_h" != "xyes"; then
986 AC_MSG_WARN([pcap headers not found. Use --with-pcap-include-dir=<path>.])
987 AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer, and ARP listener.])
989 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
991 AC_CHECK_LIB(pcap, pcap_fopen_offline,
993 AC_DEFINE(HAVE_PCAP_FOPEN_OFFLINE, 1, [Define to 1 if you have the function pcap_fopen_offline.])
997 AC_CHECK_LIB(pcap, pcap_dump_fopen,
999 AC_DEFINE(HAVE_PCAP_DUMP_FOPEN, 1, [Define to 1 if you have the function pcap_dump_fopen.])
1006 dnl #############################################################
1008 dnl # 4. Checks for typedefs
1010 dnl #############################################################
1013 dnl # Ensure that these are defined
1021 dnl # Check for socklen_t
1023 FR_CHECK_TYPE_INCLUDE(
1025 #ifdef HAVE_SYS_TYPES_H
1026 # include <sys/types.h>
1029 #ifdef HAVE_SYS_SOCKET_H
1030 # include <sys/socket.h>
1033 socklen_t, int, [socklen_t is generally 'int' on systems which don't use it]
1037 dnl # Check for uint8_t
1039 FR_CHECK_TYPE_INCLUDE(
1041 #ifdef HAVE_INTTYPES_H
1042 # include <inttypes.h>
1045 #ifdef HAVE_STDINT_H
1046 # include <stdint.h>
1049 uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic]
1053 dnl # Check for uint16_t
1055 FR_CHECK_TYPE_INCLUDE(
1057 #ifdef HAVE_INTTYPES_H
1058 # include <inttypes.h>
1061 #ifdef HAVE_STDINT_H
1062 # include <stdint.h>
1065 uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic]
1069 dnl # Check for uint32_t
1071 FR_CHECK_TYPE_INCLUDE(
1073 #ifdef HAVE_INTTYPES_H
1074 # include <inttypes.h>
1077 #ifdef HAVE_STDINT_H
1078 # include <stdint.h>
1081 uint32_t, unsigned int, [uint32_t should be the canonical 'network integer']
1085 dnl # Check for uint64_t
1087 FR_CHECK_TYPE_INCLUDE(
1089 #ifdef HAVE_INTTYPES_H
1090 # include <inttypes.h>
1093 #ifdef HAVE_STDINT_H
1094 # include <stdint.h>
1097 uint64_t, unsigned long long, [uint64_t is required for larger counters]
1100 FR_CHECK_TYPE_INCLUDE(
1102 #ifdef HAVE_SIGNAL_H
1103 # include <signal.h>
1106 sig_t, void(*sig_t)(int), [signal action callback function]
1110 dnl # Check for __uint128_t (compiler builtin)
1112 AC_CHECK_TYPE(__uint128_t, AC_DEFINE(HAVE___UINT128_T, 1, [compiler specific 128 bit unsigned integer]), [], [])
1115 dnl # Check for uint128_t (fictitious future data type)
1117 AC_CHECK_TYPE(uint128_t, AC_DEFINE(HAVE_UINT128_T, 1, [128 bit unsigned integer]), [],
1119 #ifdef HAVE_INTTYPES_H
1120 # include <inttypes.h>
1123 #ifdef HAVE_STDINT_H
1124 # include <stdint.h>
1129 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [],
1131 #ifdef HAVE_NETINET_IN_H
1132 # include <netinet/in.h>
1137 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [],
1139 #ifdef HAVE_NETINET_IN_H
1140 # include <netinet/in.h>
1143 #ifdef HAVE_SYS_SOCKET_H
1144 # include <sys/socket.h>
1148 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [],
1150 #ifdef HAVE_NETINET_IN_H
1151 # include <netinet/in.h>
1155 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [],
1157 #ifdef HAVE_SYS_TYPES_H
1158 # include <sys/types.h>
1161 #ifdef HAVE_SYS_SOCKET_H
1162 # include <sys/socket.h>
1171 dnl #############################################################
1173 dnl # 5. Checks for structures and functions
1175 dnl #############################################################
1214 dnl # Check if we have utmpx.h
1215 dnl # if so, check if struct utmpx has entry ut_xtime
1216 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
1218 if test "x$ac_cv_header_utmpx_h" = "xyes"; then
1219 FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
1220 if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then
1221 AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
1226 dnl # struct ip_pktinfo
1228 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
1229 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then
1230 AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
1234 dnl # struct in6_pktinfo
1236 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
1237 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then
1238 AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
1241 dnl #############################################################
1243 dnl # 6. Checks for compiler characteristics
1245 dnl #############################################################
1248 dnl # Ensure that these are defined
1253 dnl # See if this is OS/2
1255 AC_MSG_CHECKING([type of OS])
1258 if test "$OS" = "OS/2"; then
1265 if test "x$developer" = "xyes"; then
1266 AC_MSG_NOTICE([Setting additional developer CFLAGS])
1269 dnl # Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1271 AX_CC_WDOCUMENTATION_FLAG
1272 if test "x$ax_cv_cc_wdocumentation_flag" = "xyes"; then
1273 devflags="-Wdocumentation"
1276 if test "x$GCC" = "xyes"; then
1277 devflags="$devflags -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -W -Wredundant-decls -Wundef -Wformat-y2k -Wno-format-extra-args -Wno-format-zero-length -Wno-cast-align -Wformat-nonliteral -Wformat-security -Wformat=2 -DWITH_VERIFY_PTR=1"
1281 AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1283 CFLAGS="$CFLAGS $devflags"
1285 dnl # Enable experimental modules (we want to know if code changes breaks one of them)
1287 if test "x$EXPERIMENTAL" != "xno"; then
1288 AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1293 CFLAGS="$CFLAGS -DNDEBUG"
1298 dnl # May of been set outside of this configure script
1300 AC_MSG_CHECKING([if building with -DNDEBUG])
1301 if echo "$CFLAGS" | grep '\-DNDEBUG' > /dev/null; then
1302 AC_MSG_RESULT([yes])
1303 AC_DEFINE([WITH_NDEBUG], [1], [define if the server was built with -DNDEBUG])
1311 dnl # append the current git hash onto the version string
1313 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1314 RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1315 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],[${RADIUSD_VERSION_COMMIT}],[Commit HEAD at time of configuring])
1320 dnl #############################################################
1322 dnl # 7. Checks for library functions
1324 dnl #############################################################
1326 dnl Check for talloc
1327 dnl extra argument: --with-talloc-include-dir=DIR
1329 AC_ARG_WITH(talloc-include-dir,
1330 [ --with-talloc-include-dir=DIR directory to look for talloc include files in],
1333 AC_MSG_ERROR([Need talloc-include-dir])
1338 talloc_include_dir="$withval"
1342 dnl Check for talloc
1343 dnl extra argument: --with-talloc-lib-dir=DIR
1345 AC_ARG_WITH(talloc-lib-dir,
1346 [ --with-talloc-lib-dir=DIR directory to look for talloc library files in],
1349 AC_MSG_ERROR([Need talloc-lib-dir])
1354 talloc_lib_dir="$withval"
1359 dnl extra argument: --with-pcap-include-dir=DIR
1361 AC_ARG_WITH(pcap-include-dir,
1362 [ --with-pcap-include-dir=DIR directory to look for pcap include files in],
1365 AC_MSG_ERROR([Need pcap-include-dir])
1370 pcap_include_dir="$withval"
1375 dnl extra argument: --with-pcap-lib-dir=DIR
1377 AC_ARG_WITH(pcap-lib-dir,
1378 [ --with-pcap-lib-dir=DIR directory to look for pcap library files in],
1381 AC_MSG_ERROR([Need pcap-lib-dir])
1386 pcap_lib_dir="$withval"
1391 dnl # Check for talloc header files
1393 smart_try_dir="$talloc_include_dir"
1394 FR_SMART_CHECK_INCLUDE([talloc.h])
1395 if test "x$ac_cv_header_talloc_h" != "xyes"; then
1396 AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
1397 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1400 smart_try_dir="$talloc_lib_dir"
1401 FR_SMART_CHECK_LIB(talloc, _talloc)
1402 if test "x$ac_cv_lib_talloc__talloc" != "xyes"; then
1403 AC_MSG_WARN([talloc library not found. Use --with-talloc-lib-dir=<path>.])
1404 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1408 dnl # Check for libcrypt
1409 dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1411 AC_CHECK_LIB(crypt, crypt,
1415 if test "$CRYPTLIB" != ""; then
1416 AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1418 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1421 dnl Check for libcipher
1422 AC_CHECK_LIB(cipher, setkey,
1423 CRYPTLIB="${CRYPTLIB} -lcipher"
1428 dnl # Check for libexecinfo support, on some systems this is built into libc
1429 dnl # on others it's a separate library.
1431 dnl extra argument: --with-execinfo-lib-dir
1433 AC_ARG_WITH(execinfo-lib-dir,
1434 [ --with-execinfo-lib-dir=DIR directory to look for execinfo library files in],
1435 [ case "$withval" in
1437 AC_MSG_ERROR([Need execinfo-lib-dir])
1442 execinfo_lib_dir="$withval"
1447 dnl extra argument: --with-execinfo-include-dir
1448 execinfo_include_dir=
1449 AC_ARG_WITH(execinfo-include-dir,
1450 [ --with-execinfo-include-dir=DIR directory to look for execinfo include files in],
1451 [ case "$withval" in
1453 AC_MSG_ERROR(Need execinfo-include-dir)
1458 execinfo_include_dir="$withval"
1464 dnl # Look for execinfo.h and symbols
1466 smart_try_dir=$execinfo_include_dir
1467 FR_SMART_CHECK_INCLUDE(execinfo.h)
1468 if test "x$ac_cv_header_execinfo_h" = "xyes"; then
1469 smart_try_dir=$execinfo_lib_dir
1470 FR_SMART_CHECK_LIB(execinfo, backtrace_symbols)
1471 if test "x$ac_cv_lib_execinfo_backtrace_symbols" != "xyes"; then
1472 dnl # Might be provided as part of libc
1473 AC_MSG_CHECKING([if execinfo provided as part of libc])
1476 #include <execinfo.h>
1480 backtrace_symbols(&sym, sizeof(sym)) ],
1483 ac_cv_lib_execinfo_backtrace_symbols=yes
1487 ac_cv_lib_execinfo_backtrace_symbols=no
1492 if test "x$ac_cv_lib_execinfo_backtrace_symbols" = "xyes"; then
1493 AC_DEFINE(HAVE_EXECINFO, [1], [define this if we have <execinfo.h> and symbols])
1498 dnl # Check for regular expression support, if were using PCRE it MUST be included
1499 dnl # before all others, else we seem to still pickup the posix symbols for regcomp
1500 dnl # and regexec, which results in crashes as soon as we call any posix regex
1503 dnl extra argument: --with-pcre-lib-dir
1505 AC_ARG_WITH(pcre-lib-dir,
1506 [ --with-pcre-lib-dir=DIR directory to look for pcre library files in],
1507 [ case "$withval" in
1509 AC_MSG_ERROR([Need pcre-lib-dir])
1514 pcre_lib_dir="$withval"
1519 dnl extra argument: --with-pcre-include--dir
1521 AC_ARG_WITH(pcre-include-dir,
1522 [ --with-pcre-include-dir=DIR directory to look for PCRE include files in],
1523 [ case "$withval" in
1525 AC_MSG_ERROR(Need pcre-include-dir)
1530 pcre_include_dir="$withval"
1540 dnl # First look for PCRE
1542 smart_try_dir=$pcre_include_dir
1543 FR_SMART_CHECK_INCLUDE(pcreposix.h)
1544 if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
1545 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1546 AC_DEFINE(HAVE_PCREPOSIX_H, [1], [define this if we have the <pcreposix.h> header file])
1550 LIBS="-lpcre -lpcreposix $LIBS"
1553 dnl # Then fallback to POSIX regular expressions
1557 FR_SMART_CHECK_INCLUDE(regex.h)
1558 if test "x$ac_cv_header_regex_h" = "xyes"; then
1559 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1568 [AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)]) REGEX_EXTENDED=yes]
1571 dnl # Fixme, this is needed for mingw builds, but not available on some Linux systems
1572 dnl # despite the presence of regex.h
1574 dnl # LIBS="$LIBS -lregex"
1579 AC_SUBST(REGEX_PCRE)
1580 AC_SUBST(REGEX_EXTENDED)
1583 dnl # Check the style of gethostbyaddr, in order of preference
1584 dnl # GNU (_r eight args)
1586 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1589 dnl # SYSV (_r six args)
1591 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1594 dnl # BSD (three args, may not be thread safe)
1596 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1599 dnl # Tru64 has BSD version, but it is thread safe
1600 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1601 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1603 gethostbyaddrrstyle=""
1604 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1608 dnl # With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1609 dnl # Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1610 dnl # override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1611 dnl # style support.
1613 AC_CHECK_DECLS([gethostbyaddr_r], [],
1615 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1616 [style of gethostbyaddr_r functions ])
1617 gethostbyaddrrstyle=BSD
1618 AC_MSG_WARN([FreeBSD overridden to BSD-style])
1628 if test "x$gethostbyaddrrstyle" = "x"; then
1634 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ],
1636 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1637 gethostbyaddrrstyle=GNU
1642 if test "x$gethostbyaddrrstyle" = "x"; then
1648 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] ,
1650 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1651 gethostbyaddrrstyle=SYSV
1657 if test "x$gethostbyaddrrstyle" = "x"; then
1663 [ gethostbyaddr(NULL, 0, 0) ],
1665 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1666 gethostbyaddrrstyle=BSD
1671 if test "x$gethostbyaddrrstyle" = "x"; then
1672 AC_MSG_RESULT([none! It must not exist, here.])
1674 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1677 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1678 AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1682 dnl # Check the style of gethostbyname, in order of preference
1683 dnl # GNU (_r seven args)
1684 dnl # SYSV (_r five args)
1685 dnl # BSD (two args, may not be thread safe)
1686 dnl # Tru64 has BSD version, but it _is_ thread safe
1687 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1688 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1690 gethostbynamerstyle=""
1691 AC_MSG_CHECKING([gethostbyname_r() syntax])
1697 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ],
1699 AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1700 gethostbynamerstyle=GNU
1704 if test "x$gethostbynamerstyle" = "x"; then
1710 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] ,
1712 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1713 gethostbynamerstyle=SYSV
1718 if test "x$gethostbynamerstyle" = "x"; then
1724 [ gethostbyname(NULL) ],
1726 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1727 gethostbynamerstyle=BSD
1732 if test "x$gethostbynamerstyle" = "x"; then
1733 AC_MSG_RESULT([none! It must not exist, here.])
1735 AC_MSG_RESULT([${gethostbynamerstyle}-style])
1738 if test "x$gethostbynamerstyle" = "xBSD"; then
1739 AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1743 dnl # Check for non-posix solaris ctime_r (extra buflen int arg)
1745 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1746 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1748 AC_MSG_CHECKING([ctime_r() syntax])
1753 [ ctime_r(NULL, NULL, 0) ],
1755 AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1756 ctimerstyle="SOLARIS"
1760 if test "x$ctimerstyle" = "x"; then
1765 [ ctime_r(NULL, NULL) ],
1767 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1773 if test "x$ctimerstyle" = "x"; then
1774 AC_MSG_RESULT([none! It must not exist, here.])
1776 AC_MSG_RESULT([${ctimerstyle}-style])
1779 AC_SUBST(HOSTINFO, $host)
1781 dnl #############################################################
1783 dnl # 8. Checks for system services
1785 dnl #############################################################
1788 dnl # Figure out where libtool is located,
1792 AC_MSG_RESULT([top_builddir=$top_builddir])
1793 dnl # AC_SUBST(top_builddir)
1796 dnl # import libtool stuff
1798 dnl #############################################################
1800 dnl # Configure in any module directories.
1802 dnl #############################################################
1804 dnl ############################################################
1805 dnl # Remove any conflicting definitions if autoconf.h
1806 dnl # is being included by a module.
1807 dnl #############################################################
1808 AH_BOTTOM([#include <freeradius-devel/automask.h>])
1810 dnl ############################################################
1811 dnl # make modules by list
1812 dnl #############################################################
1813 if test "x$EXPERIMENTAL" = "xyes"; then
1814 for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
1815 MODULES="$MODULES $foo"
1819 dnl # make ONLY the stable modules
1821 for foo in `cat "${srcdir}"/src/modules/stable`; do
1822 MODULES="$MODULES $foo"
1826 dnl ############################################################
1827 dnl # Add autoconf subdirs, based on the module list we
1828 dnl # previously created.
1829 dnl #############################################################
1831 for bar in $MODULES; do
1832 if test -f "${srcdir}"/src/modules/$bar/configure; then
1833 mysubdirs="$mysubdirs src/modules/$bar"
1838 dnl # Don't change the variable name here. Autoconf goes bonkers
1841 AC_CONFIG_SUBDIRS($mysubdirs)
1844 dnl #############################################################
1846 dnl # Add -Werror last, so it doesn't interfere with autoconf's
1847 dnl # test programs.
1849 dnl #############################################################
1850 if test "x$werror" == "xyes"; then
1851 CFLAGS="-Werror $CFLAGS"
1854 dnl #############################################################
1856 dnl # And finally, output the results.
1858 dnl #############################################################
1859 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
1860 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
1861 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main && chmod +x checkrad radlast radtest)])
1862 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts && chmod +x rc.radiusd cron/radiusd.cron.daily cron/radiusd.cron.monthly cryptpasswd)])
1865 dnl # Substitute whatever libraries we found to be necessary
1868 AC_SUBST(INSTALLSTRIP)
1870 AC_SUBST(USE_SHARED_LIBS)
1871 USE_STATIC_LIBS="yes"
1872 AC_SUBST(USE_STATIC_LIBS)
1873 AC_SUBST(STATIC_MODULES)
1877 ./src/include/build-radpaths-h \
1878 ./src/main/radsniff.mk \
1879 ./src/main/checkrad \
1880 ./src/main/radlast \
1881 ./src/main/radtest \
1882 ./scripts/rc.radiusd \
1883 ./scripts/cron/radiusd.cron.daily \
1884 ./scripts/cron/radiusd.cron.monthly \
1885 ./scripts/cryptpasswd \
1886 ./raddb/radrelay.conf \
1887 ./raddb/radiusd.conf