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