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
213 AC_CHECK_PROG(GMAKE, gmake, yes, no)
214 if test $GMAKE = no; then
215 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
217 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
219 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
220 if test -z "$makever"; then
221 AC_MSG_ERROR([GNU Make is not installed. Please download and install it from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.])
225 dnl # autoconf explicitly sets MAKEFLAGS and MFLAGS to '' even though we
226 dnl # didn't tell it to, so we have to use FR_MAKEFLAGS.
228 dnl # determine the number of cores available and set the number of build
229 dnl # processes appropriately.
233 dnl # Temporarily disabled because test and installation targets do not
234 dnl # have dependencies set up correctly for multiple build processes.
235 dnl if test "x$ax_cv_system_cores" != "x"; then
236 dnl : ${FR_MAKEFLAGS=-j$ax_cv_system_cores}
238 AC_SUBST(FR_MAKEFLAGS)
241 dnl # See if we have Git.
243 AC_CHECK_PROG(GIT, git, yes, no)
245 dnl Put this in later, when all distributed modules use autoconf.
246 dnl AC_ARG_WITH(disablemodulefoo,
247 dnl [ --without-rlm_foo Disables module compilation. Module list:]
248 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
249 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
250 dnl awk '{print " "$0}']))
252 AC_ARG_ENABLE(strict-dependencies,
253 [ --enable-strict-dependencies fail configure on lack of module dependancy.])
255 AC_ARG_ENABLE(werror,
256 [ --enable-werror causes the build to fail if any warnings are generated.],
257 [ case "$enableval" in
267 dnl # extra argument: --with-docdir
269 docdir='${datadir}/doc/freeradius'
270 AC_MSG_CHECKING([docdir])
272 [ --with-docdir=DIR directory for documentation [DATADIR/doc/freeradius] ],
279 [[\\/$]]* | ?:[[\\/]]* )
283 AC_MSG_ERROR([expected an absolute directory name for --with-docdir: $withval])
288 AC_MSG_RESULT($docdir)
289 if test "x$docdir" = xno; then
290 AC_MSG_WARN([Documentation files will NOT be installed.])
294 dnl # extra argument: --with-logdir
296 logdir='${localstatedir}/log/radius'
297 AC_MSG_CHECKING(logdir)
299 [ --with-logdir=DIR directory for logfiles [LOCALSTATEDIR/log/radius] ],
302 AC_MSG_ERROR([Need logdir])
306 [[\\/$]]* | ?:[[\\/]]* )
310 AC_MSG_ERROR([expected an absolute directory name for --with-logdir: $withval])
315 AC_MSG_RESULT($logdir)
318 dnl # extra argument: --with-radacctdir
320 radacctdir='${logdir}/radacct'
321 AC_MSG_CHECKING(radacctdir)
322 AC_ARG_WITH(radacctdir,
323 [ --with-radacctdir=DIR directory for detail files [LOGDIR/radacct] ],
326 AC_MSG_ERROR([Need radacctdir])
330 [[\\/$]]* | ?:[[\\/]]* )
331 radacctdir="$withval"
334 AC_MSG_ERROR([expected an absolute directory name for --with-radacctdir: $withval])
339 AC_MSG_RESULT($radacctdir)
342 dnl # extra argument: --with-raddbdir
344 raddbdir='${sysconfdir}/raddb'
345 AC_MSG_CHECKING(raddbdir)
346 AC_ARG_WITH(raddbdir,
347 [ --with-raddbdir=DIR directory for config files [SYSCONFDIR/raddb] ],
350 AC_MSG_ERROR([Need raddbdir])
354 [[\\/$]]* | ?:[[\\/]]* )
358 AC_MSG_ERROR([expected an absolute directory name for --with-raddbdir: $withval])
363 AC_MSG_RESULT($raddbdir)
365 modconfdir='${raddbdir}/mods-config'
369 dnl # extra argument: --with-ascend-binary
371 WITH_ASCEND_BINARY=yes
372 AC_ARG_WITH(ascend-binary,
373 [ --with-ascend-binary include support for Ascend binary filter attributes (default=yes)],
378 WITH_ASCEND_BINARY=no
381 if test "x$WITH_ASCEND_BINARY" = "xyes"; then
382 AC_DEFINE(WITH_ASCEND_BINARY, [1], [include support for Ascend binary filter attributes])
386 dnl # extra argument: --with-threads
390 [ --with-threads use threads, if available. (default=yes) ],
400 dnl # extra argument: --with-tcp
404 [ --with-tcp compile in TCP support. (default=yes)],
412 if test "x$WITH_TCP" = "xyes"; then
413 AC_DEFINE(WITH_TCP, [1], [define if you want TCP support (For RADSec et al)])
417 dnl # extra argument: --with-vmps
421 [ --with-vmps compile in VMPS support. (default=yes)],
429 if test "x$WITH_VMPS" = "xyes"; then
430 AC_DEFINE(WITH_VMPS, [1], [define if you want VMPS support])
434 dnl # extra argument: --with-dhcp
438 [ --with-dhcp compile in DHCP support. (default=yes)],
446 if test "x$WITH_DHCP" = "xyes"; then
447 AC_DEFINE(WITH_DHCP, [1], [define if you want DHCP support])
451 dnl # Allow the user to specify a list of modules to be linked
452 dnl # statically to the server.
455 AC_ARG_WITH(static_modules,
456 [ --with-static-modules=QUOTED-MODULE-LIST],[
457 for i in $withval; do
458 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
463 AC_ARG_WITH(shared-libs,
464 [ --with-shared-libs build dynamic libraries and link against them. (default=yes)],
475 [ --with-modules=QUOTED-MODULE-LIST],[
476 for i in $withval; do
477 MODULES="$MODULES $i"
482 dnl # extra argument: --with-experimental-modules
485 AC_ARG_WITH(experimental-modules,
486 [ --with-experimental-modules use experimental and unstable modules. (default=no, unless --enable-developer=yes) ],
499 dnl # extra argument: --with-udpfromto
502 AC_ARG_WITH(udpfromto,
503 [ --with-udpfromto compile in UDPFROMTO support. (default=yes)],
513 if test "x$WITH_UDPFROMTO" = "xyes"; then
514 AC_DEFINE(WITH_UDPFROMTO, [], [define if you want udpfromto])
518 dnl # extra argument: --with-openssl
522 [ --with-openssl use OpenSSL. (default=yes)],
534 dnl # extra argument: --with-openssl-includes=dir
537 AC_ARG_WITH(openssl-includes,
538 [ --with-openssl-includes=DIR directory to look for OpenSSL include files in],
540 *) OPENSSL_INCLUDE_DIR="$withval"
546 dnl # extra argument: --with-openssl-libraries=dir
549 AC_ARG_WITH(openssl-libraries,
550 [ --with-openssl-libraries=DIR directory to look for OpenSSL library files in],
552 *) OPENSSL_LIB_DIR="$withval"
558 dnl # These next two arguments don't actually do anything. They're
559 dnl # place holders so that the top-level configure script can tell
560 dnl # the user how to configure lower-level modules
564 dnl # extra argument: --with-rlm-FOO-lib-dir
566 AC_ARG_WITH(rlm-FOO-lib-dir,
567 [ --with-rlm-FOO-lib-dir=DIR directory to look for library files used by module FOO in],
575 dnl # extra argument: --with-rlm-FOO-include-dir
577 AC_ARG_WITH(rlm-FOO-include-dir,
578 [ --with-rlm-FOO-include-dir=DIR directory to look for include files used by module FOO in],
585 dnl #############################################################
587 dnl # 1. Checks for programs
589 dnl #############################################################
592 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
593 if test "x$ac_cv_path_PERL" = "x"; then
594 AC_MSG_WARN([perl not found - Simultaneous-Use and checkrad may not work])
596 AC_PATH_PROG(SNMPGET, snmpget)
597 if test "x$ac_cv_path_SNMPGET" = "x"; then
598 AC_MSG_WARN([snmpget not found - Simultaneous-Use and checkrad may not work])
601 AC_PATH_PROG(SNMPWALK, snmpwalk)
602 if test "x$ac_cv_path_SNMPWALK" = "x"; then
603 AC_MSG_WARN([snmpwalk not found - Simultaneous-Use and checkrad may not work])
606 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
609 dnl # FIXME This is truly gross.
611 missing_dir=`cd $ac_aux_dir && pwd`
612 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
613 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
614 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
616 AC_PATH_PROG(LOCATE,locate)
617 AC_PATH_PROG(DIRNAME,dirname)
618 AC_PATH_PROG(GREP,grep)
620 dnl #############################################################
622 dnl # 2. Checks for libraries
624 dnl #############################################################
627 dnl # If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
630 if test "x$WITH_THREADS" = "xyes"; then
631 if test $ac_cv_prog_suncc = "yes"; then
635 AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
638 dnl # pthread stuff is usually in -lpthread
639 dnl # or in -lc_r, on *BSD
641 dnl # On Some systems, we need extra pre-processor flags, to get them to
642 dnl # to do the threading properly.
644 AC_CHECK_LIB(pthread, pthread_create,
646 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
647 LIBS="-lpthread $LIBS"
650 AC_CHECK_LIB(c_r, pthread_create,
651 [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
652 [ WITH_THREADS="no" ]
659 dnl # If we have NO pthread libraries, remove any knowledge of threads.
661 if test "x$WITH_THREADS" != "xyes"; then
663 ac_cv_header_pthread_h="no"
667 dnl # We need sem_init() and friends, as they're the friendliest
668 dnl # semaphore functions for threading.
670 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
671 dnl # Some systems have them in -lsem
672 dnl # Solaris has them in -lposix4
673 dnl # NetBSD has them in -lsemaphore
676 AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt semaphore,
678 [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]])]
682 if test "x$WITH_THREADS" = "xyes"; then
683 AC_DEFINE(WITH_THREADS, [1], [define if you want thread support])
687 dnl # Check if we need -lsocket
689 AC_CHECK_LIB(dl, dlopen)
692 dnl # Check if we need -lsocket
694 AC_CHECK_LIB(socket, getsockname)
697 dnl # Check for -lresolv
698 dnl # This library may be needed later.
700 AC_CHECK_LIB(resolv, inet_aton)
703 dnl # Check if we need -lnsl. Usually if we want to
704 dnl # link against -lsocket we need to include -lnsl as well.
706 AC_CHECK_LIB(nsl, inet_ntoa)
707 AC_CHECK_LIB(ws2_32, htonl)
710 dnl # Check the pcap library for the RADIUS sniffer.
712 smart_try_dir="$pcap_lib_dir"
713 FR_SMART_CHECK_LIB(pcap, pcap_open_live)
714 if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes"; then
715 AC_MSG_WARN([pcap library not found. Use --with-pcap-lib-dir=<path>.])
716 AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer and ARP listener.])
718 PCAP_LIBS="${smart_lib}"
720 AC_DEFINE(HAVE_LIBPCAP, 1,
721 [Define to 1 if you have the `pcap' library (-lpcap).]
727 dnl #############################################################
729 dnl # 3. Checks for header files
731 dnl #############################################################
734 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
735 dnl # getopt will be #included, but won't link. <sigh>
740 CFLAGS="$CFLAGS -D_ALL_SOURCE"
743 CFLAGS="$CFLAGS -DDARWIN"
744 LIBS="-framework DirectoryService $LIBS"
796 dnl # FreeBSD requires sys/socket.h before net/if.h
798 AC_CHECK_HEADERS(net/if.h, [], [],
800 #ifdef HAVE_SYS_SOCKET_H
801 # include <sys/socket.h>
806 dnl # other checks which require headers
808 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
810 AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
813 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
815 AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
819 dnl # Were we told to use OpenSSL, if we were and we find an error, call AC_MSG_FAILURE and exit
821 if test "x$WITH_OPENSSL" = xyes; then
823 old_LDFLAGS="$LDFLAGS"
825 OPENSSL_INCLUDE="-DNO_OPENSSL"
827 if test "x$OPENSSL_LIB_DIR" != "x"; then
828 LDFLAGS="-L$OPENSSL_LIB_DIR $LDFLAGS"
832 dnl # Check we can link to libssl
834 AC_CHECK_LIB(crypto, DH_new,
836 LIBS="-lcrypto $LIBS"
837 AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
838 AC_CHECK_LIB(ssl, SSL_new,
840 AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl).])
841 if test "x$OPENSSL_LIB_DIR" != "x"; then
842 OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
844 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
847 AC_MSG_FAILURE([failed linking to libssl])
855 dnl # Check we can find required headers
857 old_CPPFLAGS=$CPPFLAGS
859 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
860 CPPFLAGS="-isystem $OPENSSL_INCLUDE_DIR $CPPFLAGS"
861 CFLAGS="-isystem $OPENSSL_INCLUDE_DIR $CFLAGS"
865 dnl # Stupid RedHat shit
867 CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
880 AC_MSG_FAILURE([failed locating OpenSSL headers])
884 AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
886 [#include <openssl/crypto.h>
887 #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
896 AC_MSG_FAILURE([OpenSSL version too old])
900 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
901 OPENSSL_INCLUDE="-isystem $OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
903 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
907 dnl # Now check that the header versions match the library
909 AC_MSG_CHECKING([OpenSSL library and header version consistency])
914 #include <openssl/opensslv.h>
915 #include <openssl/crypto.h>
918 if (SSLeay() == OPENSSL_VERSION_NUMBER) {
921 printf("library: %lx header: %lx... ", (unsigned long) SSLeay(), (unsigned long) OPENSSL_VERSION_NUMBER);
931 AC_MSG_FAILURE([OpenSSL library version does not match header version])
935 if test "x$OPENSSL_LIBS" = x; then
937 LDFLAGS="$old_LDFLAGS"
939 if test "x$OPENSSL_INCLUDE" = x; then
940 CPPFLAGS=$old_CPPFLAGS
945 AC_SUBST(OPENSSL_INCLUDE)
946 AC_SUBST(OPENSSL_LIBS)
950 dnl # Check the pcap includes for the RADIUS sniffer.
952 if test "x$PCAP_LIBS" = x; then
953 AC_MSG_NOTICE([skipping test for pcap.h.])
955 smart_try_dir="$pcap_include_dir"
956 FR_SMART_CHECK_INCLUDE([pcap.h])
957 if test "x$ac_cv_header_pcap_h" != "xyes"; then
958 AC_MSG_WARN([pcap headers not found. Use --with-pcap-include-dir=<path>.])
959 AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer, and ARP listener.])
961 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
963 AC_CHECK_LIB(pcap, pcap_fopen_offline,
965 AC_DEFINE(HAVE_PCAP_FOPEN_OFFLINE, 1, [Define to 1 if you have the function pcap_fopen_offline.])
969 AC_CHECK_LIB(pcap, pcap_dump_fopen,
971 AC_DEFINE(HAVE_PCAP_DUMP_FOPEN, 1, [Define to 1 if you have the function pcap_dump_fopen.])
978 dnl #############################################################
980 dnl # 4. Checks for typedefs
982 dnl #############################################################
985 dnl # Ensure that these are defined
993 dnl # Check for socklen_t
995 FR_CHECK_TYPE_INCLUDE(
997 #ifdef HAVE_SYS_TYPES_H
998 # include <sys/types.h>
1001 #ifdef HAVE_SYS_SOCKET_H
1002 # include <sys/socket.h>
1005 socklen_t, int, [socklen_t is generally 'int' on systems which don't use it]
1009 dnl # Check for uint8_t
1011 FR_CHECK_TYPE_INCLUDE(
1013 #ifdef HAVE_INTTYPES_H
1014 # include <inttypes.h>
1017 #ifdef HAVE_STDINT_H
1018 # include <stdint.h>
1021 uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic]
1025 dnl # Check for uint16_t
1027 FR_CHECK_TYPE_INCLUDE(
1029 #ifdef HAVE_INTTYPES_H
1030 # include <inttypes.h>
1033 #ifdef HAVE_STDINT_H
1034 # include <stdint.h>
1037 uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic]
1041 dnl # Check for uint32_t
1043 FR_CHECK_TYPE_INCLUDE(
1045 #ifdef HAVE_INTTYPES_H
1046 # include <inttypes.h>
1049 #ifdef HAVE_STDINT_H
1050 # include <stdint.h>
1053 uint32_t, unsigned int, [uint32_t should be the canonical 'network integer']
1056 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [],
1058 #ifdef HAVE_NETINET_IN_H
1059 # include <netinet/in.h>
1064 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [],
1066 #ifdef HAVE_NETINET_IN_H
1067 # include <netinet/in.h>
1070 #ifdef HAVE_SYS_SOCKET_H
1071 # include <sys/socket.h>
1075 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [],
1077 #ifdef HAVE_NETINET_IN_H
1078 # include <netinet/in.h>
1082 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [],
1084 #ifdef HAVE_SYS_TYPES_H
1085 # include <sys/types.h>
1088 #ifdef HAVE_SYS_SOCKET_H
1089 # include <sys/socket.h>
1098 dnl #############################################################
1100 dnl # 5. Checks for structures and functions
1102 dnl #############################################################
1141 dnl # Check if we have utmpx.h
1142 dnl # if so, check if struct utmpx has entry ut_xtime
1143 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
1145 if test "x$ac_cv_header_utmpx_h" = "xyes"; then
1146 FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
1147 if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then
1148 AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
1153 dnl # struct ip_pktinfo
1155 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
1156 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then
1157 AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
1161 dnl # struct in6_pktinfo
1163 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
1164 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then
1165 AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
1168 dnl #############################################################
1170 dnl # 6. Checks for compiler characteristics
1172 dnl #############################################################
1175 dnl # Ensure that these are defined
1180 dnl # See if this is OS/2
1182 AC_MSG_CHECKING([type of OS])
1185 if test "$OS" = "OS/2"; then
1192 if test "x$developer" = "xyes"; then
1193 AC_MSG_NOTICE([Setting additional developer CFLAGS])
1196 dnl # Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1198 AX_CC_WDOCUMENTATION_FLAG
1199 if test "x$ax_cv_cc_wdocumentation_flag" = "xyes"; then
1200 devflags="-Wdocumentation"
1203 if test "x$GCC" = "xyes"; then
1204 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"
1208 AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1210 CFLAGS="$CFLAGS $devflags"
1212 dnl # Enable experimental modules (we want to know if code changes breaks one of them)
1214 if test "x$EXPERIMENTAL" != "xno"; then
1215 AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1220 CFLAGS="$CFLAGS -DNDEBUG"
1225 dnl # May of been set outside of this configure script
1227 AC_MSG_CHECKING([if building with -DNDEBUG])
1228 if echo "$CFLAGS" | grep '\-DNDEBUG' > /dev/null; then
1229 AC_MSG_RESULT([yes])
1230 AC_DEFINE([WITH_NDEBUG], [1], [define if the server was built with -DNDEBUG])
1238 dnl # append the current git hash onto the version string
1240 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1241 RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1242 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],["${RADIUSD_VERSION_COMMIT}"],[Commit HEAD at time of configuring])
1247 dnl #############################################################
1249 dnl # 7. Checks for library functions
1251 dnl #############################################################
1253 dnl Check for talloc
1254 dnl extra argument: --with-talloc-include-dir=DIR
1256 AC_ARG_WITH(talloc-include-dir,
1257 [ --with-talloc-include-dir=DIR directory to look for talloc include files in],
1260 AC_MSG_ERROR([Need talloc-include-dir])
1265 talloc_include_dir="$withval"
1269 dnl Check for talloc
1270 dnl extra argument: --with-talloc-lib-dir=DIR
1272 AC_ARG_WITH(talloc-lib-dir,
1273 [ --with-talloc-lib-dir=DIR directory to look for talloc library files in],
1276 AC_MSG_ERROR([Need talloc-lib-dir])
1281 talloc_lib_dir="$withval"
1286 dnl extra argument: --with-pcap-include-dir=DIR
1288 AC_ARG_WITH(pcap-include-dir,
1289 [ --with-pcap-include-dir=DIR directory to look for pcap include files in],
1292 AC_MSG_ERROR([Need pcap-include-dir])
1297 pcap_include_dir="$withval"
1302 dnl extra argument: --with-pcap-lib-dir=DIR
1304 AC_ARG_WITH(pcap-lib-dir,
1305 [ --with-pcap-lib-dir=DIR directory to look for pcap library files in],
1308 AC_MSG_ERROR([Need pcap-lib-dir])
1313 pcap_lib_dir="$withval"
1318 dnl # Check for talloc header files
1320 smart_try_dir="$talloc_include_dir"
1321 FR_SMART_CHECK_INCLUDE([talloc.h])
1322 if test "x$ac_cv_header_talloc_h" != "xyes"; then
1323 AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
1324 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1327 smart_try_dir="$talloc_lib_dir"
1328 FR_SMART_CHECK_LIB(talloc, _talloc)
1329 if test "x$ac_cv_lib_talloc__talloc" != "xyes"; then
1330 AC_MSG_WARN([talloc library not found. Use --with-talloc-lib-dir=<path>.])
1331 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1335 dnl # Check for libcrypt
1336 dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1338 AC_CHECK_LIB(crypt, crypt,
1342 if test "$CRYPTLIB" != ""; then
1343 AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1345 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1348 dnl Check for libcipher
1349 AC_CHECK_LIB(cipher, setkey,
1350 CRYPTLIB="${CRYPTLIB} -lcipher"
1356 dnl # Check for regular expression support, if were using PCRE it MUST be included
1357 dnl # before all others, else we seem to still pickup the posix symbols for regcomp
1358 dnl # and regexec, which results in crashes as soon as we call any posix regex
1361 dnl extra argument: --with-pcre-lib-dir
1363 AC_ARG_WITH(rlm-pcre-lib-dir,
1364 [ --with-pcre-lib-dir=DIR directory to look for PCRE library files in],
1365 [ case "$withval" in
1367 AC_MSG_ERROR(Need rlm-pcre-lib-dir)
1372 pcre_lib_dir="$withval"
1377 dnl extra argument: --with-pcre-include--dir
1379 AC_ARG_WITH(rlm-pcre-include-dir,
1380 [ --with-pcre-include-dir=DIR directory to look for PCRE include files in],
1381 [ case "$withval" in
1383 AC_MSG_ERROR(Need rlm-pcre-include-dir)
1388 pcre_include_dir="$withval"
1398 dnl # First look for PCRE
1400 smart_try_dir=$pcre_include_dir
1401 FR_SMART_CHECK_INCLUDE(pcreposix.h)
1402 if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
1403 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1404 AC_DEFINE(HAVE_PCREPOSIX_H, [1], [define this if we have the <pcreposix.h> header file])
1408 LIBS="-lpcre -lpcreposix $LIBS"
1411 dnl # Then fallback to POSIX regular expressions
1415 FR_SMART_CHECK_INCLUDE(regex.h)
1416 if test "x$ac_cv_header_regex_h" = "xyes"; then
1417 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1426 [AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)]) REGEX_EXTENDED=yes]
1429 dnl # Fixme, this is needed for mingw builds, but not available on some Linux systems
1430 dnl # despite the presence of regex.h
1432 dnl # LIBS="$LIBS -lregex"
1437 AC_SUBST(REGEX_PCRE)
1438 AC_SUBST(REGEX_EXTENDED)
1441 dnl # Check the style of gethostbyaddr, in order of preference
1442 dnl # GNU (_r eight args)
1444 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1447 dnl # SYSV (_r six args)
1449 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1452 dnl # BSD (three args, may not be thread safe)
1454 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1457 dnl # Tru64 has BSD version, but it is thread safe
1458 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1459 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1461 gethostbyaddrrstyle=""
1462 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1466 dnl # With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1467 dnl # Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1468 dnl # override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1469 dnl # style support.
1471 AC_CHECK_DECLS([gethostbyaddr_r], [],
1473 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1474 [style of gethostbyaddr_r functions ])
1475 gethostbyaddrrstyle=BSD
1476 AC_MSG_WARN([FreeBSD overridden to BSD-style])
1486 if test "x$gethostbyaddrrstyle" = "x"; then
1492 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ],
1494 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1495 gethostbyaddrrstyle=GNU
1500 if test "x$gethostbyaddrrstyle" = "x"; then
1506 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] ,
1508 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1509 gethostbyaddrrstyle=SYSV
1515 if test "x$gethostbyaddrrstyle" = "x"; then
1521 [ gethostbyaddr(NULL, 0, 0) ],
1523 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1524 gethostbyaddrrstyle=BSD
1529 if test "x$gethostbyaddrrstyle" = "x"; then
1530 AC_MSG_RESULT([none! It must not exist, here.])
1532 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1535 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1536 AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1540 dnl # Check the style of gethostbyname, in order of preference
1541 dnl # GNU (_r seven args)
1542 dnl # SYSV (_r five args)
1543 dnl # BSD (two args, may not be thread safe)
1544 dnl # Tru64 has BSD version, but it _is_ thread safe
1545 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1546 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1548 gethostbynamerstyle=""
1549 AC_MSG_CHECKING([gethostbyname_r() syntax])
1555 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ],
1557 AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1558 gethostbynamerstyle=GNU
1562 if test "x$gethostbynamerstyle" = "x"; then
1568 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] ,
1570 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1571 gethostbynamerstyle=SYSV
1576 if test "x$gethostbynamerstyle" = "x"; then
1582 [ gethostbyname(NULL) ],
1584 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1585 gethostbynamerstyle=BSD
1590 if test "x$gethostbynamerstyle" = "x"; then
1591 AC_MSG_RESULT([none! It must not exist, here.])
1593 AC_MSG_RESULT([${gethostbynamerstyle}-style])
1596 if test "x$gethostbynamerstyle" = "xBSD"; then
1597 AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1601 dnl # Check for non-posix solaris ctime_r (extra buflen int arg)
1603 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1604 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1606 AC_MSG_CHECKING([ctime_r() syntax])
1611 [ ctime_r(NULL, NULL, 0) ],
1613 AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1614 ctimerstyle="SOLARIS"
1618 if test "x$ctimerstyle" = "x"; then
1623 [ ctime_r(NULL, NULL) ],
1625 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1631 if test "x$ctimerstyle" = "x"; then
1632 AC_MSG_RESULT([none! It must not exist, here.])
1634 AC_MSG_RESULT([${ctimerstyle}-style])
1637 AC_SUBST(HOSTINFO, $host)
1639 dnl #############################################################
1641 dnl # 8. Checks for system services
1643 dnl #############################################################
1646 dnl # Figure out where libtool is located,
1650 AC_MSG_RESULT([top_builddir=$top_builddir])
1651 dnl # AC_SUBST(top_builddir)
1654 dnl # import libtool stuff
1656 dnl #############################################################
1658 dnl # Configure in any module directories.
1660 dnl #############################################################
1662 dnl ############################################################
1663 dnl # Remove any conflicting definitions if autoconf.h
1664 dnl # is being included by a module.
1665 dnl #############################################################
1666 AH_BOTTOM([#include <freeradius-devel/automask.h>])
1668 dnl ############################################################
1669 dnl # make modules by list
1670 dnl #############################################################
1671 if test "x$EXPERIMENTAL" = "xyes"; then
1672 for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
1673 MODULES="$MODULES $foo"
1677 dnl # make ONLY the stable modules
1679 for foo in `cat "${srcdir}"/src/modules/stable`; do
1680 MODULES="$MODULES $foo"
1684 dnl ############################################################
1685 dnl # Add autoconf subdirs, based on the module list we
1686 dnl # previously created.
1687 dnl #############################################################
1689 for bar in $MODULES; do
1690 if test -f "${srcdir}"/src/modules/$bar/configure; then
1691 mysubdirs="$mysubdirs src/modules/$bar"
1696 dnl # Don't change the variable name here. Autoconf goes bonkers
1699 AC_CONFIG_SUBDIRS($mysubdirs)
1702 dnl #############################################################
1704 dnl # Add -Werror last, so it doesn't interfere with autoconf's
1705 dnl # test programs.
1707 dnl #############################################################
1708 if test "x$werror" == "xyes"; then
1709 CFLAGS="-Werror $CFLAGS"
1712 dnl #############################################################
1714 dnl # And finally, output the results.
1716 dnl #############################################################
1717 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
1718 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
1719 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main && chmod +x checkrad radlast radtest)])
1720 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts && chmod +x rc.radiusd cron/radiusd.cron.daily cron/radiusd.cron.monthly cryptpasswd)])
1723 dnl # Substitute whatever libraries we found to be necessary
1726 AC_SUBST(INSTALLSTRIP)
1728 AC_SUBST(USE_SHARED_LIBS)
1729 USE_STATIC_LIBS="yes"
1730 AC_SUBST(USE_STATIC_LIBS)
1731 AC_SUBST(STATIC_MODULES)
1735 ./src/include/build-radpaths-h \
1736 ./src/main/radsniff.mk \
1737 ./src/main/checkrad \
1738 ./src/main/radlast \
1739 ./src/main/radtest \
1740 ./scripts/rc.radiusd \
1741 ./scripts/cron/radiusd.cron.daily \
1742 ./scripts/cron/radiusd.cron.monthly \
1743 ./scripts/cryptpasswd \
1744 ./raddb/dictionary \
1745 ./raddb/radrelay.conf \
1746 ./raddb/radiusd.conf