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