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