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 # Check for GNU cc
124 dnl # check for AIX, to allow us to use some BSD functions
125 dnl # must be before macros that call the compiler.
129 AC_PROG_GCC_TRADITIONAL
134 dnl # Definitive check for whether the compiler is clang
139 dnl # Set Default CFLAGS for GCC compatible compilers
141 if test "x$GCC" = "xyes"; then
142 CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
146 dnl # -Qunused-arguments means the compiler won't complain about unsupported arguments
148 AX_CC_QUNUSED_ARGUMENTS_FLAG
149 if test "x$ax_cv_cc_qunused_arguments_flag" = "xyes"; then
150 CFLAGS="$CFLAGS -Qunused-arguments"
151 LDFLAGS="$LDFLAGS -Qunused-arguments"
155 dnl # Compile in large (2G+) file support.
160 dnl # check for system bytesex
161 dnl # AC_DEFINES WORDS_BIGENDIAN
168 AC_CHECK_PROG(GMAKE, gmake, yes, no)
169 if test $GMAKE = no; then
170 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
172 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
174 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
175 if test -z "$makever"; then
176 AC_MSG_ERROR([GNU Make is not installed. Please download and install it from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.])
180 dnl # autoconf explicitly sets MAKEFLAGS and MFLAGS to '' even though we
181 dnl # didn't tell it to, so we have to use FR_MAKEFLAGS.
183 dnl # determine the number of cores available and set the number of build
184 dnl # processes appropriately.
188 dnl # Temporarily disabled because test and installation targets do not
189 dnl # have dependencies set up correctly for multiple build processes.
190 dnl if test "x$ax_cv_system_cores" != "x"; then
191 dnl : ${FR_MAKEFLAGS=-j$ax_cv_system_cores}
193 AC_SUBST(FR_MAKEFLAGS)
196 dnl # See if we have Git.
198 AC_CHECK_PROG(GIT, git, yes, no)
200 dnl Put this in later, when all distributed modules use autoconf.
201 dnl AC_ARG_WITH(disablemodulefoo,
202 dnl [ --without-rlm_foo Disables module compilation. Module list:]
203 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
204 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
205 dnl awk '{print " "$0}']))
207 AC_ARG_ENABLE(strict-dependencies,
208 [ --enable-strict-dependencies fail configure on lack of module dependancy.])
210 AC_ARG_ENABLE(werror,
211 [ --enable-werror causes the build to fail if any warnings are generated.],
212 [ case "$enableval" in
222 dnl # extra argument: --with-docdir
224 docdir='${datadir}/doc/freeradius'
225 AC_MSG_CHECKING([docdir])
227 [ --with-docdir=DIR directory for documentation [DATADIR/doc/freeradius] ],
234 [[\\/$]]* | ?:[[\\/]]* )
238 AC_MSG_ERROR([expected an absolute directory name for --with-docdir: $withval])
243 AC_MSG_RESULT($docdir)
244 if test "x$docdir" = xno; then
245 AC_MSG_WARN([Documentation files will NOT be installed.])
249 dnl # extra argument: --with-logdir
251 logdir='${localstatedir}/log/radius'
252 AC_MSG_CHECKING(logdir)
254 [ --with-logdir=DIR directory for logfiles [LOCALSTATEDIR/log/radius] ],
257 AC_MSG_ERROR([Need logdir])
261 [[\\/$]]* | ?:[[\\/]]* )
265 AC_MSG_ERROR([expected an absolute directory name for --with-logdir: $withval])
270 AC_MSG_RESULT($logdir)
273 dnl # extra argument: --with-radacctdir
275 radacctdir='${logdir}/radacct'
276 AC_MSG_CHECKING(radacctdir)
277 AC_ARG_WITH(radacctdir,
278 [ --with-radacctdir=DIR directory for detail files [LOGDIR/radacct] ],
281 AC_MSG_ERROR([Need radacctdir])
285 [[\\/$]]* | ?:[[\\/]]* )
286 radacctdir="$withval"
289 AC_MSG_ERROR([expected an absolute directory name for --with-radacctdir: $withval])
294 AC_MSG_RESULT($radacctdir)
297 dnl # extra argument: --with-raddbdir
299 raddbdir='${sysconfdir}/raddb'
300 AC_MSG_CHECKING(raddbdir)
301 AC_ARG_WITH(raddbdir,
302 [ --with-raddbdir=DIR directory for config files [SYSCONFDIR/raddb] ],
305 AC_MSG_ERROR([Need raddbdir])
309 [[\\/$]]* | ?:[[\\/]]* )
313 AC_MSG_ERROR([expected an absolute directory name for --with-raddbdir: $withval])
318 AC_MSG_RESULT($raddbdir)
320 modconfdir="$raddbdir/mods-config"
324 dnl # extra argument: --with-ascend-binary
326 WITH_ASCEND_BINARY=yes
327 AC_ARG_WITH(ascend-binary,
328 [ --with-ascend-binary include support for Ascend binary filter attributes (default=yes)],
333 WITH_ASCEND_BINARY=no
336 if test "x$WITH_ASCEND_BINARY" = "xyes"; then
337 AC_DEFINE(WITH_ASCEND_BINARY, [1], [include support for Ascend binary filter attributes])
341 dnl # extra argument: --with-threads
345 [ --with-threads Use threads, if available. (default=yes) ],
355 dnl # extra argument: --with-tcp
359 [ --with-tcp Compile in TCP support. (default=yes)],
367 if test "x$WITH_TCP" = "xyes"; then
368 AC_DEFINE(WITH_TCP, [1], [define if you want TCP support (For RADSec et al)])
372 dnl # extra argument: --with-vmps
376 [ --with-vmps Compile in VMPS support. (default=yes)],
384 if test "x$WITH_VMPS" = "xyes"; then
385 AC_DEFINE(WITH_VMPS, [1], [define if you want VMPS support])
389 dnl # extra argument: --with-dhcp
393 [ --with-dhcp Compile in DHCP support. (default=yes)],
401 if test "x$WITH_DHCP" = "xyes"; then
402 AC_DEFINE(WITH_DHCP, [1], [define if you want DHCP support])
406 dnl # Allow the user to specify a list of modules to be linked
407 dnl # statically to the server.
410 AC_ARG_WITH(static_modules,
411 [ --with-static-modules=QUOTED-MODULE-LIST],[
412 for i in $withval; do
413 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
419 [ --with-modules=QUOTED-MODULE-LIST],[
420 for i in $withval; do
421 MODULES="$MODULES $i"
426 dnl # extra argument: --with-experimental-modules
429 AC_ARG_WITH(experimental-modules,
430 [ --with-experimental-modules Use experimental and unstable modules. (default=no, unless --enable-developer=yes) ],
443 dnl # extra argument: --with-openssl
447 [ --with-openssl Use OpenSSL. (default=yes)],
459 dnl # extra argument: --with-openssl-includes=dir
462 AC_ARG_WITH(openssl-includes,
463 [ --with-openssl-includes=DIR Directory to look for OpenSSL include files],
465 *) OPENSSL_INCLUDE_DIR="$withval"
471 dnl # extra argument: --with-openssl-libraries=dir
474 AC_ARG_WITH(openssl-libraries,
475 [ --with-openssl-libraries=DIR Directory to look for OpenSSL library files],
477 *) OPENSSL_LIB_DIR="$withval"
483 dnl # These next two arguments don't actually do anything. They're
484 dnl # place holders so that the top-level configure script can tell
485 dnl # the user how to configure lower-level modules
489 dnl # extra argument: --with-rlm-FOO-lib-dir
491 AC_ARG_WITH(rlm-FOO-lib-dir,
492 [ --with-rlm-FOO-lib-dir=DIR Directory to look for library files used by module FOO],
500 dnl # extra argument: --with-rlm-FOO-include-dir
502 AC_ARG_WITH(rlm-FOO-include-dir,
503 [ --with-rlm-FOO-include-dir=DIR Directory to look for include files used by module FOO],
511 dnl # extra argument: --with-udpfromto
514 AC_ARG_WITH(udpfromto,
515 [ --with-udpfromto Compile in UDPFROMTO support. (default=no)],
525 if test "x$WITH_UDPFROMTO" = "xyes"; then
526 AC_DEFINE(WITH_UDPFROMTO, [], [define if you want udpfromto])
529 dnl #############################################################
531 dnl # 1. Checks for programs
533 dnl #############################################################
536 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
537 if test "x$ac_cv_path_PERL" = "x"; then
538 AC_MSG_WARN([perl not found - Simultaneous-Use and checkrad may not work])
540 AC_PATH_PROG(SNMPGET, snmpget)
541 if test "x$ac_cv_path_SNMPGET" = "x"; then
542 AC_MSG_WARN([snmpget not found - Simultaneous-Use and checkrad may not work])
545 AC_PATH_PROG(SNMPWALK, snmpwalk)
546 if test "x$ac_cv_path_SNMPWALK" = "x"; then
547 AC_MSG_WARN([snmpwalk not found - Simultaneous-Use and checkrad may not work])
550 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
553 dnl # FIXME This is truly gross.
555 missing_dir=`cd $ac_aux_dir && pwd`
556 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
557 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
558 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
560 AC_PATH_PROG(LOCATE,locate)
561 AC_PATH_PROG(DIRNAME,dirname)
562 AC_PATH_PROG(GREP,grep)
564 dnl #############################################################
566 dnl # 2. Checks for libraries
568 dnl #############################################################
571 dnl # If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
574 if test "x$WITH_THREADS" = "xyes"; then
575 if test $ac_cv_prog_suncc = "yes"; then
579 AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
582 dnl # pthread stuff is usually in -lpthread
583 dnl # or in -lc_r, on *BSD
585 dnl # On Some systems, we need extra pre-processor flags, to get them to
586 dnl # to do the threading properly.
588 AC_CHECK_LIB(pthread, pthread_create,
590 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
591 LIBS="-lpthread $LIBS"
594 AC_CHECK_LIB(c_r, pthread_create,
595 [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
596 [ WITH_THREADS="no" ]
603 dnl # If we have NO pthread libraries, remove any knowledge of threads.
605 if test "x$WITH_THREADS" != "xyes"; then
607 ac_cv_header_pthread_h="no"
611 dnl # We need sem_init() and friends, as they're the friendliest
612 dnl # semaphore functions for threading.
614 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
615 dnl # Some systems have them in -lsem
616 dnl # Solaris has them in -lposix4
617 dnl # NetBSD has them in -lsemaphore
620 AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt semaphore,
622 [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]])]
626 if test "x$WITH_THREADS" = "xyes"; then
627 AC_DEFINE(WITH_THREADS, [1], [define if you want thread support])
631 dnl # Check if we need -lsocket
633 AC_CHECK_LIB(dl, dlopen)
636 dnl # Check if we need -lsocket
638 AC_CHECK_LIB(socket, getsockname)
641 dnl # Check for -lresolv
642 dnl # This library may be needed later.
644 AC_CHECK_LIB(resolv, inet_aton)
647 dnl # Check if we need -lnsl. Usually if we want to
648 dnl # link against -lsocket we need to include -lnsl as well.
650 AC_CHECK_LIB(nsl, inet_ntoa)
651 AC_CHECK_LIB(ws2_32, htonl)
654 dnl # Check the pcap library for the RADIUS sniffer.
657 AC_CHECK_LIB(pcap, pcap_open_live,
660 AC_DEFINE(HAVE_LIBPCAP, 1,
661 [Define to 1 if you have the `pcap' library (-lpcap).]
665 AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer.])
671 dnl #############################################################
673 dnl # 3. Checks for header files
675 dnl #############################################################
678 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
679 dnl # getopt will be #included, but won't link. <sigh>
684 CFLAGS="$CFLAGS -D_ALL_SOURCE"
687 CFLAGS="$CFLAGS -DDARWIN"
688 LIBS="-framework DirectoryService $LIBS"
740 dnl # FreeBSD requires sys/socket.h before net/if.h
742 AC_CHECK_HEADERS(net/if.h, [], [],
743 [#ifdef HAVE_SYS_SOCKET_H
744 # include <sys/socket.h>
749 dnl # other checks which require headers
751 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
753 AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
756 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
758 AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
762 dnl # Were we told to use OpenSSL, if we were and we find an error, call AC_MSG_FAILURE and exit
764 if test "x$WITH_OPENSSL" = xyes; then
766 old_LDFLAGS="$LDFLAGS"
768 OPENSSL_INCLUDE="-DNO_OPENSSL"
770 if test "x$OPENSSL_LIB_DIR" != "x"; then
771 LDFLAGS="$LDFLAGS -L$OPENSSL_LIB_DIR"
775 dnl # Check we can link to libssl
777 AC_CHECK_LIB(crypto, DH_new,
779 LIBS="-lcrypto $LIBS"
780 AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
781 AC_CHECK_LIB(ssl, SSL_new,
783 AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl).])
784 if test "x$OPENSSL_LIB_DIR" != "x"; then
785 OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
787 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
790 AC_MSG_FAILURE([failed linking to libssl])
798 dnl # Check we can find required headers
800 old_CPPFLAGS=$CPPFLAGS
801 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
802 CPPFLAGS="$CPPFLAGS -I$OPENSSL_INCLUDE_DIR"
806 dnl # Stupid RedHat shit
808 CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
821 AC_MSG_FAILURE([failed locating OpenSSL headers])
825 AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
827 [#include <openssl/crypto.h>
828 #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
837 AC_MSG_FAILURE([OpenSSL version too old])
841 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
842 OPENSSL_INCLUDE="-I$OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
844 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
848 dnl # Now check that the header versions match the library
850 AC_MSG_CHECKING([OpenSSL library and header version consistency])
855 #include <openssl/opensslv.h>
856 #include <openssl/crypto.h>
859 if (SSLeay() == OPENSSL_VERSION_NUMBER) {
862 printf("library: %lx header: %lx... ", (unsigned long) SSLeay(), (unsigned long) OPENSSL_VERSION_NUMBER);
872 AC_MSG_FAILURE([OpenSSL library version does not match header version])
876 CPPFLAGS=$old_CPPFLAGS
878 LDFLAGS="$old_LDFLAGS"
881 AC_SUBST(OPENSSL_INCLUDE)
882 AC_SUBST(OPENSSL_LIBS)
886 dnl # Check the pcap includes for the RADIUS sniffer.
888 if test "x$PCAP_LIBS" = x; then
889 AC_MSG_NOTICE([skipping test for pcap.h.])
891 AC_CHECK_HEADER(pcap.h,
893 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
895 AC_CHECK_LIB(pcap, pcap_fopen_offline,
897 AC_DEFINE(HAVE_PCAP_FOPEN_OFFLINE, 1, [Define to 1 if you have the function pcap_fopen_offline.])
901 AC_CHECK_LIB(pcap, pcap_dump_fopen,
903 AC_DEFINE(HAVE_PCAP_DUMP_FOPEN, 1, [Define to 1 if you have the function pcap_dump_fopen.])
909 AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer.])
915 dnl #############################################################
917 dnl # 4. Checks for typedefs
919 dnl #############################################################
922 dnl # Ensure that these are defined
930 dnl # Check for socklen_t
932 FR_CHECK_TYPE_INCLUDE(
934 #ifdef HAVE_SYS_TYPES_H
935 # include <sys/types.h>
938 #ifdef HAVE_SYS_SOCKET_H
939 # include <sys/socket.h>
942 socklen_t, int, [socklen_t is generally 'int' on systems which don't use it]
946 dnl # Check for uint8_t
948 FR_CHECK_TYPE_INCLUDE(
950 #ifdef HAVE_INTTYPES_H
951 # include <inttypes.h>
958 uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic]
962 dnl # Check for uint16_t
964 FR_CHECK_TYPE_INCLUDE(
966 #ifdef HAVE_INTTYPES_H
967 # include <inttypes.h>
974 uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic]
978 dnl # Check for uint32_t
980 FR_CHECK_TYPE_INCLUDE(
982 #ifdef HAVE_INTTYPES_H
983 # include <inttypes.h>
990 uint32_t, unsigned int, [uint32_t should be the canonical 'network integer']
993 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [],
995 #ifdef HAVE_NETINET_IN_H
996 # include <netinet/in.h>
1001 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [],
1003 #ifdef HAVE_NETINET_IN_H
1004 # include <netinet/in.h>
1007 #ifdef HAVE_SYS_SOCKET_H
1008 # include <sys/socket.h>
1012 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [],
1014 #ifdef HAVE_NETINET_IN_H
1015 # include <netinet/in.h>
1019 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [],
1021 #ifdef HAVE_SYS_TYPES_H
1022 # include <sys/types.h>
1025 #ifdef HAVE_SYS_SOCKET_H
1026 # include <sys/socket.h>
1035 dnl #############################################################
1037 dnl # 5. Checks for structures and functions
1039 dnl #############################################################
1078 dnl # Check if we have utmpx.h
1079 dnl # if so, check if struct utmpx has entry ut_xtime
1080 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
1082 if test "x$ac_cv_header_utmpx_h" = "xyes"; then
1083 FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
1084 if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then
1085 AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
1090 dnl # struct ip_pktinfo
1092 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
1093 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then
1094 AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
1098 dnl # struct in6_pktinfo
1100 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
1101 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then
1102 AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
1105 dnl #############################################################
1107 dnl # 6. Checks for compiler characteristics
1109 dnl #############################################################
1112 dnl # Ensure that these are defined
1117 dnl # See if this is OS/2
1119 AC_MSG_CHECKING([type of OS])
1122 if test "$OS" = "OS/2"; then
1129 if test "x$developer" = "xyes"; then
1130 AC_MSG_NOTICE([Setting additional developer CFLAGS])
1133 dnl # Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1135 AX_CC_WDOCUMENTATION_FLAG
1136 if test "x$ax_cv_cc_wdocumentation_flag" = "xyes"; then
1137 devflags="-Wdocumentation"
1140 if test "x$GCC" = "xyes"; then
1141 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"
1145 AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1147 CFLAGS="$CFLAGS $devflags"
1149 dnl # Enable experimental modules (we want to know if code changes breaks one of them)
1151 if test "x$EXPERIMENTAL" != "xno"; then
1152 AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1157 CFLAGS="$CFLAGS -DNDEBUG"
1159 AC_MSG_RESULT([no.])
1165 dnl # append the current git hash onto the version string
1167 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1168 RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1169 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],["${RADIUSD_VERSION_COMMIT}"],[Commit HEAD at time of configuring])
1174 dnl #############################################################
1176 dnl # 7. Checks for library functions
1178 dnl #############################################################
1180 dnl Check for talloc
1181 dnl extra argument: --with-talloc-include-dir=DIR
1183 AC_ARG_WITH(talloc-include-dir,
1184 [AS_HELP_STRING([--with-talloc-include-dir=DIR],
1185 [Directory where the talloc includes may be found])],
1188 AC_MSG_ERROR([Need talloc-include-dir])
1193 talloc_include_dir="$withval"
1198 dnl # Check for talloc header files
1200 smart_try_dir="$talloc_include_dir"
1201 FR_SMART_CHECK_INCLUDE([talloc.h])
1202 if test "x$ac_cv_header_talloc_h" != "xyes"; then
1203 AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
1204 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1206 INCLUDE="${SMART_CFLAGS} ${INCLUDE}"
1207 LIBS="-ltalloc ${LIBS}"
1211 dnl # Check for libcrypt
1212 dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1214 AC_CHECK_LIB(crypt, crypt,
1218 if test "$CRYPTLIB" != ""; then
1219 AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1221 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1224 dnl Check for libcipher
1225 AC_CHECK_LIB(cipher, setkey,
1226 CRYPTLIB="${CRYPTLIB} -lcipher"
1232 dnl # Check for regular expression support, if were using PCRE it MUST be included
1233 dnl # before all others, else we seem to still pickup the posix symbols for regcomp
1234 dnl # and regexec, which results in crashes as soon as we call any posix regex
1237 dnl extra argument: --with-pcre-lib-dir
1239 AC_ARG_WITH(rlm-pcre-lib-dir,
1240 [ --with-pcre-lib-dir=DIR directory for PCRE library files []],
1241 [ case "$withval" in
1243 AC_MSG_ERROR(Need rlm-pcre-lib-dir)
1248 pcre_lib_dir="$withval"
1253 dnl extra argument: --with-pcre-include--dir
1255 AC_ARG_WITH(rlm-pcre-include-dir,
1256 [ --with-pcre-include-dir=DIR directory for PCRE include files []],
1257 [ case "$withval" in
1259 AC_MSG_ERROR(Need rlm-pcre-include-dir)
1264 pcre_include_dir="$withval"
1274 dnl # First look for PCRE
1276 smart_try_dir=$pcre_include_dir
1277 FR_SMART_CHECK_INCLUDE(pcreposix.h)
1278 if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
1279 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1280 AC_DEFINE(HAVE_PCREPOSIX_H, [1], [define this if we have the <pcreposix.h> header file])
1284 LIBS="-lpcre -lpcreposix $LIBS"
1287 dnl # Then fallback to POSIX regular expressions
1291 FR_SMART_CHECK_INCLUDE(regex.h)
1292 if test "x$ac_cv_header_regex_h" = "xyes"; then
1293 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
1302 [AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)]) REGEX_EXTENDED=yes]
1304 LIBS="$LIBS -lregex"
1309 AC_SUBST(REGEX_PCRE)
1310 AC_SUBST(REGEX_EXTENDED)
1313 dnl # Check the style of gethostbyaddr, in order of preference
1314 dnl # GNU (_r eight args)
1316 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1319 dnl # SYSV (_r six args)
1321 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1324 dnl # BSD (three args, may not be thread safe)
1326 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1329 dnl # Tru64 has BSD version, but it is thread safe
1330 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1331 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1333 gethostbyaddrrstyle=""
1334 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1338 dnl # With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1339 dnl # Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1340 dnl # override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1341 dnl # style support.
1343 AC_CHECK_DECLS([gethostbyaddr_r], [],
1345 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1346 [style of gethostbyaddr_r functions ])
1347 gethostbyaddrrstyle=BSD
1348 AC_MSG_WARN([FreeBSD overridden to BSD-style])
1358 if test "x$gethostbyaddrrstyle" = "x"; then
1364 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ],
1366 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1367 gethostbyaddrrstyle=GNU
1372 if test "x$gethostbyaddrrstyle" = "x"; then
1378 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] ,
1380 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1381 gethostbyaddrrstyle=SYSV
1387 if test "x$gethostbyaddrrstyle" = "x"; then
1393 [ gethostbyaddr(NULL, 0, 0) ],
1395 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1396 gethostbyaddrrstyle=BSD
1401 if test "x$gethostbyaddrrstyle" = "x"; then
1402 AC_MSG_RESULT([none! It must not exist, here.])
1404 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1407 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1408 AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1412 dnl # Check the style of gethostbyname, in order of preference
1413 dnl # GNU (_r seven args)
1414 dnl # SYSV (_r five args)
1415 dnl # BSD (two args, may not be thread safe)
1416 dnl # Tru64 has BSD version, but it _is_ thread safe
1417 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1418 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1420 gethostbynamerstyle=""
1421 AC_MSG_CHECKING([gethostbyname_r() syntax])
1427 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ],
1429 AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1430 gethostbynamerstyle=GNU
1434 if test "x$gethostbynamerstyle" = "x"; then
1440 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] ,
1442 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1443 gethostbynamerstyle=SYSV
1448 if test "x$gethostbynamerstyle" = "x"; then
1454 [ gethostbyname(NULL) ],
1456 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1457 gethostbynamerstyle=BSD
1462 if test "x$gethostbynamerstyle" = "x"; then
1463 AC_MSG_RESULT([none! It must not exist, here.])
1465 AC_MSG_RESULT([${gethostbynamerstyle}-style])
1468 if test "x$gethostbynamerstyle" = "xBSD"; then
1469 AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1473 dnl # Check for non-posix solaris ctime_r (extra buflen int arg)
1475 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1476 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1478 AC_MSG_CHECKING([ctime_r() syntax])
1483 [ ctime_r(NULL, NULL, 0) ],
1485 AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1486 ctimerstyle="SOLARIS"
1490 if test "x$ctimerstyle" = "x"; then
1495 [ ctime_r(NULL, NULL) ],
1497 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1503 if test "x$ctimerstyle" = "x"; then
1504 AC_MSG_RESULT([none! It must not exist, here.])
1506 AC_MSG_RESULT([${ctimerstyle}-style])
1509 AC_SUBST(HOSTINFO, $host)
1511 dnl #############################################################
1513 dnl # 8. Checks for system services
1515 dnl #############################################################
1518 dnl # Figure out where libtool is located,
1522 AC_MSG_RESULT([top_builddir=$top_builddir])
1523 dnl # AC_SUBST(top_builddir)
1526 dnl # import libtool stuff
1528 dnl #############################################################
1530 dnl # Configure in any module directories.
1532 dnl #############################################################
1534 dnl ############################################################
1535 dnl # Remove any conflicting definitions if autoconf.h
1536 dnl # is being included by a module.
1537 dnl #############################################################
1538 AH_BOTTOM([#include <freeradius-devel/automask.h>])
1540 dnl ############################################################
1541 dnl # make modules by list
1542 dnl #############################################################
1543 if test "x$EXPERIMENTAL" = "xyes"; then
1544 for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
1545 MODULES="$MODULES $foo"
1549 dnl # make ONLY the stable modules
1551 for foo in `cat "${srcdir}"/src/modules/stable`; do
1552 MODULES="$MODULES $foo"
1556 dnl ############################################################
1557 dnl # Add autoconf subdirs, based on the module list we
1558 dnl # previously created.
1559 dnl #############################################################
1561 for bar in $MODULES; do
1562 if test -f "${srcdir}"/src/modules/$bar/configure; then
1563 mysubdirs="$mysubdirs src/modules/$bar"
1568 dnl # Don't change the variable name here. Autoconf goes bonkers
1571 AC_CONFIG_SUBDIRS($mysubdirs)
1574 dnl #############################################################
1576 dnl # Add -Werror last, so it doesn't interfere with autoconf's
1577 dnl # test programs.
1579 dnl #############################################################
1580 if test "x$werror" == "xyes"; then
1581 CFLAGS="-Werror $CFLAGS"
1584 dnl #############################################################
1586 dnl # And finally, output the results.
1588 dnl #############################################################
1589 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
1590 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
1591 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main && chmod +x checkrad radlast radtest)])
1592 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts && chmod +x rc.radiusd radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
1595 dnl # Substitute whatever libraries we found to be necessary
1598 AC_SUBST(INSTALLSTRIP)
1600 USE_SHARED_LIBS=$enable_shared
1601 AC_SUBST(USE_SHARED_LIBS)
1602 USE_STATIC_LIBS=$enable_static
1603 AC_SUBST(USE_STATIC_LIBS)
1604 AC_SUBST(STATIC_MODULES)
1608 ./src/include/build-radpaths-h \
1609 ./src/main/radsniff.mk \
1610 ./src/main/checkrad \
1611 ./src/main/radlast \
1612 ./src/main/radtest \
1613 ./scripts/rc.radiusd \
1614 ./scripts/radiusd.cron.daily \
1615 ./scripts/radiusd.cron.monthly \
1616 ./scripts/cryptpasswd \
1617 ./raddb/dictionary \
1618 ./raddb/radrelay.conf \
1619 ./raddb/radiusd.conf