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)
115 dnl # Locate the directory in which a particular file is found.
117 dnl # Usage: FR_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a)
119 dnl # Defines the variable MYSQLLIB_DIR to be the directory(s) in
120 dnl # which the file libmysqlclient.a is to be found.
123 AC_DEFUN([FR_LOCATE_DIR],
125 dnl # If we have the program 'locate', then the problem of finding a
126 dnl # particular file becomes MUCH easier.
130 dnl # No 'locate' defined, do NOT do anything.
132 if test "x$LOCATE" != "x"; then
134 dnl # Root through a series of directories, looking for the given file.
139 for x in `${LOCATE} $file 2>/dev/null`; do
141 dnl # When asked for 'foo', locate will also find 'foo_bar', which we
142 dnl # don't want. We want that EXACT filename.
144 dnl # We ALSO want to be able to look for files like 'mysql/mysql.h',
145 dnl # and properly match them, too. So we try to strip off the last
146 dnl # part of the filename, using the name of the file we're looking
147 dnl # for. If we CANNOT strip it off, then the name will be unchanged.
149 base=`echo $x | sed "s%/${file}%%"`
150 if test "x$x" = "x$base"; then
154 dir=`${DIRNAME} $x 2>/dev/null`
156 dnl # Exclude a number of directories.
158 exclude=`echo ${dir} | ${GREP} /home`
159 if test "x$exclude" != "x"; then
164 dnl # OK, we have an exact match. Let's be sure that we only find ONE
165 dnl # matching directory.
167 already=`echo \$$1 ${DIRS} | ${GREP} ${dir}`
168 if test "x$already" = "x"; then
175 dnl # And remember the directory in which we found the file.
177 eval "$1=\"\$$1 $DIRS\""
181 dnl #######################################################################
183 dnl # Look for a library in a number of places.
185 dnl # FR_SMART_CHECK_LIB(library, function)
187 AC_DEFUN([FR_SMART_CHECK_LIB], [
189 sm_lib_safe=`echo "$1" | sed 'y%./+-%__p_%'`
190 sm_func_safe=`echo "$2" | sed 'y%./+-%__p_%'`
191 AC_MSG_CHECKING([for $2 in -l$1])
198 dnl # Try first any user-specified directory, otherwise we may pick up
199 dnl # the wrong version.
201 if test "x$smart_try_dir" != "x"; then
202 for try in $smart_try_dir; do
203 LIBS="-L$try -l$1 $old_LIBS"
204 AC_TRY_LINK([extern char $2();],
206 smart_lib="-L$try -l$1")
207 if test "x$smart_lib" != "x"; then
215 dnl # Try using the default library path
217 if test "x$smart_lib" = "x"; then
218 LIBS="-l$1 $old_LIBS"
219 AC_TRY_LINK([extern char $2();],
226 dnl # Try to guess possible locations.
228 if test "x$smart_lib" = "x"; then
229 FR_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}])
230 FR_LOCATE_DIR(smart_lib_dir,[lib$1.a])
232 for try in $smart_lib_dir /usr/local/lib /opt/lib; do
233 LIBS="-L$try -l$1 $old_LIBS"
234 AC_TRY_LINK([extern char $2();],
236 smart_lib="-L$try -l$1")
237 if test "x$smart_lib" != "x"; then
245 dnl # Found it, set the appropriate variable.
247 if test "x$smart_lib" != "x"; then
249 eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
250 LIBS="$smart_lib $old_LIBS"
251 SMART_LIBS="$smart_lib $SMART_LIBS"
257 dnl #######################################################################
259 dnl # Look for a header file in a number of places.
261 dnl # FR_SMART_CHECK_INCLUDE(foo.h, [ #include <other.h> ])
263 AC_DEFUN([FR_SMART_CHECK_INCLUDE], [
265 ac_safe=`echo "$1" | sed 'y%./+-%__pm%'`
266 AC_MSG_CHECKING([for $1])
273 dnl # Try first any user-specified directory, otherwise we may pick up
274 dnl # the wrong version.
276 if test "x$smart_try_dir" != "x"; then
277 for try in $smart_try_dir; do
278 CFLAGS="$old_CFLAGS -I$try"
282 smart_include="-I$try",
284 if test "x$smart_include" != "x"; then
292 dnl # Try using the default includes.
294 if test "x$smart_include" = "x"; then
303 dnl # Try to guess possible locations.
305 if test "x$smart_include" = "x"; then
306 FR_LOCATE_DIR(smart_include_dir,$1)
308 for try in $smart_include_dir /usr/local/include /opt/include; do
309 CFLAGS="$old_CFLAGS -I$try"
313 smart_include="-I$try",
315 if test "x$smart_include" != "x"; then
323 dnl # Found it, set the appropriate variable.
325 if test "x$smart_include" != "x"; then
327 eval "ac_cv_header_$ac_safe=yes"
328 CFLAGS="$old_CFLAGS $smart_include"
329 SMART_CFLAGS="$SMART_CFLAGS $smart_include"
335 dnl #######################################################################
337 dnl # Look for a header file in a number of places.
339 dnl # Usage: FR_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member)
340 dnl # If the member is defined, then the variable
341 dnl # ac_cv_type_struct_foo_has_member is set to 'yes'
343 AC_DEFUN([FR_CHECK_STRUCT_HAS_MEMBER], [
344 AC_MSG_CHECKING([for $3 in $2])
346 dnl BASED on 'offsetof':
347 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
353 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
356 [ int foo = offsetof($2, $3) ],
360 ac_safe_type=`echo "$2" | sed 'y% %_%'`
361 if test "x$has_element" != "x"; then
363 eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
366 eval "ac_cv_type_${ac_safe_type}_has_$3="
370 dnl Autoconf 2.61 breaks the support for chained configure scripts
371 dnl in combination with config.cache
372 m4_pushdef([AC_OUTPUT],
374 unset ac_cv_env_LIBS_set
375 unset ac_cv_env_LIBS_value
376 m4_popdef([AC_OUTPUT])
377 AC_OUTPUT([$1],[$2],[$3])
380 # See if the compilation works with __thread, for thread-local storage
384 AC_MSG_CHECKING(for TLS)
385 AC_RUN_IFELSE([AC_LANG_SOURCE([[ static __thread int val; int main() { return 0; } ]])],[have_tls=yes],[have_tls=no],[have_tls=no ])
386 AC_MSG_RESULT($have_tls)
387 if test "$have_tls" = "yes"; then
388 AC_DEFINE([HAVE_THREAD_TLS],[1],[Define if the compiler supports __thread])
393 AC_DEFUN([AC_LIB_READLINE], [
394 AC_CACHE_CHECK([for a readline compatible library],
395 ac_cv_lib_readline, [
398 for readline_lib in readline edit editline; do
399 for termcap_lib in "" termcap curses ncurses; do
400 if test -z "$termcap_lib"; then
401 TRY_LIB="-l$readline_lib"
403 TRY_LIB="-l$readline_lib -l$termcap_lib"
405 LIBS="$ORIG_LIBS $TRY_LIB"
406 AC_TRY_LINK_FUNC(readline, ac_cv_lib_readline="$TRY_LIB")
407 if test -n "$ac_cv_lib_readline"; then
408 LIBREADLINE="$TRY_LIB"
412 if test -n "$ac_cv_lib_readline"; then
416 if test -z "$ac_cv_lib_readline"; then
417 ac_cv_lib_readline="no"
420 AC_SUBST(LIBREADLINE)
423 if test "$ac_cv_lib_readline" != "no"; then
424 AC_DEFINE(HAVE_LIBREADLINE, 1,
425 [Define if you have a readline compatible library])
426 AC_CHECK_HEADERS(readline.h readline/readline.h)
427 AC_CACHE_CHECK([whether readline supports history],
428 ac_cv_lib_readline_history, [
429 ac_cv_lib_readline_history="no"
430 AC_TRY_LINK_FUNC(add_history, ac_cv_lib_readline_history="yes")
432 if test "$ac_cv_lib_readline_history" = "yes"; then
433 AC_DEFINE(HAVE_READLINE_HISTORY, 1,
434 [Define if your readline library has \`add_history'])
435 AC_CHECK_HEADERS(history.h readline/history.h)
440 AC_INCLUDE(aclocal.m4)