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