Fix typo
[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 AC_PROG_RANLIB
54
55 dnl Compile in large (2G+) file support.
56 AC_SYS_LARGEFILE
57
58 dnl # check for system bytesex
59 dnl # AC_DEFINES WORDS_BIGENDIAN
60 AC_C_BIGENDIAN
61
62 dnl Find GNU Make.
63 AC_CHECK_PROG(GMAKE, gmake, yes, no)
64 if test $GMAKE = no; then
65   AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
66 else
67   AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
68 fi
69 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
70 if test -z "$makever"; then
71   AC_MSG_ERROR(GNU Make is not installed.  Please download and install it
72                 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
73 fi
74
75 AC_ARG_WITH(system-libtldl,
76 [  --with-system-libtldl   Use the libtltdl installed in your system (default=use our own)],
77 [
78 LIBLTDL="-lltdl"
79 INCLTDL=
80 LTDL_SUBDIRS=
81 ],
82 [
83 AC_LIBLTDL_INSTALLABLE
84
85 dnl tell Makefile to build ltdl if needed
86 if test x"$enable_ltdl_install" = x"yes"; then
87   LTDL_SUBDIRS=libltdl
88 fi
89 ])
90 AC_SUBST(LTDL_SUBDIRS)
91
92 dnl use system-wide libtool, if it exists
93 AC_ARG_WITH(system-libtool,
94 [  --with-system-libtool   Use the libtool installed in your system (default=use our own)],
95 [ AC_PATH_PROG(LIBTOOL, libtool,,$PATH:/usr/local/bin) ],
96 [
97   LIBTOOL="`pwd`/libtool"
98   AC_SUBST(LIBTOOL)
99   dnl ensure that we're looking for dlopen
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   if test "x$OPENSSL_LIB_DIR" != "x"; then
524     LIBS="-L$OPENSSL_LIB_DIR $LIBS"
525   fi
526   AC_CHECK_LIB(crypto, DH_new,
527     [
528         LIBS="-lcrypto $LIBS"
529         AC_DEFINE(HAVE_LIBCRYPTO, 1,
530             [Define to 1 if you have the `crypto' library (-lcrypto).])
531         AC_CHECK_LIB(ssl, SSL_new,
532             [
533                 AC_DEFINE(HAVE_LIBSSL, 1,
534                     [Define to 1 if you have the `ssl' library (-lssl).])
535                 if test "x$OPENSSL_LIB_DIR" != "x"; then
536                     OPENSSL_LIBS="-L$OPENSSL_LIB_DIR"
537                 fi
538                 OPENSSL_LIBS="$OPENSSL_LIBS -lcrypto -lssl -lcrypto"
539             ], [])
540     ], [])
541   LIBS=$old_LIBS
542 fi
543
544 AC_CHECK_LIB(ws2_32, htonl)
545
546 dnl Check the pcap library for the RADIUS sniffer.
547 PCAP_LIBS=
548 AC_CHECK_LIB(pcap, pcap_open_live,
549         [ PCAP_LIBS="-lpcap"
550         AC_DEFINE(HAVE_LIBPCAP, 1,
551                 [Define to 1 if you have the `pcap' library (-lpcap).])
552         ],
553         [ AC_MSG_WARN([pcap library not found, silently disabling the RADIUS sniffer.]) ])
554
555 AC_LIB_READLINE
556
557 dnl #############################################################
558 dnl #
559 dnl #  3. Checks for header files
560 dnl #
561 dnl #############################################################
562
563 dnl #
564 dnl # Interix requires us to set -D_ALL_SOURCE, otherwise
565 dnl # getopt will be #included, but won't link.  <sigh>
566 dnl #
567 dnl #
568 case "$host" in
569 *-interix*)
570         CFLAGS="$CFLAGS -D_ALL_SOURCE"
571         ;;
572 *-darwin*)
573         CFLAGS="$CFLAGS -DDARWIN"
574         LIBS="-framework DirectoryService $LIBS"
575         ;;
576 esac
577
578 AC_HEADER_DIRENT
579 AC_HEADER_STDC
580 AC_HEADER_TIME
581 AC_HEADER_SYS_WAIT
582
583 AC_CHECK_HEADERS( \
584         unistd.h \
585         crypt.h \
586         errno.h \
587         resource.h \
588         sys/resource.h \
589         getopt.h \
590         malloc.h \
591         utmp.h \
592         utmpx.h \
593         signal.h \
594         sys/select.h \
595         syslog.h \
596         inttypes.h \
597         stdint.h \
598         stdio.h \
599         netdb.h \
600         semaphore.h \
601         arpa/inet.h \
602         netinet/in.h \
603         sys/types.h \
604         sys/socket.h \
605         winsock.h \
606         sys/time.h \
607         sys/wait.h \
608         sys/security.h \
609         fcntl.h \
610         sys/fcntl.h \
611         sys/prctl.h \
612         sys/un.h \
613         glob.h \
614         prot.h \
615         pwd.h \
616         grp.h \
617         sia.h \
618         siad.h
619 )
620
621 dnl FreeBSD requires sys/socket.h before net/if.h
622 AC_CHECK_HEADERS(net/if.h, [], [],
623 [#ifdef HAVE_SYS_SOCKET_H
624 # include <sys/socket.h>
625 # endif
626 ])
627
628 REGEX=no
629 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H, [], [define this if we have the <regex.h> header file]))
630 if test "x$ac_cv_header_regex_h" = "xyes"; then
631   REGEX_EXTENDED=no
632   REGEX=yes
633   AC_EGREP_CPP(yes,
634     [#include <regex.h>
635      #ifdef REG_EXTENDED
636        yes
637      #endif
638      ], [AC_DEFINE(HAVE_REG_EXTENDED, [], [define this if we have REG_EXTENDED (from <regex.h>)]) REGEX_EXTENDED=yes])
639 fi
640 AC_SUBST(REGEX)
641 AC_SUBST(REGEX_EXTENDED)
642
643 dnl #
644 dnl #  other checks which require headers
645 dnl #
646 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
647 then
648   AC_DEFINE(OSFC2, [], [define if you have OSFC2 authentication])
649 fi
650
651 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
652 then
653   AC_DEFINE(OSFSIA, [], [define if you have OSFSIA authentication])
654 fi
655
656 dnl Check for OpenSSL includes.
657 OPENSSL_INCLUDE="-DNO_OPENSSL"
658 if test "x$WITH_OPENSSL" = xyes; then
659   if test "x$OPENSSL_LIBS" = "x"; then
660     AC_MSG_NOTICE([skipping test for openssl/ssl.h])
661   else
662     old_CPPFLAGS=$CPPFLAGS
663     if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
664         CPPFLAGS="$CPPFLAGS -I$OPENSSL_INCLUDE_DIR"
665     fi
666     dnl # stupid RedHat shit
667     CPPFLAGS="$CPPFLAGS -DOPENSSL_NO_KRB5"
668     AC_CHECK_HEADERS( \
669         openssl/ssl.h \
670         openssl/crypto.h \
671         openssl/err.h \
672         openssl/evp.h \
673         openssl/engine.h,
674         [],
675         OPENSSL_LIBS=
676     )
677     if test "x$OPENSSL_LIBS" != "x"; then
678         AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
679         AC_EGREP_CPP(yes,
680             [#include <openssl/crypto.h>
681              #if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
682              yes
683              #endif
684             ], goodssl="yes")
685         if test "x$goodssl" != "xyes"; then
686             AC_MSG_RESULT(no)
687             OPENSSL_LIBS=
688         else
689             AC_MSG_RESULT(yes)
690             if test "x$OPENSSL_INCLUDE_DIR" != "x"; then
691                 OPENSSL_INCLUDE="-I$OPENSSL_INCLUDE_DIR -DOPENSSL_NO_KRB5"
692             else
693                 OPENSSL_INCLUDE="-DOPENSSL_NO_KRB5"
694             fi
695         fi
696     fi
697     CPPFLAGS=$old_CPPFLAGS
698   fi
699 fi
700 AC_SUBST(OPENSSL_INCLUDE)
701 AC_SUBST(OPENSSL_LIBS)
702 export OPENSSL_LIBS
703
704 dnl Check the pcap includes for the RADIUS sniffer.
705 if test "x$PCAP_LIBS" = x; then
706     AC_MSG_NOTICE([skipping test for pcap.h.])
707 else
708     AC_CHECK_HEADER(pcap.h,
709         AC_DEFINE(HAVE_PCAP_H, 1,
710                 [Define to 1 if you have the <pcap.h> header file.]),
711         [ PCAP_LIBS=
712         AC_MSG_WARN([pcap.h not found, silently disabling the RADIUS sniffer.])
713         ])
714 fi
715 AC_SUBST(PCAP_LIBS)
716
717 dnl #############################################################
718 dnl #
719 dnl #  4. Checks for typedefs
720 dnl #
721 dnl #############################################################
722
723 dnl #
724 dnl # Ensure that these are defined
725 dnl #
726 AC_TYPE_OFF_T
727 AC_TYPE_PID_T
728 AC_TYPE_SIZE_T
729 AC_TYPE_UID_T
730
731 dnl check for socklen_t
732 FR_CHECK_TYPE_INCLUDE([
733 #ifdef HAVE_SYS_TYPES_H
734 #include <sys/types.h>
735 #endif
736 #ifdef HAVE_SYS_SOCKET_H
737 #include <sys/socket.h>
738 #endif
739 ],socklen_t, int, [socklen_t is generally 'int' on systems which don't use it])
740
741 dnl check for uint8_t
742 FR_CHECK_TYPE_INCLUDE([
743 #ifdef HAVE_INTTYPES_H
744 #include <inttypes.h>
745 #endif
746 #ifdef HAVE_STDINT_H
747 #include <stdint.h>
748 #endif
749 ],uint8_t, unsigned char, [uint8_t should be the canonical 'octet' for network traffic])
750
751 dnl check for uint16_t
752 FR_CHECK_TYPE_INCLUDE([
753 #ifdef HAVE_INTTYPES_H
754 #include <inttypes.h>
755 #endif
756 #ifdef HAVE_STDINT_H
757 #include <stdint.h>
758 #endif
759 ],uint16_t, unsigned short, [uint16_t should be the canonical '2 octets' for network traffic])
760
761 dnl check for uint32_t
762 FR_CHECK_TYPE_INCLUDE([
763 #ifdef HAVE_INTTYPES_H
764 #include <inttypes.h>
765 #endif
766 #ifdef HAVE_STDINT_H
767 #include <stdint.h>
768 #endif
769 ],uint32_t, unsigned int, [uint32_t should be the canonical 'network integer])
770
771 AC_CHECK_TYPE(struct in6_addr, AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, [IPv6 address structure]), [], [
772 #ifdef HAVE_NETINET_IN_H
773 #include <netinet/in.h>
774 #endif
775 ])
776
777 AC_CHECK_TYPE(struct sockaddr_storage, AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Generic socket addresses]), [], [
778 #ifdef HAVE_NETINET_IN_H
779 #include <netinet/in.h>
780 #endif
781 #ifdef HAVE_SYS_SOCKET_H
782 #include <sys/socket.h>
783 #endif
784 ])
785
786 AC_CHECK_TYPE(struct sockaddr_in6, AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, [IPv6 socket addresses]), [], [
787 #ifdef HAVE_NETINET_IN_H
788 #include <netinet/in.h>
789 #endif
790 ])
791
792 AC_CHECK_TYPE(struct addrinfo, AC_DEFINE(HAVE_STRUCT_ADDRINFO, 1, [Generic DNS lookups]), [], [
793 #ifdef HAVE_SYS_TYPES_H
794 #include <sys/types.h>
795 #endif
796 #ifdef HAVE_SYS_SOCKET_H
797 #include <sys/socket.h>
798 #endif
799 #ifdef HAVE_NETDB_H
800 #include <netdb.h>
801 #endif
802 ])
803
804 dnl #############################################################
805 dnl #
806 dnl #  5. Checks for structures and functions
807 dnl #
808 dnl #############################################################
809 AC_CHECK_FUNCS( \
810         getopt_long \
811         lockf \
812         strsignal \
813         sigaction \
814         sigprocmask \
815         pthread_sigmask \
816         snprintf \
817         vsnprintf \
818         setsid \
819         strncasecmp \
820         strcasecmp \
821         localtime_r \
822         ctime_r \
823         gmtime_r \
824         strsep \
825         inet_aton \
826         inet_pton \
827         inet_ntop \
828         setlinebuf \
829         setvbuf \
830         getusershell \
831         initgroups \
832         getaddrinfo \
833         getnameinfo \
834         closefrom \
835         gettimeofday \
836         getpeereid \
837         setuid \
838         setresuid \
839         getresuid \
840         strlcat \
841         strlcpy
842 )
843 RADIUSD_NEED_DECLARATIONS( \
844         crypt \
845         strncasecmp \
846         strcasecmp \
847         inet_aton \
848         setlinebuf \
849         getusershell \
850         endusershell
851 )
852
853 AC_TYPE_SIGNAL
854
855 dnl # check if we have utmpx.h
856 dnl # if so, check if struct utmpx has entry ut_xtime
857 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
858 if test "x$ac_cv_header_utmpx_h" = "xyes"
859 then
860  FR_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
861  if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"
862  then
863    AC_DEFINE(ut_xtime,ut_tv.tv_sec, [define to something if you don't have ut_xtime in struct utmpx])
864  fi
865 fi
866
867 dnl # struct ip_pktinfo
868 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in_pktinfo], ipi_addr)
869 if test "x$ac_cv_type_struct_in_pktinfo_has_ipi_addr" = "xyes"
870 then
871         AC_DEFINE(HAVE_IP_PKTINFO, [], [define if you have IP_PKTINFO (Linux)])
872 fi
873
874 dnl # struct in6_pktinfo
875 FR_CHECK_STRUCT_HAS_MEMBER([#include <netinet/in.h>], [struct in6_pktinfo], ipi6_addr)
876 if test "x$ac_cv_type_struct_in6_pktinfo_has_ipi6_addr" = "xyes"
877 then
878         AC_DEFINE(HAVE_IN6_PKTINFO, [], [define if you have IN6_PKTINFO (Linux)])
879 fi
880
881 dnl #############################################################
882 dnl #
883 dnl #  6. Checks for compiler characteristics
884 dnl #
885 dnl #############################################################
886
887 dnl #
888 dnl # Ensure that these are defined
889 dnl #
890 AC_C_CONST
891
892 dnl #
893 dnl # See if this is OS/2
894 dnl #
895 AC_MSG_CHECKING(type of OS)
896 OS=`uname -s`
897 AC_MSG_RESULT($OS)
898 if test "$OS" = "OS/2"; then
899         LIBPREFIX=
900 else
901         LIBPREFIX=lib
902 fi
903 AC_SUBST(LIBPREFIX)
904
905 dnl #
906 dnl # Set Default CFLAGS
907 dnl #
908 if test "x$GCC" = "xyes"; then
909     CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
910 fi
911
912 AC_MSG_CHECKING(for developer gcc flags)
913 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
914   devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -W -Wredundant-decls -Wundef"
915   CFLAGS="$CFLAGS $devflags"
916   INSTALLSTRIP=""
917   AC_MSG_RESULT(yes.  Using $devflags)
918 else
919   devflags=""
920   CFLAGS="$CFLAGS -DNDEBUG"
921   INSTALLSTRIP=""
922   AC_MSG_RESULT(no.)
923 fi
924
925 FR_TLS
926
927 dnl #############################################################
928 dnl #
929 dnl #  7. Checks for library functions
930 dnl #
931 dnl #############################################################
932
933 dnl Check for libcrypt
934 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
935 AC_CHECK_LIB(crypt, crypt,
936   CRYPTLIB="-lcrypt"
937 )
938 if test "$CRYPTLIB" != ""; then
939   AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function])
940 else
941   AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT, [], [Do we have the crypt function]))
942 fi
943
944 dnl Check for libcipher
945 AC_CHECK_LIB(cipher, setkey,
946    CRYPTLIB="${CRYPTLIB} -lcipher"
947 )
948 AC_SUBST(CRYPTLIB)
949
950 dnl Check the style of gethostbyaddr, in order of preference
951 dnl GNU (_r eight args)
952 AC_DEFINE(GNUSTYLE, [1], [GNU-Style get*byaddr_r])
953 dnl SYSV (_r six args)
954 AC_DEFINE(SYSVSTYLE, [2], [SYSV-Style get*byaddr_r])
955 dnl BSD (three args, may not be thread safe)
956 AC_DEFINE(BSDSTYLE, [3], [BSD-Style get*byaddr_r])
957 dnl Tru64 has BSD version, but it is thread safe
958 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
959 dnl We need #stdio.h to define NULL on FreeBSD (at least)
960 gethostbyaddrrstyle=""
961 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
962 case "$host" in
963 *-freebsd*)
964 dnl With FreeBSD, check if there's a prototype for gethostbyaddr_r.
965 dnl Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
966 dnl override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
967 dnl style support.
968         AC_CHECK_DECLS([gethostbyaddr_r], [], [
969                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
970                         [style of gethostbyaddr_r functions ])
971                 gethostbyaddrrstyle=BSD
972                 AC_MSG_WARN([FreeBSD overridden to BSD-style])
973         ], [
974 #ifdef HAVE_NETDB_H
975 #include <netdb.h>
976 #endif
977 ])
978         ;;
979 esac
980 if test "x$gethostbyaddrrstyle" = "x"; then
981         AC_TRY_LINK([
982 #include <stdio.h>
983 #include <netdb.h>
984 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
985         AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE, [style of gethostbyaddr_r functions ])
986         gethostbyaddrrstyle=GNU
987 ])
988 fi
989 if test "x$gethostbyaddrrstyle" = "x"; then
990         AC_TRY_LINK([
991 #include <stdio.h>
992 #include <netdb.h>
993 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
994                 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE, [style of gethostbyaddr_r functions ])
995                 gethostbyaddrrstyle=SYSV
996         ])
997 fi
998 if test "x$gethostbyaddrrstyle" = "x"; then
999         AC_TRY_LINK([
1000 #include <stdio.h>
1001 #include <netdb.h>
1002 ], [ gethostbyaddr(NULL, 0, 0)  ], [
1003                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE, [style of gethostbyaddr_r functions ])
1004                 gethostbyaddrrstyle=BSD
1005         ])
1006 fi
1007
1008 if test "x$gethostbyaddrrstyle" = "x"; then
1009         AC_MSG_RESULT([none!  It must not exist, here.])
1010 else
1011         AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
1012 fi
1013
1014 if test "x$gethostbyaddrrstyle" = "xBSD"; then
1015         AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
1016 fi
1017
1018 dnl Check the style of gethostbyname, in order of preference
1019 dnl GNU (_r seven args)
1020 dnl SYSV (_r five args)
1021 dnl BSD (two args, may not be thread safe)
1022 dnl Tru64 has BSD version, but it _is_ thread safe
1023 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
1024 dnl We need #stdio.h to define NULL on FreeBSD (at least)
1025 gethostbynamerstyle=""
1026 AC_MSG_CHECKING([gethostbyname_r() syntax])
1027 AC_TRY_LINK([
1028 #include <stdio.h>
1029 #include <netdb.h>
1030 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ], [
1031         AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE, [style of gethostbyname_r functions ])
1032         gethostbynamerstyle=GNU
1033 ])
1034 if test "x$gethostbynamerstyle" = "x"; then
1035         AC_TRY_LINK([
1036 #include <stdio.h>
1037 #include <netdb.h>
1038 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] , [
1039                 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE, [style of gethostbyname_r functions ])
1040                 gethostbynamerstyle=SYSV
1041         ])
1042 fi
1043 if test "x$gethostbynamerstyle" = "x"; then
1044         AC_TRY_LINK([
1045 #include <stdio.h>
1046 #include <netdb.h>
1047 ], [ gethostbyname(NULL)  ], [
1048                 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE, [style of gethostbyname_r functions ])
1049                 gethostbynamerstyle=BSD
1050         ])
1051 fi
1052
1053 if test "x$gethostbynamerstyle" = "x"; then
1054         AC_MSG_RESULT([none!  It must not exist, here.])
1055 else
1056         AC_MSG_RESULT([${gethostbynamerstyle}-style])
1057 fi
1058
1059 if test "x$gethostbynamerstyle" = "xBSD"; then
1060         AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
1061 fi
1062
1063 dnl check for non-posix solaris ctime_r (extra buflen int arg)
1064 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
1065 AC_DEFINE(SOLARISSTYLE, [2], [Solaris-Style ctime_r])
1066 ctimerstyle=""
1067 AC_MSG_CHECKING([ctime_r() syntax])
1068 AC_TRY_LINK([
1069 #include <time.h>
1070 ], [ ctime_r(NULL, NULL, 0) ], [
1071         AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE, [style of ctime_r function])
1072         ctimerstyle="SOLARIS"
1073 ])
1074 if test "x$ctimerstyle" = "x"; then
1075         AC_TRY_LINK([
1076 #include <time.h>
1077 ], [ ctime_r(NULL, NULL) ], [
1078                 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE, [style of ctime_r function])
1079                 ctimerstyle="POSIX"
1080         ])
1081 fi
1082
1083 if test "x$ctimerstyle" = "x"; then
1084         AC_MSG_RESULT([none!  It must not exist, here.])
1085 else
1086         AC_MSG_RESULT([${ctimerstyle}-style])
1087 fi
1088
1089 AC_SUBST(HOSTINFO, $host)
1090
1091 dnl #############################################################
1092 dnl #
1093 dnl #  8. Checks for system services
1094 dnl #
1095 dnl #############################################################
1096
1097 dnl #
1098 dnl # Figure out where libtool is located,
1099 dnl #
1100 top_builddir=`pwd`
1101 export top_builddir
1102 AC_MSG_RESULT([top_builddir=$top_builddir])
1103 dnl # AC_SUBST(top_builddir)
1104 AC_SUBST(LIBLTDL)
1105 AC_SUBST(INCLTDL)
1106
1107 dnl import libtool stuff
1108
1109 dnl #############################################################
1110 dnl #
1111 dnl #  Configure in any module directories.
1112 dnl #
1113 dnl #############################################################
1114
1115 mysubdirs="$LIBLTDLPATH"
1116 if test "x$EXPERIMENTAL" = "xyes"; then
1117   bar=`ls -1 "${srcdir}"/src/modules/rlm_*/configure | sed 's%/configure%%'`
1118   dnl # get rid of LF's.
1119   mysubdirs=`echo $mysubdirs $bar`
1120 else
1121   dnl #
1122   dnl # Find 'configure' in ONLY the stable modules
1123   dnl #
1124   for bar in `cat "${srcdir}"/src/modules/stable`; do
1125     if test -f "${srcdir}"/src/modules/$bar/configure; then
1126       mysubdirs="$mysubdirs src/modules/$bar"
1127     fi
1128   done
1129 fi
1130
1131 dnl ############################################################
1132 dnl # make modules by list
1133 dnl #############################################################
1134 if test "x$EXPERIMENTAL" = "xyes"; then
1135   for foo in `ls -1 "${srcdir}"/src/modules | grep rlm_`; do
1136     MODULES="$MODULES $foo"
1137   done
1138 else
1139    dnl #
1140    dnl # make ONLY the stable modules
1141    dnl #
1142    for foo in `cat "${srcdir}"/src/modules/stable`; do
1143     MODULES="$MODULES $foo"
1144    done
1145 fi
1146
1147 dnl #
1148 dnl #  Don't change the variable name here.  Autoconf goes bonkers
1149 dnl #  if you do.
1150 dnl #
1151 AC_CONFIG_SUBDIRS($LTDL_SUBDIRS $mysubdirs)
1152 AC_SUBST(MODULES)
1153
1154 dnl #############################################################
1155 dnl #
1156 dnl #  And finally, output the results.
1157 dnl #
1158 dnl #############################################################
1159
1160 AC_CONFIG_COMMANDS([stamp-h], [echo timestamp > src/include/stamp-h])
1161 AC_CONFIG_COMMANDS([build-radpaths-h], [(cd ./src/include && /bin/sh ./build-radpaths-h)])
1162 AC_CONFIG_COMMANDS([main-chmod], [(cd ./src/main   && chmod +x checkrad.pl radlast radtest)])
1163 AC_CONFIG_COMMANDS([scripts-chmod], [(cd ./scripts    && chmod +x rc.radiusd radwatch radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
1164
1165 dnl #
1166 dnl #  Substitute whatever libraries we found to be necessary
1167 dnl #
1168 AC_SUBST(LIBS)
1169 AC_SUBST(INSTALLSTRIP)
1170
1171 USE_SHARED_LIBS=$enable_shared
1172 AC_SUBST(USE_SHARED_LIBS)
1173 USE_STATIC_LIBS=$enable_static
1174 AC_SUBST(USE_STATIC_LIBS)
1175 AC_SUBST(STATIC_MODULES)
1176 AC_SUBST(RADIUSD_MAJOR_VERSION)
1177 AC_SUBST(RADIUSD_MINOR_VERSION)
1178 AC_SUBST(RADIUSD_VERSION)
1179
1180 AC_OUTPUT(\
1181         ./Make.inc \
1182         ./src/include/build-radpaths-h \
1183         ./src/main/Makefile \
1184         ./src/main/checkrad.pl \
1185         ./src/main/radlast \
1186         ./src/main/radtest \
1187         ./scripts/rc.radiusd \
1188         ./scripts/radwatch \
1189         ./scripts/radiusd.cron.daily \
1190         ./scripts/radiusd.cron.monthly \
1191         ./scripts/cryptpasswd \
1192         ./raddb/dictionary \
1193         ./raddb/radrelay.conf \
1194         ./raddb/radiusd.conf
1195 )