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