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