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