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