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
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/asn1.h>
144 #include <ucd-snmp/snmp.h>
145 #include <ucd-snmp/snmp_impl.h>],
147 SNMP_INCLUDE="";ucdsnmp=yes,
151 dnl # If not, look for it in a number of directories and in ucd-snmp.
153 if test "x$ucdsnmp" = "x"; then
155 for try in /usr/include /usr/local/include $snmp_include_dir; do
156 CFLAGS="$old_CFLAGS -I$try"
158 #ifdef HAVE_SYS_TYPES_H
159 #include <sys/types.h>
173 #include <ucd-snmp/asn1.h>
174 #include <ucd-snmp/snmp.h>
175 #include <ucd-snmp/snmp_impl.h>],
177 SNMP_INCLUDE="-I$try";ucdsnmp=yes,
179 if test "x$ucdsnmp" != "x"; then
186 if test "x$ucdsnmp" = "x"; then
188 for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
189 CFLAGS="$old_CFLAGS -I$try"
191 dnl # First, see if we can build it WITHOUT using any special includes and without ucd-snmp
194 #ifdef HAVE_SYS_TYPES_H
195 #include <sys/types.h>
211 #include <snmp_impl.h>],
213 SNMP_INCLUDE="";ucdsnmp=no,
215 if test "x$ucdsnmp" != "x"; then
223 dnl # If not, look for it in a number of directories and without ucd-snmp
225 if test "x$ucdsnmp" = "x"; then
227 for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
228 CFLAGS="$old_CFLAGS -I$try"
230 #ifdef HAVE_SYS_TYPES_H
231 #include <sys/types.h>
247 #include <snmp_impl.h>],
249 SNMP_INCLUDE="-I$try";ucdsnmp=no,
251 if test "x$ucdsnmp" != "x"; then
258 if test "x$ucdsnmp" = "x"; then
261 if test "x$ucdsnmp" = "xyes"; then
262 AC_MSG_RESULT((ucd-snmp)yes)
263 AC_DEFINE(HAVE_UCD_SNMP_ASN1_SNMP_SNMPIMPL_H)
266 AC_DEFINE(HAVE_ASN1_SNMP_SNMPIMPL_H)
269 dnl # Now do the same thing, looking for the SNMP library directory
271 AC_MSG_CHECKING([for snmp_build_var_op in -lsnmp])
274 dnl # First, see if we can build it WITHOUT using any special includes
277 LIBS="$old_LIBS -lsnmp"
278 AC_TRY_LINK([extern char snmp_build_var_op();],
279 [ snmp_build_var_op()],
283 if test "x$SNMP_LIBS" = "x"; then
284 for try in /usr/lib /usr/local/lib /usr/local/snmp/lib $snmp_lib_dir; do
285 LIBS="$old_LIBS -L$try -lsnmp"
286 AC_TRY_LINK([extern char snmp_build_var_op();],
287 [ snmp_build_var_op()],
288 SNMP_LIBS="-L$try -lsnmp",
290 if test "x$SNMP_LIBS" != "x"; then
294 dnl # That didn't work. Try adding the '-lcrypto' line.
295 dnl # Some SNMP libraries are linked against SSL...
297 LIBS="$old_LIBS -L$try -lsnmp -lcrypto"
298 AC_TRY_LINK([extern char snmp_build_var_op();],
299 [ snmp_build_var_op()],
300 SNMP_LIBS="-L$try -lsnmp -lcrypto",
302 if test "x$SNMP_LIBS" != "x"; then
310 dnl # If one or the other isn't found, disable them both..
311 dnl # If both are found, enable them both.
314 if test "x$SNMP_LIBS" = "x"; then
320 AC_DEFINE(HAVE_LIBSNMP)
327 dnl # Locate the directory in which a particular file is found.
329 dnl # Usage: FR_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a)
331 dnl # Defines the variable MYSQLLIB_DIR to be the directory(s) in
332 dnl # which the file libmysqlclient.a is to be found.
335 AC_DEFUN(FR_LOCATE_DIR,
337 dnl # If we have the program 'locate', then the problem of finding a
338 dnl # particular file becomes MUCH easier.
342 dnl # No 'locate' defined, do NOT do anything.
344 if test "x$LOCATE" != "x"; then
346 dnl # Root through a series of directories, looking for the given file.
351 for x in `${LOCATE} $file 2>/dev/null`; do
353 dnl # When asked for 'foo', locate will also find 'foo_bar', which we
354 dnl # don't want. We want that EXACT filename.
356 dnl # We ALSO want to be able to look for files like 'mysql/mysql.h',
357 dnl # and properly match them, too. So we try to strip off the last
358 dnl # part of the filename, using the name of the file we're looking
359 dnl # for. If we CANNOT strip it off, then the name will be unchanged.
361 base=`echo $x | sed "s%/${file}%%"`
362 if test "x$x" = "x$base"; then
366 dir=`${DIRNAME} $x 2>/dev/null`
368 dnl # Exclude a number of directories.
370 exclude=`echo ${dir} | ${GREP} /home`
371 if test "x$exclude" != "x"; then
376 dnl # OK, we have an exact match. Let's be sure that we only find ONE
377 dnl # matching directory.
379 already=`echo \$$1 ${DIRS} | ${GREP} ${dir}`
380 if test "x$already" = "x"; then
387 dnl # And remember the directory in which we found the file.
389 eval "$1=\"\$$1 $DIRS\""
393 dnl #######################################################################
395 dnl # Look for a library in a number of places.
397 AC_DEFUN(FR_SMART_CHECK_LIB, [
399 sm_lib_safe=`echo "$1" | sed 'y%./+-%__p_%'`
400 sm_func_safe=`echo "$2" | sed 'y%./+-%__p_%'`
401 AC_MSG_CHECKING([for $2 in -l$1])
407 dnl # Try to link it first, using the default libs && library paths
411 AC_TRY_LINK([extern char $2();],
415 if test "x$smart_lib" = "x"; then
416 FR_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}])
417 FR_LOCATE_DIR(smart_lib_dir,[lib$1.a])
419 for try in $smart_try_dir $smart_lib_dir /usr/local/lib/ /opt/lib; do
420 LIBS="$old_LIBS -L$try -l$1"
422 AC_TRY_LINK([extern char $2();],
424 smart_lib="-L$try -l$1")
425 if test "x$smart_lib" != "x"; then
433 dnl # Found it, set the appropriate variable.
435 if test "x$smart_lib" != "x"; then
437 eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
438 LIBS="$old_LIBS $smart_lib"
439 SMART_LIBS="$SMART_LIBS $smart_lib"
445 dnl #######################################################################
447 dnl # Look for a header file in a number of places.
449 dnl # FR_SMART_CHECK_INCLUDE(foo.h, [ #include <other.h> ])
451 AC_DEFUN(FR_SMART_CHECK_INCLUDE, [
453 ac_safe=`echo "$1" | sed 'y%./+-%__pm%'`
454 AC_MSG_CHECKING([for $1])
460 dnl # Try to link it first, using the default includes
469 if test "x$smart_include" = "x"; then
470 FR_LOCATE_DIR(smart_include_dir,$1)
472 for try in $smart_try_dir $smart_include_dir /usr/local/include/ /opt/include; do
473 CFLAGS="$old_CFLAGS -I$try"
478 smart_include="-I$try",
481 if test "x$smart_include" != "x"; then
489 dnl # Found it, set the appropriate variable.
491 if test "x$smart_include" != "x"; then
493 eval "ac_cv_header_$ac_safe=yes"
494 CFLAGS="$old_CFLAGS $smart_include"
495 SMART_CFLAGS="$SMART_CFLAGS $smart_include"
501 dnl #######################################################################
503 dnl # Look for a header file in a number of places.
505 dnl # Usage: FR_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member)
506 dnl # If the member is defined, then the variable
507 dnl # ac_cv_type_struct_foo_has_member is set to 'yes'
509 AC_DEFUN(FR_CHECK_STRUCT_HAS_MEMBER, [
510 AC_MSG_CHECKING([for $3 in $2])
512 dnl BASED on 'offsetof':
513 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
519 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
522 [ int foo = offsetof($2, $3) ],
526 ac_safe_type=`echo "$2" | sed 'y% %_%'`
527 if test "x$has_element" != "x"; then
529 eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
532 eval "ac_cv_type_${ac_safe_type}_has_$3="
536 AC_DEFUN(FR_LIBLTDL_PATH,
539 if test x"$enable_ltdl_install" = x"yes"; then
540 AC_CONFIG_SUBDIRS('libltdl')
543 AC_SUBST(LIBLTDLPATH)