First distrib-configure test release.
[freeradius.git] / configure.in
1 dnl This should be processed after a new module is added!
2
3 dnl #############################################################
4 dnl #
5 dnl #  For information about autoconf, see:
6 dnl #
7 dnl #  http://www.gnu.org/software/autoconf/
8 dnl #  
9 dnl #  The recommended order is:
10 dnl #
11 dnl #  AC_INIT(file)
12 dnl #  0. checks for compiler, libtool, and command line options
13 dnl #  1. checks for programs
14 dnl #  2. checks for libraries
15 dnl #  3. checks for header files
16 dnl #  4. checks for typedefs
17 dnl #  5. checks for structures and functions
18 dnl #  6. checks for compiler characteristics
19 dnl #  7. checks for library functions
20 dnl #  8. checks for system services
21 dnl #  AC_OUTPUT([file...])
22 dnl #
23 dnl #############################################################
24
25 AC_INIT(src/main/radiusd.c)
26 AC_CONFIG_HEADER(src/include/autoconf.h)
27 AC_REVISION($Revision$)dnl
28 dnl AC_PREFIX_DEFAULT(/usr/local)
29
30 dnl #############################################################
31 dnl #
32 dnl #  0. Checks for compiler, libtool, and command line options.
33 dnl #
34 dnl #############################################################
35
36 dnl Check for GNU cc
37 AC_PROG_CC
38 AC_PROG_GCC_TRADITIONAL
39 AC_PROG_CC_SUNPRO
40 AC_PROG_RANLIB
41
42 PACKAGE=freeradius
43
44 dnl Find GNU Make.
45 AC_CHECK_PROG(GMAKE, gmake, yes, no)
46 if test $GMAKE = no; then
47   AC_PATH_PROG(MAKE, make, /usr/local/bin/make)
48 else
49   AC_PATH_PROG(MAKE, gmake, /usr/local/gnu/bin/make)
50 fi
51 makever=`$ac_cv_path_MAKE --version 2>&1 | grep "GNU Make"`
52 if test -z "$makever"; then
53   AC_MSG_ERROR(GNU Make is not installed.  Please download and install it
54                 from ftp://prep.ai.mit.edu/pub/gnu/make/ before continuing.)
55 fi
56
57 dnl libltdl is installable
58 AC_LIBLTDL_INSTALLABLE
59
60 dnl ensure that we're looking for dlopen
61 AC_LIBTOOL_DLOPEN
62
63 dnl Figure out how to build shared libraries
64 AC_PROG_LIBTOOL
65
66 dnl Put this in later, when all distributed modules use autoconf.
67 dnl AC_ARG_WITH(disablemodulefoo,
68 dnl [  --without-rlm_foo       Disables module compilation.  Module list:]
69 dnl esyscmd([find src/modules -type d -name rlm_\* -print |\
70 dnl     sed -e 's%src/modules/.*/% (sub)- %; s%.*/%- %' |\
71 dnl     awk '{print "                            "$0}']))
72
73 AC_ARG_ENABLE(rlm-best-guess,
74 [  --enable-rlm-best-guess  Try to build all, but don't fail when lacking
75                                 dependancies. ])
76 if test x"${enable_rlm_best_guess+set}" = xset; then
77   enable_rlm_best_guess=yes
78   ac_configure_args="$ac_configure_args --enable-rlm-best-guess"
79 fi
80
81 AC_ARG_WITH(fooincludedir,
82 [  --with-FOO-include-dir=DIR   Dir for includes for FOO, module dependancy.])
83
84 AC_ARG_WITH(foolibdir,
85 [  --with-FOO-lib-dir=DIR  Dir for libraries for FOO, module dependancy.])
86
87 dnl extra argument: --with-logdir
88 logdir='${localstatedir}/log'
89 AC_MSG_CHECKING(logdir)
90 AC_ARG_WITH(logdir,
91 [  --with-logdir=DIR       Directory for logfiles [LOCALSTATEDIR/log] ],
92 [ case "$withval" in
93     no)
94         AC_MSG_ERROR(Need logdir)
95         ;;
96     yes)
97         ;;
98     *)
99         logdir="$withval"
100         ;;
101   esac ]
102 )
103 AC_SUBST(logdir)
104 AC_MSG_RESULT($logdir)
105
106 dnl extra argument: --with-radacctdir
107 radacctdir='${logdir}/radacct'
108 AC_MSG_CHECKING(radacctdir)
109 AC_ARG_WITH(radacctdir,
110 [  --with-radacctdir=PATH  Directory for detail files [LOGDIR/radacct] ],
111 [ case "$withval" in
112     no)
113         AC_MSG_ERROR(Need radacctdir)
114         ;;
115     yes)
116         ;;
117     *)
118         radacctdir="$withval"
119         ;;
120   esac ]
121 )
122 AC_SUBST(radacctdir)
123 AC_MSG_RESULT($radacctdir)
124
125 dnl extra argument: --with-raddbdir
126 raddbdir='${sysconfdir}/raddb'
127 AC_MSG_CHECKING(raddbdir)
128 AC_ARG_WITH(raddbdir,
129 [  --with-raddbdir=DIR     Directory for config files [SYSCONFDIR/raddb] ],
130 [ case "$withval" in
131     no)
132         AC_MSG_ERROR(Need raddbdir)
133         ;;
134     yes)
135         ;;
136     *)
137         raddbdir="$withval"
138         ;;
139   esac ]
140 )
141 AC_SUBST(raddbdir)
142 AC_MSG_RESULT($raddbdir)
143
144 dnl extra argument: --with-dict-nocase
145 WITH_DICT_NOCASE=yes
146 AC_ARG_WITH(dict-nocase,
147 [  --with-dict-nocase      Make dictionary case-independant (default=yes)],
148 [  case "$withval" in
149     yes)
150         ;;
151     *)
152         WITH_DICT_NOCASE=""
153   esac ]
154 )
155 if test "X$WITH_DICT_NOCASE" = "Xyes"; then
156   AC_DEFINE(WITH_DICT_NOCASE)
157 fi
158
159 dnl extra argument: --with-ascend-binary
160 ASCEND_BINARY=yes
161 AC_ARG_WITH(ascend-binary,
162 [  --with-ascend-binary    Include support for Ascend binary filter attributes (default=yes)],
163 [ case "$withval" in
164     yes)
165         ;;
166     *)
167         ASCEND_BINARY=""
168   esac ]
169 )
170 if test "X$ASCEND_BINARY" = "Xyes"; then
171   AC_DEFINE(ASCEND_BINARY)
172 fi
173
174 dnl extra argument: --with-threads
175 WITH_THREADS=yes
176 AC_ARG_WITH(threads,
177 [  --with-threads          Use threads, if available.  (default=yes) ],
178 [ case "$withval" in
179     yes)
180         ;;
181     *)
182         WITH_THREADS=""
183   esac ]
184 )
185
186 dnl extra argument: --with-thread-pool
187 WITH_THREAD_POOL=no
188 AC_ARG_WITH(thread-pool,
189 [  --with-thread-pool      Use a pool of threads for high-load systems.  (default=no) ],
190 [ case "$withval" in
191     yes)
192         WITH_THREAD_POOL=yes
193         ;;
194     *)
195         ;;
196   esac ]
197 )
198
199 dnl extra argument: --with-snmp
200 WITH_SNMP=yes
201 AC_ARG_WITH(snmp,
202 [  --with-snmp             Compile in SNMP support. (default=yes)],
203 [ case "$withval" in
204     yes)
205         ;;
206     *)
207         WITH_SNMP=no
208   esac ]
209 )
210
211
212
213 dnl   move these into the mysql configure.in file
214 AC_ARG_WITH(mysql-include-dir,
215 [  --with-mysql-include-dir=DIR       Directory where the MySQL includes may be found ],
216 [ mysql_include_dir="$withval" ]
217 )
218
219 AC_ARG_WITH(mysql-lib-dir,
220 [  --with-mysql-lib-dir=DIR       Directory where the MySQL libraries may be found ],
221 [ mysql_lib_dir="$withval" ]
222 )
223
224 AC_ARG_WITH(mysql-dir,
225 [  --with-mysql-dir=DIR       Base directory where MySQL is installed ],
226 [ mysql_lib_dir="$withval/lib/mysql"
227   mysql_include_dir="$withval/include"
228 ]
229 )
230
231 AC_ARG_ENABLE(ltdl-install,
232 [  --disable-ltdl-install  do not install libltdl])
233 if test x"${enable_ltdl_install+set}" != xset; then
234   enable_ltdl_install=yes
235   ac_configure_args="$ac_configure_args --enable-ltdl-install"
236 fi
237 AC_CONFIG_SUBDIRS(libltdl)
238
239 dnl #
240 dnl #  Allow the user to specify a list of modules to be linked
241 dnl #  statically to the server.
242 dnl #
243 STATIC_MODULES=
244 AC_ARG_WITH(static_modules,
245 [  --with-static-modules=QUOTED-MODULE-LIST],[
246   for i in $withval; do
247     STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
248   done
249 ])
250
251 dnl #
252 dnl #  Enable developer C compiler warnings
253 dnl #
254 AC_ARG_ENABLE(developer,
255 [  --enable-developer      Turns on super-duper-extra-compile-warnings 
256                               when using gcc.],
257 [ case "$withval" in
258     *)
259         developer=no
260         ;;
261     yes)
262         developer=yes
263   esac ]
264 )
265
266 if test "x$developer" != "xno" -a -d $srcdir/CVS; then
267   dnl turn on the developer flag when taken from a CVS checkout (not a release)
268   developer="yes"
269 fi
270
271 dnl See what include-style is used by the make program.
272 dnl AC_MSG_CHECKING(include style for make)
273 dnl echo "include /dev/null" > testmake.$$
274 dnl echo "all:" >> testmake.$$
275 dnl make -f testmake.$$ >/dev/null 2>&1
276 dnl if test $? = 0
277 dnl then
278 dnl     INCLUDE=include
279 dnl     IQUOTE=
280 dnl else
281 dnl     INCLUDE=.include
282 dnl     IQUOTE='"'
283 dnl fi
284 dnl rm -f testmake.$$
285 dnl AC_MSG_RESULT(" $INCLUDE")
286 dnl AC_SUBST(INCLUDE)
287 dnl AC_SUBST(IQUOTE)
288
289 dnl #############################################################
290 dnl #
291 dnl #  1. Checks for programs
292 dnl #
293 dnl #############################################################
294
295 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
296 if test ! -x $ac_cv_path_PERL; then
297   AC_MSG_ERROR(perl not found - fatal)
298 fi
299 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
300 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
301 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
302
303 dnl FIXME This is truly gross.
304 missing_dir=`cd $ac_aux_dir && pwd`
305 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
306 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
307 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
308
309 dnl #
310 dnl # check for AIX, to allow us to use some BSD functions
311 dnl # must be before macros that call the compiler.
312 dnl #
313 AC_AIX
314
315 dnl #############################################################
316 dnl #
317 dnl #  2. Checks for libraries
318 dnl #
319 dnl #############################################################
320
321 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
322 PTHREADLIB=
323 if test "$WITH_THREADS" = "yes"; then 
324   if test $ac_cv_prog_suncc = "yes"; then
325     CFLAGS="$CFLAGS -mt"
326   fi
327
328   AC_CHECK_HEADERS(pthread.h)
329
330   if test "X$ac_cv_header_pthread_h" = "X"; then
331     AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
332   fi
333
334 dnl # 
335 dnl # pthread stuff is usually in -lpthread
336 dnl # 
337   AC_CHECK_LIB(pthread, pthread_create,
338     PTHREADLIB="-lpthread"
339   )
340
341 dnl # 
342 dnl # Except for *BSD, where it's in -lc_r,
343 dnl # and where we've got to add extra CFLAGS.
344 dnl # 
345   if test "X$PTHREADLIB" = "X"; then
346     SAVED_CFLAGS=$CFLAGS
347     CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
348     AC_CHECK_LIB(c_r, pthread_create,
349       PTHREADLIB="-lc_r"
350     )
351   fi
352
353 dnl # 
354 dnl # If we have NO pthread libraries, remove any knowledge of threads.
355 dnl # 
356   if test "x$PTHREADLIB" = "x"; then
357     CFLAGS=$SAVED_CFLAGS
358     ac_cv_header_pthread_h="no"
359   else
360     LIBS="$LIBS $PTHREADLIB"
361     CFLAGS="$CFLAGS -D_REENTRANT"
362   fi
363 fi
364
365 dnl #
366 dnl #  Checks to ensure that the thread pool code can build.
367 dnl #
368 if test "$WITH_THREAD_POOL" = "yes"; then
369   dnl #
370   dnl # If using thread pools, check that threading is enabled
371   dnl #
372   if test "$WITH_THREADS" != "yes"; then
373     AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
374   fi
375
376   dnl #
377   dnl # If using thread pools, check that we have thread libraries
378   dnl #
379   if test "X$PTHREADLIB" = "X"; then
380     AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
381   fi
382
383 dnl #
384 dnl #  Check for sem_init all by itself
385 dnl #
386   AC_CHECK_FUNC(sem_init)
387   if test "X$ac_cv_func_sem_init" = "Xno"; then
388
389 dnl #
390 dnl #  If not found, sem_init is in -lposix4 on Solaris
391 dnl #
392     AC_CHECK_LIB(posix4, sem_init)
393
394     if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
395       AC_MSG_WARN(You do not have posix semaphores.  Disabling thread pools)
396       WITH_THREAD_POOL=no
397     fi
398   fi
399
400 dnl #
401 dnl #  Finally, after all of the checks above, we see if
402 dnl #  we can REALLY use the thread pools.
403 dnl #
404   if test "$WITH_THREAD_POOL" = "yes"; then
405     AC_DEFINE(WITH_THREAD_POOL,1)
406   fi
407 fi
408
409 dnl Check if we need -lsocket
410 AC_CHECK_LIB(socket, getsockname)
411
412 dnl Check for -lresolv
413 dnl This library may be needed later.
414 AC_CHECK_LIB(resolv, inet_aton)
415
416 dnl Check if we need -lnsl. Usually if we want to
417 dnl link against -lsocket we need to include -lnsl as well.
418 AC_CHECK_LIB(nsl, inet_ntoa)
419
420 dnl #############################################################
421 dnl #
422 dnl #  3. Checks for header files
423 dnl #
424 dnl #############################################################
425
426 AC_HEADER_DIRENT
427 AC_HEADER_STDC
428 AC_HEADER_TIME
429 AC_HEADER_SYS_WAIT
430
431 AC_CHECK_HEADERS( \
432         unistd.h \
433         crypt.h \
434         errno.h \
435         resource.h \
436         getopt.h \
437         malloc.h \
438         utmp.h \
439         utmpx.h \
440         signal.h \
441         sys/select.h \
442         syslog.h \
443         inttypes.h \
444         stdint.h \
445         stdio.h \
446         netdb.h \
447         arpa/inet.h \
448         netinet/in.h \
449         sys/types.h \
450         sys/socket.h \
451         sys/time.h
452 )
453
454 REGEX=no
455 AC_CHECK_HEADER(regex.h, AC_DEFINE(HAVE_REGEX_H))
456 if test "x$ac_cv_header_regex_h" = "xyes"; then
457   REGEX_EXTENDED=no
458   REGEX=yes
459   AC_EGREP_CPP(yes,
460     [#include <regex.h>
461      #ifdef REG_EXTENDED
462        yes
463      #endif
464      ], [AC_DEFINE(HAVE_REG_EXTENDED) REGEX_EXTENDED=yes])
465 fi
466 AC_SUBST(REGEX)
467 AC_SUBST(REGEX_EXTENDED)
468
469
470 dnl #############################################################
471 dnl #
472 dnl #  4. Checks for typedefs
473 dnl #
474 dnl #############################################################
475
476 dnl #
477 dnl # Ensure that these are defined
478 dnl #
479 AC_TYPE_OFF_T 
480 AC_TYPE_PID_T
481 AC_TYPE_SIZE_T
482 AC_TYPE_UID_T
483
484 dnl check for socklen_t
485 AC_CHECK_TYPE_INCLUDE([
486 #ifdef HAVE_SYS_TYPES_H
487 #include <sys/types.h>
488 #endif
489 #ifdef HAVE_SYS_SOCKET_H
490 #include <sys/socket.h>
491 #endif
492 ],socklen_t, int)
493
494 dnl check for uint8_t
495 AC_CHECK_TYPE_INCLUDE([
496 #ifdef HAVE_INTTYPES_H
497 #include <inttypes.h>
498 #endif
499 #ifdef HAVE_STDINT_H
500 #include <stdint.h>
501 #endif
502 ],uint8_t, unsigned char)
503
504 dnl check for uint32_t
505 AC_CHECK_TYPE_INCLUDE([
506 #ifdef HAVE_INTTYPES_H
507 #include <inttypes.h>
508 #endif
509 #ifdef HAVE_STDINT_H
510 #include <stdint.h>
511 #endif
512 ],uint32_t, unsigned int)
513
514 dnl #############################################################
515 dnl #
516 dnl #  5. Checks for structures and functions
517 dnl #
518 dnl #############################################################
519 AC_CHECK_FUNCS( \
520         getopt_long \
521         lockf \
522         strsignal \
523         sigaction \
524         sigprocmask \
525         snprintf \
526         vsnprintf \
527         setsid \
528         strncasecmp \
529         strcasecmp \
530         strsep \
531         inet_aton \
532         gethostname \
533         setlinebuf \
534         setvbuf \
535         getusershell
536 )
537 RADIUSD_NEED_DECLARATIONS( \
538         crypt \
539         strncasecmp \
540         strcasecmp \
541         inet_aton \
542         gethostname \
543         setlinebuf \
544         getusershell \
545         endusershell
546 )
547
548 AC_TYPE_SIGNAL
549
550 dnl #############################################################
551 dnl #
552 dnl #  6. Checks for compiler characteristics
553 dnl #
554 dnl #############################################################
555
556 dnl #
557 dnl # Ensure that these are defined
558 dnl #
559 AC_C_CONST 
560
561 dnl #
562 dnl # See if this is OS/2
563 dnl #
564 AC_MSG_CHECKING(type of OS)
565 OS=`uname -s`
566 AC_MSG_RESULT($OS)
567 if test "$OS" = "OS/2"; then
568         LIBPREFIX=
569 else
570         LIBPREFIX=lib
571 fi
572 AC_SUBST(LIBPREFIX)
573
574 dnl #
575 dnl # Set Default CFLAGS
576 dnl #
577 if test "x$GCC" = "xyes"; then
578     CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
579 fi
580
581 AC_MSG_CHECKING(for developer gcc flags)
582 if test "x$developer" = "xyes" -a "x$GCC" = "xyes"; then
583   devflags="-Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
584   CFLAGS="$CFLAGS $devflags"
585   AC_MSG_RESULT(yes.  Using $devflags)
586 else
587   devflags="none"
588   CFLAGS="$CFLAGS -DNDEBUG"
589   AC_MSG_RESULT(no.)
590 fi
591
592 dnl #############################################################
593 dnl #
594 dnl #  7. Checks for library functions
595 dnl #
596 dnl #############################################################
597
598 dnl Check for libcrypt
599 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
600 AC_CHECK_LIB(crypt, crypt,
601   CRYPTLIB="-lcrypt"
602 )
603 AC_SUBST(CRYPTLIB)
604 if test "$CRYPTLIB" != ""; then
605   AC_DEFINE(HAVE_CRYPT)
606 else
607   AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
608 fi
609
610 if test "x$WITH_SNMP" = "xyes"; then
611   SNMP_CHECKS
612 fi
613
614 POSTGRESQL_CHECKS
615 MYSQL_CHECKS
616 ORACLE_CHECKS
617 ODBC_CHECKS
618
619 dnl #############################################################
620 dnl #
621 dnl #  8. Checks for system services
622 dnl #
623 dnl #############################################################
624
625 dnl #
626 dnl # Figure out where libtool is located,
627 dnl #
628 LIBTOOL="`pwd`/libtool"
629 AC_SUBST(LIBTOOL)
630 AC_SUBST(LIBLTDL)
631 AC_SUBST(INCLTDL)
632 top_builddir=`pwd`
633 AC_SUBST(top_builddir)
634
635 dnl #############################################################
636 dnl #
637 dnl #  Configure in any module directories.
638 dnl #
639 dnl #############################################################
640
641 dnl This 'echo' is a way to get 'find' output on one line.  (Make sure that -n
642 dnl    works, or the 'sed's at configure-time will fail!  Presumably, if you have
643 dnl    autoconf, you have a decent echo.  :/  Maybe.)
644 dnl Someone suggest a nicer way to do this!
645 AC_CONFIG_SUBDIRS(esyscmd(echo -n `find src/modules -name configure -print |sed 's%configure$%%'`))
646
647 dnl #############################################################
648 dnl #
649 dnl #  And finally, output the results.
650 dnl #
651 dnl #############################################################
652
653 dnl #
654 dnl #  Substitute whatever libraries we found to be necessary
655 dnl #
656 AC_SUBST(LIBS)
657
658 USE_SHARED_LIBS=$enable_shared
659 AC_SUBST(USE_SHARED_LIBS)
660 USE_STATIC_LIBS=$enable_static
661 AC_SUBST(USE_STATIC_LIBS)
662 AC_SUBST(STATIC_MODULES)
663
664 AC_OUTPUT(\
665         ./Make.inc \
666         ./src/include/build-radpaths-h \
667         ./src/main/checkrad.pl \
668         ./src/main/radlast \
669         ./src/main/radtest \
670         ./scripts/rc.radiusd \
671         ./scripts/radwatch \
672         ./scripts/check-radiusd-config \
673         ./scripts/radiusd.cron.daily \
674         ./scripts/radiusd.cron.monthly \
675         ./raddb/radiusd.conf
676 )
677
678 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
679 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
680 AC_OUTPUT_COMMANDS([(cd ./src/main   && chmod +x checkrad.pl radlast radtest)])
681 AC_OUTPUT_COMMANDS([(cd ./scripts    && chmod +x rc.radiusd radwatch check-radiusd-config radiusd.cron.daily radiusd.cron.monthly)])
682 AC_OUTPUT_COMMANDS([
683 cat >> src/include/autoconf.h <<EOF
684
685 #define HOSTINFO        "$host"
686 EOF
687 ],host=$host)