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