Prefix *_ENDIAN macros with RADIUS_
[freeradius.git] / configure.ac
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 #
47 dnl #  Still useful for custom builds
48 dnl #
49 RADIUSD_VERSION_STRING=`cat VERSION`
50
51 dnl #
52 dnl #  Add definitions to Make.inc as it's used by various build targets
53 dnl #
54 AC_SUBST([RADIUSD_VERSION_STRING])
55
56 dnl #
57 dnl #  Add definitions to autoconf.h, so that the headers that we install
58 dnl #  contain the version number of the server.
59 dnl #
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])
62
63 dnl #############################################################
64 dnl #
65 dnl #  Override some of the default autoconf variables such as
66 dnl #  CFLAGS if were building in developer mode
67 dnl #
68 dnl #############################################################
69
70 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.
74 dnl #
75 AC_ARG_ENABLE(developer,
76 [  --enable-developer      enables features of interest to developers.],
77 [ case "$enableval" in
78   no)
79     developer=no
80     ;;
81   *)
82     developer=yes
83   esac ]
84 )
85
86 dnl #
87 dnl #  Turn on the developer flag when taken from a git checkout (not a release)
88 dnl #
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])
92     developer="yes"
93   fi
94 fi
95
96 dnl #
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.
101 dnl #
102 if test "x$developer" = "xyes"; then
103   : ${CFLAGS=-g3}
104 fi
105
106 dnl #############################################################
107 dnl #
108 dnl #  0. Checks for compiler, libtool, and command line options.
109 dnl #
110 dnl #############################################################
111
112 dnl #
113 dnl #  Get system information
114 dnl #
115 AC_CANONICAL_SYSTEM
116
117 dnl #
118 dnl #  Check for GNU cc
119 dnl #
120 AC_PROG_CC
121 AC_PROG_CXX
122
123 dnl #
124 dnl #  check for AIX, to allow us to use some BSD functions
125 dnl #  must be before macros that call the compiler.
126 dnl #
127 AC_AIX
128
129 AC_PROG_GCC_TRADITIONAL
130 AC_PROG_CC_SUNPRO
131 AC_PROG_RANLIB
132
133 dnl #
134 dnl #  Definitive check for whether the compiler is clang
135 dnl #
136 AX_CC_IS_CLANG
137 if test "x$ax_cv_cc_clang" = "xyes"; then
138   AC_SUBST(clang_path, "$CC")
139 else
140   AC_SUBST(clang_path, "")
141 fi
142
143
144 dnl #
145 dnl #  Set Default CFLAGS for GCC compatible compilers
146 dnl #
147 if test "x$GCC" = "xyes"; then
148   CFLAGS="$CFLAGS -Wall -std=c99 -D_GNU_SOURCE"
149 fi
150
151 dnl #
152 dnl #  -Qunused-arguments means the compiler won't complain about unsupported arguments
153 dnl #
154 AX_CC_QUNUSED_ARGUMENTS_FLAG
155 if test "x$ax_cv_cc_qunused_arguments_flag" = "xyes"; then
156   CFLAGS="$CFLAGS -Qunused-arguments"
157   LDFLAGS="$LDFLAGS -Qunused-arguments"
158 fi
159
160 dnl #
161 dnl #  Compile in large (2G+) file support.
162 dnl #
163 AC_SYS_LARGEFILE
164
165 dnl #
166 dnl #  check for system bytesex
167 dnl #  AC_DEFINES WORDS_BIGENDIAN
168 dnl #
169 AC_C_BIGENDIAN(
170   [AC_DEFINE(RADIUS_BIG_ENDIAN, 1, [Define if your processor stores words with the most significant byte first])],
171   [AC_DEFINE(RADIUS_LITTLE_ENDIAN, 1, [Define if your processor stores words with the least significant byte first])]
172 )
173
174 dnl #
175 dnl #  Find GNU Make.
176 dnl #
177 AC_CHECK_PROG(GMAKE, gmake, yes, no)
178 if test $GMAKE = no; then
179   AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
180 else
181   AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
182 fi
183 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
184 if test -z "$makever"; then
185   AC_MSG_ERROR([GNU Make is not installed.  Please download and install it from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.])
186 fi
187
188 dnl #
189 dnl #  autoconf explicitly sets MAKEFLAGS and MFLAGS to '' even though we
190 dnl #  didn't tell it to, so we have to use FR_MAKEFLAGS.
191 dnl #
192 dnl #  determine the number of cores available and set the number of build
193 dnl #  processes appropriately.
194 dnl #
195 AX_SYSTEM_CORES
196
197 dnl #  Temporarily disabled because test and installation targets do not
198 dnl #  have dependencies set up correctly for multiple build processes.
199 dnl if test "x$ax_cv_system_cores" != "x"; then
200 dnl  : ${FR_MAKEFLAGS=-j$ax_cv_system_cores}
201 dnl fi
202 AC_SUBST(FR_MAKEFLAGS)
203
204 dnl #
205 dnl #  See if we have Git.
206 dnl #
207 AC_CHECK_PROG(GIT, git, yes, no)
208
209 dnl Put this in later, when all distributed modules use autoconf.
210 dnl AC_ARG_WITH(disablemodulefoo,
211 dnl [  --without-rlm_foo         Disables module compilation.  Module list:]
212 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
213 dnl   sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
214 dnl   awk '{print "                            "$0}']))
215
216 AC_ARG_ENABLE(strict-dependencies,
217 [  --enable-strict-dependencies  fail configure on lack of module dependancy.])
218
219 AC_ARG_ENABLE(werror,
220 [  --enable-werror         causes the build to fail if any warnings are generated.],
221 [ case "$enableval" in
222     no)
223       werror=no
224     ;;
225     *)
226       werror=yes
227   esac ]
228 )
229
230 dnl #
231 dnl #  extra argument: --with-docdir
232 dnl #
233 docdir='${datadir}/doc/freeradius'
234 AC_MSG_CHECKING([docdir])
235 AC_ARG_WITH(docdir,
236 [  --with-docdir=DIR       directory for documentation [DATADIR/doc/freeradius] ],
237 [ case "$withval" in
238   no)
239     docdir=no
240     ;;
241   yes)
242     ;;
243   [[\\/$]]* | ?:[[\\/]]* )
244     docdir="$withval"
245     ;;
246   *)
247     AC_MSG_ERROR([expected an absolute directory name for --with-docdir: $withval])
248     ;;
249   esac ]
250 )
251 AC_SUBST(docdir)
252 AC_MSG_RESULT($docdir)
253 if test "x$docdir" = xno; then
254   AC_MSG_WARN([Documentation files will NOT be installed.])
255 fi
256
257 dnl #
258 dnl #  extra argument: --with-logdir
259 dnl #
260 logdir='${localstatedir}/log/radius'
261 AC_MSG_CHECKING(logdir)
262 AC_ARG_WITH(logdir,
263 [  --with-logdir=DIR       directory for logfiles [LOCALSTATEDIR/log/radius] ],
264 [ case "$withval" in
265   no)
266     AC_MSG_ERROR([Need logdir])
267     ;;
268   yes)
269     ;;
270   [[\\/$]]* | ?:[[\\/]]* )
271     logdir="$withval"
272     ;;
273   *)
274     AC_MSG_ERROR([expected an absolute directory name for --with-logdir: $withval])
275     ;;
276   esac ]
277 )
278 AC_SUBST(logdir)
279 AC_MSG_RESULT($logdir)
280
281 dnl #
282 dnl #  extra argument: --with-radacctdir
283 dnl #
284 radacctdir='${logdir}/radacct'
285 AC_MSG_CHECKING(radacctdir)
286 AC_ARG_WITH(radacctdir,
287 [  --with-radacctdir=DIR   directory for detail files [LOGDIR/radacct] ],
288 [ case "$withval" in
289   no)
290     AC_MSG_ERROR([Need radacctdir])
291     ;;
292   yes)
293     ;;
294   [[\\/$]]* | ?:[[\\/]]* )
295     radacctdir="$withval"
296     ;;
297   *)
298     AC_MSG_ERROR([expected an absolute directory name for --with-radacctdir: $withval])
299     ;;
300   esac ]
301 )
302 AC_SUBST(radacctdir)
303 AC_MSG_RESULT($radacctdir)
304
305 dnl #
306 dnl #  extra argument: --with-raddbdir
307 dnl #
308 raddbdir='${sysconfdir}/raddb'
309 AC_MSG_CHECKING(raddbdir)
310 AC_ARG_WITH(raddbdir,
311 [  --with-raddbdir=DIR     directory for config files [SYSCONFDIR/raddb] ],
312 [ case "$withval" in
313   no)
314     AC_MSG_ERROR([Need raddbdir])
315     ;;
316   yes)
317     ;;
318   [[\\/$]]* | ?:[[\\/]]* )
319     raddbdir="$withval"
320     ;;
321   *)
322     AC_MSG_ERROR([expected an absolute directory name for --with-raddbdir: $withval])
323     ;;
324   esac ]
325 )
326 AC_SUBST(raddbdir)
327 AC_MSG_RESULT($raddbdir)
328
329 dnl #
330 dnl #  extra argument: --with-dictdir
331 dnl #
332 dictdir='${datarootdir}/freeradius'
333 AC_MSG_CHECKING(dictdir)
334 AC_ARG_WITH(dictdir,
335 [  --with-dictdir=DIR      directory for dictionary files [DATAROOTDIR/freeradius] ],
336 [ case "$withval" in
337   no)
338     AC_MSG_ERROR([Need dictdir])
339     ;;
340   yes)
341     ;;
342   [[\\/$]]* | ?:[[\\/]]* )
343     dictdir="$withval"
344     ;;
345   *)
346     AC_MSG_ERROR([expected an absolute directory name for --with-dictdir: $withval])
347     ;;
348   esac ]
349 )
350 AC_SUBST(dictdir)
351 AC_MSG_RESULT($dictdir)
352
353 modconfdir='${raddbdir}/mods-config'
354 AC_SUBST(modconfdir)
355
356 dnl #
357 dnl #  extra argument: --with-ascend-binary
358 dnl #
359 WITH_ASCEND_BINARY=yes
360 AC_ARG_WITH(ascend-binary,
361 [  --with-ascend-binary    include support for Ascend binary filter attributes (default=yes)],
362 [ case "$withval" in
363   yes)
364     ;;
365   *)
366     WITH_ASCEND_BINARY=no
367   esac ]
368 )
369 if test "x$WITH_ASCEND_BINARY" = "xyes"; then
370   AC_DEFINE(WITH_ASCEND_BINARY, [1], [include support for Ascend binary filter attributes])
371 fi
372
373 dnl #
374 dnl #  extra argument: --with-threads
375 dnl #
376 WITH_THREADS=yes
377 AC_ARG_WITH(threads,
378 [  --with-threads          use threads, if available.  (default=yes) ],
379 [ case "$withval" in
380   yes)
381     ;;
382   *)
383     WITH_THREADS=no
384   esac ]
385 )
386
387 dnl #
388 dnl #  extra argument: --with-tcp
389 dnl #
390 WITH_TCP=yes
391 AC_ARG_WITH(tcp,
392 [  --with-tcp              compile in TCP support. (default=yes)],
393 [ case "$withval" in
394   yes)
395     ;;
396   *)
397     WITH_TCP=no
398   esac ]
399 )
400 if test "x$WITH_TCP" = "xyes"; then
401   AC_DEFINE(WITH_TCP, [1], [define if you want TCP support (For RADSec et al)])
402 fi
403
404 dnl #
405 dnl #  extra argument: --with-vmps
406 dnl #
407 WITH_VMPS=yes
408 AC_ARG_WITH(vmps,
409 [  --with-vmps             compile in VMPS support. (default=yes)],
410 [ case "$withval" in
411   yes)
412     ;;
413   *)
414     WITH_VMPS=no
415   esac ]
416 )
417 if test "x$WITH_VMPS" = "xyes"; then
418   AC_DEFINE(WITH_VMPS, [1], [define if you want VMPS support])
419 fi
420
421 dnl #
422 dnl #  extra argument: --with-dhcp
423 dnl #
424 WITH_DHCP=yes
425 AC_ARG_WITH(dhcp,
426 [  --with-dhcp             compile in DHCP support. (default=yes)],
427 [ case "$withval" in
428   yes)
429     ;;
430   *)
431     WITH_DHCP=no
432   esac ]
433 )
434 if test "x$WITH_DHCP" = "xyes"; then
435   AC_DEFINE(WITH_DHCP, [1], [define if you want DHCP support])
436 fi
437
438 dnl #
439 dnl #  Allow the user to specify a list of modules to be linked
440 dnl #  statically to the server.
441 dnl #
442 STATIC_MODULES=
443 AC_ARG_WITH(static_modules,
444 [  --with-static-modules=QUOTED-MODULE-LIST],[
445   for i in $withval; do
446     STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
447   done
448 ])
449
450 USE_SHARED_LIBS=yes
451 AC_ARG_WITH(shared-libs,
452 [AS_HELP_STRING([--with-shared-libs ],
453 [build dynamic libraries and link against them. (default=yes)])],
454 [ case "$withval" in
455   no)
456     USE_SHARED_LIBS=no
457     ;;
458   *)
459   esac
460 ])
461
462 MODULES=
463 AC_ARG_WITH(modules,
464 [  --with-modules=QUOTED-MODULE-LIST],[
465  for i in $withval; do
466    MODULES="$MODULES $i"
467  done
468 ])
469
470 dnl #
471 dnl #  extra argument: --with-experimental-modules
472 dnl #
473 EXPERIMENTAL=
474 AC_ARG_WITH(experimental-modules,
475 [AS_HELP_STRING([--with-experimental-modules],
476 [use experimental and unstable modules. (default=no, unless --enable-developer=yes)])],
477 [ case "$withval" in
478   yes)
479     EXPERIMENTAL=yes
480     ;;
481   no)
482     EXPERIMENTAL=no
483     ;;
484   *)
485   esac ]
486 )
487
488 dnl #
489 dnl #  extra argument: --with-udpfromto
490 dnl #
491 WITH_UDPFROMTO=yes
492 AC_ARG_WITH(udpfromto,
493 [  --with-udpfromto        compile in UDPFROMTO support. (default=yes)],
494 [ case "$withval" in
495   yes)
496     WITH_UDPFROMTO=yes
497     ;;
498   *)
499     WITH_UDPFROMTO=no
500   esac ]
501 )
502
503 if test "x$WITH_UDPFROMTO" = "xyes"; then
504   AC_DEFINE(WITH_UDPFROMTO, [], [define if you want udpfromto])
505 fi
506
507 dnl #
508 dnl #  These next two arguments don't actually do anything.  They're
509 dnl #  place holders so that the top-level configure script can tell
510 dnl #  the user how to configure lower-level modules
511 dnl #
512
513 dnl #
514 dnl #  extra argument: --with-rlm-FOO-lib-dir
515 dnl #
516 AC_ARG_WITH(rlm-FOO-lib-dir,
517 [AS_HELP_STRING([--with-rlm-FOO-lib-dir=DIR],
518 [directory in which to look for library files used by module FOO])],
519 [ case "$withval" in
520   *)
521     ;;
522   esac ]
523 )
524
525 dnl #
526 dnl #  extra argument: --with-rlm-FOO-include-dir
527 dnl #
528 AC_ARG_WITH(rlm-FOO-include-dir,
529 [AS_HELP_STRING([--with-rlm-FOO-include-dir=DIR],
530 [directory in which to look for include files used by module FOO])],
531 [ case "$withval" in
532   *)
533     ;;
534   esac ]
535 )
536
537 dnl #
538 dnl #  extra argument: --with-openssl
539 dnl #
540 WITH_OPENSSL=yes
541 AC_ARG_WITH(openssl,
542 [  --with-openssl          use OpenSSL. (default=yes)],
543 [ case "$withval" in
544   no)
545     WITH_OPENSSL=no
546     ;;
547   *)
548     WITH_OPENSSL=yes
549     ;;
550   esac ]
551 )
552
553 dnl #
554 dnl #  extra argument: --with-openssl-lib-dir=dir
555 dnl #
556 openssl_lib_dir=
557 AC_ARG_WITH(openssl-lib-dir,
558 [AS_HELP_STRING([--with-openssl-lib-dir=DIR],
559 [directory to look for OpenSSL library files])],
560 [ case "$withval" in
561   *) openssl_lib_dir="$withval"
562     ;;
563   esac ]
564 )
565
566 dnl #
567 dnl #  extra argument: --with-openssl-includes=dir
568 dnl #
569 openssl_include_dir=
570 AC_ARG_WITH(openssl-include-dir,
571 [AS_HELP_STRING([--with-openssl-include-dir=DIR],
572 [directory to look for OpenSSL include files])],
573 [ case "$withval" in
574   *) openssl_include_dir="$withval"
575     ;;
576   esac ]
577 )
578
579 dnl #############################################################
580 dnl #
581 dnl #  1. Checks for programs
582 dnl #
583 dnl #############################################################
584
585 CHECKRAD=checkrad
586 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
587 if test "x$ac_cv_path_PERL" = "x"; then
588   AC_MSG_WARN([perl not found - Simultaneous-Use and checkrad may not work])
589 fi
590 AC_PATH_PROG(SNMPGET, snmpget)
591 if test "x$ac_cv_path_SNMPGET" = "x"; then
592   AC_MSG_WARN([snmpget not found - Simultaneous-Use and checkrad may not work])
593 fi
594
595 AC_PATH_PROG(SNMPWALK, snmpwalk)
596 if test "x$ac_cv_path_SNMPWALK" = "x"; then
597   AC_MSG_WARN([snmpwalk not found - Simultaneous-Use and checkrad may not work])
598 fi
599
600 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
601
602 dnl #
603 dnl #  FIXME This is truly gross.
604 dnl #
605 missing_dir=`cd $ac_aux_dir && pwd`
606 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
607 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
608 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
609
610 AC_PATH_PROG(LOCATE,locate)
611 AC_PATH_PROG(DIRNAME,dirname)
612 AC_PATH_PROG(GREP,grep)
613
614 dnl #############################################################
615 dnl #
616 dnl #  2. Checks for libraries
617 dnl #
618 dnl #############################################################
619
620 dnl Check for talloc
621 dnl extra argument: --with-talloc-lib-dir=DIR
622 talloc_lib_dir=
623 AC_ARG_WITH(talloc-lib-dir,
624   [AS_HELP_STRING([--with-talloc-lib-dir=DIR],
625   [directory in which to look for talloc library files])],
626   [case "$withval" in
627     no)
628       AC_MSG_ERROR([Need talloc-lib-dir])
629       ;;
630     yes)
631       ;;
632     *)
633       talloc_lib_dir="$withval"
634       ;;
635   esac])
636
637 dnl extra argument: --with-talloc-include-dir=DIR
638 talloc_include_dir=
639 AC_ARG_WITH(talloc-include-dir,
640   [AS_HELP_STRING([--with-talloc-include-dir=DIR],
641   [directory in which to look for talloc include files])],
642   [case "$withval" in
643     no)
644       AC_MSG_ERROR([Need talloc-include-dir])
645       ;;
646     yes)
647       ;;
648     *)
649       talloc_include_dir="$withval"
650       ;;
651   esac])
652
653 smart_try_dir="$talloc_lib_dir"
654 FR_SMART_CHECK_LIB(talloc, _talloc)
655 if test "x$ac_cv_lib_talloc__talloc" != "xyes"; then
656   AC_MSG_WARN([talloc library not found. Use --with-talloc-lib-dir=<path>.])
657   AC_MSG_ERROR([FreeRADIUS requires libtalloc])
658 fi
659
660 TALLOC_LIBS="${smart_lib}"
661 TALLOC_LDFLAGS="${smart_ldflags}"
662 AC_SUBST(TALLOC_LIBS)
663 AC_SUBST(TALLOC_LDFLAGS)
664 LIBS="$old_LIBS"
665
666 dnl #
667 dnl #  If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
668 dnl #
669 old_CFLAGS=$CFLAGS
670 if test "x$WITH_THREADS" = "xyes"; then
671   if test $ac_cv_prog_suncc = "yes"; then
672     CFLAGS="$CFLAGS -mt"
673   fi
674
675   AC_CHECK_HEADERS(pthread.h, [],
676     [
677       WITH_THREADS="no"
678       fail=[pthread.h]
679     ])
680
681   dnl #
682   dnl #  pthread stuff is usually in -lpthread
683   dnl #  or in -lc_r, on *BSD
684   dnl #
685   dnl #  On Some systems, we need extra pre-processor flags, to get them to
686   dnl #  to do the threading properly.
687   dnl #
688   AC_CHECK_LIB(pthread, pthread_create,
689     [
690       CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
691       LIBS="-lpthread $LIBS"
692     ],
693     [
694       dnl #
695       dnl # -pthread is not a typo, it's a GCC option which sets additional flags required
696       dnl # for multithreading with the pthreads library.
697       dnl #
698       AC_CHECK_LIB(c_r, pthread_create,
699         [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
700         [
701           WITH_THREADS="no"
702           fail=[-lpthread]
703         ]
704       )
705     ]
706   )
707
708   if test "x$WITH_THREADS" != "xyes"; then
709     AC_MSG_WARN([silently not building with thread support.])
710     AC_MSG_WARN([FAILURE: thread support requires: $fail.])
711   else
712     AC_DEFINE(WITH_THREADS, [1], [define if you want thread support])
713   fi
714 fi
715
716 dnl #
717 dnl #  If we have NO pthread libraries, remove any knowledge of threads.
718 dnl #
719 if test "x$WITH_THREADS" != "xyes"; then
720   CFLAGS=$old_CFLAGS
721   ac_cv_header_pthread_h="no"
722   WITH_THREADS=no
723 else
724   dnl #
725   dnl #  We need sem_init() and friends, as they're the friendliest
726   dnl #  semaphore functions for threading.
727   dnl #
728   dnl #  HP/UX requires linking with librt, too, to get the sem_* symbols.
729   dnl #  Some systems have them in -lsem
730   dnl #  Solaris has them in -lposix4
731   dnl #  NetBSD has them in -lsemaphore
732   dnl #
733
734   AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt semaphore,
735     [],
736     [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]])]
737   )
738 fi
739
740 dnl #
741 dnl #  Check if we need -lsocket
742 dnl #
743 AC_CHECK_LIB(dl, dlopen)
744
745 dnl #
746 dnl #  Check if we need -lsocket
747 dnl #
748 AC_CHECK_LIB(socket, getsockname)
749
750 dnl #
751 dnl #  Check for -lresolv
752 dnl #  This library may be needed later.
753 dnl #
754 AC_CHECK_LIB(resolv, inet_aton)
755
756 dnl #
757 dnl #  Check if we need -lnsl. Usually if we want to
758 dnl #  link against -lsocket we need to include -lnsl as well.
759 dnl #
760 AC_CHECK_LIB(nsl, inet_ntoa)
761 AC_CHECK_LIB(ws2_32, htonl)
762
763 dnl #
764 dnl #  Check the pcap library for the RADIUS sniffer.
765 dnl #
766 dnl extra argument: --with-pcap-lib-dir=DIR
767 pcap_lib_dir=
768 AC_ARG_WITH(pcap-lib-dir,
769   [AS_HELP_STRING([--with-pcap-lib-dir=DIR],
770   [directory in which to look for pcap library files])],
771   [case "$withval" in
772     no)
773       AC_MSG_ERROR([Need pcap-lib-dir])
774       ;;
775     yes)
776       ;;
777     *)
778       pcap_lib_dir="$withval"
779       ;;
780   esac])
781
782 dnl extra argument: --with-pcap-include-dir=DIR
783 pcap_include_dir=
784 AC_ARG_WITH(pcap-include-dir,
785   [AS_HELP_STRING([--with-pcap-include-dir=DIR],
786   [directory in which to look for pcap include files])],
787   [case "$withval" in
788     no)
789       AC_MSG_ERROR([Need pcap-include-dir])
790       ;;
791     yes)
792       ;;
793     *)
794       pcap_include_dir="$withval"
795       ;;
796   esac])
797
798 smart_try_dir="$pcap_lib_dir"
799 FR_SMART_CHECK_LIB(pcap, pcap_open_live)
800 if test "x$ac_cv_lib_pcap_pcap_open_live" != "xyes"; then
801   AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer, and ARP listener.  Use --with-pcap-lib-dir=<path>.])
802 else
803   AC_DEFINE(HAVE_LIBPCAP, 1,
804     [Define to 1 if you have the `pcap' library (-lpcap).]
805   )
806
807   AC_CHECK_FUNCS(\
808     pcap_fopen_offline \
809     pcap_dump_fopen \
810     pcap_create \
811     pcap_activate
812   )
813
814   PCAP_LIBS="${smart_lib}"
815   PCAP_LDFLAGS="${smart_ldflags}"
816 fi
817 dnl Set by FR_SMART_CHECK_LIB
818 LIBS="${old_LIBS}"
819
820 dnl Check for collectdclient
821 dnl extra argument: --with-collectdclient-lib-dir=DIR
822 collectdclient_lib_dir=
823 AC_ARG_WITH(collectdclient-lib-dir,
824   [AS_HELP_STRING([--with-collectdclient-lib-dir=DIR],
825   [directory in which to look for collectdclient library files])],
826   [case "$withval" in
827     no)
828       AC_MSG_ERROR([Need collectdclient-lib-dir])
829       ;;
830     yes)
831       ;;
832     *)
833       collectdclient_lib_dir="$withval"
834       ;;
835   esac])
836
837 dnl extra argument: --with-collectdclient-include-dir=DIR
838 collectdclient_include_dir=
839 AC_ARG_WITH(collectdclient-include-dir,
840   [AS_HELP_STRING([--with-collectdclient-include-dir=DIR],
841   [directory in which to look for collectdclient include files])],
842   [case "$withval" in
843     no)
844       AC_MSG_ERROR([Need collectdclient-include-dir])
845       ;;
846     yes)
847       ;;
848     *)
849       collectdclient_include_dir="$withval"
850       ;;
851   esac])
852
853 smart_try_dir="$collectdclient_lib_dir"
854 FR_SMART_CHECK_LIB(collectdclient, lcc_connect)
855 if test "x$ac_cv_lib_collectdclient_lcc_connect" != "xyes"; then
856   AC_MSG_WARN([collectdclient library not found. Use --with-collectdclient-lib-dir=<path>.])
857 else
858   COLLECTDC_LIBS="${smart_lib}"
859   COLLECTDC_LDFLAGS="${smart_ldflags}"
860 fi
861 dnl Set by FR_SMART_CHECKLIB
862 LIBS="${old_LIBS}"
863
864 VL_LIB_READLINE
865
866 dnl #############################################################
867 dnl #
868 dnl #  3. Checks for header files
869 dnl #
870 dnl #############################################################
871
872 dnl #
873 dnl # Check for talloc header files
874 dnl #
875 smart_try_dir="$talloc_include_dir"
876 FR_SMART_CHECK_INCLUDE([talloc.h])
877 if test "x$ac_cv_header_talloc_h" != "xyes"; then
878   AC_MSG_WARN([talloc headers not found. Use --with-talloc-include-dir=<path>.])
879   AC_MSG_ERROR([FreeRADIUS requires libtalloc])
880 fi
881
882 dnl #
883 dnl #  Interix requires us to set -D_ALL_SOURCE, otherwise
884 dnl #  getopt will be #included, but won't link.  <sigh>
885 dnl #
886 case "$host" in
887   *-interix*)
888     CFLAGS="$CFLAGS -D_ALL_SOURCE"
889     ;;
890   *-darwin*)
891     CFLAGS="$CFLAGS -DDARWIN"
892     LIBS="-framework DirectoryService $LIBS"
893     AC_DEFINE([__APPLE_USE_RFC_3542], 1, [Force OSX >= 10.7 Lion to use RFC2292 IPv6 socket options])
894     ;;
895 esac
896
897 AC_HEADER_DIRENT
898 AC_HEADER_STDC
899 AC_HEADER_TIME
900 AC_HEADER_SYS_WAIT
901
902 AC_CHECK_HEADERS( \
903   dlfcn.h \
904   unistd.h \
905   crypt.h \
906   errno.h \
907   resource.h \
908   sys/resource.h \
909   getopt.h \
910   malloc.h \
911   utmp.h \
912   utmpx.h \
913   signal.h \
914   sys/select.h \
915   syslog.h \
916   inttypes.h \
917   stdint.h \
918   stdbool.h \
919   stdio.h \
920   netdb.h \
921   semaphore.h \
922   arpa/inet.h \
923   netinet/in.h \
924   sys/types.h \
925   sys/socket.h \
926   winsock.h \
927   utime.h \
928   sys/time.h \
929   sys/wait.h \
930   sys/security.h \
931   fcntl.h \
932   sys/fcntl.h \
933   sys/prctl.h \
934   sys/ptrace.h \
935   sys/un.h \
936   glob.h \
937   prot.h \
938   pwd.h \
939   grp.h \
940   stddef.h \
941   fnmatch.h \
942   sia.h \
943   siad.h \
944   features.h \
945   limits.h
946 )
947
948 dnl #
949 dnl #  FreeBSD requires sys/socket.h before net/if.h
950 dnl #
951 AC_CHECK_HEADERS(net/if.h, [], [],
952   [
953     #ifdef HAVE_SYS_SOCKET_H
954     #  include <sys/socket.h>
955     #endif
956   ]
957 )
958
959 dnl #
960 dnl #  other checks which require headers
961 dnl #
962 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
963 then
964   AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
965 fi
966
967 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
968 then
969   AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
970 fi
971
972 dnl #
973 dnl #  Were we told to use OpenSSL, if we were and we find an error, call AC_MSG_FAILURE and exit
974 dnl #
975 if test "x$WITH_OPENSSL" = xyes; then
976   OLD_LIBS="$LIBS"
977
978   dnl #
979   dnl #  Apparently OpenSSL will attempt to build with kerberos if we don't pass this?!
980   dnl #
981   CFLAGS="$CFLAGS -DOPENSSL_NO_KRB5"
982
983   dnl #
984   dnl #  Check we can link to libcrypto and libssl
985   dnl #
986   smart_try_dir="$openssl_lib_dir"
987   FR_SMART_CHECK_LIB(crypto, DH_new)
988   if test "x$ac_cv_lib_crypto_DH_new" = "xyes"; then
989     AC_DEFINE(HAVE_LIBCRYPTO, 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
990     OPENSSL_LIBS="$smart_lib"
991     OPENSSL_LDFLAGS="$smart_ldflags"
992
993     FR_SMART_CHECK_LIB(ssl, SSL_new)
994     if test "x$ac_cv_lib_ssl_SSL_new" != "xyes"; then
995       AC_MSG_FAILURE([failed linking to libssl. Use --with-openssl-lib-dir=<path>, or --with-openssl=no (builds without OpenSSL)])
996     else
997       AC_DEFINE(HAVE_LIBSSL, 1, [Define to 1 if you have the `ssl' library (-lssl).])
998       OPENSSL_LIBS="$OPENSSL_LIBS $smart_lib"
999
1000       if test "$OPENSSL_LDFLAGS" != "$smart_ldflags"; then
1001         AC_MSG_FAILURE(["inconsistent LDFLAGS between -lssl '$smart_ldflags' and -lcrypto '$OPENSSL_LDFLAGS'"])
1002       fi
1003     fi
1004   else
1005     AC_MSG_FAILURE([failed linking to libcrypto. Use --with-openssl-lib-dir=<path>, or --with-openssl=no (builds without OpenSSL)])
1006   fi
1007
1008   smart_try_dir="$openssl_include_dir"
1009   FR_SMART_CHECK_INCLUDE(openssl/ssl.h)
1010   if test "x$ac_cv_header_openssl_ssl_h" = "xyes"; then
1011     AC_DEFINE(HAVE_OPENSSL_SSL_H, 1, [Define to 1 if you have the <openssl/ssl.h> header file.])
1012
1013     AC_CHECK_HEADERS( \
1014       openssl/crypto.h \
1015       openssl/err.h \
1016       openssl/evp.h \
1017       openssl/md5.h \
1018       openssl/md4.h \
1019       openssl/sha.h \
1020       openssl/ocsp.h \
1021       openssl/engine.h,
1022       [],
1023       [
1024         AC_MSG_FAILURE([failed locating OpenSSL headers. Use --with-openssl-include-dir=<path>, or --with-openssl=no (builds without OpenSSL)])
1025       ]
1026     )
1027
1028     AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
1029     AC_EGREP_CPP(yes,
1030       [#include <openssl/crypto.h>
1031        #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
1032        yes
1033        #endif
1034       ],
1035       [
1036         AC_MSG_RESULT(yes)
1037       ],
1038       [
1039         AC_MSG_RESULT(no)
1040         AC_MSG_FAILURE([OpenSSL version too old])
1041       ]
1042     )
1043
1044     dnl #
1045     dnl #  CPPFLAGS are passed to the compiler first, so we use
1046     dnl #  them to ensure things like --sysroot don't override the
1047     dnl #  library location we discovered previously.
1048     dnl #
1049     old_CPPFLAGS="$CPPFLAGS"
1050     CPPFLAGS="$OPENSSL_LDFLAGS $CPPFLAGS"
1051
1052     dnl #
1053     dnl #  Now check that the header versions match the library
1054     dnl #
1055     AC_MSG_CHECKING([OpenSSL library and header version consistency])
1056     AC_RUN_IFELSE(
1057       [AC_LANG_PROGRAM(
1058         [[
1059           #include <stdio.h>
1060           #include <openssl/opensslv.h>
1061           #include <openssl/crypto.h>
1062         ]],
1063         [[
1064           printf("library: %lx header: %lx... ", (unsigned long) SSLeay(), (unsigned long) OPENSSL_VERSION_NUMBER);
1065           if (SSLeay() == OPENSSL_VERSION_NUMBER) {
1066             return 0;
1067           } else {
1068             return 1;
1069           }
1070         ]]
1071       )],
1072       [
1073         AC_MSG_RESULT(yes)
1074       ],
1075       [
1076         AC_MSG_RESULT(no)
1077         AC_MSG_FAILURE([OpenSSL library version does not match header version])
1078       ]
1079     )
1080     CPPFLAGS="$old_CPPFLAGS"
1081   fi
1082
1083   LIBS="$OLD_LIBS"
1084   AC_SUBST(OPENSSL_LIBS)
1085   AC_SUBST(OPENSSL_LDFLAGS)
1086   export OPENSSL_LIBS OPENSSL_LDFLAGS
1087 fi
1088
1089 dnl #
1090 dnl #  Check the pcap includes for the RADIUS sniffer.
1091 dnl #
1092 if test "x$PCAP_LIBS" = x; then
1093   AC_MSG_NOTICE([skipping test for pcap.h.])
1094 else
1095   dnl #
1096   dnl # Check for pcap header files
1097   dnl #
1098   smart_try_dir="$pcap_include_dir"
1099   FR_SMART_CHECK_INCLUDE([pcap.h])
1100   if test "x$ac_cv_header_pcap_h" == "xyes"; then
1101     AC_DEFINE(HAVE_PCAP_H, 1, [Define to 1 if you have the <pcap.h> header file.])
1102     AC_SUBST(PCAP_LIBS)
1103     AC_SUBST(PCAP_LDFLAGS)
1104   else
1105     AC_MSG_WARN([pcap headers not found, silently disabling the RADIUS sniffer, and ARP listener. Use --with-pcap-include-dir=<path>.])
1106   fi
1107 fi
1108
1109 dnl Check for collectd-client
1110 if test "x$COLLECTDC_LIBS" = x; then
1111   AC_MSG_NOTICE([skipping test for collectd/client.h.])
1112 else
1113   dnl #
1114   dnl # Check for collectd-client header files
1115   dnl #
1116   smart_try_dir="$collectdclient_include_dir"
1117   FR_SMART_CHECK_INCLUDE([collectd/client.h])
1118   if test "x$ac_cv_header_collectd_client_h" == "xyes"; then
1119     AC_DEFINE(HAVE_COLLECTDC_H, 1, [Define to 1 if you have the `collectdclient' library (-lcollectdclient).])
1120     AC_SUBST(COLLECTDC_LIBS)
1121     AC_SUBST(COLLECTDC_LDFLAGS)
1122   else
1123     AC_MSG_WARN([collectdclient headers not found. Use --with-collectdclient-include-dir=<path>.])
1124   fi
1125 fi
1126
1127 dnl #############################################################
1128 dnl #
1129 dnl #  4. Checks for typedefs
1130 dnl #
1131 dnl #############################################################
1132
1133 dnl #
1134 dnl #  Ensure that these are defined
1135 dnl #
1136 AC_TYPE_OFF_T
1137 AC_TYPE_PID_T
1138 AC_TYPE_SIZE_T
1139 AC_TYPE_UID_T
1140
1141 dnl #
1142 dnl #  Check for socklen_t
1143 dnl #
1144 FR_CHECK_TYPE_INCLUDE(
1145   [
1146     #ifdef HAVE_SYS_TYPES_H
1147     #  include <sys/types.h>
1148     #endif
1149
1150     #ifdef HAVE_SYS_SOCKET_H
1151     #  include <sys/socket.h>
1152     #endif
1153   ],
1154   socklen_t, int, [socklen_t is generally 'int' on systems which don't use it]
1155 )
1156
1157 dnl #
1158 dnl #  Check for uint8_t
1159 dnl #
1160 FR_CHECK_TYPE_INCLUDE(
1161   [
1162     #ifdef HAVE_INTTYPES_H
1163     #  include <inttypes.h>
1164     #endif
1165
1166     #ifdef HAVE_STDINT_H
1167     #  include <stdint.h>
1168     #endif
1169   ],
1170   uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic]
1171 )
1172
1173 dnl #
1174 dnl #  Check for uint16_t
1175 dnl #
1176 FR_CHECK_TYPE_INCLUDE(
1177   [
1178     #ifdef HAVE_INTTYPES_H
1179     #  include <inttypes.h>
1180     #endif
1181
1182     #ifdef HAVE_STDINT_H
1183     #  include <stdint.h>
1184     #endif
1185   ],
1186   uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic]
1187 )
1188
1189 dnl #
1190 dnl #  Check for uint32_t
1191 dnl #
1192 FR_CHECK_TYPE_INCLUDE(
1193   [
1194     #ifdef HAVE_INTTYPES_H
1195     #  include <inttypes.h>
1196     #endif
1197
1198     #ifdef HAVE_STDINT_H
1199     #  include <stdint.h>
1200     #endif
1201   ],
1202   uint32_t, unsigned int, [uint32_t should be the canonical 'network integer']
1203 )
1204
1205 dnl #
1206 dnl #  Check for uint64_t
1207 dnl #
1208 FR_CHECK_TYPE_INCLUDE(
1209   [
1210     #ifdef HAVE_INTTYPES_H
1211     #  include <inttypes.h>
1212     #endif
1213
1214     #ifdef HAVE_STDINT_H
1215     #  include <stdint.h>
1216     #endif
1217   ],
1218   uint64_t, unsigned long long, [uint64_t is required for larger counters]
1219 )
1220
1221 dnl #
1222 dnl #  Check for __uint128_t (compiler builtin)
1223 dnl #
1224 AC_CHECK_TYPE(__uint128_t, AC_DEFINE(HAVE___UINT128_T, 1, [compiler specific 128 bit unsigned integer]), [], [])
1225
1226 dnl #
1227 dnl #  Check for uint128_t (fictitious future data type)
1228 dnl #
1229 AC_CHECK_TYPE(uint128_t, AC_DEFINE(HAVE_UINT128_T, 1, [128 bit unsigned integer]), [],
1230   [
1231     #ifdef HAVE_INTTYPES_H
1232     #  include <inttypes.h>
1233     #endif
1234
1235     #ifdef HAVE_STDINT_H
1236     #  include <stdint.h>
1237     #endif
1238   ]
1239 )
1240
1241 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [],
1242   [
1243     #ifdef HAVE_NETINET_IN_H
1244     #  include <netinet/in.h>
1245     #endif
1246   ]
1247 )
1248
1249 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [],
1250   [
1251     #ifdef HAVE_NETINET_IN_H
1252     #  include <netinet/in.h>
1253     #endif
1254
1255     #ifdef HAVE_SYS_SOCKET_H
1256     #  include <sys/socket.h>
1257     #endif
1258 ])
1259
1260 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [],
1261   [
1262     #ifdef HAVE_NETINET_IN_H
1263     #  include <netinet/in.h>
1264     #endif
1265 ])
1266
1267 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [],
1268   [
1269     #ifdef HAVE_SYS_TYPES_H
1270     #  include <sys/types.h>
1271     #endif
1272
1273     #ifdef HAVE_SYS_SOCKET_H
1274     #  include <sys/socket.h>
1275     #endif
1276
1277     #ifdef HAVE_NETDB_H
1278     #  include <netdb.h>
1279     #endif
1280   ]
1281 )
1282
1283 dnl #
1284 dnl #  Check for sig_t
1285 dnl #
1286 dnl #  FR_CHECK_TYPE_INCLUDE doesn't work for callbacks as it doesn't produce typedefs
1287 dnl #
1288 AC_MSG_CHECKING([if sig_t is defined])
1289 AC_LINK_IFELSE(
1290   [AC_LANG_PROGRAM(
1291     [[
1292       #ifdef HAVE_SIGNAL_H
1293       #  include <signal.h>
1294       #endif
1295     ]],
1296     [[
1297       sig_t func;
1298       return 0;
1299     ]]
1300   )],
1301   [
1302       AC_MSG_RESULT(yes)
1303       AC_DEFINE(HAVE_SIG_T, 1, [Define if the type sig_t is defined by signal.h])
1304   ],
1305   [
1306       AC_MSG_RESULT(no)
1307   ]
1308 )
1309
1310 dnl #############################################################
1311 dnl #
1312 dnl #  5. Checks for structures and functions
1313 dnl #
1314 dnl #############################################################
1315 AC_CHECK_FUNCS( \
1316   getopt_long \
1317   fcntl \
1318   strsignal \
1319   sigaction \
1320   sigprocmask \
1321   pthread_sigmask \
1322   snprintf \
1323   vsnprintf \
1324   setsid \
1325   strncasecmp \
1326   strcasecmp \
1327   localtime_r \
1328   ctime_r \
1329   gmtime_r \
1330   strsep \
1331   inet_aton \
1332   inet_pton \
1333   inet_ntop \
1334   mallopt \
1335   setlinebuf \
1336   setvbuf \
1337   getusershell \
1338   initgroups \
1339   getaddrinfo \
1340   getnameinfo \
1341   closefrom \
1342   gettimeofday \
1343   getpeereid \
1344   setuid \
1345   setresuid \
1346   getresuid \
1347   strlcat \
1348   strlcpy
1349 )
1350
1351 AC_TYPE_SIGNAL
1352
1353 dnl #
1354 dnl #  Check if we have utmpx.h
1355 dnl #  if so, check if struct utmpx has entry ut_xtime
1356 dnl #  if not, set it to define ut_xtime == ut_tv.tv_sec
1357 dnl #
1358 if test "x$ac_cv_header_utmpx_h" = "xyes"; then
1359  FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
1360  if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"; then
1361    AC_DEFINE(ut_xtime, ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
1362  fi
1363 fi
1364
1365 dnl #
1366 dnl #  struct ip_pktinfo
1367 dnl #
1368 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
1369 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"; then
1370   AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
1371 fi
1372
1373 dnl #
1374 dnl #  struct in6_pktinfo
1375 dnl #
1376 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
1377 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"; then
1378   AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
1379 fi
1380
1381 dnl #
1382 dnl #  Check for htonll and htonlll
1383 dnl #
1384 AC_MSG_CHECKING([if htonll is defined])
1385 AC_LINK_IFELSE(
1386   [AC_LANG_PROGRAM(
1387     [[
1388       #include <sys/types.h>
1389       #include <netinet/in.h>
1390     ]],
1391     [[
1392       return htonll(0);
1393     ]]
1394   )],
1395   [
1396       AC_MSG_RESULT(yes)
1397       AC_DEFINE(HAVE_HTONLL, 1, [Define if the function (or macro) htonll exists.])
1398   ],
1399   [
1400       AC_MSG_RESULT(no)
1401   ]
1402 )
1403
1404 AC_MSG_CHECKING([if htonlll is defined])
1405 AC_LINK_IFELSE(
1406   [AC_LANG_PROGRAM(
1407     [[
1408       #include <sys/types.h>
1409       #include <netinet/in.h>
1410     ]],
1411     [[
1412       return htonlll(0);
1413     ]]
1414   )],
1415   [
1416       AC_MSG_RESULT(yes)
1417       AC_DEFINE(HAVE_HTONLLL, 1, [Define if the function (or macro) htonlll exists.])
1418   ],
1419   [
1420       AC_MSG_RESULT(no)
1421   ]
1422 )
1423
1424 dnl #############################################################
1425 dnl #
1426 dnl #  6. Checks for compiler characteristics
1427 dnl #
1428 dnl #############################################################
1429
1430 dnl #
1431 dnl #  Ensure that these are defined
1432 dnl #
1433 AC_C_CONST
1434
1435 dnl #
1436 dnl #  See if this is OS/2
1437 dnl #
1438 AC_MSG_CHECKING([type of OS])
1439 OS=`uname -s`
1440 AC_MSG_RESULT($OS)
1441 if test "$OS" = "OS/2"; then
1442   LIBPREFIX=
1443 else
1444   LIBPREFIX=lib
1445 fi
1446 AC_SUBST(LIBPREFIX)
1447
1448 if test "x$developer" = "xyes"; then
1449   AC_MSG_NOTICE([Setting additional developer CFLAGS])
1450
1451   dnl #
1452   dnl #  Tell the compiler to parse doxygen documentation and verify it against function and variable declarations
1453   dnl #
1454   AX_CC_WDOCUMENTATION_FLAG
1455   if test "x$ax_cv_cc_wdocumentation_flag" = "xyes"; then
1456     devflags="-Wdocumentation"
1457   fi
1458
1459   if test "x$GCC" = "xyes"; then
1460     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"
1461     INSTALLSTRIP=""
1462   fi
1463
1464   AC_MSG_NOTICE([Developer CFLAGS are "$devflags"])
1465
1466   CFLAGS="$CFLAGS $devflags"
1467   dnl #
1468   dnl #  Enable experimental modules (we want to know if code changes breaks one of them)
1469   dnl #
1470   if test "x$EXPERIMENTAL" != "xno"; then
1471     AC_MSG_NOTICE([is developer build, enabling experimental modules implicitly, disable with --without-experimental-modules])
1472     EXPERIMENTAL=yes
1473   fi
1474 else
1475   devflags=""
1476   CFLAGS="$CFLAGS -DNDEBUG"
1477   INSTALLSTRIP=""
1478 fi
1479
1480 dnl #
1481 dnl #  May of been set outside of this configure script
1482 dnl #
1483 AC_MSG_CHECKING([if building with -DNDEBUG])
1484 if echo "$CFLAGS" | grep '\-DNDEBUG' > /dev/null; then
1485   AC_MSG_RESULT([yes])
1486   AC_DEFINE([WITH_NDEBUG], [1], [define if the server was built with -DNDEBUG])
1487 else
1488   AC_MSG_RESULT([no])
1489 fi
1490
1491 export EXPERIMENTAL
1492
1493 dnl #
1494 dnl #  append the current git hash onto the version string
1495 dnl #
1496 if test -d $srcdir/.git -a "x$GIT" = "xyes"; then
1497   RADIUSD_VERSION_COMMIT=`git log --pretty=format:'%h' -n 1`
1498   AC_DEFINE_UNQUOTED([RADIUSD_VERSION_COMMIT],[${RADIUSD_VERSION_COMMIT}],[Commit HEAD at time of configuring])
1499 fi
1500
1501 dnl #
1502 dnl #  check for some compiler features
1503 dnl #
1504 FR_TLS
1505 FR_HAVE_BUILTIN_CHOOSE_EXPR
1506 FR_HAVE_BUILTIN_TYPES_COMPATIBLE_P
1507 FR_HAVE_BUILTIN_BSWAP_64
1508
1509 dnl #############################################################
1510 dnl #
1511 dnl #  7. Checks for library functions
1512 dnl #
1513 dnl #############################################################
1514
1515 dnl #
1516 dnl # Check for talloc_set_memlimit
1517 dnl # This was only included in version 2.0.8
1518 dnl #
1519 AC_CHECK_LIB(talloc, talloc_set_memlimit,
1520   [
1521     AC_DEFINE(HAVE_TALLOC_SET_MEMLIMIT, 1, [Define to 1 if you have the function talloc_set_memlimit.])
1522   ]
1523 )
1524
1525 dnl #
1526 dnl # Check for libcrypt
1527 dnl # We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
1528 dnl #
1529 AC_CHECK_LIB(crypt, crypt,
1530   CRYPTLIB="-lcrypt"
1531 )
1532
1533 if test "$CRYPTLIB" != ""; then
1534   AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
1535 else
1536   AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
1537 fi
1538
1539 dnl Check for libcipher
1540 AC_CHECK_LIB(cipher, setkey,
1541    CRYPTLIB="${CRYPTLIB} -lcipher"
1542 )
1543 AC_SUBST(CRYPTLIB)
1544
1545 dnl #
1546 dnl #  Check for libexecinfo support, on some systems this is built into libc
1547 dnl #  on others it's a separate library.
1548 dnl #
1549 dnl extra argument: --with-execinfo-lib-dir
1550 execinfo_lib_dir=
1551 AC_ARG_WITH(execinfo-lib-dir,
1552 [AS_HELP_STRING([--with-execinfo-lib-dir=DIR],
1553 [directory in which to look for execinfo library files])],
1554 [ case "$withval" in
1555     no)
1556         AC_MSG_ERROR([Need execinfo-lib-dir])
1557         ;;
1558     yes)
1559         ;;
1560     *)
1561         execinfo_lib_dir="$withval"
1562         ;;
1563   esac ]
1564 )
1565
1566 dnl extra argument: --with-execinfo-include-dir
1567 execinfo_include_dir=
1568 AC_ARG_WITH(execinfo-include-dir,
1569 [AS_HELP_STRING([--with-execinfo-include-dir=DIR],
1570 [directory in which to look for execinfo include files])],
1571 [ case "$withval" in
1572     no)
1573         AC_MSG_ERROR([Need execinfo-include-dir])
1574         ;;
1575     yes)
1576         ;;
1577     *)
1578         execinfo_include_dir="$withval"
1579         ;;
1580   esac ]
1581 )
1582
1583 dnl #
1584 dnl #  Look for execinfo.h and symbols
1585 dnl #
1586 smart_try_dir=$execinfo_include_dir
1587 FR_SMART_CHECK_INCLUDE(execinfo.h)
1588 if test "x$ac_cv_header_execinfo_h" = "xyes"; then
1589   smart_try_dir=$execinfo_lib_dir
1590   FR_SMART_CHECK_LIB(execinfo, backtrace_symbols)
1591   if test "x$ac_cv_lib_execinfo_backtrace_symbols" != "xyes"; then
1592     dnl # Might be provided as part of libc
1593     AC_MSG_CHECKING([if execinfo provided as part of libc])
1594     AC_TRY_LINK(
1595       [
1596         #include <execinfo.h>
1597       ],
1598       [
1599         void *sym[1];
1600         backtrace_symbols(&sym, sizeof(sym)) ],
1601       [
1602         AC_MSG_RESULT(yes)
1603         ac_cv_lib_execinfo_backtrace_symbols="yes"
1604       ],
1605       [
1606         AC_MSG_RESULT(no)
1607       ]
1608     )
1609   fi
1610
1611   if test "x$ac_cv_lib_execinfo_backtrace_symbols" = "xyes"; then
1612     AC_DEFINE(HAVE_EXECINFO, [1], [define this if we have <execinfo.h> and symbols])
1613   fi
1614 fi
1615
1616 dnl #
1617 dnl #  Check for regular expression support, if were using PCRE it MUST be included
1618 dnl #  before all others, else we seem to still pickup the posix symbols for regcomp
1619 dnl #  and regexec, which results in crashes as soon as we call any posix regex
1620 dnl #  functions.
1621 dnl #
1622 dnl extra argument: --with-pcre-lib-dir
1623 pcre_lib_dir=
1624 AC_ARG_WITH(pcre-lib-dir,
1625 [AS_HELP_STRING([--with-pcre-lib-dir=DIR],
1626 [directory in which to look for pcre library files])],
1627 [ case "$withval" in
1628     no)
1629         AC_MSG_ERROR(Need pcre-lib-dir)
1630         ;;
1631     yes)
1632         ;;
1633     *)
1634         pcre_lib_dir="$withval"
1635         ;;
1636   esac ]
1637 )
1638
1639 dnl extra argument: --with-pcre-include-dir
1640 pcre_include_dir=
1641 AC_ARG_WITH(pcre-include-dir,
1642 [AS_HELP_STRING([--with-pcre-include-dir=DIR],
1643 [directory in which to look for pcre include files])],
1644 [ case "$withval" in
1645     no)
1646         AC_MSG_ERROR(Need pcre-include-dir)
1647         ;;
1648     yes)
1649         ;;
1650     *)
1651         pcre_include_dir="$withval"
1652         ;;
1653   esac ]
1654 )
1655
1656 dnl extra argument: --with-regex
1657 REGEX=
1658 AC_ARG_WITH(regex,
1659 [AS_HELP_STRING([--with-regex],
1660 [Whether to build with regular expressions (default=yes)])],
1661 [ case "$withval" in
1662     no)
1663         REGEX=no
1664         ;;
1665     *)
1666         ;;
1667   esac ]
1668 )
1669
1670 dnl #
1671 dnl #  First look for PCRE
1672 dnl #
1673 if test "x$REGEX" = "x"; then
1674   smart_try_dir=$pcre_include_dir
1675   FR_SMART_CHECK_INCLUDE(pcreposix.h)
1676   if test "x$ac_cv_header_pcreposix_h" = "xyes"; then
1677     smart_try_dir=$pcre_lib_dir
1678     FR_SMART_CHECK_LIB(pcre, pcre_compile)
1679     if test "x$ac_cv_lib_pcre_pcre_compile" = "xyes"; then
1680       REGEX=yes
1681
1682       smart_try_dir=$pcre_lib_dir
1683       AC_DEFINE(HAVE_PCRE, [1], [define this if we have libpcre])
1684
1685       dnl #
1686       dnl #  Hack to get -L<path> and -lpcreposix at the start
1687       dnl #  of the linker arguments.
1688       dnl #
1689       LIBS=$(echo "$LIBS" | sed -e 's/-lpcre/-lpcre -lpcreposix/')
1690     fi
1691   fi
1692 fi
1693
1694 dnl #
1695 dnl #  If no PCRE, fallback to POSIX regular expressions
1696 dnl #
1697 if test "x$REGEX" = "x"; then
1698   smart_try_dir=
1699   FR_SMART_CHECK_INCLUDE(regex.h)
1700   if test "x$ac_cv_header_regex_h" = "xyes"; then
1701     REGEX=yes
1702     AC_MSG_CHECKING([for extended regular expressions])
1703     AC_EGREP_CPP(yes,
1704       [
1705         #include <regex.h>
1706         #ifdef REG_EXTENDED
1707         yes
1708         #endif
1709       ],
1710       [
1711         AC_MSG_RESULT(yes)
1712         AC_DEFINE(HAVE_REG_EXTENDED, [1], [define this if we have REG_EXTENDED (from <regex.h>)])
1713       ],
1714       [
1715         AC_MSG_RESULT(no)
1716       ]
1717     )
1718
1719     dnl #
1720     dnl #  Some platforms require the regex library to be linked explicitly
1721     dnl #
1722     AC_CHECK_LIB(regex, regcomp,
1723       [
1724         LIBS="-lregex $LIBS"
1725       ]
1726     )
1727   fi
1728 fi
1729
1730 if test "x$REGEX" = "xyes"; then
1731   AC_DEFINE(HAVE_REGEX, 1, [Define if we have any regular expression library])
1732 fi
1733
1734 dnl #
1735 dnl #  Check the style of gethostbyaddr, in order of preference
1736 dnl #  GNU (_r eight args)
1737 dnl #
1738 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
1739
1740 dnl #
1741 dnl #  SYSV (_r six args)
1742 dnl #
1743 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
1744
1745 dnl #
1746 dnl #  BSD (three args, may not be thread safe)
1747 dnl #
1748 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
1749
1750 dnl #
1751 dnl #  Tru64 has BSD version, but it is thread safe
1752 dnl #  http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
1753 dnl #  We need #stdio.h to define NULL on FreeBSD (at least)
1754 dnl #
1755 gethostbyaddrrstyle=""
1756 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
1757 case "$host" in
1758   *-freebsd*)
1759     dnl #
1760     dnl #  With FreeBSD, check if there's a prototype for gethostbyaddr_r.
1761     dnl #  Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
1762     dnl #  override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
1763     dnl #  style support.
1764     dnl #
1765     AC_CHECK_DECLS([gethostbyaddr_r], [],
1766       [
1767         AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
1768           [style of gethostbyaddr_r functions ])
1769         gethostbyaddrrstyle=BSD
1770         AC_MSG_WARN([FreeBSD overridden to BSD-style])
1771       ],
1772       [
1773         #ifdef HAVE_NETDB_H
1774         #include <netdb.h>
1775         #endif
1776       ])
1777     ;;
1778 esac
1779
1780 if test "x$gethostbyaddrrstyle" = "x"; then
1781   AC_TRY_LINK(
1782     [
1783       #include <stdio.h>
1784       #include <netdb.h>
1785     ],
1786     [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ],
1787     [
1788       AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
1789       gethostbyaddrrstyle=GNU
1790     ]
1791   )
1792 fi
1793
1794 if test "x$gethostbyaddrrstyle" = "x"; then
1795   AC_TRY_LINK(
1796     [
1797       #include <stdio.h>
1798       #include <netdb.h>
1799     ],
1800     [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] ,
1801     [
1802       AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
1803       gethostbyaddrrstyle=SYSV
1804     ]
1805   )
1806 fi
1807
1808
1809 if test "x$gethostbyaddrrstyle" = "x"; then
1810   AC_TRY_LINK(
1811     [
1812       #include <stdio.h>
1813       #include <netdb.h>
1814     ],
1815     [ gethostbyaddr(NULL, 0, 0)  ],
1816     [
1817       AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1818       gethostbyaddrrstyle=BSD
1819     ]
1820   )
1821 fi
1822
1823 if test "x$gethostbyaddrrstyle" = "x"; then
1824   AC_MSG_RESULT([none!  It must not exist, here.])
1825 else
1826   AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1827 fi
1828
1829 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1830   AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1831 fi
1832
1833 dnl #
1834 dnl #  Check the style of gethostbyname, in order of preference
1835 dnl #  GNU (_r seven args)
1836 dnl #  SYSV (_r five args)
1837 dnl #  BSD (two args, may not be thread safe)
1838 dnl #  Tru64 has BSD version, but it _is_ thread safe
1839 dnl #    http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1840 dnl #  We need #stdio.h to define NULL on FreeBSD (at least)
1841 dnl #
1842 gethostbynamerstyle=""
1843 AC_MSG_CHECKING([gethostbyname_r() syntax])
1844 AC_TRY_LINK(
1845   [
1846     #include <stdio.h>
1847     #include <netdb.h>
1848   ],
1849   [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ],
1850   [
1851     AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1852     gethostbynamerstyle=GNU
1853   ]
1854 )
1855
1856 if test "x$gethostbynamerstyle" = "x"; then
1857   AC_TRY_LINK(
1858     [
1859       #include <stdio.h>
1860       #include <netdb.h>
1861     ],
1862     [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] ,
1863     [
1864       AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1865       gethostbynamerstyle=SYSV
1866     ]
1867   )
1868 fi
1869
1870 if test "x$gethostbynamerstyle" = "x"; then
1871   AC_TRY_LINK(
1872     [
1873       #include <stdio.h>
1874       #include <netdb.h>
1875     ],
1876     [ gethostbyname(NULL) ],
1877     [
1878       AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1879       gethostbynamerstyle=BSD
1880     ]
1881   )
1882 fi
1883
1884 if test "x$gethostbynamerstyle" = "x"; then
1885   AC_MSG_RESULT([none!  It must not exist, here.])
1886 else
1887   AC_MSG_RESULT([${gethostbynamerstyle}-style])
1888 fi
1889
1890 if test "x$gethostbynamerstyle" = "xBSD"; then
1891   AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1892 fi
1893
1894 dnl #
1895 dnl #  Check for thread-safe getpwnam_r and getgrnam_r
1896 dnl #
1897 if test "x$ac_cv_header_pwd_h" = "xyes"; then
1898   AC_MSG_CHECKING([getpwnam_r])
1899   AC_TRY_LINK(
1900     [
1901       #include <stdlib.h>
1902       #include <sys/types.h>
1903       #include <pwd.h>
1904     ],
1905     [ getpwnam_r(NULL, NULL, NULL, 0, NULL) ],
1906     [
1907       AC_MSG_RESULT([yes])
1908       AC_DEFINE(HAVE_GETPWNAM_R, 1,
1909                 [Define to 1 if you have the getpwnam_r.]
1910                 )
1911     ],
1912     [
1913         AC_MSG_RESULT(no)
1914     ]
1915   )
1916 fi
1917
1918 if test "x$ac_cv_header_grp_h" = "xyes"; then
1919   AC_MSG_CHECKING([getgrnam_r])
1920   AC_TRY_LINK(
1921     [
1922       #include <stdlib.h>
1923       #include <sys/types.h>
1924       #include <grp.h>
1925     ],
1926     [ getgrnam_r(NULL, NULL, NULL, 0, NULL) ],
1927     [
1928       AC_MSG_RESULT([yes])
1929       AC_DEFINE(HAVE_GETGRNAM_R, 1,
1930                 [Define to 1 if you have the getgrnam_r.]
1931                 )
1932     ],
1933     [
1934         AC_MSG_RESULT(no)
1935     ]
1936   )
1937 fi
1938
1939
1940 dnl #
1941 dnl #  Check for non-posix solaris ctime_r (extra buflen int arg)
1942 dnl #
1943 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1944 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1945 ctimerstyle=""
1946 AC_MSG_CHECKING([ctime_r() syntax])
1947 AC_TRY_LINK(
1948   [
1949     #include <time.h>
1950   ],
1951   [ ctime_r(NULL, NULL, 0) ],
1952   [
1953     AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1954     ctimerstyle="SOLARIS"
1955   ]
1956 )
1957
1958 if test "x$ctimerstyle" = "x"; then
1959   AC_TRY_LINK(
1960     [
1961       #include <time.h>
1962     ],
1963     [ ctime_r(NULL, NULL) ],
1964     [
1965       AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1966       ctimerstyle="POSIX"
1967     ]
1968   )
1969 fi
1970
1971 if test "x$ctimerstyle" = "x"; then
1972     AC_MSG_RESULT([none!  It must not exist, here.])
1973 else
1974     AC_MSG_RESULT([${ctimerstyle}-style])
1975 fi
1976
1977 AC_SUBST(HOSTINFO, $host)
1978
1979 dnl #############################################################
1980 dnl #
1981 dnl #  8. Checks for system services
1982 dnl #
1983 dnl #############################################################
1984
1985 dnl #
1986 dnl #  Figure out where libtool is located,
1987 dnl #
1988 top_builddir=`pwd`
1989 export top_builddir
1990 AC_MSG_RESULT([top_builddir=$top_builddir])
1991 dnl #  AC_SUBST(top_builddir)
1992
1993 dnl #
1994 dnl #  import libtool stuff
1995 dnl #
1996 dnl #############################################################
1997 dnl #
1998 dnl #  Configure in any module directories.
1999 dnl #
2000 dnl #############################################################
2001
2002 dnl ############################################################
2003 dnl #  Remove any conflicting definitions if autoconf.h
2004 dnl #  is being included by a module.
2005 dnl #############################################################
2006 AH_BOTTOM([#include <freeradius-devel/automask.h>])
2007
2008 dnl ############################################################
2009 dnl #  make modules by list
2010 dnl #############################################################
2011 if test "x$EXPERIMENTAL" = "xyes"; then
2012   for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
2013     MODULES="$MODULES $foo"
2014   done
2015 else
2016    dnl #
2017    dnl #  make ONLY the stable modules
2018    dnl #
2019    for foo in `cat "${srcdir}"/src/modules/stable`; do
2020       MODULES="$MODULES $foo"
2021    done
2022 fi
2023
2024 dnl ############################################################
2025 dnl #  Add autoconf subdirs, based on the module list we
2026 dnl #  previously created.
2027 dnl #############################################################
2028 mysubdirs=""
2029 for bar in $MODULES; do
2030   if test -f "${srcdir}"/src/modules/$bar/configure; then
2031     mysubdirs="$mysubdirs src/modules/$bar"
2032   fi
2033 done
2034
2035 dnl #
2036 dnl #  Don't change the variable name here.  Autoconf goes bonkers
2037 dnl #  if you do.
2038 dnl #
2039 AC_CONFIG_SUBDIRS($mysubdirs)
2040 AC_SUBST(MODULES)
2041
2042 dnl #############################################################
2043 dnl #
2044 dnl #  Add -Werror last, so it doesn't interfere with autoconf's
2045 dnl #  test programs.
2046 dnl #
2047 dnl #############################################################
2048 if test "x$werror" == "xyes"; then
2049   CFLAGS="-Werror $CFLAGS"
2050 fi
2051
2052 dnl #############################################################
2053 dnl #
2054 dnl #  And finally, output the results.
2055 dnl #
2056 dnl #############################################################
2057 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
2058 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
2059 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main && chmod +x checkrad radlast radtest)])
2060 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts && chmod +x rc.radiusd cron/radiusd.cron.daily cron/radiusd.cron.monthly cryptpasswd)])
2061
2062 dnl #
2063 dnl #  Substitute whatever libraries we found to be necessary
2064 dnl #
2065 AC_SUBST(LIBS)
2066 AC_SUBST(INSTALLSTRIP)
2067
2068 AC_SUBST(USE_SHARED_LIBS)
2069 USE_STATIC_LIBS="yes"
2070 AC_SUBST(USE_STATIC_LIBS)
2071 AC_SUBST(STATIC_MODULES)
2072
2073 AC_OUTPUT(\
2074   ./Make.inc \
2075   ./src/include/build-radpaths-h \
2076   ./src/main/radsniff.mk \
2077   ./src/main/checkrad \
2078   ./src/main/radlast \
2079   ./src/main/radtest \
2080   ./scripts/rc.radiusd \
2081   ./scripts/cron/radiusd.cron.daily \
2082   ./scripts/cron/radiusd.cron.monthly \
2083   ./scripts/cryptpasswd \
2084   ./raddb/radrelay.conf \
2085   ./raddb/radiusd.conf
2086 )