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 # Check for regular expression support
751 dnl extra argument: --with-pcre-lib-dir
753 AC_ARG_WITH(rlm-pcre-lib-dir,
754 [ --with-pcre-lib-dir=DIR directory for PCRE library files []],
757 AC_MSG_ERROR(Need rlm-pcre-lib-dir)
762 pcre_lib_dir="$withval"
767 dnl extra argument: --with-pcre-include--dir
769 AC_ARG_WITH(rlm-pcre-include-dir,
770 [ --with-pcre-include-dir=DIR directory for PCRE include files []],
773 AC_MSG_ERROR(Need rlm-pcre-include-dir)
778 pcre_include_dir="$withval"
788 dnl # First look for PCRE
790 smart_try_dir=$pcre_include_dir
791 FR_SMART_CHECK_INCLUDE(pcreposix.h)
792 if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
793 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
794 AC_DEFINE(HAVE_PCREPOSIX_H, [1], [define this if we have the <pcreposix.h> header file])
798 LIBS="$LIBS -lpcreposix"
801 dnl # Then fallback to POSIX regular expressions
805 FR_SMART_CHECK_INCLUDE(regex.h)
806 if test "x$ac_cv_header_regex_h" = "xyes"; then
807 AC_DEFINE(HAVE_REGEX_H, [1], [define if we have any regex])
816 [AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)]) REGEX_EXTENDED=yes]
823 AC_SUBST(REGEX_EXTENDED)
826 dnl # other checks which require headers
828 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
830 AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
833 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
835 AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
839 dnl # Were we told to use OpenSSL, if we were and we find an error, call AC_MSG_FAILURE and exit
841 if test "x$WITH_OPENSSL" = xyes; then
843 old_LDFLAGS="$LDFLAGS"
845 OPENSSL_INCLUDE="-DNO_OPENSSL"
847 if test "x$OPENSSL_LIB_DIR" != "x"; then
848 LDFLAGS="$LDFLAGS -L$OPENSSL_LIB_DIR"
852 dnl # Check we can link to libssl
854 AC_CHECK_LIB(crypto, DH_new,
856 LIBS="-lcrypto $LIBS"
857 AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
858 AC_CHECK_LIB(ssl, SSL_new,
860 AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl).])
861 if test "x$OPENSSL_LIB_DIR" != "x"; then
862 OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
864 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
867 AC_MSG_FAILURE([failed linking to libssl])
875 dnl # Check we can find required headers
877 old_CPPFLAGS=$CPPFLAGS
878 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
879 CPPFLAGS="$CPPFLAGS -I$OPENSSL_INCLUDE_DIR"
883 dnl # Stupid RedHat shit
885 CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
898 AC_MSG_FAILURE([failed locating OpenSSL headers])
902 AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
904 [#include <openssl/crypto.h>
905 #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
914 AC_MSG_FAILURE([OpenSSL version too old])
918 if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
919 OPENSSL_INCLUDE="-I$OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
921 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
925 dnl # Now check that the header versions match the library
927 AC_MSG_CHECKING([OpenSSL library and header version consistency])
932 #include <openssl/opensslv.h>
933 #include <openssl/crypto.h>
936 if (SSLeay() == OPENSSL_VERSION_NUMBER) {
939 printf("library: %lx header: %lx... ", (unsigned long) SSLeay(), (unsigned long) OPENSSL_VERSION_NUMBER);
949 AC_MSG_FAILURE([OpenSSL library version does not match header version])
953 CPPFLAGS=$old_CPPFLAGS
955 LDFLAGS="$old_LDFLAGS"
958 AC_SUBST(OPENSSL_INCLUDE)
959 AC_SUBST(OPENSSL_LIBS)
963 dnl # Check the pcap includes for the RADIUS sniffer.
965 if test "x$PCAP_LIBS" = x; then
966 AC_MSG_NOTICE([skipping test for pcap.h.])
968 AC_CHECK_HEADER(pcap.h,
970 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
972 AC_CHECK_LIB(pcap, pcap_fopen_offline,
974 AC_DEFINE(HAVE_PCAP_FOPEN_OFFLINE, 1, [Define to 1 if you have the function pcap_fopen_offline.])
978 AC_CHECK_LIB(pcap, pcap_dump_fopen,
980 AC_DEFINE(HAVE_PCAP_DUMP_FOPEN, 1, [Define to 1 if you have the function pcap_dump_fopen.])
986 AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer.])
992 dnl #############################################################
994 dnl # 4. Checks for typedefs
996 dnl #############################################################
999 dnl # Ensure that these are defined
1007 dnl # Check for socklen_t
1009 FR_CHECK_TYPE_INCLUDE(
1011 #ifdef HAVE_SYS_TYPES_H
1012 # include <sys/types.h>
1015 #ifdef HAVE_SYS_SOCKET_H
1016 # include <sys/socket.h>
1019 socklen_t, int, [socklen_t is generally 'int' on systems which don't use it]
1023 dnl # Check for uint8_t
1025 FR_CHECK_TYPE_INCLUDE(
1027 #ifdef HAVE_INTTYPES_H
1028 # include <inttypes.h>
1031 #ifdef HAVE_STDINT_H
1032 # include <stdint.h>
1035 uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic]
1039 dnl # Check for uint16_t
1041 FR_CHECK_TYPE_INCLUDE(
1043 #ifdef HAVE_INTTYPES_H
1044 # include <inttypes.h>
1047 #ifdef HAVE_STDINT_H
1048 # include <stdint.h>
1051 uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic]
1055 dnl # Check for uint32_t
1057 FR_CHECK_TYPE_INCLUDE(
1059 #ifdef HAVE_INTTYPES_H
1060 # include <inttypes.h>
1063 #ifdef HAVE_STDINT_H
1064 # include <stdint.h>
1067 uint32_t, unsigned int, [uint32_t should be the canonical 'network integer']
1070 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [],
1072 #ifdef HAVE_NETINET_IN_H
1073 # include <netinet/in.h>
1078 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [],
1080 #ifdef HAVE_NETINET_IN_H
1081 # include <netinet/in.h>
1084 #ifdef HAVE_SYS_SOCKET_H
1085 # include <sys/socket.h>
1089 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [],
1091 #ifdef HAVE_NETINET_IN_H
1092 # include <netinet/in.h>
1096 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [],
1098 #ifdef HAVE_SYS_TYPES_H
1099 # include <sys/types.h>
1102 #ifdef HAVE_SYS_SOCKET_H
1103 # include <sys/socket.h>
1112 dnl #############################################################
1114 dnl # 5. Checks for structures and functions
1116 dnl #############################################################
1155 dnl # Check if we have utmpx.h
1156 dnl # if so, check if struct utmpx has entry ut_xtime
1157 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
1159 if test "x$ac_cv_header_utmpx_h" = "xyes"; then
1160 FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
1161 if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then
1162 AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
1167 dnl # struct ip_pktinfo
1169 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
1170 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then
1171 AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
1175 dnl # struct in6_pktinfo
1177 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
1178 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then
1179 AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
1182 dnl #############################################################
1184 dnl # 6. Checks for compiler characteristics
1186 dnl #############################################################
1189 dnl # Ensure that these are defined
1194 dnl # See if this is OS/2
1196 AC_MSG_CHECKING([type of OS])
1199 if test "$OS" = "OS/2"; then
1206 if test "x$developer" = "xyes"; then
1207 AC_MSG_NOTICE([Setting additional developer CFLAGS])
1210 dnl # Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1212 AX_CC_WDOCUMENTATION_FLAG
1213 if test "x$ax_cv_cc_wdocumentation_flag" = "xyes"; then
1214 devflags="-Wdocumentation"
1217 if test "x$GCC" = "xyes"; then
1218 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"
1222 AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1224 CFLAGS="$CFLAGS $devflags"
1226 dnl # Enable experimental modules (we want to know if code changes breaks one of them)
1228 if test "x$EXPERIMENTAL" != "xno"; then
1229 AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1234 CFLAGS="$CFLAGS -DNDEBUG"
1236 AC_MSG_RESULT([no.])
1242 dnl # append the current git hash onto the version string
1244 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1245 RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1246 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],["${RADIUSD_VERSION_COMMIT}"],[Commit HEAD at time of configuring])
1251 dnl #############################################################
1253 dnl # 7. Checks for library functions
1255 dnl #############################################################
1257 dnl Check for talloc
1258 dnl extra argument: --with-talloc-include-dir=DIR
1260 AC_ARG_WITH(talloc-include-dir,
1261 [AS_HELP_STRING([--with-talloc-include-dir=DIR],
1262 [Directory where the talloc includes may be found])],
1265 AC_MSG_ERROR([Need talloc-include-dir])
1270 talloc_include_dir="$withval"
1275 dnl # Check for talloc header files
1277 smart_try_dir="$talloc_include_dir"
1278 FR_SMART_CHECK_INCLUDE([talloc.h])
1279 if test "x$ac_cv_header_talloc_h" != "xyes"; then
1280 AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
1281 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1283 INCLUDE="${SMART_CFLAGS} ${INCLUDE}"
1284 LIBS="-ltalloc ${LIBS}"
1288 dnl # Check for libcrypt
1289 dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1291 AC_CHECK_LIB(crypt, crypt,
1295 if test "$CRYPTLIB" != ""; then
1296 AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1298 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1301 dnl Check for libcipher
1302 AC_CHECK_LIB(cipher, setkey,
1303 CRYPTLIB="${CRYPTLIB} -lcipher"
1308 dnl # Check the style of gethostbyaddr, in order of preference
1309 dnl # GNU (_r eight args)
1311 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1314 dnl # SYSV (_r six args)
1316 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1319 dnl # BSD (three args, may not be thread safe)
1321 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1324 dnl # Tru64 has BSD version, but it is thread safe
1325 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1326 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1328 gethostbyaddrrstyle=""
1329 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1333 dnl # With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1334 dnl # Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1335 dnl # override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1336 dnl # style support.
1338 AC_CHECK_DECLS([gethostbyaddr_r], [],
1340 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1341 [style of gethostbyaddr_r functions ])
1342 gethostbyaddrrstyle=BSD
1343 AC_MSG_WARN([FreeBSD overridden to BSD-style])
1353 if test "x$gethostbyaddrrstyle" = "x"; then
1359 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ],
1361 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1362 gethostbyaddrrstyle=GNU
1367 if test "x$gethostbyaddrrstyle" = "x"; then
1373 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] ,
1375 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1376 gethostbyaddrrstyle=SYSV
1382 if test "x$gethostbyaddrrstyle" = "x"; then
1388 [ gethostbyaddr(NULL, 0, 0) ],
1390 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1391 gethostbyaddrrstyle=BSD
1396 if test "x$gethostbyaddrrstyle" = "x"; then
1397 AC_MSG_RESULT([none! It must not exist, here.])
1399 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1402 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1403 AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1407 dnl # Check the style of gethostbyname, in order of preference
1408 dnl # GNU (_r seven args)
1409 dnl # SYSV (_r five args)
1410 dnl # BSD (two args, may not be thread safe)
1411 dnl # Tru64 has BSD version, but it _is_ thread safe
1412 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1413 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1415 gethostbynamerstyle=""
1416 AC_MSG_CHECKING([gethostbyname_r() syntax])
1422 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ],
1424 AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1425 gethostbynamerstyle=GNU
1429 if test "x$gethostbynamerstyle" = "x"; then
1435 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] ,
1437 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1438 gethostbynamerstyle=SYSV
1443 if test "x$gethostbynamerstyle" = "x"; then
1449 [ gethostbyname(NULL) ],
1451 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1452 gethostbynamerstyle=BSD
1457 if test "x$gethostbynamerstyle" = "x"; then
1458 AC_MSG_RESULT([none! It must not exist, here.])
1460 AC_MSG_RESULT([${gethostbynamerstyle}-style])
1463 if test "x$gethostbynamerstyle" = "xBSD"; then
1464 AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1468 dnl # Check for non-posix solaris ctime_r (extra buflen int arg)
1470 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1471 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1473 AC_MSG_CHECKING([ctime_r() syntax])
1478 [ ctime_r(NULL, NULL, 0) ],
1480 AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1481 ctimerstyle="SOLARIS"
1485 if test "x$ctimerstyle" = "x"; then
1490 [ ctime_r(NULL, NULL) ],
1492 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1498 if test "x$ctimerstyle" = "x"; then
1499 AC_MSG_RESULT([none! It must not exist, here.])
1501 AC_MSG_RESULT([${ctimerstyle}-style])
1504 AC_SUBST(HOSTINFO, $host)
1506 dnl #############################################################
1508 dnl # 8. Checks for system services
1510 dnl #############################################################
1513 dnl # Figure out where libtool is located,
1517 AC_MSG_RESULT([top_builddir=$top_builddir])
1518 dnl # AC_SUBST(top_builddir)
1521 dnl # import libtool stuff
1523 dnl #############################################################
1525 dnl # Configure in any module directories.
1527 dnl #############################################################
1529 dnl ############################################################
1530 dnl # Remove any conflicting definitions if autoconf.h
1531 dnl # is being included by a module.
1532 dnl #############################################################
1533 AH_BOTTOM([#include <freeradius-devel/automask.h>])
1535 dnl ############################################################
1536 dnl # make modules by list
1537 dnl #############################################################
1538 if test "x$EXPERIMENTAL" = "xyes"; then
1539 for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
1540 MODULES="$MODULES $foo"
1544 dnl # make ONLY the stable modules
1546 for foo in `cat "${srcdir}"/src/modules/stable`; do
1547 MODULES="$MODULES $foo"
1551 dnl ############################################################
1552 dnl # Add autoconf subdirs, based on the module list we
1553 dnl # previously created.
1554 dnl #############################################################
1556 for bar in $MODULES; do
1557 if test -f "${srcdir}"/src/modules/$bar/configure; then
1558 mysubdirs="$mysubdirs src/modules/$bar"
1563 dnl # Don't change the variable name here. Autoconf goes bonkers
1566 AC_CONFIG_SUBDIRS($mysubdirs)
1569 dnl #############################################################
1571 dnl # Add -Werror last, so it doesn't interfere with autoconf's
1572 dnl # test programs.
1574 dnl #############################################################
1575 if test "x$werror" == "xyes"; then
1576 CFLAGS="-Werror $CFLAGS"
1579 dnl #############################################################
1581 dnl # And finally, output the results.
1583 dnl #############################################################
1584 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
1585 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
1586 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main && chmod +x checkrad radlast radtest)])
1587 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts && chmod +x rc.radiusd radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
1590 dnl # Substitute whatever libraries we found to be necessary
1593 AC_SUBST(INSTALLSTRIP)
1595 USE_SHARED_LIBS=$enable_shared
1596 AC_SUBST(USE_SHARED_LIBS)
1597 USE_STATIC_LIBS=$enable_static
1598 AC_SUBST(USE_STATIC_LIBS)
1599 AC_SUBST(STATIC_MODULES)
1603 ./src/include/build-radpaths-h \
1604 ./src/main/radsniff.mk \
1605 ./src/main/checkrad \
1606 ./src/main/radlast \
1607 ./src/main/radtest \
1608 ./scripts/rc.radiusd \
1609 ./scripts/radiusd.cron.daily \
1610 ./scripts/radiusd.cron.monthly \
1611 ./scripts/cryptpasswd \
1612 ./raddb/dictionary \
1613 ./raddb/radrelay.conf \
1614 ./raddb/radiusd.conf