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