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