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