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 #############################################################
36 RADIUSD_MAJOR_VERSION=`cat VERSION | cut -f1 -d.`
37 RADIUSD_MINOR_VERSION=`cat VERSION | cut -f2 -d.`
38 RADIUSD_INCRM_VERSION=`cat VERSION | cut -f3 -d. | sed 's/[[\.-]].*$//'`
40 RADIUSD_VERSION=`printf "%02i%02i%02i" $RADIUSD_MAJOR_VERSION $RADIUSD_MINOR_VERSION $RADIUSD_INCRM_VERSION`
43 dnl # Still useful for custom builds
45 RADIUSD_VERSION_STRING=`cat VERSION`
48 dnl # Add definitions to Make.inc as it's used by various build targets
50 AC_SUBST([RADIUSD_VERSION_STRING])
53 dnl # Add definitions to autoconf.h, so that the headers that we install
54 dnl # contain the version number of the server.
56 AC_DEFINE_UNQUOTED([RADIUSD_VERSION], [${RADIUSD_VERSION}], [Version integer in format <ma><ma><mi><mi><in><in>])
57 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_STRING], ["${RADIUSD_VERSION_STRING}"], [Raw version string from VERSION file])
59 dnl #############################################################
61 dnl # Override some of the default autoconf variables such as
62 dnl # CFLAGS if were building in developer mode
64 dnl #############################################################
67 dnl # Enable developer features like debugging symbols.
68 dnl # These checks must be done before expanding the AC_PROG_CC
69 dnl # and AC_PROG_CXX macros.
71 AC_ARG_ENABLE(developer,
72 [ --enable-developer enables features of interest to developers.],
73 [ case "$enableval" in
83 dnl # Turn on the developer flag when taken from a git checkout (not a release)
85 if test -d $srcdir/.git; then
86 if test "x$developer" != "xno"; then
87 AC_MSG_NOTICE([found .git directory, enabling developer build implicitly, disable with --disable-developer])
93 dnl # Autoconf sets -O2 and -g by default, but this is a PITA for debugging
94 dnl # so we remove the defaults if were building in developer mode, and set
95 dnl # -g3 so nice things like macro values are included. Other arguments are
96 dnl # added later when we know what compiler were using.
98 if test "x$developer" = "xyes"; then
102 dnl #############################################################
104 dnl # 0. Checks for compiler, libtool, and command line options.
106 dnl #############################################################
109 dnl # Get system information
114 dnl # Check for GNU cc
120 dnl # check for AIX, to allow us to use some BSD functions
121 dnl # must be before macros that call the compiler.
125 AC_PROG_GCC_TRADITIONAL
130 dnl # Definitive check for whether the compiler is clang
133 if test "x$ax_cv_cc_clang" = "xyes"; then
134 AC_SUBST(clang_path, "$CC")
136 AC_SUBST(clang_path, "")
141 dnl # Set Default CFLAGS for GCC compatible compilers
143 if test "x$GCC" = "xyes"; then
144 CFLAGS="$CFLAGS -Wall -std=c99 -D_GNU_SOURCE"
148 dnl # -Qunused-arguments means the compiler won't complain about unsupported arguments
150 AX_CC_QUNUSED_ARGUMENTS_FLAG
151 if test "x$ax_cv_cc_qunused_arguments_flag" = "xyes"; then
152 CFLAGS="$CFLAGS -Qunused-arguments"
153 LDFLAGS="$LDFLAGS -Qunused-arguments"
157 dnl # Compile in large (2G+) file support.
162 dnl # check for system bytesex
163 dnl # AC_DEFINES WORDS_BIGENDIAN
166 [AC_DEFINE(FR_BIG_ENDIAN, 1, [Define if your processor stores words with the most significant byte first])],
167 [AC_DEFINE(FR_LITTLE_ENDIAN, 1, [Define if your processor stores words with the least significant byte first])]
173 AC_CHECK_PROG(GMAKE, gmake, yes, no)
174 if test $GMAKE = no; then
175 AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
177 AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
179 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
180 if test -z "$makever"; then
181 AC_MSG_ERROR([GNU Make is not installed. Please download and install it from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.])
185 dnl # autoconf explicitly sets MAKEFLAGS and MFLAGS to '' even though we
186 dnl # didn't tell it to, so we have to use FR_MAKEFLAGS.
188 dnl # determine the number of cores available and set the number of build
189 dnl # processes appropriately.
193 dnl # Temporarily disabled because test and installation targets do not
194 dnl # have dependencies set up correctly for multiple build processes.
195 dnl if test "x$ax_cv_system_cores" != "x"; then
196 dnl : ${FR_MAKEFLAGS=-j$ax_cv_system_cores}
198 AC_SUBST(FR_MAKEFLAGS)
201 dnl # See if we have Git.
203 AC_CHECK_PROG(GIT, git, yes, no)
205 dnl Put this in later, when all distributed modules use autoconf.
206 dnl AC_ARG_WITH(disablemodulefoo,
207 dnl [ --without-rlm_foo Disables module compilation. Module list:]
208 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
209 dnl sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
210 dnl awk '{print " "$0}']))
212 AC_ARG_ENABLE(strict-dependencies,
213 [ --enable-strict-dependencies fail configure on lack of module dependancy.])
215 AC_ARG_ENABLE(werror,
216 [ --enable-werror causes the build to fail if any warnings are generated.],
217 [ case "$enableval" in
227 dnl # extra argument: --with-docdir
229 docdir='${datadir}/doc/freeradius'
230 AC_MSG_CHECKING([docdir])
232 [ --with-docdir=DIR directory for documentation [DATADIR/doc/freeradius] ],
239 [[\\/$]]* | ?:[[\\/]]* )
243 AC_MSG_ERROR([expected an absolute directory name for --with-docdir: $withval])
248 AC_MSG_RESULT($docdir)
249 if test "x$docdir" = xno; then
250 AC_MSG_WARN([Documentation files will NOT be installed.])
254 dnl # extra argument: --with-logdir
256 logdir='${localstatedir}/log/radius'
257 AC_MSG_CHECKING(logdir)
259 [ --with-logdir=DIR directory for logfiles [LOCALSTATEDIR/log/radius] ],
262 AC_MSG_ERROR([Need logdir])
266 [[\\/$]]* | ?:[[\\/]]* )
270 AC_MSG_ERROR([expected an absolute directory name for --with-logdir: $withval])
275 AC_MSG_RESULT($logdir)
278 dnl # extra argument: --with-radacctdir
280 radacctdir='${logdir}/radacct'
281 AC_MSG_CHECKING(radacctdir)
282 AC_ARG_WITH(radacctdir,
283 [ --with-radacctdir=DIR directory for detail files [LOGDIR/radacct] ],
286 AC_MSG_ERROR([Need radacctdir])
290 [[\\/$]]* | ?:[[\\/]]* )
291 radacctdir="$withval"
294 AC_MSG_ERROR([expected an absolute directory name for --with-radacctdir: $withval])
299 AC_MSG_RESULT($radacctdir)
302 dnl # extra argument: --with-raddbdir
304 raddbdir='${sysconfdir}/raddb'
305 AC_MSG_CHECKING(raddbdir)
306 AC_ARG_WITH(raddbdir,
307 [ --with-raddbdir=DIR directory for config files [SYSCONFDIR/raddb] ],
310 AC_MSG_ERROR([Need raddbdir])
314 [[\\/$]]* | ?:[[\\/]]* )
318 AC_MSG_ERROR([expected an absolute directory name for --with-raddbdir: $withval])
323 AC_MSG_RESULT($raddbdir)
326 dnl # extra argument: --with-dictdir
328 dictdir='${datarootdir}/freeradius'
329 AC_MSG_CHECKING(dictdir)
331 [ --with-dictdir=DIR directory for dictionary files [DATAROOTDIR/freeradius] ],
334 AC_MSG_ERROR([Need dictdir])
338 [[\\/$]]* | ?:[[\\/]]* )
342 AC_MSG_ERROR([expected an absolute directory name for --with-dictdir: $withval])
347 AC_MSG_RESULT($dictdir)
349 modconfdir='${raddbdir}/mods-config'
353 dnl # extra argument: --with-ascend-binary
355 WITH_ASCEND_BINARY=yes
356 AC_ARG_WITH(ascend-binary,
357 [ --with-ascend-binary include support for Ascend binary filter attributes (default=yes)],
362 WITH_ASCEND_BINARY=no
365 if test "x$WITH_ASCEND_BINARY" = "xyes"; then
366 AC_DEFINE(WITH_ASCEND_BINARY, [1], [include support for Ascend binary filter attributes])
370 dnl # extra argument: --with-threads
374 [ --with-threads use threads, if available. (default=yes) ],
384 dnl # extra argument: --with-tcp
388 [ --with-tcp compile in TCP support. (default=yes)],
396 if test "x$WITH_TCP" = "xyes"; then
397 AC_DEFINE(WITH_TCP, [1], [define if you want TCP support (For RADSec et al)])
401 dnl # extra argument: --with-vmps
405 [ --with-vmps compile in VMPS support. (default=yes)],
413 if test "x$WITH_VMPS" = "xyes"; then
414 AC_DEFINE(WITH_VMPS, [1], [define if you want VMPS support])
418 dnl # extra argument: --with-dhcp
422 [ --with-dhcp compile in DHCP support. (default=yes)],
430 if test "x$WITH_DHCP" = "xyes"; then
431 AC_DEFINE(WITH_DHCP, [1], [define if you want DHCP support])
435 dnl # Allow the user to specify a list of modules to be linked
436 dnl # statically to the server.
439 AC_ARG_WITH(static_modules,
440 [ --with-static-modules=QUOTED-MODULE-LIST],[
441 for i in $withval; do
442 STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
447 AC_ARG_WITH(shared-libs,
448 [AS_HELP_STRING([--with-shared-libs ],
449 [build dynamic libraries and link against them. (default=yes)])],
460 [ --with-modules=QUOTED-MODULE-LIST],[
461 for i in $withval; do
462 MODULES="$MODULES $i"
467 dnl # extra argument: --with-experimental-modules
470 AC_ARG_WITH(experimental-modules,
471 [AS_HELP_STRING([--with-experimental-modules],
472 [use experimental and unstable modules. (default=no, unless --enable-developer=yes)])],
485 dnl # extra argument: --with-udpfromto
488 AC_ARG_WITH(udpfromto,
489 [ --with-udpfromto compile in UDPFROMTO support. (default=yes)],
499 if test "x$WITH_UDPFROMTO" = "xyes"; then
500 AC_DEFINE(WITH_UDPFROMTO, [], [define if you want udpfromto])
504 dnl # These next two arguments don't actually do anything. They're
505 dnl # place holders so that the top-level configure script can tell
506 dnl # the user how to configure lower-level modules
510 dnl # extra argument: --with-rlm-FOO-lib-dir
512 AC_ARG_WITH(rlm-FOO-lib-dir,
513 [AS_HELP_STRING([--with-rlm-FOO-lib-dir=DIR],
514 [directory in which to look for library files used by module FOO])],
522 dnl # extra argument: --with-rlm-FOO-include-dir
524 AC_ARG_WITH(rlm-FOO-include-dir,
525 [AS_HELP_STRING([--with-rlm-FOO-include-dir=DIR],
526 [directory in which to look for include files used by module FOO])],
534 dnl # extra argument: --with-openssl
538 [ --with-openssl use OpenSSL. (default=yes)],
550 dnl # extra argument: --with-openssl-lib-dir=dir
553 AC_ARG_WITH(openssl-lib-dir,
554 [AS_HELP_STRING([--with-openssl-lib-dir=DIR],
555 [directory to look for OpenSSL library files])],
557 *) openssl_lib_dir="$withval"
563 dnl # extra argument: --with-openssl-includes=dir
566 AC_ARG_WITH(openssl-include-dir,
567 [AS_HELP_STRING([--with-openssl-include-dir=DIR],
568 [directory to look for OpenSSL include files])],
570 *) openssl_include_dir="$withval"
576 dnl # extra argument: --disable-openssl-version-check
578 AC_ARG_ENABLE(openssl-version-check,
579 [AS_HELP_STRING([--disable-openssl-version-check],
580 [disable vulnerable OpenSSL version check])]
582 if test "x$enable_openssl_version_check" != "xno"; then
583 AC_DEFINE(ENABLE_OPENSSL_VERSION_CHECK, [1],
584 [Define to 1 to have OpenSSL version check enabled])
585 openssl_version_check_config="\
587 # allow_vulnerable_openssl: Allow the server to start with
588 # versions of OpenSSL known to have critical vulnerabilities.
590 # This check is based on the version number reported by libssl
591 # and may not reflect patches applied to libssl by
592 # distribution maintainers.
594 allow_vulnerable_openssl = no"
596 openssl_version_check_config=
598 AC_SUBST([openssl_version_check_config])
601 dnl #############################################################
603 dnl # 1. Checks for programs
605 dnl #############################################################
608 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
609 if test "x$ac_cv_path_PERL" = "x"; then
610 AC_MSG_WARN([perl not found - Simultaneous-Use and checkrad may not work])
612 AC_PATH_PROG(SNMPGET, snmpget)
613 if test "x$ac_cv_path_SNMPGET" = "x"; then
614 AC_MSG_WARN([snmpget not found - Simultaneous-Use and checkrad may not work])
617 AC_PATH_PROG(SNMPWALK, snmpwalk)
618 if test "x$ac_cv_path_SNMPWALK" = "x"; then
619 AC_MSG_WARN([snmpwalk not found - Simultaneous-Use and checkrad may not work])
622 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
625 dnl # FIXME This is truly gross.
627 missing_dir=`cd $ac_aux_dir && pwd`
628 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
629 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
630 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
632 AC_PATH_PROG(LOCATE,locate)
633 AC_PATH_PROG(DIRNAME,dirname)
634 AC_PATH_PROG(GREP,grep)
636 dnl #############################################################
638 dnl # 2. Checks for libraries
640 dnl #############################################################
643 dnl extra argument: --with-talloc-lib-dir=DIR
645 AC_ARG_WITH(talloc-lib-dir,
646 [AS_HELP_STRING([--with-talloc-lib-dir=DIR],
647 [directory in which to look for talloc library files])],
650 AC_MSG_ERROR([Need talloc-lib-dir])
655 talloc_lib_dir="$withval"
659 dnl extra argument: --with-talloc-include-dir=DIR
661 AC_ARG_WITH(talloc-include-dir,
662 [AS_HELP_STRING([--with-talloc-include-dir=DIR],
663 [directory in which to look for talloc include files])],
666 AC_MSG_ERROR([Need talloc-include-dir])
671 talloc_include_dir="$withval"
675 smart_try_dir="$talloc_lib_dir"
676 FR_SMART_CHECK_LIB(talloc, _talloc)
677 if test "x$ac_cv_lib_talloc__talloc" != "xyes"; then
678 AC_MSG_WARN([talloc library not found. Use --with-talloc-lib-dir=<path>.])
679 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
682 TALLOC_LIBS="${smart_lib}"
683 TALLOC_LDFLAGS="${smart_ldflags}"
684 AC_SUBST(TALLOC_LIBS)
685 AC_SUBST(TALLOC_LDFLAGS)
689 dnl # If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
692 if test "x$WITH_THREADS" = "xyes"; then
693 if test $ac_cv_prog_suncc = "yes"; then
697 AC_CHECK_HEADERS(pthread.h, [],
704 dnl # pthread stuff is usually in -lpthread
705 dnl # or in -lc_r, on *BSD
707 dnl # On Some systems, we need extra pre-processor flags, to get them to
708 dnl # to do the threading properly.
710 if test "x$WITH_THREADS" != "xno"; then
711 AC_CHECK_LIB(pthread, pthread_create,
714 CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
715 LIBS="-lpthread $LIBS"
718 dnl # -pthread should add all required CPP definitions and linker
719 dnl # arguments. But not all compilers support it, or some compilers
720 dnl # only support it on certain platforms.
723 if test "x$ax_cv_cc_pthread_flag" != 'xyes'; then
724 CFLAGS="$CFLAGS -pthread"
730 dnl # Check for libc_r which used to be the threading library used
731 dnl # for FreeBSD. Internet says it may be deprecated, but if we
732 dnl # can't find lpthread it's probably worth checking.
734 if test "x$HAVE_LPTHREAD" != "xyes"; then
735 AC_CHECK_LIB(c_r, pthread_create,
737 CFLAGS="$CFLAGS -D_THREAD_SAFE"
740 dnl # -pthread should add all required CPP definitions and linker
741 dnl # arguments. But not all compilers support it, or some compilers
742 dnl # only support it on certain platforms.
745 if test "x$ax_cv_cc_pthread_flag" != 'xyes'; then
748 CFLAGS="$CFLAGS -pthread"
751 [ fail=[-lc_r or -lpthread] ]
756 if test "x$WITH_THREADS" != "xyes"; then
757 AC_MSG_WARN([silently not building with thread support.])
758 AC_MSG_WARN([FAILURE: thread support requires: $fail.])
760 AC_DEFINE(WITH_THREADS, [1], [define if you want thread support])
765 dnl # If we have NO pthread libraries, remove any knowledge of threads.
767 if test "x$WITH_THREADS" != "xyes"; then
769 ac_cv_header_pthread_h="no"
773 dnl # We need sem_init() and friends, as they're the friendliest
774 dnl # semaphore functions for threading.
776 dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
777 dnl # Some systems have them in -lsem
778 dnl # Solaris has them in -lposix4
779 dnl # NetBSD has them in -lsemaphore
782 AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt semaphore,
784 [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]])]
789 dnl # Check if we have -ldl
791 AC_CHECK_LIB(dl, dlopen)
794 dnl # Check if we need -lsocket
796 AC_CHECK_LIB(socket, getsockname)
799 dnl # Check for -lresolv
800 dnl # This library may be needed later.
802 AC_CHECK_LIB(resolv, inet_aton)
805 dnl # Check if we need -lnsl. Usually if we want to
806 dnl # link against -lsocket we need to include -lnsl as well.
808 AC_CHECK_LIB(nsl, inet_ntoa)
809 AC_CHECK_LIB(ws2_32, htonl)
812 dnl # Check the pcap library for the RADIUS sniffer.
814 dnl extra argument: --with-pcap-lib-dir=DIR
816 AC_ARG_WITH(pcap-lib-dir,
817 [AS_HELP_STRING([--with-pcap-lib-dir=DIR],
818 [directory in which to look for pcap library files])],
821 AC_MSG_ERROR([Need pcap-lib-dir])
826 pcap_lib_dir="$withval"
830 dnl extra argument: --with-pcap-include-dir=DIR
832 AC_ARG_WITH(pcap-include-dir,
833 [AS_HELP_STRING([--with-pcap-include-dir=DIR],
834 [directory in which to look for pcap include files])],
837 AC_MSG_ERROR([Need pcap-include-dir])
842 pcap_include_dir="$withval"
846 smart_try_dir="$pcap_lib_dir"
847 FR_SMART_CHECK_LIB(pcap, pcap_open_live)
848 if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes"; then
849 AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer, and ARP listener. Use --with-pcap-lib-dir=<path>.])
851 AC_DEFINE(HAVE_LIBPCAP, 1,
852 [Define to 1 if you have the `pcap' library (-lpcap).]
862 PCAP_LIBS="${smart_lib}"
863 PCAP_LDFLAGS="${smart_ldflags}"
865 dnl Set by FR_SMART_CHECK_LIB
868 dnl Check for collectdclient
869 dnl extra argument: --with-collectdclient-lib-dir=DIR
870 collectdclient_lib_dir=
871 AC_ARG_WITH(collectdclient-lib-dir,
872 [AS_HELP_STRING([--with-collectdclient-lib-dir=DIR],
873 [directory in which to look for collectdclient library files])],
876 AC_MSG_ERROR([Need collectdclient-lib-dir])
881 collectdclient_lib_dir="$withval"
885 dnl extra argument: --with-collectdclient-include-dir=DIR
886 collectdclient_include_dir=
887 AC_ARG_WITH(collectdclient-include-dir,
888 [AS_HELP_STRING([--with-collectdclient-include-dir=DIR],
889 [directory in which to look for collectdclient include files])],
892 AC_MSG_ERROR([Need collectdclient-include-dir])
897 collectdclient_include_dir="$withval"
901 smart_try_dir="$collectdclient_lib_dir"
902 FR_SMART_CHECK_LIB(collectdclient, lcc_connect)
903 if test "x$ac_cv_lib_collectdclient_lcc_connect" != "xyes"; then
904 AC_MSG_WARN([collectdclient library not found. Use --with-collectdclient-lib-dir=<path>.])
906 COLLECTDC_LIBS="${smart_lib}"
907 COLLECTDC_LDFLAGS="${smart_ldflags}"
909 dnl Set by FR_SMART_CHECKLIB
913 dnl extra argument: --with-cap-lib-dir=DIR
915 AC_ARG_WITH(cap-lib-dir,
916 [AS_HELP_STRING([--with-cap-lib-dir=DIR],
917 [directory in which to look for cap library files])],
920 AC_MSG_ERROR([Need cap-lib-dir])
925 cap_lib_dir="$withval"
929 dnl extra argument: --with-cap-include-dir=DIR
931 AC_ARG_WITH(cap-include-dir,
932 [AS_HELP_STRING([--with-cap-include-dir=DIR],
933 [directory in which to look for cap include files])],
936 AC_MSG_ERROR([Need cap-include-dir])
941 cap_include_dir="$withval"
945 smart_try_dir="$cap_lib_dir"
946 FR_SMART_CHECK_LIB(cap, cap_get_proc)
947 if test "x$ac_cv_lib_cap_cap_get_proc" != "xyes"; then
948 AC_MSG_WARN([cap library not found, debugger checks will not be enabled. Use --with-cap-lib-dir=<path>.])
950 AC_DEFINE(HAVE_LIBCAP, 1,
951 [Define to 1 if you have the `cap' library (-lcap).]
958 dnl #############################################################
960 dnl # 3. Checks for header files
962 dnl #############################################################
965 dnl # Check for talloc header files
967 smart_try_dir="$talloc_include_dir"
968 FR_SMART_CHECK_INCLUDE([talloc.h])
969 if test "x$ac_cv_header_talloc_h" != "xyes"; then
970 AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
971 AC_MSG_ERROR([FreeRADIUS requires libtalloc])
975 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
976 dnl # getopt will be #included, but won't link. <sigh>
980 CFLAGS="$CFLAGS -D_ALL_SOURCE"
983 CFLAGS="$CFLAGS -DDARWIN"
984 LIBS="-framework DirectoryService $LIBS"
985 AC_DEFINE([__APPLE_USE_RFC_3542], 1, [Force OSX >= 10.7 Lion to use RFC2292 IPv6 socket options])
1042 dnl # FreeBSD requires sys/socket.h before net/if.h
1044 AC_CHECK_HEADERS(net/if.h, [], [],
1046 #ifdef HAVE_SYS_SOCKET_H
1047 # include <sys/socket.h>
1053 dnl # other checks which require headers
1055 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
1057 AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
1060 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
1062 AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
1066 dnl # Were we told to use OpenSSL, if we were and we find an error, call AC_MSG_FAILURE and exit
1068 if test "x$WITH_OPENSSL" = xyes; then
1072 dnl # Apparently OpenSSL will attempt to build with kerberos if we don't pass this?!
1074 CFLAGS="$CFLAGS -DOPENSSL_NO_KRB5"
1077 dnl # Check we can link to libcrypto and libssl
1079 smart_try_dir="$openssl_lib_dir"
1080 FR_SMART_CHECK_LIB(crypto, DH_new)
1081 if test "x$ac_cv_lib_crypto_DH_new" = "xyes"; then
1082 AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
1083 OPENSSL_LIBS="$smart_lib"
1084 OPENSSL_LDFLAGS="$smart_ldflags"
1086 FR_SMART_CHECK_LIB(ssl, SSL_new)
1087 if test "x$ac_cv_lib_ssl_SSL_new" != "xyes"; then
1088 AC_MSG_FAILURE([failed linking to libssl. Use --with-openssl-lib-dir=<path>, or --with-openssl=no (builds without OpenSSL)])
1090 AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl).])
1091 OPENSSL_LIBS="$OPENSSL_LIBS $smart_lib"
1093 if test "$OPENSSL_LDFLAGS" != "$smart_ldflags"; then
1094 AC_MSG_FAILURE(["inconsistent LDFLAGS between -lssl '$smart_ldflags' and -lcrypto '$OPENSSL_LDFLAGS'"])
1098 AC_MSG_FAILURE([failed linking to libcrypto. Use --with-openssl-lib-dir=<path>, or --with-openssl=no (builds without OpenSSL)])
1101 smart_try_dir="$openssl_include_dir"
1102 FR_SMART_CHECK_INCLUDE(openssl/ssl.h)
1103 if test "x$ac_cv_header_openssl_ssl_h" = "xyes"; then
1104 AC_DEFINE(HAVE_OPENSSL_SSL_H, 1, [Define to 1 if you have the <openssl/ssl.h> header file.])
1119 [ OPENSSL_CPPFLAGS="$smart_include" ],
1121 AC_MSG_FAILURE([failed locating OpenSSL headers. Use --with-openssl-include-dir=<path>, or --with-openssl=no (builds without OpenSSL)])
1125 AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
1127 [#include <openssl/crypto.h>
1128 #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
1137 AC_MSG_FAILURE([OpenSSL version too old])
1142 dnl # CPPFLAGS are passed to the compiler first, so we use
1143 dnl # them to ensure things like --sysroot don't override the
1144 dnl # library location we discovered previously.
1146 old_CPPFLAGS="$CPPFLAGS"
1147 CPPFLAGS="$OPENSSL_CPPFLAGS $CPPFLAGS"
1150 dnl # Now check that the header versions match the library
1152 AC_MSG_CHECKING([OpenSSL library and header version consistency])
1157 #include <openssl/opensslv.h>
1158 #include <openssl/crypto.h>
1161 printf("library: %lx header: %lx... ", (unsigned long) SSLeay(), (unsigned long) OPENSSL_VERSION_NUMBER);
1162 if (SSLeay() == OPENSSL_VERSION_NUMBER) {
1174 AC_MSG_FAILURE([OpenSSL library version does not match header version])
1177 AC_MSG_RESULT([cross-compiling (assuming yes)])
1181 dnl # Check if the new HMAC_CTX interface is defined
1184 SSL_get_client_random \
1185 SSL_get_server_random \
1186 SSL_SESSION_get_master_key \
1189 ASN1_STRING_get0_data \
1190 CONF_modules_load_file \
1191 CRYPTO_set_id_callback \
1192 CRYPTO_set_locking_callback
1194 CPPFLAGS="$old_CPPFLAGS"
1198 AC_SUBST(OPENSSL_LIBS)
1199 AC_SUBST(OPENSSL_LDFLAGS)
1200 AC_SUBST(OPENSSL_CPPFLAGS)
1201 export OPENSSL_LIBS OPENSSL_LDFLAGS OPENSSL_CPPFLAGS
1205 dnl # Check the pcap includes for the RADIUS sniffer.
1207 if test "x$PCAP_LIBS" = x; then
1208 AC_MSG_NOTICE([skipping test for pcap.h.])
1211 dnl # Check for pcap header files
1213 smart_try_dir="$pcap_include_dir"
1214 FR_SMART_CHECK_INCLUDE([pcap.h])
1215 if test "x$ac_cv_header_pcap_h" == "xyes"; then
1216 AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1218 AC_SUBST(PCAP_LDFLAGS)
1220 AC_MSG_WARN([pcap headers not found, silently disabling the RADIUS sniffer, and ARP listener. Use --with-pcap-include-dir=<path>.])
1224 dnl Check for collectd-client
1225 if test "x$COLLECTDC_LIBS" = x; then
1226 AC_MSG_NOTICE([skipping test for collectd/client.h.])
1229 dnl # Check for collectd-client header files
1231 smart_try_dir="$collectdclient_include_dir"
1232 FR_SMART_CHECK_INCLUDE([collectd/client.h])
1233 if test "x$ac_cv_header_collectd_client_h" == "xyes"; then
1234 AC_DEFINE(HAVE_COLLECTDC_H, 1, [Define to 1 if you have the `collectdclient' library (-lcollectdclient).])
1235 AC_SUBST(COLLECTDC_LIBS)
1236 AC_SUBST(COLLECTDC_LDFLAGS)
1238 AC_MSG_WARN([collectdclient headers not found. Use --with-collectdclient-include-dir=<path>.])
1243 dnl # Check the CAP includes for debugger checks
1245 if test "x$HAVE_LIBCAP" = x; then
1246 AC_MSG_NOTICE([skipping test for cap.h.])
1249 dnl # Check for CAP header files
1251 smart_try_dir="$cap_include_dir"
1252 FR_SMART_CHECK_INCLUDE([sys/capability.h])
1253 if test "x$ac_cv_header_sys_capability_h" == "xyes"; then
1254 AC_DEFINE(HAVE_CAPABILITY_H, 1, [Define to 1 if you have the <sys/capability.h> header file.])
1256 AC_MSG_WARN([cap headers not found, will not perform debugger checks. Use --with-cap-include-dir=<path>.])
1260 dnl #############################################################
1262 dnl # 4. Checks for typedefs
1264 dnl #############################################################
1267 dnl # Ensure that these are defined
1275 dnl # Check for socklen_t
1277 FR_CHECK_TYPE_INCLUDE(
1279 #ifdef HAVE_SYS_TYPES_H
1280 # include <sys/types.h>
1283 #ifdef HAVE_SYS_SOCKET_H
1284 # include <sys/socket.h>
1287 socklen_t, int, [socklen_t is generally 'int' on systems which don't use it]
1291 dnl # Check for uint8_t
1293 FR_CHECK_TYPE_INCLUDE(
1295 #ifdef HAVE_INTTYPES_H
1296 # include <inttypes.h>
1299 #ifdef HAVE_STDINT_H
1300 # include <stdint.h>
1303 uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic]
1307 dnl # Check for uint16_t
1309 FR_CHECK_TYPE_INCLUDE(
1311 #ifdef HAVE_INTTYPES_H
1312 # include <inttypes.h>
1315 #ifdef HAVE_STDINT_H
1316 # include <stdint.h>
1319 uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic]
1323 dnl # Check for uint32_t
1325 FR_CHECK_TYPE_INCLUDE(
1327 #ifdef HAVE_INTTYPES_H
1328 # include <inttypes.h>
1331 #ifdef HAVE_STDINT_H
1332 # include <stdint.h>
1335 uint32_t, unsigned int, [uint32_t should be the canonical 'network integer']
1339 dnl # Check for uint64_t
1341 FR_CHECK_TYPE_INCLUDE(
1343 #ifdef HAVE_INTTYPES_H
1344 # include <inttypes.h>
1347 #ifdef HAVE_STDINT_H
1348 # include <stdint.h>
1351 uint64_t, unsigned long long, [uint64_t is required for larger counters]
1355 dnl # Check for __uint128_t (compiler builtin)
1357 AC_CHECK_TYPE(__uint128_t, AC_DEFINE(HAVE___UINT128_T, 1, [compiler specific 128 bit unsigned integer]), [], [])
1360 dnl # Check for uint128_t (fictitious future data type)
1362 AC_CHECK_TYPE(uint128_t, AC_DEFINE(HAVE_UINT128_T, 1, [128 bit unsigned integer]), [],
1364 #ifdef HAVE_INTTYPES_H
1365 # include <inttypes.h>
1368 #ifdef HAVE_STDINT_H
1369 # include <stdint.h>
1374 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [],
1376 #ifdef HAVE_NETINET_IN_H
1377 # include <netinet/in.h>
1382 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [],
1384 #ifdef HAVE_NETINET_IN_H
1385 # include <netinet/in.h>
1388 #ifdef HAVE_SYS_SOCKET_H
1389 # include <sys/socket.h>
1393 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [],
1395 #ifdef HAVE_NETINET_IN_H
1396 # include <netinet/in.h>
1400 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [],
1402 #ifdef HAVE_SYS_TYPES_H
1403 # include <sys/types.h>
1406 #ifdef HAVE_SYS_SOCKET_H
1407 # include <sys/socket.h>
1417 dnl # Check for sig_t
1419 dnl # FR_CHECK_TYPE_INCLUDE doesn't work for callbacks as it doesn't produce typedefs
1421 AC_MSG_CHECKING([if sig_t is defined])
1425 #ifdef HAVE_SIGNAL_H
1426 # include <signal.h>
1436 AC_DEFINE(HAVE_SIG_T, 1, [Define if the type sig_t is defined by signal.h])
1443 dnl #############################################################
1445 dnl # 5. Checks for structures and functions
1447 dnl #############################################################
1498 dnl # Check if we have utmpx.h
1499 dnl # if so, check if struct utmpx has entry ut_xtime
1500 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
1502 if test "x$ac_cv_header_utmpx_h" = "xyes"; then
1503 FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
1504 if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then
1505 AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
1510 dnl # struct ip_pktinfo
1512 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
1513 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then
1514 AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
1518 dnl # struct in6_pktinfo
1520 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
1521 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then
1522 AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
1526 dnl # Check for htonll and htonlll
1528 AC_MSG_CHECKING([if htonll is defined])
1532 #include <sys/types.h>
1533 #include <netinet/in.h>
1541 AC_DEFINE(HAVE_HTONLL, 1, [Define if the function (or macro) htonll exists.])
1548 AC_MSG_CHECKING([if htonlll is defined])
1552 #include <sys/types.h>
1553 #include <netinet/in.h>
1561 AC_DEFINE(HAVE_HTONLLL, 1, [Define if the function (or macro) htonlll exists.])
1568 dnl #############################################################
1570 dnl # 6. Checks for compiler characteristics
1572 dnl #############################################################
1575 dnl # Ensure that these are defined
1580 dnl # See if this is OS/2
1582 AC_MSG_CHECKING([type of OS])
1585 if test "$OS" = "OS/2"; then
1592 if test "x$developer" = "xyes"; then
1593 AC_MSG_NOTICE([Setting additional developer CFLAGS])
1596 dnl # Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1598 AX_CC_WDOCUMENTATION_FLAG
1599 if test "x$ax_cv_cc_wdocumentation_flag" = "xyes"; then
1600 devflags="-Wdocumentation"
1604 dnl # If we have -Weverything, it really means *everything* unlike -Wall
1605 dnl # It's so verbose we need to turn off warnings which aren't useful.
1607 AX_CC_WEVERYTHING_FLAG
1608 if test "x$ax_cv_cc_weverything_flag" = "xyes"; then
1609 devflags="$devflags -W -Weverything -Wformat=2 -Wno-missing-field-initializers -Wno-date-time -Wno-padded -Wno-gnu-zero-variadic-macro-arguments -Wno-shorten-64-to-32 -Wno-sign-conversion -Wno-conversion -Wno-switch-enum -Wno-gnu-statement-expression -Wno-extended-offsetof -Wno-cast-align -Wno-documentation-unknown-command -Wno-covered-switch-default -Wno-packed -DWITH_VERIFY_PTR=1"
1611 if test "x$GCC" = "xyes"; then
1612 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"
1617 AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1619 CFLAGS="$CFLAGS $devflags"
1621 dnl # Enable experimental modules (we want to know if code changes breaks one of them)
1623 if test "x$EXPERIMENTAL" != "xno"; then
1624 AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1629 CFLAGS="$CFLAGS -DNDEBUG"
1634 dnl # May of been set outside of this configure script
1636 AC_MSG_CHECKING([if building with -DNDEBUG])
1637 if echo "$CFLAGS" | grep '\-DNDEBUG' > /dev/null; then
1638 AC_MSG_RESULT([yes])
1639 AC_DEFINE([WITH_NDEBUG], [1], [define if the server was built with -DNDEBUG])
1647 dnl # append the current git hash onto the version string
1649 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1650 RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1651 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],[${RADIUSD_VERSION_COMMIT}],[Commit HEAD at time of configuring])
1655 dnl # check for some compiler features
1658 FR_HAVE_BUILTIN_CHOOSE_EXPR
1659 FR_HAVE_BUILTIN_TYPES_COMPATIBLE_P
1660 FR_HAVE_BUILTIN_BSWAP64
1661 FR_HAVE_BOUNDED_ATTRIBUTE
1663 dnl #############################################################
1665 dnl # 7. Checks for library functions
1667 dnl #############################################################
1670 dnl # Check for talloc_set_memlimit
1671 dnl # This was only included in version 2.0.8
1673 AC_CHECK_LIB(talloc, talloc_set_memlimit,
1675 AC_DEFINE(HAVE_TALLOC_SET_MEMLIMIT, 1, [Define to 1 if you have the function talloc_set_memlimit.])
1680 dnl # Check for libcrypt
1681 dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1683 AC_CHECK_LIB(crypt, crypt,
1687 if test "$CRYPTLIB" != ""; then
1688 AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1690 AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1693 dnl Check for libcipher
1694 AC_CHECK_LIB(cipher, setkey,
1695 CRYPTLIB="${CRYPTLIB} -lcipher"
1700 dnl # Check for libexecinfo support, on some systems this is built into libc
1701 dnl # on others it's a separate library.
1703 dnl extra argument: --with-execinfo-lib-dir
1705 AC_ARG_WITH(execinfo-lib-dir,
1706 [AS_HELP_STRING([--with-execinfo-lib-dir=DIR],
1707 [directory in which to look for execinfo library files])],
1708 [ case "$withval" in
1710 AC_MSG_ERROR([Need execinfo-lib-dir])
1715 execinfo_lib_dir="$withval"
1720 dnl extra argument: --with-execinfo-include-dir
1721 execinfo_include_dir=
1722 AC_ARG_WITH(execinfo-include-dir,
1723 [AS_HELP_STRING([--with-execinfo-include-dir=DIR],
1724 [directory in which to look for execinfo include files])],
1725 [ case "$withval" in
1727 AC_MSG_ERROR([Need execinfo-include-dir])
1732 execinfo_include_dir="$withval"
1738 dnl # Look for execinfo.h and symbols
1740 smart_try_dir=$execinfo_include_dir
1741 FR_SMART_CHECK_INCLUDE(execinfo.h)
1742 if test "x$ac_cv_header_execinfo_h" = "xyes"; then
1743 smart_try_dir=$execinfo_lib_dir
1744 FR_SMART_CHECK_LIB(execinfo, backtrace_symbols)
1745 if test "x$ac_cv_lib_execinfo_backtrace_symbols" != "xyes"; then
1746 dnl # Might be provided as part of libc
1747 AC_MSG_CHECKING([if execinfo provided as part of libc])
1750 #include <execinfo.h>
1754 backtrace_symbols(&sym, sizeof(sym)) ],
1757 ac_cv_lib_execinfo_backtrace_symbols="yes"
1765 if test "x$ac_cv_lib_execinfo_backtrace_symbols" = "xyes"; then
1766 AC_DEFINE(HAVE_EXECINFO, [1], [define this if we have <execinfo.h> and symbols])
1771 dnl # Check for regular expression support.
1773 dnl extra argument: --with-pcre
1776 [AS_HELP_STRING([--with-pcre],
1777 [use libpcre (if available). (default=yes)])],
1778 [ case "$withval" in
1788 dnl extra argument: --with-pcre-lib-dir
1790 AC_ARG_WITH(pcre-lib-dir,
1791 [AS_HELP_STRING([--with-pcre-lib-dir=DIR],
1792 [directory in which to look for pcre library files])],
1793 [ case "$withval" in
1795 AC_MSG_ERROR(Need pcre-lib-dir)
1800 pcre_lib_dir="$withval"
1805 dnl extra argument: --with-pcre-include-dir
1807 AC_ARG_WITH(pcre-include-dir,
1808 [AS_HELP_STRING([--with-pcre-include-dir=DIR],
1809 [directory in which to look for pcre include files])],
1810 [ case "$withval" in
1812 AC_MSG_ERROR(Need pcre-include-dir)
1817 pcre_include_dir="$withval"
1822 dnl extra argument: --with-regex
1825 [AS_HELP_STRING([--with-regex],
1826 [Whether to build with regular expressions (default=yes)])],
1827 [ case "$withval" in
1837 dnl # First look for PCRE
1839 if test "x$REGEX" != "xno" && test "x$PCRE" != "xno"; then
1840 smart_try_dir=$pcre_include_dir
1841 FR_SMART_CHECK_INCLUDE(pcre.h)
1842 if test "x$ac_cv_header_pcre_h" = "xyes"; then
1843 smart_try_dir=$pcre_lib_dir
1844 FR_SMART_CHECK_LIB(pcre, pcre_compile)
1845 if test "x$ac_cv_lib_pcre_pcre_compile" = "xyes"; then
1847 AC_DEFINE(HAVE_PCRE, [1], [define this if we have libpcre])
1848 AC_DEFINE(HAVE_BINSAFE_REGEX, 1, [Define if we have a binary safe regular expression library])
1854 dnl # If no PCRE, fallback to POSIX regular expressions
1856 if test "x$REGEX" = "x"; then
1858 FR_SMART_CHECK_INCLUDE(regex.h)
1859 if test "x$ac_cv_header_regex_h" = "xyes"; then
1861 AC_MSG_CHECKING([for extended regular expressions])
1871 AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)])
1879 dnl # Some platforms require the regex library to be linked explicitly
1881 AC_CHECK_LIB(regex, regcomp,
1883 LIBS="-lregex $LIBS"
1888 dnl # Check for some BSD extensions which allow normal regexes to be
1895 if test x"$ac_cv_func_regncomp" = x"yes" && test x"$ac_cv_func_regnexec" = x"yes"; then
1896 AC_DEFINE(HAVE_BINSAFE_REGEX, 1, [Define if we have a binary safe regular expression library])
1901 if test "x$REGEX" = "xyes"; then
1902 AC_DEFINE(HAVE_REGEX, 1, [Define if we have any regular expression library])
1906 dnl # Check the style of gethostbyaddr, in order of preference
1907 dnl # GNU (_r eight args)
1909 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1912 dnl # SYSV (_r six args)
1914 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1917 dnl # BSD (three args, may not be thread safe)
1919 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1922 dnl # Tru64 has BSD version, but it is thread safe
1923 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1924 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
1926 gethostbyaddrrstyle=""
1927 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1931 dnl # With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1932 dnl # Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1933 dnl # override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1934 dnl # style support.
1936 AC_CHECK_DECLS([gethostbyaddr_r], [],
1938 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1939 [style of gethostbyaddr_r functions ])
1940 gethostbyaddrrstyle=BSD
1941 AC_MSG_WARN([FreeBSD overridden to BSD-style])
1951 if test "x$gethostbyaddrrstyle" = "x"; then
1957 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ],
1959 AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1960 gethostbyaddrrstyle=GNU
1965 if test "x$gethostbyaddrrstyle" = "x"; then
1971 [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] ,
1973 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1974 gethostbyaddrrstyle=SYSV
1980 if test "x$gethostbyaddrrstyle" = "x"; then
1986 [ gethostbyaddr(NULL, 0, 0) ],
1988 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1989 gethostbyaddrrstyle=BSD
1994 if test "x$gethostbyaddrrstyle" = "x"; then
1995 AC_MSG_RESULT([none! It must not exist, here.])
1997 AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
2000 if test "x$gethostbyaddrrstyle" = "xBSD"; then
2001 AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
2005 dnl # Check the style of gethostbyname, in order of preference
2006 dnl # GNU (_r seven args)
2007 dnl # SYSV (_r five args)
2008 dnl # BSD (two args, may not be thread safe)
2009 dnl # Tru64 has BSD version, but it _is_ thread safe
2010 dnl # http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
2011 dnl # We need #stdio.h to define NULL on FreeBSD (at least)
2013 gethostbynamerstyle=""
2014 AC_MSG_CHECKING([gethostbyname_r() syntax])
2020 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ],
2022 AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
2023 gethostbynamerstyle=GNU
2027 if test "x$gethostbynamerstyle" = "x"; then
2033 [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] ,
2035 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
2036 gethostbynamerstyle=SYSV
2041 if test "x$gethostbynamerstyle" = "x"; then
2047 [ gethostbyname(NULL) ],
2049 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
2050 gethostbynamerstyle=BSD
2055 if test "x$gethostbynamerstyle" = "x"; then
2056 AC_MSG_RESULT([none! It must not exist, here.])
2058 AC_MSG_RESULT([${gethostbynamerstyle}-style])
2061 if test "x$gethostbynamerstyle" = "xBSD"; then
2062 AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
2066 dnl # Check for thread-safe getpwnam_r and getgrnam_r
2068 if test "x$ac_cv_header_pwd_h" = "xyes"; then
2069 AC_MSG_CHECKING([getpwnam_r])
2073 #include <sys/types.h>
2076 [ getpwnam_r(NULL, NULL, NULL, 0, NULL) ],
2078 AC_MSG_RESULT([yes])
2079 AC_DEFINE(HAVE_GETPWNAM_R, 1,
2080 [Define to 1 if you have the getpwnam_r.]
2089 if test "x$ac_cv_header_grp_h" = "xyes"; then
2090 AC_MSG_CHECKING([getgrnam_r])
2094 #include <sys/types.h>
2097 [ getgrnam_r(NULL, NULL, NULL, 0, NULL) ],
2099 AC_MSG_RESULT([yes])
2100 AC_DEFINE(HAVE_GETGRNAM_R, 1,
2101 [Define to 1 if you have the getgrnam_r.]
2112 dnl # Check for non-posix solaris ctime_r (extra buflen int arg)
2114 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
2115 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
2117 AC_MSG_CHECKING([ctime_r() syntax])
2122 [ ctime_r(NULL, NULL, 0) ],
2124 AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
2125 ctimerstyle="SOLARIS"
2129 if test "x$ctimerstyle" = "x"; then
2134 [ ctime_r(NULL, NULL) ],
2136 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
2142 if test "x$ctimerstyle" = "x"; then
2143 AC_MSG_RESULT([none! It must not exist, here.])
2145 AC_MSG_RESULT([${ctimerstyle}-style])
2148 AC_SUBST(HOSTINFO, $host)
2150 dnl #############################################################
2152 dnl # 8. Checks for system services
2154 dnl #############################################################
2157 dnl # Figure out where libtool is located,
2161 AC_MSG_RESULT([top_builddir=$top_builddir])
2162 dnl # AC_SUBST(top_builddir)
2165 dnl # import libtool stuff
2167 dnl #############################################################
2169 dnl # Configure in any module directories.
2171 dnl #############################################################
2173 dnl ############################################################
2174 dnl # Remove any conflicting definitions if autoconf.h
2175 dnl # is being included by a module.
2176 dnl #############################################################
2177 AH_BOTTOM([#include <freeradius-devel/automask.h>])
2179 dnl ############################################################
2180 dnl # make modules by list
2181 dnl #############################################################
2182 if test "x$EXPERIMENTAL" = "xyes"; then
2183 for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
2184 MODULES="$MODULES $foo"
2188 dnl # make ONLY the stable modules
2190 for foo in `cat "${srcdir}"/src/modules/stable`; do
2191 MODULES="$MODULES $foo"
2195 dnl ############################################################
2196 dnl # Add autoconf subdirs, based on the module list we
2197 dnl # previously created.
2198 dnl #############################################################
2200 for bar in $MODULES; do
2201 if test -f "${srcdir}"/src/modules/$bar/configure; then
2202 mysubdirs="$mysubdirs src/modules/$bar"
2207 dnl # Don't change the variable name here. Autoconf goes bonkers
2210 AC_CONFIG_SUBDIRS($mysubdirs)
2213 dnl #############################################################
2215 dnl # Add -Werror last, so it doesn't interfere with autoconf's
2216 dnl # test programs.
2218 dnl #############################################################
2219 if test "x$werror" == "xyes"; then
2220 CFLAGS="-Werror $CFLAGS"
2223 dnl #############################################################
2225 dnl # And finally, output the results.
2227 dnl #############################################################
2228 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
2229 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
2230 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main && chmod +x checkrad radlast radtest)])
2231 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts && chmod +x rc.radiusd cron/radiusd.cron.daily cron/radiusd.cron.monthly cryptpasswd)])
2234 dnl # Substitute whatever libraries we found to be necessary
2237 AC_SUBST(INSTALLSTRIP)
2239 AC_SUBST(USE_SHARED_LIBS)
2240 USE_STATIC_LIBS="yes"
2241 AC_SUBST(USE_STATIC_LIBS)
2242 AC_SUBST(STATIC_MODULES)
2246 ./src/include/build-radpaths-h \
2247 ./src/main/radsniff.mk \
2248 ./src/main/checkrad \
2249 ./src/main/radlast \
2250 ./src/main/radtest \
2251 ./scripts/rc.radiusd \
2252 ./scripts/cron/radiusd.cron.daily \
2253 ./scripts/cron/radiusd.cron.monthly \
2254 ./scripts/cryptpasswd \
2255 ./raddb/radrelay.conf \
2256 ./raddb/radiusd.conf