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