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