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