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