Add "skip_duplicate_checks" for detail && tcp listeners
[freeradius.git] / configure.in
1 dnl #############################################################
2 dnl #
3 dnl #  For information about autoconf, see:
4 dnl #
5 dnl #  http://www.gnu.org/software/autoconf/
6 dnl #
7 dnl #  The recommended order is:
8 dnl #
9 dnl #  AC_INIT(file)
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...])
20 dnl #
21 dnl #############################################################
22
23 AC_PREREQ([2.59])
24 export CFLAGS LIBS LDFLAGS CPPFLAGS
25
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])
30
31 dnl #############################################################
32 dnl #
33 dnl #  Custom hackery to discover version at configure time
34 dnl #
35 dnl #############################################################
36
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/[[\.-]].*$//'`
40
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 }'`
45
46 dnl # Still useful for custom builds
47 RADIUSD_VERSION_STRING=`cat VERSION`
48
49 dnl #
50 dnl # Add definitions to Make.inc as it's used by various build targets
51 dnl #
52 AC_SUBST([RADIUSD_VERSION_STRING])
53
54 dnl #
55 dnl # Add definitions to autoconf.h, so that the headers that we install
56 dnl # contain the version number of the server.
57 dnl #
58 AC_DEFINE_UNQUOTED([RADIUSD_VERSION], [${RADIUSD_VERSION}], [Version integer in format <ma><ma><mi><mi><in><in>])
59 AC_DEFINE_UNQUOTED([RADIUSD_VERSION_STRING], ["${RADIUSD_VERSION_STRING}"], [Raw version string from VERSION file])
60
61 dnl #############################################################
62 dnl #
63 dnl #  Override some of the default autoconf variables such as
64 dnl #  CFLAGS if were building in developer mode
65 dnl #
66 dnl #############################################################
67
68 dnl #
69 dnl #  Enable developer features like debugging symbols.
70 dnl #  These checks must be done before expanding the AC_PROG_CC
71 dnl #  and AC_PROG_CXX macros.
72 dnl #
73 AC_ARG_ENABLE(developer,
74 [  --enable-developer      enables features of interest to developers.],
75 [ case "$enableval" in
76     no)
77         developer=no
78         ;;
79     *)
80         developer=yes
81   esac ]
82 )
83
84 dnl #
85 dnl # Turn on the developer flag when taken from a git checkout (not a release)
86 dnl #
87 if test -d $srcdir/.git; then
88   if test "x$developer" != "xno"; then
89     AC_MSG_NOTICE([found .git directory, enabling developer build implicitly, disable with --enable-developer=no])
90     developer="yes"
91   fi  
92 fi
93
94 dnl #
95 dnl #  Autoconf sets -O2 and -g by default, but this is a PITA for debugging
96 dnl #  so we remove the defaults if were building in developer mode, and set
97 dnl #  -g3 so nice things like macro values are included. Other arguments are
98 dnl #  added later when we know what compiler were using.
99 dnl #
100 if test "x$developer" = "xyes"; then
101   : ${CFLAGS=-g3}
102   : ${MAKEFLAGS=-j8}
103 fi
104
105 AC_SUBST(MAKEFLAGS)
106
107 dnl #############################################################
108 dnl #
109 dnl #  0. Checks for compiler, libtool, and command line options.
110 dnl #
111 dnl #############################################################
112
113 dnl Get system information
114 AC_CANONICAL_SYSTEM
115
116 dnl Check for GNU cc
117 AC_PROG_CC
118 AC_PROG_CXX
119
120 dnl #
121 dnl # check for AIX, to allow us to use some BSD functions
122 dnl # must be before macros that call the compiler.
123 dnl #
124 AC_AIX
125
126 AC_PROG_GCC_TRADITIONAL
127 AC_PROG_CC_SUNPRO
128 AC_PROG_RANLIB
129
130 AX_CC_IS_CLANG
131
132 dnl #
133 dnl # Set Default CFLAGS for GCC compatible compilers
134 dnl #
135 if test "x$GCC" = "xyes"; then
136   CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
137 fi
138
139 dnl #
140 dnl # -Qunused-arguments means the compiler won't complain about unsupported arguments
141 dnl #
142 AX_QUNUSED_ARGUMENTS_FLAG
143 if test "x$ax_cv_qunused_arguments_flag" = "xyes"; then
144   CFLAGS="$CFLAGS -Qunused-arguments"
145   LDFLAGS="$LDFLAGS -Qunused-arguments"
146 fi 
147
148 dnl Compile in large (2G+) file support.
149 AC_SYS_LARGEFILE
150
151 dnl # check for system bytesex
152 dnl # AC_DEFINES WORDS_BIGENDIAN
153 AC_C_BIGENDIAN
154
155 dnl Find GNU Make.
156 AC_CHECK_PROG(GMAKE, gmake, yes, no)
157 if test $GMAKE = no; then
158   AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
159 else
160   AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
161 fi
162 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
163 if test -z "$makever"; then
164   AC_MSG_ERROR(GNU Make is not installed.  Please download and install it
165                 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
166 fi
167
168 dnl See if we have Git.
169 AC_CHECK_PROG(GIT, git, yes, no)
170
171 dnl Put this in later, when all distributed modules use autoconf.
172 dnl AC_ARG_WITH(disablemodulefoo,
173 dnl [  --without-rlm_foo         Disables module compilation.  Module list:]
174 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
175 dnl     sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
176 dnl     awk '{print "                            "$0}']))
177
178 AC_ARG_ENABLE(strict-dependencies,
179 [  --enable-strict-dependencies  Fail configure on lack of module dependancy.])
180
181 AC_ARG_ENABLE(werror,
182 [  --enable-werror         causes the build to fail if any warnings are generated.],
183 [ case "$enableval" in
184     no)
185         werror=no
186         ;;
187     *)
188         werror=yes
189   esac ]
190 )
191
192 dnl extra argument: --with-docdir
193 docdir='${datadir}/doc/freeradius'
194 AC_MSG_CHECKING(docdir)
195 AC_ARG_WITH(docdir,
196 [  --with-docdir=DIR       Directory for documentation [DATADIR/doc/freeradius] ],
197 [ case "$withval" in
198     no)
199         docdir=no
200         ;;
201     yes)
202         ;;
203     [[\\/$]]* | ?:[[\\/]]* )
204         docdir="$withval"
205         ;;
206     *)
207         AC_MSG_ERROR([expected an absolute directory name for --with-docdir: $withval])
208         ;;
209   esac ]
210 )
211 AC_SUBST(docdir)
212 AC_MSG_RESULT($docdir)
213 if test "x$docdir" = xno; then
214         AC_MSG_WARN(Documentation files will NOT be installed.)
215 fi
216
217 dnl extra argument: --with-logdir
218 logdir='${localstatedir}/log/radius'
219 AC_MSG_CHECKING(logdir)
220 AC_ARG_WITH(logdir,
221 [  --with-logdir=DIR       Directory for logfiles [LOCALSTATEDIR/log/radius] ],
222 [ case "$withval" in
223     no)
224         AC_MSG_ERROR(Need logdir)
225         ;;
226     yes)
227         ;;
228     [[\\/$]]* | ?:[[\\/]]* )
229         logdir="$withval"
230         ;;
231     *)
232         AC_MSG_ERROR([expected an absolute directory name for --with-logdir: $withval])
233         ;;
234   esac ]
235 )
236 AC_SUBST(logdir)
237 AC_MSG_RESULT($logdir)
238
239 dnl extra argument: --with-radacctdir
240 radacctdir='${logdir}/radacct'
241 AC_MSG_CHECKING(radacctdir)
242 AC_ARG_WITH(radacctdir,
243 [  --with-radacctdir=DIR   Directory for detail files [LOGDIR/radacct] ],
244 [ case "$withval" in
245     no)
246         AC_MSG_ERROR(Need radacctdir)
247         ;;
248     yes)
249         ;;
250     [[\\/$]]* | ?:[[\\/]]* )
251         radacctdir="$withval"
252         ;;
253     *)
254         AC_MSG_ERROR([expected an absolute directory name for --with-radacctdir: $withval])
255         ;;
256   esac ]
257 )
258 AC_SUBST(radacctdir)
259 AC_MSG_RESULT($radacctdir)
260
261 dnl extra argument: --with-raddbdir
262 raddbdir='${sysconfdir}/raddb'
263 AC_MSG_CHECKING(raddbdir)
264 AC_ARG_WITH(raddbdir,
265 [  --with-raddbdir=DIR     Directory for config files [SYSCONFDIR/raddb] ],
266 [ case "$withval" in
267     no)
268         AC_MSG_ERROR(Need raddbdir)
269         ;;
270     yes)
271         ;;
272     [[\\/$]]* | ?:[[\\/]]* )
273         raddbdir="$withval"
274         ;;
275     *)
276         AC_MSG_ERROR([expected an absolute directory name for --with-raddbdir: $withval])
277         ;;
278   esac ]
279 )
280 AC_SUBST(raddbdir)
281 AC_MSG_RESULT($raddbdir)
282
283 dnl extra argument: --with-ascend-binary
284 WITH_ASCEND_BINARY=yes
285 AC_ARG_WITH(ascend-binary,
286 [  --with-ascend-binary    Include support for Ascend binary filter attributes (default=yes)],
287 [ case "$withval" in
288     yes)
289         ;;
290     *)
291         WITH_ASCEND_BINARY=no
292   esac ]
293 )
294 if test "x$WITH_ASCEND_BINARY" = "xyes"; then
295   AC_DEFINE(WITH_ASCEND_BINARY, [1], [Include support for Ascend binary filter attributes])
296 fi
297
298 dnl extra argument: --with-threads
299 WITH_THREADS=yes
300 AC_ARG_WITH(threads,
301 [  --with-threads          Use threads, if available.  (default=yes) ],
302 [ case "$withval" in
303     yes)
304         ;;
305     *)
306         WITH_THREADS=no
307   esac ]
308 )
309
310 dnl extra argument: --with-tcp
311 WITH_TCP=yes
312 AC_ARG_WITH(tcp,
313 [  --with-tcp              Compile in TCP support. (default=yes)],
314 [ case "$withval" in
315     yes)
316         ;;
317     *)
318         WITH_TCP=no
319   esac ]
320 )
321 if test "x$WITH_TCP" = "xyes"; then
322         AC_DEFINE(WITH_TCP, [1], [define if you want TCP support (For RADSec et al)])
323 fi
324
325 dnl extra argument: --with-vmps
326 WITH_VMPS=yes
327 AC_ARG_WITH(vmps,
328 [  --with-vmps             Compile in VMPS support. (default=yes)],
329 [ case "$withval" in
330     yes)
331         ;;
332     *)
333         WITH_VMPS=no
334   esac ]
335 )
336 if test "x$WITH_VMPS" = "xyes"; then
337         AC_DEFINE(WITH_VMPS, [1], [define if you want VMPS support])
338 fi
339
340 dnl extra argument: --with-dhcp
341 WITH_DHCP=yes
342 AC_ARG_WITH(dhcp,
343 [  --with-dhcp             Compile in DHCP support. (default=yes)],
344 [ case "$withval" in
345     yes)
346         ;;
347     *)
348         WITH_DHCP=no
349   esac ]
350 )
351 if test "x$WITH_DHCP" = "xyes"; then
352         AC_DEFINE(WITH_DHCP, [1], [define if you want DHCP support])
353 fi
354
355 dnl #
356 dnl #  Allow the user to specify a list of modules to be linked
357 dnl #  statically to the server.
358 dnl #
359 STATIC_MODULES=
360 AC_ARG_WITH(static_modules,
361 [  --with-static-modules=QUOTED-MODULE-LIST],[
362   for i in $withval; do
363     STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
364   done
365 ])
366
367 MODULES=
368 AC_ARG_WITH(modules,
369 [  --with-modules=QUOTED-MODULE-LIST],[
370  for i in $withval; do
371    MODULES="$MODULES $i"
372  done
373 ])
374
375 dnl extra argument: --with-experimental-modules
376 EXPERIMENTAL=
377 AC_ARG_WITH(experimental-modules,
378 [  --with-experimental-modules      Use experimental and unstable modules. (default=no, unless --enable-developer=yes) ],
379 [ case "$withval" in
380     yes)
381         EXPERIMENTAL=yes
382         ;;
383     no)
384         EXPERIMENTAL=no
385         ;;
386     *)
387   esac ]
388 )
389
390 dnl extra argument: --with-openssl
391 WITH_OPENSSL=yes
392 AC_ARG_WITH(openssl,
393 [  --with-openssl                   Use OpenSSL. (default=yes)],
394 [ case "$withval" in
395     no)
396         WITH_OPENSSL=no
397         ;;
398     *)
399         WITH_OPENSSL=yes
400         ;;
401   esac ]
402 )
403
404 dnl #
405 dnl # extra argument: --with-openssl-includes=dir
406 dnl #
407 OPENSSL_INCLUDE_DIR=
408 AC_ARG_WITH(openssl-includes,
409 [  --with-openssl-includes=DIR      Directory to look for OpenSSL include files],
410 [ case "$withval" in
411     *) OPENSSL_INCLUDE_DIR="$withval"
412         ;;
413   esac ]
414 )
415
416 dnl #
417 dnl # extra argument: --with-openssl-libraries=dir
418 dnl #
419 OPENSSL_LIB_DIR=
420 AC_ARG_WITH(openssl-libraries,
421 [  --with-openssl-libraries=DIR     Directory to look for OpenSSL library files],
422 [ case "$withval" in
423     *) OPENSSL_LIB_DIR="$withval"
424         ;;
425   esac ]
426 )
427
428 dnl #
429 dnl #  These next two arguments don't actually do anything.  They're
430 dnl #  place holders so that the top-level configure script can tell
431 dnl #  the user how to configure lower-level modules
432 dnl #
433
434 dnl #
435 dnl # extra argument: --with-rlm-FOO-lib-dir
436 dnl #
437 AC_ARG_WITH(rlm-FOO-lib-dir,
438 [  --with-rlm-FOO-lib-dir=DIR       Directory to look for library files used by module FOO],
439 [ case "$withval" in
440     *)
441         ;;
442   esac ]
443 )
444
445 dnl #
446 dnl # extra argument: --with-rlm-FOO-include-dir
447 dnl #
448 AC_ARG_WITH(rlm-FOO-include-dir,
449 [  --with-rlm-FOO-include-dir=DIR   Directory to look for include files used by module FOO],
450 [ case "$withval" in
451     *)
452         ;;
453   esac ]
454 )
455
456 dnl See what include-style is used by the make program.
457 dnl AC_MSG_CHECKING(include style for make)
458 dnl echo "include /dev/null" > testmake.$$
459 dnl echo "all:" >> testmake.$$
460 dnl make -f testmake.$$ >/dev/null 2>&1
461 dnl if test $? = 0
462 dnl then
463 dnl     INCLUDE=include
464 dnl     IQUOTE=
465 dnl else
466 dnl     INCLUDE=.include
467 dnl     IQUOTE='"'
468 dnl fi
469 dnl rm -f testmake.$$
470 dnl AC_MSG_RESULT(" $INCLUDE")
471 dnl AC_SUBST(INCLUDE)
472 dnl AC_SUBST(IQUOTE)
473
474 dnl extra argument: --with-udpfromto
475 WITH_UDPFROMTO=no
476 AC_ARG_WITH(udpfromto,
477 [  --with-udpfromto        Compile in UDPFROMTO support. (default=no)],
478 [ case "$withval" in
479     yes)
480         WITH_UDPFROMTO=yes
481         ;;
482     *)
483         WITH_UDPFROMTO=no
484   esac ]
485 )
486
487 if test "x$WITH_UDPFROMTO" = "xyes"; then
488         AC_DEFINE(WITH_UDPFROMTO, [], [define if you want udpfromto])
489 fi
490
491 dnl #############################################################
492 dnl #
493 dnl #  1. Checks for programs
494 dnl #
495 dnl #############################################################
496
497 CHECKRAD=checkrad
498 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
499 if test "x$ac_cv_path_PERL" = "x"; then
500   AC_MSG_WARN(perl not found - Simultaneous-Use and checkrad may not work)
501 fi
502 AC_PATH_PROG(SNMPGET, snmpget)
503 if test "x$ac_cv_path_SNMPGET" = "x"; then
504   AC_MSG_WARN(snmpget not found - Simultaneous-Use and checkrad may not work)
505 fi
506
507 AC_PATH_PROG(SNMPWALK, snmpwalk)
508 if test "x$ac_cv_path_SNMPWALK" = "x"; then
509   AC_MSG_WARN(snmpwalk not found - Simultaneous-Use and checkrad may not work)
510 fi
511
512 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
513
514 dnl FIXME This is truly gross.
515 missing_dir=`cd $ac_aux_dir && pwd`
516 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
517 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
518 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
519
520 AC_PATH_PROG(LOCATE,locate)
521 AC_PATH_PROG(DIRNAME,dirname)
522 AC_PATH_PROG(GREP,grep)
523
524 dnl #############################################################
525 dnl #
526 dnl #  2. Checks for libraries
527 dnl #
528 dnl #############################################################
529
530 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
531 old_CFLAGS=$CFLAGS
532 if test "x$WITH_THREADS" = "xyes"; then
533   if test $ac_cv_prog_suncc = "yes"; then
534     CFLAGS="$CFLAGS -mt"
535   fi
536
537   AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
538
539 dnl #
540 dnl # pthread stuff is usually in -lpthread
541 dnl # or in -lc_r, on *BSD
542 dnl #
543 dnl # On Some systems, we need extra pre-processor flags, to get them to
544 dnl # to do the threading properly.
545 dnl #
546   AC_CHECK_LIB(pthread, pthread_create,
547                 [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
548                   LIBS="-lpthread $LIBS" ],
549                 [ AC_CHECK_LIB(c_r, pthread_create,
550                             [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
551                             [ WITH_THREADS="no" ]
552                             ) ]
553                 )
554 fi
555
556 dnl #
557 dnl # If we have NO pthread libraries, remove any knowledge of threads.
558 dnl #
559 if test "x$WITH_THREADS" != "xyes"; then
560   CFLAGS=$old_CFLAGS
561   ac_cv_header_pthread_h="no"
562   WITH_THREADS=no
563 else
564   dnl #
565   dnl #  We need sem_init() and friends, as they're the friendliest
566   dnl #  semaphore functions for threading.
567   dnl #
568   dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
569   dnl # Some systems have them in -lsem
570   dnl # Solaris has them in -lposix4
571   dnl # NetBSD has them in -lsemaphore
572
573   AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt semaphore,
574         [],
575         [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)]
576    )
577 fi
578
579 if test "x$WITH_THREADS" = "xyes"; then
580         AC_DEFINE(WITH_THREADS, [1], [define if you want thread support])
581 fi
582
583 dnl Check if we need -lsocket
584 AC_CHECK_LIB(dl, dlopen)
585
586 dnl Check if we need -lsocket
587 AC_CHECK_LIB(socket, getsockname)
588
589 dnl Check for -lresolv
590 dnl This library may be needed later.
591 AC_CHECK_LIB(resolv, inet_aton)
592
593 dnl Check if we need -lnsl. Usually if we want to
594 dnl link against -lsocket we need to include -lnsl as well.
595 AC_CHECK_LIB(nsl, inet_ntoa)
596
597 dnl Check for OpenSSL libraries.
598 OPENSSL_LIBS=
599 if test "x$WITH_OPENSSL" = xyes; then
600   old_LIBS=$LIBS
601   old_LDFLAGS="$LDFLAGS"
602   if test "x$OPENSSL_LIB_DIR" != "x"; then
603     LDFLAGS="$LDFLAGS -L$OPENSSL_LIB_DIR"
604   fi
605   AC_CHECK_LIB(crypto, DH_new,
606     [
607         LIBS="-lcrypto $LIBS"
608         AC_DEFINE(HAVE_LIBCRYPTO, 1,
609             [Define to 1 if you have the `crypto' library (-lcrypto).])
610         AC_CHECK_LIB(ssl, SSL_new,
611             [
612                 AC_DEFINE(HAVE_LIBSSL, 1,
613                     [Define to 1 if you have the `ssl' library (-lssl).])
614                 if test "x$OPENSSL_LIB_DIR" != "x"; then
615                     OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
616                 fi
617                 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
618             ], [])
619     ], [])
620   LIBS=$old_LIBS
621   LDFLAGS="$old_LDFLAGS"
622 fi
623
624 AC_CHECK_LIB(ws2_32, htonl)
625
626 dnl Check the pcap library for the RADIUS sniffer.
627 PCAP_LIBS=
628 AC_CHECK_LIB(pcap, pcap_open_live,
629         [ PCAP_LIBS="-lpcap"
630         AC_DEFINE(HAVE_LIBPCAP, 1,
631                 [Define to 1 if you have the `pcap' library (-lpcap).])
632         ],
633         [ AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer.]) ])
634
635 VL_LIB_READLINE
636
637 dnl #############################################################
638 dnl #
639 dnl #  3. Checks for header files
640 dnl #
641 dnl #############################################################
642
643 dnl #
644 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
645 dnl # getopt will be #included, but won't link.  <sigh>
646 dnl #
647 dnl #
648 case "$host" in
649 *-interix*)
650         CFLAGS="$CFLAGS -D_ALL_SOURCE"
651         ;;
652 *-darwin*)
653         CFLAGS="$CFLAGS -DDARWIN"
654         LIBS="-framework DirectoryService $LIBS"
655         ;;
656 esac
657
658 AC_HEADER_DIRENT
659 AC_HEADER_STDC
660 AC_HEADER_TIME
661 AC_HEADER_SYS_WAIT
662
663 AC_CHECK_HEADERS( \
664         dlfcn.h \
665         unistd.h \
666         crypt.h \
667         errno.h \
668         resource.h \
669         sys/resource.h \
670         getopt.h \
671         malloc.h \
672         utmp.h \
673         utmpx.h \
674         signal.h \
675         sys/select.h \
676         syslog.h \
677         inttypes.h \
678         stdint.h \
679         stdio.h \
680         netdb.h \
681         semaphore.h \
682         arpa/inet.h \
683         netinet/in.h \
684         sys/types.h \
685         sys/socket.h \
686         winsock.h \
687         utime.h \
688         sys/time.h \
689         sys/wait.h \
690         sys/security.h \
691         fcntl.h \
692         sys/fcntl.h \
693         sys/prctl.h \
694         sys/un.h \
695         glob.h \
696         prot.h \
697         pwd.h \
698         grp.h \
699         stddef.h \
700         fnmatch.h \
701         sia.h \
702         siad.h
703 )
704
705 dnl FreeBSD requires sys/socket.h before net/if.h
706 AC_CHECK_HEADERS(net/if.h, [], [],
707 [#ifdef HAVE_SYS_SOCKET_H
708 # include <sys/socket.h>
709 # endif
710 ])
711
712 REGEX=no
713 AC_CHECK_HEADER(pcreposix.h, AC_DEFINE(HAVE_PCREPOSIX_H, [], [define this if we have the <pcreposix.h> header file]))
714 if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
715   AC_DEFINE(HAVE_REGEX_H, [], [define if we have any regex])
716   REGEX_EXTENDED=yes
717   REGEX_PCRE=yes
718   REGEX=yes
719   LIBS="$LIBS -lpcreposix"
720 else
721
722 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H, [], [define this if we have the <regex.h> header file]))
723 if test "x$ac_cv_header_regex_h" = "xyes"; then
724   REGEX_EXTENDED=no
725   REGEX_PCRE=no
726   REGEX=yes
727   AC_EGREP_CPP(yes,
728     [#include <regex.h>
729      #ifdef REG_EXTENDED
730        yes
731      #endif
732      ], [AC_DEFINE(HAVE_REG_EXTENDED, [], [define this if we have REG_EXTENDED (from <regex.h>)]) REGEX_EXTENDED=yes])
733 fi
734 fi
735
736 AC_SUBST(REGEX)
737 AC_SUBST(REGEX_PCRE)
738 AC_SUBST(REGEX_EXTENDED)
739
740 dnl #
741 dnl #  other checks which require headers
742 dnl #
743 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
744 then
745   AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
746 fi
747
748 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
749 then
750   AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
751 fi
752
753 dnl Check for OpenSSL includes.
754 OPENSSL_INCLUDE="-DNO_OPENSSL"
755 if test "x$WITH_OPENSSL" = xyes; then
756   if test "x$OPENSSL_LIBS" = "x"; then
757     AC_MSG_NOTICE([skipping test for openssl/ssl.h])
758   else
759     old_CPPFLAGS=$CPPFLAGS
760     if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
761         CPPFLAGS="$CPPFLAGS -I$OPENSSL_INCLUDE_DIR"
762     fi
763     dnl # stupid RedHat shit
764     CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
765     AC_CHECK_HEADERS( \
766         openssl/ssl.h \
767         openssl/crypto.h \
768         openssl/err.h \
769         openssl/evp.h \
770         openssl/md5.h \
771         openssl/md4.h \
772         openssl/sha.h \
773         openssl/ocsp.h \
774         openssl/engine.h,
775         [],
776         OPENSSL_LIBS=
777     )
778     if test "x$OPENSSL_LIBS" != "x"; then
779         AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
780         AC_EGREP_CPP(yes,
781             [#include <openssl/crypto.h>
782              #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
783              yes
784              #endif
785             ], goodssl="yes")
786         if test "x$goodssl" != "xyes"; then
787             AC_MSG_RESULT(no)
788             OPENSSL_LIBS=
789         else
790             AC_MSG_RESULT(yes)
791             if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
792                 OPENSSL_INCLUDE="-I$OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
793             else
794                 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
795             fi
796         fi
797     fi
798     CPPFLAGS=$old_CPPFLAGS
799   fi
800 fi
801 AC_SUBST(OPENSSL_INCLUDE)
802 AC_SUBST(OPENSSL_LIBS)
803 export OPENSSL_LIBS
804
805 dnl Check the pcap includes for the RADIUS sniffer.
806 if test "x$PCAP_LIBS" = x; then
807     AC_MSG_NOTICE([skipping test for pcap.h.])
808 else
809     AC_CHECK_HEADER(pcap.h,
810         AC_DEFINE(HAVE_PCAP_H, 1,
811                 [Define to 1 if you have the <pcap.h> header file.]),
812         [ PCAP_LIBS=
813         AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer.])
814         ])
815
816     AC_CHECK_LIB(pcap, pcap_fopen_offline,
817         [ AC_DEFINE(HAVE_PCAP_FOPEN_OFFLINE, 1,
818                 [Define to 1 if you have the function pcap_fopen_offline.])
819         ])
820     AC_CHECK_LIB(pcap, pcap_dump_fopen,
821         [ AC_DEFINE(HAVE_PCAP_DUMP_FOPEN, 1,
822                 [Define to 1 if you have the function pcap_dump_fopen.])
823         ])
824 fi
825 AC_SUBST(PCAP_LIBS)
826
827 dnl #############################################################
828 dnl #
829 dnl #  4. Checks for typedefs
830 dnl #
831 dnl #############################################################
832
833 dnl #
834 dnl # Ensure that these are defined
835 dnl #
836 AC_TYPE_OFF_T
837 AC_TYPE_PID_T
838 AC_TYPE_SIZE_T
839 AC_TYPE_UID_T
840
841 dnl check for socklen_t
842 FR_CHECK_TYPE_INCLUDE([
843 #ifdef HAVE_SYS_TYPES_H
844 #include <sys/types.h>
845 #endif
846 #ifdef HAVE_SYS_SOCKET_H
847 #include <sys/socket.h>
848 #endif
849 ],socklen_t, int, [socklen_t is generally 'int' on systems which don't use it])
850
851 dnl check for uint8_t
852 FR_CHECK_TYPE_INCLUDE([
853 #ifdef HAVE_INTTYPES_H
854 #include <inttypes.h>
855 #endif
856 #ifdef HAVE_STDINT_H
857 #include <stdint.h>
858 #endif
859 ],uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic])
860
861 dnl check for uint16_t
862 FR_CHECK_TYPE_INCLUDE([
863 #ifdef HAVE_INTTYPES_H
864 #include <inttypes.h>
865 #endif
866 #ifdef HAVE_STDINT_H
867 #include <stdint.h>
868 #endif
869 ],uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic])
870
871 dnl check for uint32_t
872 FR_CHECK_TYPE_INCLUDE([
873 #ifdef HAVE_INTTYPES_H
874 #include <inttypes.h>
875 #endif
876 #ifdef HAVE_STDINT_H
877 #include <stdint.h>
878 #endif
879 ],uint32_t, unsigned int, [uint32_t should be the canonical 'network integer])
880
881 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [], [
882 #ifdef HAVE_NETINET_IN_H
883 #include <netinet/in.h>
884 #endif
885 ])
886
887 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [], [
888 #ifdef HAVE_NETINET_IN_H
889 #include <netinet/in.h>
890 #endif
891 #ifdef HAVE_SYS_SOCKET_H
892 #include <sys/socket.h>
893 #endif
894 ])
895
896 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [], [
897 #ifdef HAVE_NETINET_IN_H
898 #include <netinet/in.h>
899 #endif
900 ])
901
902 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [], [
903 #ifdef HAVE_SYS_TYPES_H
904 #include <sys/types.h>
905 #endif
906 #ifdef HAVE_SYS_SOCKET_H
907 #include <sys/socket.h>
908 #endif
909 #ifdef HAVE_NETDB_H
910 #include <netdb.h>
911 #endif
912 ])
913
914 dnl #############################################################
915 dnl #
916 dnl #  5. Checks for structures and functions
917 dnl #
918 dnl #############################################################
919 AC_CHECK_FUNCS( \
920         getopt_long \
921         fcntl \
922         strsignal \
923         sigaction \
924         sigprocmask \
925         pthread_sigmask \
926         snprintf \
927         vsnprintf \
928         setsid \
929         strncasecmp \
930         strcasecmp \
931         localtime_r \
932         ctime_r \
933         gmtime_r \
934         strsep \
935         inet_aton \
936         inet_pton \
937         inet_ntop \
938         setlinebuf \
939         setvbuf \
940         getusershell \
941         initgroups \
942         getaddrinfo \
943         getnameinfo \
944         closefrom \
945         gettimeofday \
946         getpeereid \
947         setuid \
948         setresuid \
949         getresuid \
950         strlcat \
951         strlcpy
952 )
953
954 AC_TYPE_SIGNAL
955
956 dnl # check if we have utmpx.h
957 dnl # if so, check if struct utmpx has entry ut_xtime
958 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
959 if test "x$ac_cv_header_utmpx_h" = "xyes"
960 then
961  FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
962  if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"
963  then
964    AC_DEFINE(ut_xtime,ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
965  fi
966 fi
967
968 dnl # struct ip_pktinfo
969 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
970 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"
971 then
972         AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
973 fi
974
975 dnl # struct in6_pktinfo
976 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
977 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"
978 then
979         AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
980 fi
981
982 dnl #############################################################
983 dnl #
984 dnl #  6. Checks for compiler characteristics
985 dnl #
986 dnl #############################################################
987
988 dnl #
989 dnl # Ensure that these are defined
990 dnl #
991 AC_C_CONST
992
993 dnl #
994 dnl # See if this is OS/2
995 dnl #
996 AC_MSG_CHECKING(type of OS)
997 OS=`uname -s`
998 AC_MSG_RESULT($OS)
999 if test "$OS" = "OS/2"; then
1000         LIBPREFIX=
1001 else
1002         LIBPREFIX=lib
1003 fi
1004 AC_SUBST(LIBPREFIX)
1005
1006 if test "x$developer" = "xyes"; then
1007   AC_MSG_NOTICE([Setting additional developer CFLAGS])
1008   
1009   dnl #
1010   dnl # Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1011   dnl #
1012   AX_WDOCUMENTATION_FLAG
1013   if test "x$ax_cv_wdocumentation_flag" = "xyes"; then
1014     devflags="-Wdocumentation"
1015   fi
1016
1017   if test "x$GCC" = "xyes"; then
1018     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"
1019     INSTALLSTRIP=""
1020   fi
1021   
1022   AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1023   
1024   CFLAGS="$CFLAGS $devflags"
1025   dnl #
1026   dnl # Enable experimental modules (we want to know if code changes breaks one of them)
1027   dnl #
1028   if test "x$EXPERIMENTAL" != "xno"; then
1029     AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1030     EXPERIMENTAL=yes
1031   fi
1032 else
1033   devflags=""
1034   CFLAGS="$CFLAGS -DNDEBUG"
1035   INSTALLSTRIP=""
1036   AC_MSG_RESULT([no.])
1037 fi
1038
1039 export EXPERIMENTAL
1040
1041 dnl append the current git hash onto the version string
1042 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1043   RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1044   AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],["${RADIUSD_VERSION_COMMIT}"],[Commit HEAD at time of configuring])
1045 fi
1046
1047 FR_TLS
1048
1049 dnl #############################################################
1050 dnl #
1051 dnl #  7. Checks for library functions
1052 dnl #
1053 dnl #############################################################
1054
1055 dnl Check for talloc
1056 dnl extra argument: --with-talloc-include-dir=DIR
1057 talloc_include_dir=
1058 AC_ARG_WITH(talloc-include-dir,
1059         [AS_HELP_STRING([--with-talloc-include-dir=DIR],
1060         [Directory where the talloc includes may be found])],
1061         [case "$withval" in
1062             no)
1063                 AC_MSG_ERROR(Need talloc-include-dir)
1064             ;;
1065                 yes)
1066             ;;
1067             *)
1068                 talloc_include_dir="$withval"
1069             ;;
1070         esac])
1071
1072 dnl Check for talloc header files
1073
1074 smart_try_dir="$talloc_include_dir"
1075 FR_SMART_CHECK_INCLUDE([talloc.h])
1076 if test "x$ac_cv_header_talloc_h" != "xyes"; then
1077         AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
1078         AC_MSG_ERROR([FreeRADIUS requires libtalloc])
1079 else
1080         INCLUDE="${SMART_CFLAGS} ${INCLUDE}"
1081         LIBS="-ltalloc ${LIBS}"
1082 fi
1083
1084 dnl Check for libcrypt
1085 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1086 AC_CHECK_LIB(crypt, crypt,
1087   CRYPTLIB="-lcrypt"
1088 )
1089 if test "$CRYPTLIB" != ""; then
1090   AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1091 else
1092   AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1093 fi
1094
1095 dnl Check for libcipher
1096 AC_CHECK_LIB(cipher, setkey,
1097    CRYPTLIB="${CRYPTLIB} -lcipher"
1098 )
1099 AC_SUBST(CRYPTLIB)
1100
1101 dnl Check the style of gethostbyaddr, in order of preference
1102 dnl GNU (_r eight args)
1103 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1104 dnl SYSV (_r six args)
1105 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1106 dnl BSD (three args, may not be thread safe)
1107 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1108 dnl Tru64 has BSD version, but it is thread safe
1109 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1110 dnl We need #stdio.h to define NULL on FreeBSD (at least)
1111 gethostbyaddrrstyle=""
1112 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1113 case "$host" in
1114 *-freebsd*)
1115 dnl With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1116 dnl Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1117 dnl override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1118 dnl style support.
1119         AC_CHECK_DECLS([gethostbyaddr_r], [], [
1120                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1121                         [style of gethostbyaddr_r functions ])
1122                 gethostbyaddrrstyle=BSD
1123                 AC_MSG_WARN([FreeBSD overridden to BSD-style])
1124         ], [
1125 #ifdef HAVE_NETDB_H
1126 #include <netdb.h>
1127 #endif
1128 ])
1129         ;;
1130 esac
1131 if test "x$gethostbyaddrrstyle" = "x"; then
1132         AC_TRY_LINK([
1133 #include <stdio.h>
1134 #include <netdb.h>
1135 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
1136         AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1137         gethostbyaddrrstyle=GNU
1138 ])
1139 fi
1140 if test "x$gethostbyaddrrstyle" = "x"; then
1141         AC_TRY_LINK([
1142 #include <stdio.h>
1143 #include <netdb.h>
1144 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
1145                 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1146                 gethostbyaddrrstyle=SYSV
1147         ])
1148 fi
1149 if test "x$gethostbyaddrrstyle" = "x"; then
1150         AC_TRY_LINK([
1151 #include <stdio.h>
1152 #include <netdb.h>
1153 ], [ gethostbyaddr(NULL, 0, 0)  ], [
1154                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1155                 gethostbyaddrrstyle=BSD
1156         ])
1157 fi
1158
1159 if test "x$gethostbyaddrrstyle" = "x"; then
1160         AC_MSG_RESULT([none!  It must not exist, here.])
1161 else
1162         AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1163 fi
1164
1165 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1166         AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1167 fi
1168
1169 dnl Check the style of gethostbyname, in order of preference
1170 dnl GNU (_r seven args)
1171 dnl SYSV (_r five args)
1172 dnl BSD (two args, may not be thread safe)
1173 dnl Tru64 has BSD version, but it _is_ thread safe
1174 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1175 dnl We need #stdio.h to define NULL on FreeBSD (at least)
1176 gethostbynamerstyle=""
1177 AC_MSG_CHECKING([gethostbyname_r() syntax])
1178 AC_TRY_LINK([
1179 #include <stdio.h>
1180 #include <netdb.h>
1181 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ], [
1182         AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1183         gethostbynamerstyle=GNU
1184 ])
1185 if test "x$gethostbynamerstyle" = "x"; then
1186         AC_TRY_LINK([
1187 #include <stdio.h>
1188 #include <netdb.h>
1189 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] , [
1190                 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1191                 gethostbynamerstyle=SYSV
1192         ])
1193 fi
1194 if test "x$gethostbynamerstyle" = "x"; then
1195         AC_TRY_LINK([
1196 #include <stdio.h>
1197 #include <netdb.h>
1198 ], [ gethostbyname(NULL)  ], [
1199                 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1200                 gethostbynamerstyle=BSD
1201         ])
1202 fi
1203
1204 if test "x$gethostbynamerstyle" = "x"; then
1205         AC_MSG_RESULT([none!  It must not exist, here.])
1206 else
1207         AC_MSG_RESULT([${gethostbynamerstyle}-style])
1208 fi
1209
1210 if test "x$gethostbynamerstyle" = "xBSD"; then
1211         AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1212 fi
1213
1214 dnl check for non-posix solaris ctime_r (extra buflen int arg)
1215 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1216 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1217 ctimerstyle=""
1218 AC_MSG_CHECKING([ctime_r() syntax])
1219 AC_TRY_LINK([
1220 #include <time.h>
1221 ], [ ctime_r(NULL, NULL, 0) ], [
1222         AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1223         ctimerstyle="SOLARIS"
1224 ])
1225 if test "x$ctimerstyle" = "x"; then
1226         AC_TRY_LINK([
1227 #include <time.h>
1228 ], [ ctime_r(NULL, NULL) ], [
1229                 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1230                 ctimerstyle="POSIX"
1231         ])
1232 fi
1233
1234 if test "x$ctimerstyle" = "x"; then
1235         AC_MSG_RESULT([none!  It must not exist, here.])
1236 else
1237         AC_MSG_RESULT([${ctimerstyle}-style])
1238 fi
1239
1240 AC_SUBST(HOSTINFO, $host)
1241
1242 dnl #############################################################
1243 dnl #
1244 dnl #  8. Checks for system services
1245 dnl #
1246 dnl #############################################################
1247
1248 dnl #
1249 dnl # Figure out where libtool is located,
1250 dnl #
1251 top_builddir=`pwd`
1252 export top_builddir
1253 AC_MSG_RESULT([top_builddir=$top_builddir])
1254 dnl # AC_SUBST(top_builddir)
1255
1256 dnl import libtool stuff
1257
1258 dnl #############################################################
1259 dnl #
1260 dnl #  Configure in any module directories.
1261 dnl #
1262 dnl #############################################################
1263
1264 dnl ############################################################
1265 dnl # Remove any conflicting definitions if autoconf.h
1266 dnl # is being included by a module.
1267 dnl #############################################################
1268 AH_BOTTOM([#include <freeradius-devel/automask.h>])
1269
1270 dnl ############################################################
1271 dnl # make modules by list
1272 dnl #############################################################
1273 if test "x$EXPERIMENTAL" = "xyes"; then
1274   for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
1275     MODULES="$MODULES $foo"
1276   done
1277 else
1278    dnl #
1279    dnl # make ONLY the stable modules
1280    dnl #
1281    for foo in `cat "${srcdir}"/src/modules/stable`; do
1282     MODULES="$MODULES $foo"
1283    done
1284 fi
1285
1286 dnl ############################################################
1287 dnl # Add autoconf subdirs, based on the module list we
1288 dnl # previously created.
1289 dnl #############################################################
1290 mysubdirs=""
1291 for bar in $MODULES; do
1292   if test -f "${srcdir}"/src/modules/$bar/configure; then
1293     mysubdirs="$mysubdirs src/modules/$bar"
1294   fi
1295 done
1296
1297 dnl #
1298 dnl #  Don't change the variable name here.  Autoconf goes bonkers
1299 dnl #  if you do.
1300 dnl #
1301 AC_CONFIG_SUBDIRS($mysubdirs)
1302 AC_SUBST(MODULES)
1303
1304 dnl #############################################################
1305 dnl #
1306 dnl #  Add -Werror last, so it doesn't interfere with autoconf's
1307 dnl #  test programs.
1308 dnl #
1309 dnl #############################################################
1310
1311 if test "x$werror" == "xyes"; then
1312   CFLAGS="-Werror $CFLAGS"
1313 fi  
1314
1315 dnl #############################################################
1316 dnl #
1317 dnl #  And finally, output the results.
1318 dnl #
1319 dnl #############################################################
1320
1321 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
1322 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
1323 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main   && chmod +x checkrad radlast radtest)])
1324 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts    && chmod +x rc.radiusd radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
1325
1326 dnl #
1327 dnl #  Substitute whatever libraries we found to be necessary
1328 dnl #
1329 AC_SUBST(LIBS)
1330 AC_SUBST(INSTALLSTRIP)
1331
1332 USE_SHARED_LIBS=$enable_shared
1333 AC_SUBST(USE_SHARED_LIBS)
1334 USE_STATIC_LIBS=$enable_static
1335 AC_SUBST(USE_STATIC_LIBS)
1336 AC_SUBST(STATIC_MODULES)
1337
1338 AC_OUTPUT(\
1339         ./Make.inc \
1340         ./src/include/build-radpaths-h \
1341         ./src/main/radsniff.mk \
1342         ./src/main/checkrad \
1343         ./src/main/radlast \
1344         ./src/main/radtest \
1345         ./scripts/rc.radiusd \
1346         ./scripts/radiusd.cron.daily \
1347         ./scripts/radiusd.cron.monthly \
1348         ./scripts/cryptpasswd \
1349         ./raddb/dictionary \
1350         ./raddb/radrelay.conf \
1351         ./raddb/radiusd.conf
1352 )