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_%'`
197 dnl # Try first any user-specified directory, otherwise we may pick up
198 dnl # the wrong version.
200 if test "x$smart_try_dir" != "x"; then
201 for try in $smart_try_dir; do
202 AC_MSG_CHECKING([for $2 in -l$1 in $try])
203 LIBS="-L$try -l$1 $old_LIBS -Wl,-rpath,$try"
204 AC_TRY_LINK([extern char $2();],
207 smart_lib="-L$try -l$1 -Wl,-rpath,$try"
217 dnl # Try using the default library path
219 if test "x$smart_lib" = "x"; then
220 AC_MSG_CHECKING([for $2 in -l$1])
221 LIBS="-l$1 $old_LIBS"
222 AC_TRY_LINK([extern char $2();],
233 dnl # Try to guess possible locations.
235 if test "x$smart_lib" = "x"; then
236 FR_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}])
237 FR_LOCATE_DIR(smart_lib_dir,[lib$1.a])
239 for try in $smart_lib_dir /usr/local/lib /opt/lib; do
240 AC_MSG_CHECKING([for $2 in -l$1 in $try])
241 LIBS="-L$try -rpath$try -l$1 $old_LIBS -Wl,-rpath,$try"
242 AC_TRY_LINK([extern char $2();],
245 smart_lib="-L$try -l$1 -Wl,-rpath,$try"
255 dnl # Found it, set the appropriate variable.
257 if test "x$smart_lib" != "x"; then
258 eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
259 LIBS="$smart_lib $old_LIBS"
260 SMART_LIBS="$smart_lib $SMART_LIBS"
264 dnl #######################################################################
266 dnl # Look for a header file in a number of places.
268 dnl # FR_SMART_CHECK_INCLUDE(foo.h, [ #include <other.h> ])
270 AC_DEFUN([FR_SMART_CHECK_INCLUDE], [
272 ac_safe=`echo "$1" | sed 'y%./+-%__pm%'`
278 dnl # Try first any user-specified directory, otherwise we may pick up
279 dnl # the wrong version.
281 if test "x$smart_try_dir" != "x"; then
282 for try in $smart_try_dir; do
283 AC_MSG_CHECKING([for $1 in $try])
284 CFLAGS="$old_CFLAGS -I$try"
289 smart_include="-I$try"
302 dnl # Try using the default includes.
304 if test "x$smart_include" = "x"; then
305 AC_MSG_CHECKING([for $1])
321 dnl # Try to guess possible locations.
323 if test "x$smart_include" = "x"; then
324 FR_LOCATE_DIR(smart_include_dir,$1)
325 for try in $smart_include_dir /usr/local/include /opt/include; do
326 AC_MSG_CHECKING([for $1 in $try])
327 CFLAGS="$old_CFLAGS -I$try"
332 smart_include="-I$try"
345 dnl # Found it, set the appropriate variable.
347 if test "x$smart_include" != "x"; then
348 eval "ac_cv_header_$ac_safe=yes"
349 CFLAGS="$old_CFLAGS $smart_include"
350 SMART_CFLAGS="$SMART_CFLAGS $smart_include"
354 dnl #######################################################################
356 dnl # Look for a header file in a number of places.
358 dnl # Usage: FR_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member)
359 dnl # If the member is defined, then the variable
360 dnl # ac_cv_type_struct_foo_has_member is set to 'yes'
362 AC_DEFUN([FR_CHECK_STRUCT_HAS_MEMBER], [
363 AC_MSG_CHECKING([for $3 in $2])
365 dnl BASED on 'offsetof':
366 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
375 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
378 [ int foo = offsetof($2, $3) ],
382 ac_safe_type=`echo "$2" | sed 'y% %_%'`
383 if test "x$has_element" != "x"; then
385 eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
388 eval "ac_cv_type_${ac_safe_type}_has_$3="
392 dnl Autoconf 2.61 breaks the support for chained configure scripts
393 dnl in combination with config.cache
394 m4_pushdef([AC_OUTPUT],
396 unset ac_cv_env_LIBS_set
397 unset ac_cv_env_LIBS_value
398 m4_popdef([AC_OUTPUT])
399 AC_OUTPUT([$1],[$2],[$3])
403 # See if the compilation works with __thread, for thread-local storage
407 AC_MSG_CHECKING(for TLS)
408 AC_RUN_IFELSE([AC_LANG_SOURCE([[ static __thread int val; int main(int argc, char *argv[]) { return val = argc; } ]])],[have_tls=yes],[have_tls=no],[have_tls=no ])
409 AC_MSG_RESULT($have_tls)
410 if test "$have_tls" = "yes"; then
411 AC_DEFINE([HAVE_THREAD_TLS],[1],[Define if the compiler supports __thread])
416 AC_DEFUN([VL_LIB_READLINE], [
417 AC_CACHE_CHECK([for a readline compatible library],
418 vl_cv_lib_readline, [
420 for readline_lib in readline edit editline; do
421 for termcap_lib in "" termcap curses ncurses; do
422 if test -z "$termcap_lib"; then
423 TRY_LIB="-l$readline_lib"
425 TRY_LIB="-l$readline_lib -l$termcap_lib"
427 LIBS="$ORIG_LIBS $TRY_LIB"
428 AC_TRY_LINK_FUNC(readline, vl_cv_lib_readline="$TRY_LIB")
429 if test -n "$vl_cv_lib_readline"; then
430 LIBREADLINE="$TRY_LIB"
434 if test -n "$vl_cv_lib_readline"; then
438 if test -z "$vl_cv_lib_readline"; then
439 vl_cv_lib_readline="no"
444 if test "$vl_cv_lib_readline" != "no"; then
445 AC_DEFINE(HAVE_LIBREADLINE, 1,
446 [Define if you have a readline compatible library])
447 AC_CHECK_HEADERS(readline.h readline/readline.h)
448 AC_CACHE_CHECK([whether readline supports history],
449 [vl_cv_lib_readline_history], [
450 vl_cv_lib_readline_history="no"
451 AC_TRY_LINK_FUNC([add_history], [vl_cv_lib_readline_history="yes"])
453 if test "$vl_cv_lib_readline_history" = "yes"; then
454 AC_DEFINE(HAVE_READLINE_HISTORY, 1,
455 [Define if your readline library has \`add_history'])
456 AC_CHECK_HEADERS(history.h readline/history.h)
459 AC_SUBST(LIBREADLINE)
462 AC_INCLUDE(aclocal.m4)