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