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"
825 dnl # FreeBSD requires sys/socket.h before net/if.h
827 AC_CHECK_HEADERS(net/if.h, [], [],
829 #ifdef HAVE_SYS_SOCKET_H
830 # include <sys/socket.h>
835 dnl # other checks which require headers
837 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
839 AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
842 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
844 AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
848 dnl # Were we told to use OpenSSL, if we were and we find an error, call AC_MSG_FAILURE and exit
850 if test "x$WITH_OPENSSL" = xyes; then
852 old_LDFLAGS="$LDFLAGS"
854 OPENSSL_INCLUDE="-DNO_OPENSSL"
856 if test "x$OPENSSL_LIB_DIR" != "x"; then
857 LDFLAGS="-L$OPENSSL_LIB_DIR $LDFLAGS"
861 dnl # Check we can link to libssl
863 AC_CHECK_LIB(crypto, DH_new,
865 LIBS="-lcrypto $LIBS"
866 AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
867 AC_CHECK_LIB(ssl, SSL_new,
869 AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl).])
870 if test "x$OPENSSL_LIB_DIR" != "x"; then
871 OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
873 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
876 AC_MSG_FAILURE([failed linking to libssl])
884 dnl # Check we can find required headers
886 old_CPPFLAGS=$CPPFLAGS
888 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
889 CPPFLAGS="-isystem $OPENSSL_INCLUDE_DIR $CPPFLAGS"
890 CFLAGS="-isystem $OPENSSL_INCLUDE_DIR $CFLAGS"
894 dnl # Stupid RedHat shit
896 CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
909 AC_MSG_FAILURE([failed locating OpenSSL headers])
913 AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
915 [#include <openssl/crypto.h>
916 #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
925 AC_MSG_FAILURE([OpenSSL version too old])
929 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
930 OPENSSL_INCLUDE="-isystem $OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
932 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
936 dnl # Now check that the header versions match the library
938 AC_MSG_CHECKING([OpenSSL library and header version consistency])
943 #include <openssl/opensslv.h>
944 #include <openssl/crypto.h>
947 if (SSLeay() == OPENSSL_VERSION_NUMBER) {
950 printf("library: %lx header: %lx... ", (unsigned long) SSLeay(), (unsigned long) OPENSSL_VERSION_NUMBER);
960 AC_MSG_FAILURE([OpenSSL library version does not match header version])
964 if test "x$OPENSSL_LIBS" = x; then
966 LDFLAGS="$old_LDFLAGS"
968 if test "x$OPENSSL_INCLUDE" = x; then
969 CPPFLAGS=$old_CPPFLAGS
974 AC_SUBST(OPENSSL_INCLUDE)
975 AC_SUBST(OPENSSL_LIBS)
979 dnl # Check the pcap includes for the RADIUS sniffer.
981 if test "x$PCAP_LIBS" = x; then
982 AC_MSG_NOTICE([skipping test for pcap.h.])
984 smart_try_dir="$pcap_include_dir"
985 FR_SMART_CHECK_INCLUDE([pcap.h])
986 if test "x$ac_cv_header_pcap_h" != "xyes"; then
987 AC_MSG_WARN([pcap headers not found. Use --with-pcap-include-dir=<path>.])
988 AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer, and ARP listener.])
990 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
992 AC_CHECK_LIB(pcap, pcap_fopen_offline,
994 AC_DEFINE(HAVE_PCAP_FOPEN_OFFLINE, 1, [Define to 1 if you have the function pcap_fopen_offline.])
998 AC_CHECK_LIB(pcap, pcap_dump_fopen,
1000 AC_DEFINE(HAVE_PCAP_DUMP_FOPEN, 1, [Define to 1 if you have the function pcap_dump_fopen.])
1007 dnl #############################################################
1009 dnl # 4. Checks for typedefs
1011 dnl #############################################################
1014 dnl # Ensure that these are defined
1022 dnl # Check for socklen_t
1024 FR_CHECK_TYPE_INCLUDE(
1026 #ifdef HAVE_SYS_TYPES_H
1027 # include <sys/types.h>
1030 #ifdef HAVE_SYS_SOCKET_H
1031 # include <sys/socket.h>
1034 socklen_t, int, [socklen_t is generally 'int' on systems which don't use it]
1038 dnl # Check for uint8_t
1040 FR_CHECK_TYPE_INCLUDE(
1042 #ifdef HAVE_INTTYPES_H
1043 # include <inttypes.h>
1046 #ifdef HAVE_STDINT_H
1047 # include <stdint.h>
1050 uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic]
1054 dnl # Check for uint16_t
1056 FR_CHECK_TYPE_INCLUDE(
1058 #ifdef HAVE_INTTYPES_H
1059 # include <inttypes.h>
1062 #ifdef HAVE_STDINT_H
1063 # include <stdint.h>
1066 uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic]
1070 dnl # Check for uint32_t
1072 FR_CHECK_TYPE_INCLUDE(
1074 #ifdef HAVE_INTTYPES_H
1075 # include <inttypes.h>
1078 #ifdef HAVE_STDINT_H
1079 # include <stdint.h>
1082 uint32_t, unsigned int, [uint32_t should be the canonical 'network integer']
1086 dnl # Check for uint64_t
1088 FR_CHECK_TYPE_INCLUDE(
1090 #ifdef HAVE_INTTYPES_H
1091 # include <inttypes.h>
1094 #ifdef HAVE_STDINT_H
1095 # include <stdint.h>
1098 uint64_t, unsigned long long, [uint64_t is required for larger counters]
1101 FR_CHECK_TYPE_INCLUDE(
1103 #ifdef HAVE_SIGNAL_H
1104 # include <signal.h>
1107 sig_t, void(*sig_t)(int), [signal action callback function]
1111 dnl # Check for __uint128_t (compiler builtin)
1113 AC_CHECK_TYPE(__uint128_t, AC_DEFINE(HAVE___UINT128_T, 1, [compiler specific 128 bit unsigned integer]), [], [])
1116 dnl # Check for uint128_t (fictitious future data type)
1118 AC_CHECK_TYPE(uint128_t, AC_DEFINE(HAVE_UINT128_T, 1, [128 bit unsigned integer]), [],
1120 #ifdef HAVE_INTTYPES_H
1121 # include <inttypes.h>
1124 #ifdef HAVE_STDINT_H
1125 # include <stdint.h>
1130 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [],
1132 #ifdef HAVE_NETINET_IN_H
1133 # include <netinet/in.h>
1138 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [],
1140 #ifdef HAVE_NETINET_IN_H
1141 # include <netinet/in.h>
1144 #ifdef HAVE_SYS_SOCKET_H
1145 # include <sys/socket.h>
1149 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [],
1151 #ifdef HAVE_NETINET_IN_H
1152 # include <netinet/in.h>
1156 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [],
1158 #ifdef HAVE_SYS_TYPES_H
1159 # include <sys/types.h>
1162 #ifdef HAVE_SYS_SOCKET_H
1163 # include <sys/socket.h>
1172 dnl #############################################################
1174 dnl # 5. Checks for structures and functions
1176 dnl #############################################################
1215 dnl # Check if we have utmpx.h
1216 dnl # if so, check if struct utmpx has entry ut_xtime
1217 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
1219 if test "x$ac_cv_header_utmpx_h" = "xyes"; then
1220 FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
1221 if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then
1222 AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
1227 dnl # struct ip_pktinfo
1229 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
1230 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then
1231 AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
1235 dnl # struct in6_pktinfo
1237 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
1238 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then
1239 AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
1242 dnl #############################################################
1244 dnl # 6. Checks for compiler characteristics
1246 dnl #############################################################
1249 dnl # Ensure that these are defined
1254 dnl # See if this is OS/2
1256 AC_MSG_CHECKING([type of OS])
1259 if test "$OS" = "OS/2"; then
1266 if test "x$developer" = "xyes"; then
1267 AC_MSG_NOTICE([Setting additional developer CFLAGS])
1270 dnl # Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1272 AX_CC_WDOCUMENTATION_FLAG
1273 if test "x$ax_cv_cc_wdocumentation_flag" = "xyes"; then
1274 devflags="-Wdocumentation"
1277 if test "x$GCC" = "xyes"; then
1278 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"
1282 AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1284 CFLAGS="$CFLAGS $devflags"
1286 dnl # Enable experimental modules (we want to know if code changes breaks one of them)
1288 if test "x$EXPERIMENTAL" != "xno"; then
1289 AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1294 CFLAGS="$CFLAGS -DNDEBUG"
1299 dnl # May of been set outside of this configure script
1301 AC_MSG_CHECKING([if building with -DNDEBUG])
1302 if echo "$CFLAGS" | grep '\-DNDEBUG' > /dev/null; then
1303 AC_MSG_RESULT([yes])
1304 AC_DEFINE([WITH_NDEBUG], [1], [define if the server was built with -DNDEBUG])
1312 dnl # append the current git hash onto the version string
1314 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1315 RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1316 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],[${RADIUSD_VERSION_COMMIT}],[Commit HEAD at time of configuring])
1321 dnl #############################################################
1323 dnl # 7. Checks for library functions
1325 dnl #############################################################
1327 dnl Check for talloc
1328 dnl extra argument: --with-talloc-include-dir=DIR
1330 AC_ARG_WITH(talloc-include-dir,
1331 [ --with-talloc-include-dir=DIR directory to look for talloc include files in],
1334 AC_MSG_ERROR([Need talloc-include-dir])
1339 talloc_include_dir="$withval"
1343 dnl Check for talloc
1344 dnl extra argument: --with-talloc-lib-dir=DIR
1346 AC_ARG_WITH(talloc-lib-dir,
1347 [ --with-talloc-lib-dir=DIR directory to look for talloc library files in],
1350 AC_MSG_ERROR([Need talloc-lib-dir])
1355 talloc_lib_dir="$withval"
1360 dnl extra argument: --with-pcap-include-dir=DIR
1362 AC_ARG_WITH(pcap-include-dir,
1363 [ --with-pcap-include-dir=DIR directory to look for pcap include files in],
1366 AC_MSG_ERROR([Need pcap-include-dir])
1371 pcap_include_dir="$withval"
1376 dnl extra argument: --with-pcap-lib-dir=DIR
1378 AC_ARG_WITH(pcap-lib-dir,
1379 [ --with-pcap-lib-dir=DIR directory to look for pcap library files in],
1382 AC_MSG_ERROR([Need pcap-lib-dir])
1387 pcap_lib_dir="$withval"
1392 dnl # Check for talloc header files
1394 smart_try_dir="$talloc_include_dir"
1395 FR_SMART_CHECK_INCLUDE([talloc.h])
1396 if test "x$ac_cv_header_talloc_h" != "xyes"; then
1397 AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
1398 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1401 smart_try_dir="$talloc_lib_dir"
1402 FR_SMART_CHECK_LIB(talloc, _talloc)
1403 if test "x$ac_cv_lib_talloc__talloc" != "xyes"; then
1404 AC_MSG_WARN([talloc library not found. Use --with-talloc-lib-dir=<path>.])
1405 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1409 dnl # Check for libcrypt
1410 dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1412 AC_CHECK_LIB(crypt, crypt,
1416 if test "$CRYPTLIB" != ""; then
1417 AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1419 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1422 dnl Check for libcipher
1423 AC_CHECK_LIB(cipher, setkey,
1424 CRYPTLIB="${CRYPTLIB} -lcipher"
1430 dnl # Check for regular expression support, if were using PCRE it MUST be included
1431 dnl # before all others, else we seem to still pickup the posix symbols for regcomp
1432 dnl # and regexec, which results in crashes as soon as we call any posix regex
1435 dnl extra argument: --with-pcre-lib-dir
1437 AC_ARG_WITH(rlm-pcre-lib-dir,
1438 [ --with-pcre-lib-dir=DIR directory to look for PCRE library files in],
1439 [ case "$withval" in
1441 AC_MSG_ERROR(Need rlm-pcre-lib-dir)
1446 pcre_lib_dir="$withval"
1451 dnl extra argument: --with-pcre-include--dir
1453 AC_ARG_WITH(rlm-pcre-include-dir,
1454 [ --with-pcre-include-dir=DIR directory to look for PCRE include files in],
1455 [ case "$withval" in
1457 AC_MSG_ERROR(Need rlm-pcre-include-dir)
1462 pcre_include_dir="$withval"
1472 dnl # First look for PCRE
1474 smart_try_dir=$pcre_include_dir
1475 FR_SMART_CHECK_INCLUDE(pcreposix.h)
1476 if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
1477 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1478 AC_DEFINE(HAVE_PCREPOSIX_H, [1], [define this if we have the <pcreposix.h> header file])
1482 LIBS="-lpcre -lpcreposix $LIBS"
1485 dnl # Then fallback to POSIX regular expressions
1489 FR_SMART_CHECK_INCLUDE(regex.h)
1490 if test "x$ac_cv_header_regex_h" = "xyes"; then
1491 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1500 [AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)]) REGEX_EXTENDED=yes]
1503 dnl # Fixme, this is needed for mingw builds, but not available on some Linux systems
1504 dnl # despite the presence of regex.h
1506 dnl # LIBS="$LIBS -lregex"
1511 AC_SUBST(REGEX_PCRE)
1512 AC_SUBST(REGEX_EXTENDED)
1515 dnl # Check the style of gethostbyaddr, in order of preference
1516 dnl # GNU (_r eight args)
1518 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1521 dnl # SYSV (_r six args)
1523 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1526 dnl # BSD (three args, may not be thread safe)
1528 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1531 dnl # Tru64 has BSD version, but it is thread safe
1532 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1533 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1535 gethostbyaddrrstyle=""
1536 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1540 dnl # With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1541 dnl # Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1542 dnl # override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1543 dnl # style support.
1545 AC_CHECK_DECLS([gethostbyaddr_r], [],
1547 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1548 [style of gethostbyaddr_r functions ])
1549 gethostbyaddrrstyle=BSD
1550 AC_MSG_WARN([FreeBSD overridden to BSD-style])
1560 if test "x$gethostbyaddrrstyle" = "x"; then
1566 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ],
1568 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1569 gethostbyaddrrstyle=GNU
1574 if test "x$gethostbyaddrrstyle" = "x"; then
1580 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] ,
1582 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1583 gethostbyaddrrstyle=SYSV
1589 if test "x$gethostbyaddrrstyle" = "x"; then
1595 [ gethostbyaddr(NULL, 0, 0) ],
1597 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1598 gethostbyaddrrstyle=BSD
1603 if test "x$gethostbyaddrrstyle" = "x"; then
1604 AC_MSG_RESULT([none! It must not exist, here.])
1606 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1609 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1610 AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1614 dnl # Check the style of gethostbyname, in order of preference
1615 dnl # GNU (_r seven args)
1616 dnl # SYSV (_r five args)
1617 dnl # BSD (two args, may not be thread safe)
1618 dnl # Tru64 has BSD version, but it _is_ thread safe
1619 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1620 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1622 gethostbynamerstyle=""
1623 AC_MSG_CHECKING([gethostbyname_r() syntax])
1629 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ],
1631 AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1632 gethostbynamerstyle=GNU
1636 if test "x$gethostbynamerstyle" = "x"; then
1642 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] ,
1644 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1645 gethostbynamerstyle=SYSV
1650 if test "x$gethostbynamerstyle" = "x"; then
1656 [ gethostbyname(NULL) ],
1658 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1659 gethostbynamerstyle=BSD
1664 if test "x$gethostbynamerstyle" = "x"; then
1665 AC_MSG_RESULT([none! It must not exist, here.])
1667 AC_MSG_RESULT([${gethostbynamerstyle}-style])
1670 if test "x$gethostbynamerstyle" = "xBSD"; then
1671 AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1675 dnl # Check for non-posix solaris ctime_r (extra buflen int arg)
1677 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1678 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1680 AC_MSG_CHECKING([ctime_r() syntax])
1685 [ ctime_r(NULL, NULL, 0) ],
1687 AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1688 ctimerstyle="SOLARIS"
1692 if test "x$ctimerstyle" = "x"; then
1697 [ ctime_r(NULL, NULL) ],
1699 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1705 if test "x$ctimerstyle" = "x"; then
1706 AC_MSG_RESULT([none! It must not exist, here.])
1708 AC_MSG_RESULT([${ctimerstyle}-style])
1711 AC_SUBST(HOSTINFO, $host)
1713 dnl #############################################################
1715 dnl # 8. Checks for system services
1717 dnl #############################################################
1720 dnl # Figure out where libtool is located,
1724 AC_MSG_RESULT([top_builddir=$top_builddir])
1725 dnl # AC_SUBST(top_builddir)
1728 dnl # import libtool stuff
1730 dnl #############################################################
1732 dnl # Configure in any module directories.
1734 dnl #############################################################
1736 dnl ############################################################
1737 dnl # Remove any conflicting definitions if autoconf.h
1738 dnl # is being included by a module.
1739 dnl #############################################################
1740 AH_BOTTOM([#include <freeradius-devel/automask.h>])
1742 dnl ############################################################
1743 dnl # make modules by list
1744 dnl #############################################################
1745 if test "x$EXPERIMENTAL" = "xyes"; then
1746 for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
1747 MODULES="$MODULES $foo"
1751 dnl # make ONLY the stable modules
1753 for foo in `cat "${srcdir}"/src/modules/stable`; do
1754 MODULES="$MODULES $foo"
1758 dnl ############################################################
1759 dnl # Add autoconf subdirs, based on the module list we
1760 dnl # previously created.
1761 dnl #############################################################
1763 for bar in $MODULES; do
1764 if test -f "${srcdir}"/src/modules/$bar/configure; then
1765 mysubdirs="$mysubdirs src/modules/$bar"
1770 dnl # Don't change the variable name here. Autoconf goes bonkers
1773 AC_CONFIG_SUBDIRS($mysubdirs)
1776 dnl #############################################################
1778 dnl # Add -Werror last, so it doesn't interfere with autoconf's
1779 dnl # test programs.
1781 dnl #############################################################
1782 if test "x$werror" == "xyes"; then
1783 CFLAGS="-Werror $CFLAGS"
1786 dnl #############################################################
1788 dnl # And finally, output the results.
1790 dnl #############################################################
1791 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
1792 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
1793 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main && chmod +x checkrad radlast radtest)])
1794 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts && chmod +x rc.radiusd cron/radiusd.cron.daily cron/radiusd.cron.monthly cryptpasswd)])
1797 dnl # Substitute whatever libraries we found to be necessary
1800 AC_SUBST(INSTALLSTRIP)
1802 AC_SUBST(USE_SHARED_LIBS)
1803 USE_STATIC_LIBS="yes"
1804 AC_SUBST(USE_STATIC_LIBS)
1805 AC_SUBST(STATIC_MODULES)
1809 ./src/include/build-radpaths-h \
1810 ./src/main/radsniff.mk \
1811 ./src/main/checkrad \
1812 ./src/main/radlast \
1813 ./src/main/radtest \
1814 ./scripts/rc.radiusd \
1815 ./scripts/cron/radiusd.cron.daily \
1816 ./scripts/cron/radiusd.cron.monthly \
1817 ./scripts/cryptpasswd \
1818 ./raddb/radrelay.conf \
1819 ./raddb/radiusd.conf