1 dnl See whether we need a declaration for a function.
2 dnl RADIUSD_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
3 AC_DEFUN([RADIUSD_NEED_DECLARATION],
4 [AC_MSG_CHECKING([whether $1 must be declared])
5 AC_CACHE_VAL(radius_cv_decl_needed_$1,
18 #ifdef HAVE_RESOURCE_H
33 #ifdef HAVE_SYS_SELECT_H
34 #include <sys/select.h>
45 #ifdef HAVE_INTTYPES_H
51 #ifdef HAVE_ARPA_INET_H
52 #include <arpa/inet.h>
55 [char *(*pfn) = (char *(*)) $1],
56 eval "radius_cv_decl_needed_$1=no", eval "radius_cv_decl_needed_$1=yes")])
57 if eval "test \"`echo '$radius_cv_decl_needed_'$1`\" = yes"; then
59 radius_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
60 AC_DEFINE_UNQUOTED($radius_tr_decl)
66 dnl Check multiple functions to see whether each needs a declaration.
67 dnl RADIUSD_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
68 AC_DEFUN([RADIUSD_NEED_DECLARATIONS],
71 RADIUSD_NEED_DECLARATION($ac_func, $2)
75 dnl Checks to see if this is SUNPro we're building with
78 AC_DEFUN([AC_PROG_CC_SUNPRO],
79 [AC_CACHE_CHECK(whether we are using SUNPro C, ac_cv_prog_suncc,
80 [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
81 cat > conftest.c <<EOF
86 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
93 dnl # FR_CHECK_TYPE_INCLUDE([#includes ...], type, default-C-types)
95 dnl # This function is like AC_CHECK_TYPE, but you can give this one
96 dnl # a list of include files to check.
98 AC_DEFUN([FR_CHECK_TYPE_INCLUDE],
100 AC_CACHE_CHECK(for $2, ac_cv_type_$2,
109 if test "$ac_cv_type_$2" != "yes"; then
110 AC_DEFINE($2, $3, $4)
114 dnl #######################################################################
116 dnl # Look for SNMP in a variety of places.
118 AC_DEFUN([SNMP_CHECKS], [
120 AC_SUBST(SNMP_INCLUDE)
122 AC_MSG_CHECKING([for asn1.h,snmp.h,snmp_impl.h])
125 dnl # First, see if we can build it WITHOUT using any special includes and in ucd-snmp
128 #ifdef HAVE_SYS_TYPES_H
129 #include <sys/types.h>
143 #include <ucd-snmp/ucd-snmp-config.h>
144 #include <ucd-snmp/asn1.h>
145 #include <ucd-snmp/snmp.h>
146 #include <ucd-snmp/snmp_impl.h>],
148 SNMP_INCLUDE="";ucdsnmp=yes,
152 dnl # If not, look for it in a number of directories and in ucd-snmp.
154 if test "x$ucdsnmp" = "x"; then
156 for try in /usr/include /usr/local/include $snmp_include_dir; do
157 CFLAGS="$old_CFLAGS -I$try"
159 #ifdef HAVE_SYS_TYPES_H
160 #include <sys/types.h>
174 #include <ucd-snmp/ucd-snmp-config.h>
175 #include <ucd-snmp/asn1.h>
176 #include <ucd-snmp/snmp.h>
177 #include <ucd-snmp/snmp_impl.h>],
179 SNMP_INCLUDE="-I$try";ucdsnmp=yes,
181 if test "x$ucdsnmp" != "x"; then
188 if test "x$ucdsnmp" = "x"; then
190 for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
191 CFLAGS="$old_CFLAGS -I$try"
193 dnl # First, see if we can build it WITHOUT using any special includes and without ucd-snmp
196 #ifdef HAVE_SYS_TYPES_H
197 #include <sys/types.h>
213 #include <snmp_impl.h>],
215 SNMP_INCLUDE="";ucdsnmp=no,
217 if test "x$ucdsnmp" != "x"; then
225 dnl # If not, look for it in a number of directories and without ucd-snmp
227 if test "x$ucdsnmp" = "x"; then
229 for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
230 CFLAGS="$old_CFLAGS -I$try"
232 #ifdef HAVE_SYS_TYPES_H
233 #include <sys/types.h>
249 #include <snmp_impl.h>],
251 SNMP_INCLUDE="-I$try";ucdsnmp=no,
253 if test "x$ucdsnmp" != "x"; then
260 if test "x$ucdsnmp" = "x"; then
263 if test "x$ucdsnmp" = "xyes"; then
264 AC_MSG_RESULT((ucd-snmp)yes)
265 AC_DEFINE(HAVE_UCD_SNMP_ASN1_SNMP_SNMPIMPL_H, [], [Define if you have the <ucd-snmp/asn1.h>, <ucd-snmp/snmp_impl.h> and <ucd-snmp/snmp.h> header file.])
268 AC_DEFINE(HAVE_ASN1_SNMP_SNMPIMPL_H, [], [Define if you have the <asn1.h>, <snmp_impl.h> and <snmp.h> header file.])
271 dnl # Now do the same thing, looking for the SNMP library directory
273 AC_MSG_CHECKING([for snmp_build_var_op in -lsnmp])
276 dnl # First, see if we can build it WITHOUT using any special includes
279 LIBS="$old_LIBS -lsnmp"
280 AC_TRY_LINK([extern char snmp_build_var_op();],
281 [ snmp_build_var_op()],
285 if test "x$SNMP_LIBS" = "x"; then
286 for try in /usr/lib /usr/local/lib /usr/local/snmp/lib $with_snmp_lib_dir; do
287 LIBS="$old_LIBS -L$try -lsnmp"
288 AC_TRY_LINK([extern char snmp_build_var_op();],
289 [ snmp_build_var_op()],
290 SNMP_LIBS="-L$try -lsnmp",
292 if test "x$SNMP_LIBS" != "x"; then
296 dnl # That didn't work. Try adding the '-lcrypto' line.
297 dnl # Some SNMP libraries are linked against SSL...
299 LIBS="$old_LIBS -L$try -lsnmp -lcrypto"
300 AC_TRY_LINK([extern char snmp_build_var_op();],
301 [ snmp_build_var_op()],
302 SNMP_LIBS="-L$try -lsnmp -lcrypto",
304 if test "x$SNMP_LIBS" != "x"; then
308 dnl # That didn't work. Try adding the '-lkstat' line.
309 dnl # Some SNMP libraries are linked against Kernel Statistics,
310 dnl # in particular, Solaris 9...
312 LIBS="$old_LIBS -L$try -lsnmp -lcrypto -lkstat"
313 AC_TRY_LINK([extern char snmp_build_var_op();],
314 [ snmp_build_var_op()],
315 SNMP_LIBS="-L$try -lsnmp -lcrypto -lkstat",
317 if test "x$SNMP_LIBS" != "x"; then
325 dnl # If one or the other isn't found, disable them both..
326 dnl # If both are found, enable them both.
329 if test "x$SNMP_LIBS" = "x"; then
334 AC_DEFINE(WITH_SNMP, [], [Include SNMP subagent])
335 AC_DEFINE(HAVE_LIBSNMP, [], [Define if you have the snmp library (-lsnmp).])
342 dnl # Locate the directory in which a particular file is found.
344 dnl # Usage: FR_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a)
346 dnl # Defines the variable MYSQLLIB_DIR to be the directory(s) in
347 dnl # which the file libmysqlclient.a is to be found.
350 AC_DEFUN([FR_LOCATE_DIR],
352 dnl # If we have the program 'locate', then the problem of finding a
353 dnl # particular file becomes MUCH easier.
357 dnl # No 'locate' defined, do NOT do anything.
359 if test "x$LOCATE" != "x"; then
361 dnl # Root through a series of directories, looking for the given file.
366 for x in `${LOCATE} $file 2>/dev/null`; do
368 dnl # When asked for 'foo', locate will also find 'foo_bar', which we
369 dnl # don't want. We want that EXACT filename.
371 dnl # We ALSO want to be able to look for files like 'mysql/mysql.h',
372 dnl # and properly match them, too. So we try to strip off the last
373 dnl # part of the filename, using the name of the file we're looking
374 dnl # for. If we CANNOT strip it off, then the name will be unchanged.
376 base=`echo $x | sed "s%/${file}%%"`
377 if test "x$x" = "x$base"; then
381 dir=`${DIRNAME} $x 2>/dev/null`
383 dnl # Exclude a number of directories.
385 exclude=`echo ${dir} | ${GREP} /home`
386 if test "x$exclude" != "x"; then
391 dnl # OK, we have an exact match. Let's be sure that we only find ONE
392 dnl # matching directory.
394 already=`echo \$$1 ${DIRS} | ${GREP} ${dir}`
395 if test "x$already" = "x"; then
402 dnl # And remember the directory in which we found the file.
404 eval "$1=\"\$$1 $DIRS\""
408 dnl #######################################################################
410 dnl # Look for a library in a number of places.
412 dnl # FR_SMART_CHECK_LIB(library, function)
414 AC_DEFUN([FR_SMART_CHECK_LIB], [
416 sm_lib_safe=`echo "$1" | sed 'y%./+-%__p_%'`
417 sm_func_safe=`echo "$2" | sed 'y%./+-%__p_%'`
418 AC_MSG_CHECKING([for $2 in -l$1])
425 dnl # Try first any user-specified directory, otherwise we may pick up
426 dnl # the wrong version.
428 if test "x$smart_try_dir" != "x"; then
429 for try in $smart_try_dir; do
430 LIBS="-L$try -l$1 $old_LIBS"
431 AC_TRY_LINK([extern char $2();],
433 smart_lib="-L$try -l$1")
434 if test "x$smart_lib" != "x"; then
442 dnl # Try using the default library path
444 if test "x$smart_lib" = "x"; then
445 LIBS="-l$1 $old_LIBS"
446 AC_TRY_LINK([extern char $2();],
453 dnl # Try to guess possible locations.
455 if test "x$smart_lib" = "x"; then
456 FR_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}])
457 FR_LOCATE_DIR(smart_lib_dir,[lib$1.a])
459 for try in $smart_lib_dir /usr/local/lib /opt/lib; do
460 LIBS="-L$try -l$1 $old_LIBS"
461 AC_TRY_LINK([extern char $2();],
463 smart_lib="-L$try -l$1")
464 if test "x$smart_lib" != "x"; then
472 dnl # Found it, set the appropriate variable.
474 if test "x$smart_lib" != "x"; then
476 eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
477 LIBS="$smart_lib $old_LIBS"
478 SMART_LIBS="$smart_lib $SMART_LIBS"
484 dnl #######################################################################
486 dnl # Look for a header file in a number of places.
488 dnl # FR_SMART_CHECK_INCLUDE(foo.h, [ #include <other.h> ])
490 AC_DEFUN([FR_SMART_CHECK_INCLUDE], [
492 ac_safe=`echo "$1" | sed 'y%./+-%__pm%'`
493 AC_MSG_CHECKING([for $1])
500 dnl # Try first any user-specified directory, otherwise we may pick up
501 dnl # the wrong version.
503 if test "x$smart_try_dir" != "x"; then
504 for try in $smart_try_dir; do
505 CFLAGS="$old_CFLAGS -I$try"
509 smart_include="-I$try",
511 if test "x$smart_include" != "x"; then
519 dnl # Try using the default includes.
521 if test "x$smart_include" = "x"; then
530 dnl # Try to guess possible locations.
532 if test "x$smart_include" = "x"; then
533 FR_LOCATE_DIR(smart_include_dir,$1)
535 for try in $smart_include_dir /usr/local/include /opt/include; do
536 CFLAGS="$old_CFLAGS -I$try"
540 smart_include="-I$try",
542 if test "x$smart_include" != "x"; then
550 dnl # Found it, set the appropriate variable.
552 if test "x$smart_include" != "x"; then
554 eval "ac_cv_header_$ac_safe=yes"
555 CFLAGS="$old_CFLAGS $smart_include"
556 SMART_CFLAGS="$SMART_CFLAGS $smart_include"
562 dnl #######################################################################
564 dnl # Look for a header file in a number of places.
566 dnl # Usage: FR_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member)
567 dnl # If the member is defined, then the variable
568 dnl # ac_cv_type_struct_foo_has_member is set to 'yes'
570 AC_DEFUN([FR_CHECK_STRUCT_HAS_MEMBER], [
571 AC_MSG_CHECKING([for $3 in $2])
573 dnl BASED on 'offsetof':
574 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
580 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
583 [ int foo = offsetof($2, $3) ],
587 ac_safe_type=`echo "$2" | sed 'y% %_%'`
588 if test "x$has_element" != "x"; then
590 eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
593 eval "ac_cv_type_${ac_safe_type}_has_$3="
597 AC_INCLUDE(aclocal.m4)