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