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