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