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