Update version numbers
[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=0
29 RADIUSD_MINOR_VERSION=9.3
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 #  These next two arguments don't actually do anything.  They're
259 dnl #  place holders so that the top-level configure script can tell
260 dnl #  the user how to configure lower-level modules
261 dnl #
262
263 dnl #
264 dnl # extra argument: --with-rlm-FOO-lib-dir
265 dnl #
266 AC_ARG_WITH(rlm-FOO-lib-dir,
267 [  --with-rlm-FOO-lib-dir=DIR       Directory to look for library files used by module FOO],
268 [ case "$withval" in
269     *)
270         ;;
271   esac ]
272 )
273
274 dnl #
275 dnl # extra argument: --with-rlm-FOO-include-dir
276 dnl #
277 AC_ARG_WITH(rlm-FOO-include-dir,
278 [  --with-rlm-FOO-include-dir=DIR   Directory to look for include files used by module FOO],
279 [ case "$withval" in
280     *)
281         ;;
282   esac ]
283 )
284
285 dnl See what include-style is used by the make program.
286 dnl AC_MSG_CHECKING(include style for make)
287 dnl echo "include /dev/null" > testmake.$$
288 dnl echo "all:" >> testmake.$$
289 dnl make -f testmake.$$ >/dev/null 2>&1
290 dnl if test $? = 0
291 dnl then
292 dnl     INCLUDE=include
293 dnl     IQUOTE=
294 dnl else
295 dnl     INCLUDE=.include
296 dnl     IQUOTE='"'
297 dnl fi
298 dnl rm -f testmake.$$
299 dnl AC_MSG_RESULT(" $INCLUDE")
300 dnl AC_SUBST(INCLUDE)
301 dnl AC_SUBST(IQUOTE)
302
303 dnl #############################################################
304 dnl #
305 dnl #  1. Checks for programs
306 dnl #
307 dnl #############################################################
308
309 CHECKRAD=checkrad.pl
310 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
311 if test "x$ac_cv_path_PERL" = "x"; then
312   AC_MSG_WARN(perl not found - Simultaneous-Use and checkrad.pl may not work)
313 fi
314 AC_PATH_PROG(SNMPGET, snmpget)
315 if test "x$ac_cv_path_SNMPGET" = "x"; then
316   AC_MSG_WARN(snmpget not found - Simultaneous-Use and checkrad.pl may not work)
317 fi
318
319 AC_PATH_PROG(SNMPWALK, snmpwalk)
320 if test "x$ac_cv_path_SNMPWALK" = "x"; then
321   AC_MSG_WARN(snmpwalk not found - Simultaneous-Use and checkrad.pl may not work)
322 fi
323
324 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
325
326 dnl FIXME This is truly gross.
327 missing_dir=`cd $ac_aux_dir && pwd`
328 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
329 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
330 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
331
332 AC_PATH_PROG(LOCATE,locate)
333 AC_PATH_PROG(DIRNAME,dirname)
334 AC_PATH_PROG(GREP,grep)
335
336 dnl #############################################################
337 dnl #
338 dnl #  2. Checks for libraries
339 dnl #
340 dnl #############################################################
341
342 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
343 old_CFLAGS=$CFLAGS
344 if test "x$WITH_THREADS" = "xyes"; then 
345   if test $ac_cv_prog_suncc = "yes"; then
346     CFLAGS="$CFLAGS -mt"
347   fi
348
349   AC_CHECK_HEADERS(pthread.h, [], [ WITH_THREADS="no" ])
350
351 dnl # 
352 dnl # pthread stuff is usually in -lpthread
353 dnl # or in -lc_r, on *BSD
354 dnl # 
355 dnl # On Some systems, we need extra pre-processor flags, to get them to
356 dnl # to do the threading properly.
357 dnl # 
358   AC_CHECK_LIB(pthread, pthread_create,
359                 [ CFLAGS="$CFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
360                   LIBS="$LIBS -lpthread" ],
361                 AC_CHECK_LIB(c_r, pthread_create,
362                             [ CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE" ],
363                             [ WITH_THREADS="no" ]
364                             )
365                 )
366 fi
367
368 dnl # 
369 dnl # If we have NO pthread libraries, remove any knowledge of threads.
370 dnl # 
371 if test "x$WITH_THREADS" != "xyes"; then
372   CFLAGS=$old_CFLAGS
373   ac_cv_header_pthread_h="no"
374   WITH_THREADS=no
375 else
376   dnl #
377   dnl #  We need sem_init() and friends, as they're the friendliest
378   dnl #  semaphore functions for threading.
379   dnl #
380   dnl # HP/UX requires linking with librt, too, to get the sem_* symbols.
381   dnl # Some systems have them in -lsem
382   dnl # Solaris has them in -lposix4
383
384   AC_SEARCH_LIBS(sem_init, pthread sem posix4 rt,
385         [],
386         [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)]
387    )
388 fi
389
390 dnl Check if we need -lsocket
391 AC_CHECK_LIB(socket, getsockname)
392
393 dnl Check for -lresolv
394 dnl This library may be needed later.
395 AC_CHECK_LIB(resolv, inet_aton)
396
397 dnl Check if we need -lnsl. Usually if we want to
398 dnl link against -lsocket we need to include -lnsl as well.
399 AC_CHECK_LIB(nsl, inet_ntoa)
400
401 dnl #############################################################
402 dnl #
403 dnl #  3. Checks for header files
404 dnl #
405 dnl #############################################################
406
407 AC_HEADER_DIRENT
408 AC_HEADER_STDC
409 AC_HEADER_TIME
410 AC_HEADER_SYS_WAIT
411
412 AC_CHECK_HEADERS( \
413         unistd.h \
414         crypt.h \
415         errno.h \
416         resource.h \
417         getopt.h \
418         malloc.h \
419         utmp.h \
420         utmpx.h \
421         signal.h \
422         sys/select.h \
423         syslog.h \
424         inttypes.h \
425         stdint.h \
426         stdio.h \
427         netdb.h \
428         semaphore.h \
429         arpa/inet.h \
430         netinet/in.h \
431         sys/types.h \
432         sys/socket.h \
433         sys/time.h \
434         sys/wait.h \
435         sys/security.h \
436         fcntl.h \
437         sys/fcntl.h \
438         prot.h \
439         sia.h \
440         siad.h
441 )
442
443 REGEX=no
444 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
445 if test "x$ac_cv_header_regex_h" = "xyes"; then
446   REGEX_EXTENDED=no
447   REGEX=yes
448   AC_EGREP_CPP(yes,
449     [#include <regex.h>
450      #ifdef REG_EXTENDED
451        yes
452      #endif
453      ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
454 fi
455 AC_SUBST(REGEX)
456 AC_SUBST(REGEX_EXTENDED)
457
458 dnl #
459 dnl #  other checks which require headers
460 dnl #
461 if test "x$ac_cv_header_sys_security_h" = "xyes" && test "x$ac_cv_header_prot_h" = "xyes"
462 then
463   AC_DEFINE(OSFC2)
464 fi
465
466 if test "x$ac_cv_header_sia_h" = "xyes" && test "x$ac_cv_header_siad_h" = "xyes"
467 then
468   AC_DEFINE(OSFSIA)
469 fi
470
471
472 dnl #############################################################
473 dnl #
474 dnl #  4. Checks for typedefs
475 dnl #
476 dnl #############################################################
477
478 dnl #
479 dnl # Ensure that these are defined
480 dnl #
481 AC_TYPE_OFF_T 
482 AC_TYPE_PID_T
483 AC_TYPE_SIZE_T
484 AC_TYPE_UID_T
485
486 dnl check for socklen_t
487 AC_CHECK_TYPE_INCLUDE([
488 #ifdef HAVE_SYS_TYPES_H
489 #include <sys/types.h>
490 #endif
491 #ifdef HAVE_SYS_SOCKET_H
492 #include <sys/socket.h>
493 #endif
494 ],socklen_t, int)
495
496 dnl check for uint8_t
497 AC_CHECK_TYPE_INCLUDE([
498 #ifdef HAVE_INTTYPES_H
499 #include <inttypes.h>
500 #endif
501 #ifdef HAVE_STDINT_H
502 #include <stdint.h>
503 #endif
504 ],uint8_t, unsigned char)
505
506 dnl check for uint16_t
507 AC_CHECK_TYPE_INCLUDE([
508 #ifdef HAVE_INTTYPES_H
509 #include <inttypes.h>
510 #endif
511 #ifdef HAVE_STDINT_H
512 #include <stdint.h>
513 #endif
514 ],uint16_t, unsigned short)
515
516 dnl check for uint32_t
517 AC_CHECK_TYPE_INCLUDE([
518 #ifdef HAVE_INTTYPES_H
519 #include <inttypes.h>
520 #endif
521 #ifdef HAVE_STDINT_H
522 #include <stdint.h>
523 #endif
524 ],uint32_t, unsigned int)
525
526 dnl #############################################################
527 dnl #
528 dnl #  5. Checks for structures and functions
529 dnl #
530 dnl #############################################################
531 AC_CHECK_FUNCS( \
532         getopt_long \
533         lockf \
534         strsignal \
535         sigaction \
536         sigprocmask \
537         pthread_sigmask \
538         snprintf \
539         vsnprintf \
540         setsid \
541         strncasecmp \
542         strcasecmp \
543         localtime_r \
544         ctime_r \
545         gmtime_r \
546         strsep \
547         inet_aton \
548         gethostname \
549         setlinebuf \
550         setvbuf \
551         getusershell
552 )
553 RADIUSD_NEED_DECLARATIONS( \
554         crypt \
555         strncasecmp \
556         strcasecmp \
557         inet_aton \
558         gethostname \
559         setlinebuf \
560         getusershell \
561         endusershell
562 )
563
564 AC_TYPE_SIGNAL
565
566 dnl # check if we have utmpx.h
567 dnl # if so, check if struct utmpx has entry ut_xtime
568 dnl # if not, set it to define ut_xtime == ut_tv.tv_sec
569 if test "x$ac_cv_header_utmpx_h" = "xyes"
570 then
571  AC_CHECK_STRUCT_HAS_MEMBER([#include <utmpx.h>], [struct utmpx], ut_xtime)
572  if test "x$ac_cv_type_struct_utmpx_has_ut_xtime" = "x"
573  then
574    AC_DEFINE(ut_xtime,ut_tv.tv_sec)
575  fi
576 fi
577
578 dnl #############################################################
579 dnl #
580 dnl #  6. Checks for compiler characteristics
581 dnl #
582 dnl #############################################################
583
584 dnl #
585 dnl # Ensure that these are defined
586 dnl #
587 AC_C_CONST 
588
589 dnl #
590 dnl # See if this is OS/2
591 dnl #
592 AC_MSG_CHECKING(type of OS)
593 OS=`uname -s`
594 AC_MSG_RESULT($OS)
595 if test "$OS" = "OS/2"; then
596         LIBPREFIX=
597 else
598         LIBPREFIX=lib
599 fi
600 AC_SUBST(LIBPREFIX)
601
602 dnl #
603 dnl # Set Default CFLAGS
604 dnl #
605 if test "x$GCC" = "xyes"; then
606     CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
607 fi
608
609 AC_MSG_CHECKING(for developer gcc flags)
610 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
611   devflags="-g -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
612   CFLAGS="$CFLAGS $devflags"
613   INSTALLSTRIP=""
614   AC_MSG_RESULT(yes.  Using $devflags)
615 else
616   devflags=""
617   CFLAGS="$CFLAGS -DNDEBUG"
618   INSTALLSTRIP="-s"
619   AC_MSG_RESULT(no.)
620 fi
621
622 dnl #############################################################
623 dnl #
624 dnl #  7. Checks for library functions
625 dnl #
626 dnl #############################################################
627
628 dnl Check for libcrypt
629 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
630 AC_CHECK_LIB(crypt, crypt,
631   CRYPTLIB="-lcrypt"
632 )
633 if test "$CRYPTLIB" != ""; then
634   AC_DEFINE(HAVE_CRYPT)
635 else
636   AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
637 fi
638
639 dnl Check for libcipher
640 AC_CHECK_LIB(cipher, setkey,
641    CRYPTLIB="${CRYPTLIB} -lcipher"
642 )
643 AC_SUBST(CRYPTLIB)
644
645 if test "x$WITH_SNMP" = "xyes"; then
646   SNMP_CHECKS
647 fi
648
649 dnl Check the style of gethostbyaddr, in order of preference
650 dnl GNU (_r eight args)
651 dnl SYSV (_r six args)
652 dnl BSD (three args, may not be thread safe)
653 dnl Tru64 has BSD version, but it is thread safe
654 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1739____.HTM
655 dnl We need #stdio.h to define NULL on FreeBSD (at least)
656 gethostbyaddrrstyle=""
657 AC_MSG_CHECKING([gethostbyaddr_r() syntax])
658 case "$host" in
659 *-freebsd*)
660         AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
661         gethostbyaddrrstyle=BSD
662         AC_MSG_WARN([FreeBSD overridden to BSD-style])
663         ;;
664 esac
665 if test "x$gethostbyaddrrstyle" = "x"; then
666         AC_TRY_LINK([
667 #include <stdio.h>
668 #include <netdb.h>
669 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL, NULL) ], [
670         AC_DEFINE(GETHOSTBYADDRRSTYLE, GNUSTYLE)
671         gethostbyaddrrstyle=GNU
672 ])
673 fi
674 if test "x$gethostbyaddrrstyle" = "x"; then
675         AC_TRY_LINK([
676 #include <stdio.h>
677 #include <netdb.h>
678 ], [ gethostbyaddr_r(NULL, 0, 0, NULL, NULL, 0, NULL) ] , [
679                 AC_DEFINE(GETHOSTBYADDRRSTYLE, SYSVSTYLE)
680                 gethostbyaddrrstyle=SYSV
681         ])
682 fi
683 if test "x$gethostbyaddrrstyle" = "x"; then
684         AC_TRY_LINK([
685 #include <stdio.h>
686 #include <netdb.h>
687 ], [ gethostbyaddr(NULL, 0, 0)  ], [
688                 AC_DEFINE(GETHOSTBYADDRRSTYLE, BSDSTYLE)
689                 gethostbyaddrrstyle=BSD
690                 AC_MSG_WARN([ ****** BSD Style gethostbyaddr might NOT be thread-safe! ****** ])
691         ])
692 fi
693
694 if test "x$gethostbyaddrrstyle" = "x"; then
695         AC_MSG_RESULT([none!  It must not exist, here.])
696 else
697         AC_MSG_RESULT([${gethostbyaddrrstyle}-style])
698 fi
699
700 dnl Check the style of gethostbyname, in order of preference
701 dnl GNU (_r seven args)
702 dnl SYSV (_r five args)
703 dnl BSD (two args, may not be thread safe)
704 dnl Tru64 has BSD version, but it _is_ thread safe
705 dnl     http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51B_HTML/MAN/MAN3/1946____.HTM
706 dnl We need #stdio.h to define NULL on FreeBSD (at least)
707 gethostbynamerstyle=""
708 AC_MSG_CHECKING([gethostbyname_r() syntax])
709 AC_TRY_LINK([
710 #include <stdio.h>
711 #include <netdb.h>
712 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL, NULL) ], [
713         AC_DEFINE(GETHOSTBYNAMERSTYLE, GNUSTYLE)
714         gethostbynamerstyle=GNU
715 ])
716 if test "x$gethostbynamerstyle" = "x"; then
717         AC_TRY_LINK([
718 #include <stdio.h>
719 #include <netdb.h>
720 ], [ gethostbyname_r(NULL, NULL, NULL, 0, NULL) ] , [
721                 AC_DEFINE(GETHOSTBYNAMERSTYLE, SYSVSTYLE)
722                 gethostbynamerstyle=SYSV
723         ])
724 fi
725 if test "x$gethostbynamerstyle" = "x"; then
726         AC_TRY_LINK([
727 #include <stdio.h>
728 #include <netdb.h>
729 ], [ gethostbyname(NULL)  ], [
730                 AC_DEFINE(GETHOSTBYNAMERSTYLE, BSDSTYLE)
731                 gethostbynamerstyle=BSD
732                 AC_MSG_WARN([ ****** BSD Style gethostbyname might NOT be thread-safe! ****** ])
733         ])
734 fi
735
736 if test "x$gethostbynamerstyle" = "x"; then
737         AC_MSG_RESULT([none!  It must not exist, here.])
738 else
739         AC_MSG_RESULT([${gethostbynamerstyle}-style])
740 fi
741
742 dnl If configuring with large file support, determine the right flags to
743 dnl use based on the platform.  This is the wrong approach; autoconf 2.50
744 dnl comes with a macro that takes the right approach.  But this works well
745 dnl enough until we switch to autoconf 2.50 or later.
746 if test x"$rad_enable_largefiles" = xyes ; then
747     AC_MSG_CHECKING(for largefile linkage)
748     case "$host" in
749     *-aix4.[01]*)
750         AC_MSG_RESULT(no)
751         AC_MSG_ERROR([AIX before 4.2 does not support large files])
752         ;;
753     *-aix4*)
754         AC_MSG_RESULT(ok)
755         LFS_CFLAGS="-D_LARGE_FILES"
756         LFS_LDFLAGS=""
757         LFS_LIBS=""
758         ;;
759     *-hpux*)
760         AC_MSG_RESULT(ok)
761         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
762         LFS_LDFLAGS=""
763         LFS_LIBS=""
764         ;;
765     *-irix*)
766         AC_MSG_RESULT(no)
767         AC_MSG_ERROR([Large files not supported on this platform])
768         ;;
769     *-linux*)
770         AC_MSG_RESULT(maybe)
771         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
772         LFS_LDFLAGS=""
773         LFS_LIBS=""
774         AC_DEFINE([_GNU_SOURCE], 1,
775                   [Some versions of glibc need this defined for pread/pwrite.])
776         ;;
777     *-solaris*)
778         AC_MSG_RESULT(ok)
779         AC_PATH_PROG(GETCONF, getconf)
780         if test -z "$GETCONF" ; then
781             AC_MSG_ERROR([getconf required to configure large file support])
782         fi
783         LFS_CFLAGS=`$GETCONF LFS_CFLAGS`
784         LFS_LDFLAGS=`$GETCONF LFS_LDFLAGS`
785         LFS_LIBS=`$GETCONF LFS_LIBS`
786         ;;
787     *)
788         AC_MSG_RESULT(maybe)
789         LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
790         LFS_LDFLAGS=""
791         LFS_LIBS=""
792         ;;
793     esac
794     AC_SUBST(LFS_CFLAGS)
795     AC_SUBST(LFS_LDFLAGS)
796     AC_SUBST(LFS_LIBS)
797 fi
798
799 dnl #############################################################
800 dnl #
801 dnl #  8. Checks for system services
802 dnl #
803 dnl #############################################################
804
805 dnl #
806 dnl # Figure out where libtool is located,
807 dnl #
808 top_builddir=`pwd`
809 export top_builddir
810 AC_MSG_RESULT([top_builddir=$top_builddir])
811 AC_SUBST(top_builddir)
812 AC_SUBST(LIBLTDL)
813 AC_SUBST(INCLTDL)
814
815 dnl #
816 dnl #  Work around stupid autoconf crap
817 dnl #
818 if test "x$INCLTDL" != "x";then
819   INCLTDL='-I${top_builddir}/''libltdl'
820 fi
821
822 dnl import libtool stuff
823
824 dnl #############################################################
825 dnl #
826 dnl #  Configure in any module directories.
827 dnl #
828 dnl #############################################################
829
830 mysubdirs=
831 if test "x$EXPERIMENTAL" = "xyes"; then
832   bar=`ls -1 src/modules/rlm_*/configure | sed 's%/configure%%'`
833   dnl # get rid of LF's.
834   mysubdirs=`echo $bar`
835 else
836   dnl # 
837   dnl # Find 'configure' in ONLY the stable modules
838   dnl # 
839   for bar in `cat src/modules/stable`; do
840     if test -f src/modules/$bar/configure; then
841       mysubdirs="$mysubdirs src/modules/$bar"
842     fi
843   done
844 fi
845
846 dnl ############################################################
847 dnl # make modules by list
848 dnl #############################################################
849 MODULES=
850 if test "x$EXPERIMENTAL" = "xyes"; then
851   for foo in `ls -1 src/modules | grep rlm_`; do
852     MODULES="$MODULES $foo"
853   done
854 else
855    dnl #
856    dnl # make ONLY the stable modules
857    dnl #
858    for foo in `cat src/modules/stable`; do
859     MODULES="$MODULES $foo"
860    done
861 fi
862
863 dnl #
864 dnl #  Don't change the variable name here.  Autoconf goes bonkers
865 dnl #  if you do.
866 dnl #
867 AC_CONFIG_SUBDIRS($mysubdirs)
868 AC_SUBST(MODULES)
869
870 dnl #############################################################
871 dnl #
872 dnl #  And finally, output the results.
873 dnl #
874 dnl #############################################################
875
876 dnl #
877 dnl #  Substitute whatever libraries we found to be necessary
878 dnl #
879 AC_SUBST(LIBS)
880 AC_SUBST(INSTALLSTRIP)
881
882 USE_SHARED_LIBS=$enable_shared
883 AC_SUBST(USE_SHARED_LIBS)
884 USE_STATIC_LIBS=$enable_static
885 AC_SUBST(USE_STATIC_LIBS)
886 AC_SUBST(STATIC_MODULES)
887 AC_SUBST(RADIUSD_MAJOR_VERSION)
888 AC_SUBST(RADIUSD_MINOR_VERSION)
889 AC_SUBST(RADIUSD_VERSION)
890 export CFLAGS LIBS
891
892 AC_OUTPUT(\
893         ./Make.inc \
894         ./src/include/build-radpaths-h \
895         ./src/main/Makefile \
896         ./src/main/checkrad.pl \
897         ./src/main/radlast \
898         ./src/main/radtest \
899         ./scripts/rc.radiusd \
900         ./scripts/radwatch \
901         ./scripts/check-radiusd-config \
902         ./scripts/radiusd.cron.daily \
903         ./scripts/radiusd.cron.monthly \
904         ./scripts/cryptpasswd \
905         ./raddb/dictionary \
906         ./raddb/radiusd.conf
907 )
908
909 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
910 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
911 AC_OUTPUT_COMMANDS([(cd ./src/main   && chmod +x checkrad.pl radlast radtest)])
912 AC_OUTPUT_COMMANDS([(cd ./scripts    && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly cryptpasswd)])
913 AC_OUTPUT_COMMANDS([
914 cat >> src/include/autoconf.h <<EOF
915
916 #define HOSTINFO        "$host"
917 #define RADIUSD_VERSION "$RADIUSD_VERSION"
918 EOF
919 ],host=$host)