defined new function: AC_CHECK_TYPE_INCLUDE, which is like the
[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-attrib-nmc
137 ATTRIB_NMC=yes
138 AC_ARG_WITH(attrib-nmc,
139 [  --with-attrib-nmc       Include USR-style vendor specific attributes (default=yes)],
140 [ case "$withval" in
141     yes)
142         ;;
143     *)
144         ATTRIB_NMC=""
145   esac ]
146 )
147 if test "X$ATTRIB_NMC" = "Xyes"; then
148   AC_DEFINE(ATTRIB_NMC)
149 fi
150
151 dnl extra argument: --with-ascend-binary
152 ASCEND_BINARY=yes
153 AC_ARG_WITH(ascend-binary,
154 [  --with-ascend-binary    Include support for Ascend binary filter attributes (default=yes)],
155 [ case "$withval" in
156     yes)
157         ;;
158     *)
159         ASCEND_BINARY=""
160   esac ]
161 )
162 if test "X$ASCEND_BINARY" = "Xyes"; then
163   AC_DEFINE(ASCEND_BINARY)
164 fi
165
166 dnl extra argument: --with-threads
167 WITH_THREADS=yes
168 AC_ARG_WITH(threads,
169 [  --with-threads          Use threads, if available.  (default=yes) ],
170 [ case "$withval" in
171     yes)
172         ;;
173     *)
174         WITH_THREADS=""
175   esac ]
176 )
177
178 dnl extra argument: --with-thread-pool
179 WITH_THREAD_POOL=no
180 AC_ARG_WITH(thread-pool,
181 [  --with-thread-pool      Use a pool of threads for high-load systems.  (default=no) ],
182 [ case "$withval" in
183     *)
184         WITH_THREAD_POOL=$withval
185   esac ]
186 )
187
188 dnl extra argument: --with-snmp
189 AC_ARG_WITH(snmp,
190 [  --with-snmp             Compile in SNMP support. (default=no)],
191 [ case "$withval" in
192     no)
193         ;;
194     yes)
195         AC_DEFINE(WITH_SNMP)
196         SNMPLIB="-lsnmp -lcrypto"
197         SNMPINC=-I/usr/include/ucd-snmp
198   esac ]
199 )
200
201 AC_SUBST(SNMPLIB)
202 AC_SUBST(SNMPINC)
203
204
205 AC_ARG_ENABLE(ltdl-install,
206 [  --disable-ltdl-install  do not install libltdl])
207 if test x"${enable_ltdl_install+set}" != xset; then
208   enable_ltdl_install=yes
209   ac_configure_args="$ac_configure_args --enable-ltdl-install"
210 fi
211 AC_CONFIG_SUBDIRS(libltdl)
212
213 dnl #
214 dnl #  Allow the user to specify a list of modules to be linked
215 dnl #  statically to the server.
216 dnl #
217 STATIC_MODULES=
218 AC_ARG_WITH(static_modules,
219 [  --with-static-modules=QUOTED-MODULE-LIST],[
220   for i in $withval; do
221     STATIC_MODULES="$STATIC_MODULES -dlpreopen ../modules/rlm_$i/rlm_$i.la"
222   done
223 ])
224
225 dnl See what include-style is used by the make program.
226 dnl AC_MSG_CHECKING(include style for make)
227 dnl echo "include /dev/null" > testmake.$$
228 dnl echo "all:" >> testmake.$$
229 dnl make -f testmake.$$ >/dev/null 2>&1
230 dnl if test $? = 0
231 dnl then
232 dnl     INCLUDE=include
233 dnl     IQUOTE=
234 dnl else
235 dnl     INCLUDE=.include
236 dnl     IQUOTE='"'
237 dnl fi
238 dnl rm -f testmake.$$
239 dnl AC_MSG_RESULT(" $INCLUDE")
240 dnl AC_SUBST(INCLUDE)
241 dnl AC_SUBST(IQUOTE)
242
243 dnl #############################################################
244 dnl #
245 dnl #  1. Checks for programs
246 dnl #
247 dnl #############################################################
248
249 AC_PATH_PROG(PERL, perl, /usr/local/bin/perl)
250 if test ! -x $ac_cv_path_PERL; then
251   AC_MSG_ERROR(perl not found - fatal)
252 fi
253 AC_PATH_PROG(SNMPGET, snmpget, /usr/local/bin/snmpget)
254 AC_PATH_PROG(SNMPWALK, snmpwalk, /usr/local/bin/snmpwalk)
255 AC_PATH_PROG(RUSERS, rusers, /usr/bin/rusers)
256
257 dnl FIXME This is truly gross.
258 missing_dir=`cd $ac_aux_dir && pwd`
259 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
260 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
261 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
262
263 dnl #
264 dnl # check for AIX, to allow us to use some BSD functions
265 dnl # must be before macros that call the compiler.
266 dnl #
267 AC_AIX
268
269 dnl #############################################################
270 dnl #
271 dnl #  2. Checks for libraries
272 dnl #
273 dnl #############################################################
274
275 dnl If using pthreads, check for -lpthread (posix) or -lc_r (*BSD)
276 PTHREADLIB=
277 if test "$WITH_THREADS" = "yes"; then 
278   if test $ac_cv_prog_suncc = "yes"; then
279     CFLAGS="$CFLAGS -mt"
280   fi
281
282   AC_CHECK_HEADERS(pthread.h)
283
284   if test "X$ac_cv_header_pthread_h" = "X"; then
285     AC_MSG_ERROR("You are trying to use threads without a POSIX <pthread.h>")
286   fi
287
288 dnl # 
289 dnl # pthread stuff is usually in -lpthread
290 dnl # 
291   AC_CHECK_LIB(pthread, pthread_create,
292     PTHREADLIB="-lpthread"
293   )
294
295 dnl # 
296 dnl # Except for *BSD, where it's in -lc_r,
297 dnl # and where we've got to add extra CFLAGS.
298 dnl # 
299   if test "X$PTHREADLIB" = "X"; then
300     SAVED_CFLAGS=$CFLAGS
301     CFLAGS="$CFLAGS -pthread -D_THREAD_SAFE"
302     AC_CHECK_LIB(c_r, pthread_create,
303       PTHREADLIB="-lc_r"
304     )
305   fi
306
307 dnl # 
308 dnl # If we have NO pthread libraries, remove any knowledge of threads.
309 dnl # 
310   if test "x$PTHREADLIB" = "x"; then
311     CFLAGS=$SAVED_CFLAGS
312     ac_cv_header_pthread_h="no"
313   else
314     LIBS="$LIBS $PTHREADLIB"
315     CFLAGS="$CFLAGS -D_REENTRANT"
316   fi
317 fi
318
319 dnl #
320 dnl #  Checks to ensure that the thread pool code can build.
321 dnl #
322 if test "$WITH_THREAD_POOL" = "yes"; then
323   dnl #
324   dnl # If using thread pools, check that threading is enabled
325   dnl #
326   if test "$WITH_THREADS" != "yes"; then
327     AC_MSG_ERROR(You must have threads enabled for thread pools to work.)
328   fi
329
330   dnl #
331   dnl # If using thread pools, check that we have thread libraries
332   dnl #
333   if test "X$PTHREADLIB" = "X"; then
334     AC_MSG_ERROR(You must have threading libraries for thread pools to work.)
335   fi
336
337 dnl #
338 dnl #  Check for sem_init all by itself
339 dnl #
340   AC_CHECK_FUNC(sem_init)
341   if test "X$ac_cv_func_sem_init" = "Xno"; then
342
343 dnl #
344 dnl #  If not found, sem_init is in -lposix4 on Solaris
345 dnl #
346     AC_CHECK_LIB(posix4, sem_init)
347
348     if test "X$ac_cv_lib_posix4_sem_init" = "X"; then
349       AC_MSG_WARN(You do not have posix semaphores.  Disabling thread pools)
350       WITH_THREAD_POOL=no
351     fi
352   fi
353
354 dnl #
355 dnl #  Finally, after all of the checks above, we see if
356 dnl #  we can REALLY use the thread pools.
357 dnl #
358   if test "$WITH_THREAD_POOL" = "yes"; then
359     AC_DEFINE(WITH_THREAD_POOL,1)
360   fi
361 fi
362
363 dnl Check if we need -lsocket
364 AC_CHECK_LIB(socket, getsockname)
365
366 dnl Check for -lresolv
367 dnl This library may be needed later.
368 AC_CHECK_LIB(resolv, inet_aton)
369
370 dnl Check if we need -lnsl. Usually if we want to
371 dnl link against -lsocket we need to include -lnsl as well.
372 AC_CHECK_LIB(nsl, inet_ntoa)
373
374 dnl #############################################################
375 dnl #
376 dnl #  3. Checks for header files
377 dnl #
378 dnl #############################################################
379
380 AC_HEADER_DIRENT
381 AC_HEADER_STDC
382 AC_HEADER_TIME
383 AC_HEADER_SYS_WAIT
384
385 AC_CHECK_HEADERS( \
386         unistd.h \
387         crypt.h \
388         errno.h \
389         resource.h \
390         getopt.h \
391         malloc.h \
392         utmp.h \
393         utmpx.h \
394         sys/select.h \
395         regex.h \
396         syslog.h \
397         inttypes.h \
398         stdint.h \
399         arpa/inet.h \
400         netinet/in.h \
401         sys/types.h \
402         sys/socket.h \
403         sys/time.h
404 )
405
406 dnl #############################################################
407 dnl #
408 dnl #  4. Checks for typedefs
409 dnl #
410 dnl #############################################################
411
412 dnl #
413 dnl # Ensure that these are defined
414 dnl #
415 AC_TYPE_OFF_T 
416 AC_TYPE_PID_T
417 AC_TYPE_SIZE_T
418 AC_TYPE_UID_T
419
420 dnl check for socklen_t
421 AC_CHECK_TYPE_INCLUDE([
422 #ifdef HAVE_SYS_TYPES_H
423 #include <sys/types.h>
424 #endif
425 #ifdef HAVE_SYS_SOCKET_H
426 #include <sys/socket.h>
427 #endif
428 ],socklen_t, int)
429
430 dnl check for uint8_t
431 AC_CHECK_TYPE_INCLUDE([
432 #ifdef HAVE_INTTYPES_H
433 #include <inttypes.h>
434 #endif
435 #ifdef HAVE_STDINT_H
436 #include <stdint.h>
437 #endif
438 ],uint8_t, unsigned char)
439
440 dnl check for uint32_t
441 AC_CHECK_TYPE_INCLUDE([
442 #ifdef HAVE_INTTYPES_H
443 #include <inttypes.h>
444 #endif
445 #ifdef HAVE_STDINT_H
446 #include <stdint.h>
447 #endif
448 ],uint32_t, unsigned int)
449
450 dnl #############################################################
451 dnl #
452 dnl #  5. Checks for structures and functions
453 dnl #
454 dnl #############################################################
455 AC_CHECK_FUNCS( \
456         getopt_long \
457         lockf \
458         strsignal \
459         sigaction \
460         sigprocmask \
461         snprintf \
462         vsnprintf \
463         setsid \
464         strncasecmp \
465         strcasecmp \
466         strsep \
467         inet_aton \
468         gethostname \
469         setlinebuf \
470         setvbuf \
471         getusershell
472 )
473 RADIUSD_NEED_DECLARATIONS( \
474         crypt \
475         strncasecmp \
476         strcasecmp \
477         inet_aton \
478         gethostname \
479         setlinebuf \
480         getusershell \
481         endusershell
482 )
483
484 AC_TYPE_SIGNAL
485
486 dnl #############################################################
487 dnl #
488 dnl #  6. Checks for compiler characteristics
489 dnl #
490 dnl #############################################################
491
492 dnl #
493 dnl # Ensure that these are defined
494 dnl #
495 AC_C_CONST 
496
497 dnl #
498 dnl # See if this is OS/2
499 dnl #
500 AC_MSG_CHECKING(type of OS)
501 OS=`uname -s`
502 AC_MSG_RESULT($OS)
503 if test "$OS" = "OS/2"; then
504         LIBPREFIX=
505 else
506         LIBPREFIX=lib
507 fi
508 AC_SUBST(LIBPREFIX)
509
510 dnl #
511 dnl # Set Default CFLAGS
512 dnl #
513 if test "$GCC" = "yes"; then
514     CFLAGS="$CFLAGS -Wall -D_GNU_SOURCE"
515 fi
516
517 dnl #############################################################
518 dnl #
519 dnl #  7. Checks for library functions
520 dnl #
521 dnl #############################################################
522
523 dnl Check for libcrypt
524 dnl We use crypt(3) which may be in libc, or in libcrypt (eg FreeBSD)
525 AC_CHECK_LIB(crypt, crypt,
526   CRYPTLIB="-lcrypt"
527 )
528 AC_SUBST(CRYPTLIB)
529 if test "$CRYPTLIB" != ""; then
530   AC_DEFINE(HAVE_CRYPT)
531 else
532   AC_CHECK_FUNC(crypt, AC_DEFINE(HAVE_CRYPT))
533 fi
534
535 dnl #############################################################
536 dnl #
537 dnl #  8. Checks for system services
538 dnl #
539 dnl #############################################################
540
541 dnl #
542 dnl # Figure out where libtool is located,
543 dnl #
544 LIBTOOL="`pwd`/libtool"
545 AC_SUBST(LIBTOOL)
546 AC_SUBST(LIBLTDL)
547 AC_SUBST(INCLTDL)
548 top_builddir=`pwd`
549 AC_SUBST(top_builddir)
550
551 dnl #############################################################
552 dnl #
553 dnl #  And finally, output the results.
554 dnl #
555 dnl #############################################################
556
557 dnl #
558 dnl #  Substitute whatever libraries we found to be necessary
559 dnl #
560 AC_SUBST(LIBS)
561
562 USE_SHARED_LIBS=$enable_shared
563 AC_SUBST(USE_SHARED_LIBS)
564 USE_STATIC_LIBS=$enable_static
565 AC_SUBST(USE_STATIC_LIBS)
566 AC_SUBST(STATIC_MODULES)
567
568 AC_OUTPUT(\
569         ./Make.inc \
570         ./src/include/build-radpaths-h \
571         ./src/main/checkrad.pl \
572         ./src/main/radlast \
573         ./src/main/radtest \
574         ./scripts/rc.radiusd \
575         ./scripts/radwatch \
576         ./scripts/check-radiusd-config \
577         ./raddb/radiusd.conf
578 )
579
580 AC_OUTPUT_COMMANDS([echo timestamp > src/include/stamp-h])
581 AC_OUTPUT_COMMANDS([(cd ./src/include && /bin/sh ./build-radpaths-h)])
582 AC_OUTPUT_COMMANDS([(cd ./src/main   && chmod +x checkrad.pl radlast radtest)])
583 AC_OUTPUT_COMMANDS([(cd ./scripts    && chmod +x rc.radiusd radwatch check-radiusd-config)])