Bump version number to 1.1.7
[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.7
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 dnl With FreeBSD, check if there's a prototype for gethostbyaddr_r.
849 dnl Some versions (FreeBSD 5.1?) have a symbol but no prototype - so we
850 dnl override this test to BSDSTYLE. FreeBSD 6.2 and up have proper GNU
851 dnl style support.
852         AC_CHECK_DECLS([gethostbyaddr_r], [], [
853                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE,
854                         [style of gethostbyaddr_r functions ])
855                 gethostbyaddrrstyle=BSD
856                 AC_MSG_WARN([FreeBSD overridden to BSD-style])
857         ], [
858 #ifdef HAVE_NETDB_H
859 #include <netdb.h>
860 #endif
861 ])
862         ;;
863 esac
864 if test "x$gethostbyaddrrstyle" = "x"; then
865         AC_TRY_LINK([
866 #include <stdio.h>
867 #include <netdb.h>
868 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
869         AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
870         gethostbyaddrrstyle=GNU
871 ])
872 fi
873 if test "x$gethostbyaddrrstyle" = "x"; then
874         AC_TRY_LINK([
875 #include <stdio.h>
876 #include <netdb.h>
877 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
878                 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
879                 gethostbyaddrrstyle=SYSV
880         ])
881 fi
882 if test "x$gethostbyaddrrstyle" = "x"; then
883         AC_TRY_LINK([
884 #include <stdio.h>
885 #include <netdb.h>
886 ], [ gethostbyaddr(NULL, 0, 0)  ], [
887                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
888                 gethostbyaddrrstyle=BSD
889         ])
890 fi
891
892 if test "x$gethostbyaddrrstyle" = "x"; then
893         AC_MSG_RESULT([none!  It must not exist, here.])
894 else
895         AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
896 fi
897
898 if test "x$gethostbyaddrrstyle" = "xBSD"; then
899         AC_MSG_WARN([ ****** BSD-style gethostbyaddr might NOT be thread-safe! ****** ])
900 fi
901
902 dnl Check the style of gethostbyname, in order of preference
903 dnl GNU (_r seven args)
904 dnl SYSV (_r five args)
905 dnl BSD (two args, may not be thread safe)
906 dnl Tru64 has BSD version, but it _is_ thread safe
907 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
908 dnl We need #stdio.h to define NULL on FreeBSD (at least)
909 gethostbynamerstyle=""
910 AC_MSG_CHECKING([gethostbyname_r() syntax])
911 AC_TRY_LINK([
912 #include <stdio.h>
913 #include <netdb.h>
914 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ], [
915         AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE)
916         gethostbynamerstyle=GNU
917 ])
918 if test "x$gethostbynamerstyle" = "x"; then
919         AC_TRY_LINK([
920 #include <stdio.h>
921 #include <netdb.h>
922 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] , [
923                 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE)
924                 gethostbynamerstyle=SYSV
925         ])
926 fi
927 if test "x$gethostbynamerstyle" = "x"; then
928         AC_TRY_LINK([
929 #include <stdio.h>
930 #include <netdb.h>
931 ], [ gethostbyname(NULL)  ], [
932                 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE)
933                 gethostbynamerstyle=BSD
934         ])
935 fi
936
937 if test "x$gethostbynamerstyle" = "x"; then
938         AC_MSG_RESULT([none!  It must not exist, here.])
939 else
940         AC_MSG_RESULT([${gethostbynamerstyle}-style])
941 fi
942
943 if test "x$gethostbynamerstyle" = "xBSD"; then
944         AC_MSG_WARN([ ****** BSD-style gethostbyname might NOT be thread-safe! ****** ])
945 fi
946
947 dnl check for non-posix solaris ctime_r (extra buflen int arg)
948 ctimerstyle=""
949 AC_MSG_CHECKING([ctime_r() syntax])
950 AC_TRY_LINK([
951 #include <time.h>
952 ], [ ctime_r(NULL, NULL, 0) ], [
953         AC_DEFINE(CTIMERSTYLE, SOLARISSTYLE)
954         ctimerstyle="SOLARIS"
955 ])
956 if test "x$ctimerstyle" = "x"; then
957         AC_TRY_LINK([
958 #include <time.h>
959 ], [ ctime_r(NULL, NULL) ], [
960                 AC_DEFINE(CTIMERSTYLE, POSIXSTYLE)
961                 ctimerstyle="POSIX"
962         ])
963 fi
964
965 if test "x$ctimerstyle" = "x"; then
966         AC_MSG_RESULT([none!  It must not exist, here.])
967 else
968         AC_MSG_RESULT([${ctimerstyle}-style])
969 fi
970
971
972 dnl If configuring with large file support, determine the right flags to
973 dnl use based on the platform.  This is the wrong approach; autoconf 2.50
974 dnl comes with a macro that takes the right approach.  But this works well
975 dnl enough until we switch to autoconf 2.50 or later.
976 if test x"$rad_enable_largefiles" = xyes ; then
977     AC_MSG_CHECKING(for largefile linkage)
978     case "$host" in
979     *-aix4.[01]*)
980         AC_MSG_RESULT(no)
981         AC_MSG_ERROR([AIX before 4.2 does not support large files])
982         ;;
983     *-aix4*)
984         AC_MSG_RESULT(ok)
985         LFS_CFLAGS="-D_LARGE_FILES"
986         LFS_LDFLAGS=""
987         LFS_LIBS=""
988         ;;
989     *-hpux*)
990         AC_MSG_RESULT(ok)
991         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
992         LFS_LDFLAGS=""
993         LFS_LIBS=""
994         ;;
995     *-irix*)
996         AC_MSG_RESULT(no)
997         AC_MSG_ERROR([Large files not supported on this platform])
998         ;;
999     *-linux*)
1000         AC_MSG_RESULT(maybe)
1001         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
1002         LFS_LDFLAGS=""
1003         LFS_LIBS=""
1004         AC_DEFINE([_GNU_SOURCE], 1,
1005                   [Some versions of glibc need this defined for pread/pwrite.])
1006         ;;
1007     *-solaris*)
1008         AC_MSG_RESULT(ok)
1009         AC_PATH_PROG(GETCONF, getconf)
1010         if test -z "$GETCONF" ; then
1011             AC_MSG_ERROR([getconf required to configure large file support])
1012         fi
1013         LFS_CFLAGS=`$GETCONF LFS_CFLAGS`
1014         LFS_LDFLAGS=`$GETCONF LFS_LDFLAGS`
1015         LFS_LIBS=`$GETCONF LFS_LIBS`
1016         ;;
1017     *)
1018         AC_MSG_RESULT(maybe)
1019         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
1020         LFS_LDFLAGS=""
1021         LFS_LIBS=""
1022         ;;
1023     esac
1024     AC_SUBST(LFS_CFLAGS)
1025     AC_SUBST(LFS_LDFLAGS)
1026     AC_SUBST(LFS_LIBS)
1027 fi
1028
1029 AC_SUBST(HOSTINFO, $host)
1030
1031 dnl #############################################################
1032 dnl #
1033 dnl #  8. Checks for system services
1034 dnl #
1035 dnl #############################################################
1036
1037 dnl #
1038 dnl # Figure out where libtool is located,
1039 dnl #
1040 top_builddir=`pwd`
1041 export top_builddir
1042 AC_MSG_RESULT([top_builddir=$top_builddir])
1043 dnl # AC_SUBST(top_builddir)
1044 AC_SUBST(LIBLTDL)
1045 AC_SUBST(INCLTDL)
1046
1047 dnl import libtool stuff
1048
1049 dnl #############################################################
1050 dnl #
1051 dnl #  Configure in any module directories.
1052 dnl #
1053 dnl #############################################################
1054
1055 mysubdirs=
1056 if test "x$EXPERIMENTAL" = "xyes"; then
1057   bar=`ls -1 src/modules/rlm_*/configure | sed 's%/configure%%'`
1058   dnl # get rid of LF's.
1059   mysubdirs=`echo $bar`
1060 else
1061   dnl # 
1062   dnl # Find 'configure' in ONLY the stable modules
1063   dnl # 
1064   for bar in `cat src/modules/stable`; do
1065     if test -f src/modules/$bar/configure; then
1066       mysubdirs="$mysubdirs src/modules/$bar"
1067     fi
1068   done
1069 fi
1070
1071 dnl ############################################################
1072 dnl # make modules by list
1073 dnl #############################################################
1074 if test "x$EXPERIMENTAL" = "xyes"; then
1075   for foo in `ls -1 src/modules | grep rlm_`; do
1076     MODULES="$MODULES $foo"
1077   done
1078 else
1079    dnl #
1080    dnl # make ONLY the stable modules
1081    dnl #
1082    for foo in `cat src/modules/stable`; do
1083     MODULES="$MODULES $foo"
1084    done
1085 fi
1086
1087 dnl #
1088 dnl #  Don't change the variable name here.  Autoconf goes bonkers
1089 dnl #  if you do.
1090 dnl #
1091 AC_CONFIG_SUBDIRS($LTDL_SUBDIRS $mysubdirs)
1092 AC_SUBST(MODULES)
1093
1094 dnl #############################################################
1095 dnl #
1096 dnl #  And finally, output the results.
1097 dnl #
1098 dnl #############################################################
1099
1100 dnl #
1101 dnl #  Substitute whatever libraries we found to be necessary
1102 dnl #
1103 AC_SUBST(LIBS)
1104 AC_SUBST(INSTALLSTRIP)
1105
1106 USE_SHARED_LIBS=$enable_shared
1107 AC_SUBST(USE_SHARED_LIBS)
1108 USE_STATIC_LIBS=$enable_static
1109 AC_SUBST(USE_STATIC_LIBS)
1110 AC_SUBST(STATIC_MODULES)
1111 AC_SUBST(RADIUSD_MAJOR_VERSION)
1112 AC_SUBST(RADIUSD_MINOR_VERSION)
1113 AC_SUBST(RADIUSD_VERSION)
1114 export CFLAGS LIBS
1115
1116 AC_OUTPUT(\
1117         ./Make.inc \
1118         ./src/include/build-radpaths-h \
1119         ./src/main/Makefile \
1120         ./src/main/checkrad.pl \
1121         ./src/main/radlast \
1122         ./src/main/radtest \
1123         ./scripts/rc.radiusd \
1124         ./scripts/radwatch \
1125         ./scripts/check-radiusd-config \
1126         ./scripts/radiusd.cron.daily \
1127         ./scripts/radiusd.cron.monthly \
1128         ./scripts/cryptpasswd \
1129         ./raddb/dictionary \
1130         ./raddb/radiusd.conf
1131 )
1132
1133 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
1134 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
1135 AC_OUTPUT_COMMANDS([(cd ./src/main   && chmod +x checkrad.pl radlast radtest)])
1136 AC_OUTPUT_COMMANDS([(cd ./scripts    && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])