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