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