New file to fix corrupted restored one.
[freeradius.git] / aclocal.m4
1 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
2 ## Copyright (C) 1996-1999 Free Software Foundation, Inc.
3 ## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 ##
19 ## As a special exception to the GNU General Public License, if you
20 ## distribute this file as part of a program that contains a
21 ## configuration script generated by Autoconf, you may include it under
22 ## the same distribution terms that you use for the rest of that program.
23
24 # serial 40 AC_PROG_LIBTOOL
25 AC_DEFUN(AC_PROG_LIBTOOL,
26 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
27
28 # Save cache, so that ltconfig can load it
29 AC_CACHE_SAVE
30
31 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
32 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
33 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
34 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
35 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
36 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
37 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
38 || AC_MSG_ERROR([libtool configure failed])
39
40 # Reload cache, that may have been modified by ltconfig
41 AC_CACHE_LOAD
42
43 # This can be used to rebuild libtool when needed
44 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
45
46 # Always use our own libtool.
47 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
48 AC_SUBST(LIBTOOL)dnl
49
50 # Redirect the config.log output again, so that the ltconfig log is not
51 # clobbered by the next message.
52 exec 5>>./config.log
53 ])
54
55 AC_DEFUN(AC_LIBTOOL_SETUP,
56 [AC_PREREQ(2.13)dnl
57 AC_REQUIRE([AC_ENABLE_SHARED])dnl
58 AC_REQUIRE([AC_ENABLE_STATIC])dnl
59 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
60 AC_REQUIRE([AC_CANONICAL_HOST])dnl
61 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
62 AC_REQUIRE([AC_PROG_RANLIB])dnl
63 AC_REQUIRE([AC_PROG_CC])dnl
64 AC_REQUIRE([AC_PROG_LD])dnl
65 AC_REQUIRE([AC_PROG_NM])dnl
66 AC_REQUIRE([AC_PROG_LN_S])dnl
67 dnl
68
69 case "$target" in
70 NONE) lt_target="$host" ;;
71 *) lt_target="$target" ;;
72 esac
73
74 # Check for any special flags to pass to ltconfig.
75 libtool_flags="--cache-file=$cache_file"
76 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
77 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
78 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
79 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
80 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
81 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
82 [libtool_flags="$libtool_flags --enable-dlopen"])
83 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
84 [libtool_flags="$libtool_flags --enable-win32-dll"])
85 AC_ARG_ENABLE(libtool-lock,
86   [  --disable-libtool-lock  avoid locking (might break parallel builds)])
87 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
88 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
89
90 # Some flags need to be propagated to the compiler or linker for good
91 # libtool support.
92 case "$lt_target" in
93 *-*-irix6*)
94   # Find out which ABI we are using.
95   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
96   if AC_TRY_EVAL(ac_compile); then
97     case "`/usr/bin/file conftest.o`" in
98     *32-bit*)
99       LD="${LD-ld} -32"
100       ;;
101     *N32*)
102       LD="${LD-ld} -n32"
103       ;;
104     *64-bit*)
105       LD="${LD-ld} -64"
106       ;;
107     esac
108   fi
109   rm -rf conftest*
110   ;;
111
112 *-*-sco3.2v5*)
113   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
114   SAVE_CFLAGS="$CFLAGS"
115   CFLAGS="$CFLAGS -belf"
116   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
117     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
118   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
119     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
120     CFLAGS="$SAVE_CFLAGS"
121   fi
122   ;;
123
124 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
125 [*-*-cygwin* | *-*-mingw*)
126   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
127   AC_CHECK_TOOL(AS, as, false)
128   AC_CHECK_TOOL(OBJDUMP, objdump, false)
129   ;;
130 ])
131 esac
132 ])
133
134 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
135 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
136
137 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
138 AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
139
140 # AC_ENABLE_SHARED - implement the --enable-shared flag
141 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
142 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
143 #   `yes'.
144 AC_DEFUN(AC_ENABLE_SHARED, [dnl
145 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
146 AC_ARG_ENABLE(shared,
147 changequote(<<, >>)dnl
148 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
149 changequote([, ])dnl
150 [p=${PACKAGE-default}
151 case "$enableval" in
152 yes) enable_shared=yes ;;
153 no) enable_shared=no ;;
154 *)
155   enable_shared=no
156   # Look at the argument we got.  We use all the common list separators.
157   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
158   for pkg in $enableval; do
159     if test "X$pkg" = "X$p"; then
160       enable_shared=yes
161     fi
162   done
163   IFS="$ac_save_ifs"
164   ;;
165 esac],
166 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
167 ])
168
169 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
170 AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
171 AC_ENABLE_SHARED(no)])
172
173 # AC_ENABLE_STATIC - implement the --enable-static flag
174 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
175 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
176 #   `yes'.
177 AC_DEFUN(AC_ENABLE_STATIC, [dnl
178 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
179 AC_ARG_ENABLE(static,
180 changequote(<<, >>)dnl
181 <<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
182 changequote([, ])dnl
183 [p=${PACKAGE-default}
184 case "$enableval" in
185 yes) enable_static=yes ;;
186 no) enable_static=no ;;
187 *)
188   enable_static=no
189   # Look at the argument we got.  We use all the common list separators.
190   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
191   for pkg in $enableval; do
192     if test "X$pkg" = "X$p"; then
193       enable_static=yes
194     fi
195   done
196   IFS="$ac_save_ifs"
197   ;;
198 esac],
199 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
200 ])
201
202 # AC_DISABLE_STATIC - set the default static flag to --disable-static
203 AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
204 AC_ENABLE_STATIC(no)])
205
206
207 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
208 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
209 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
210 #   `yes'.
211 AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
212 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
213 AC_ARG_ENABLE(fast-install,
214 changequote(<<, >>)dnl
215 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
216 changequote([, ])dnl
217 [p=${PACKAGE-default}
218 case "$enableval" in
219 yes) enable_fast_install=yes ;;
220 no) enable_fast_install=no ;;
221 *)
222   enable_fast_install=no
223   # Look at the argument we got.  We use all the common list separators.
224   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
225   for pkg in $enableval; do
226     if test "X$pkg" = "X$p"; then
227       enable_fast_install=yes
228     fi
229   done
230   IFS="$ac_save_ifs"
231   ;;
232 esac],
233 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
234 ])
235
236 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
237 AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
238 AC_ENABLE_FAST_INSTALL(no)])
239
240 # AC_PROG_LD - find the path to the GNU or non-GNU linker
241 AC_DEFUN(AC_PROG_LD,
242 [AC_ARG_WITH(gnu-ld,
243 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
244 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
245 AC_REQUIRE([AC_PROG_CC])dnl
246 AC_REQUIRE([AC_CANONICAL_HOST])dnl
247 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
248 ac_prog=ld
249 if test "$ac_cv_prog_gcc" = yes; then
250   # Check if gcc -print-prog-name=ld gives a path.
251   AC_MSG_CHECKING([for ld used by GCC])
252   ac_prog=`($CC -print-prog-name=ld) 2>&5`
253   case "$ac_prog" in
254     # Accept absolute paths.
255 changequote(,)dnl
256     [\\/]* | [A-Za-z]:[\\/]*)
257       re_direlt='/[^/][^/]*/\.\./'
258 changequote([,])dnl
259       # Canonicalize the path of ld
260       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
261       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
262         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
263       done
264       test -z "$LD" && LD="$ac_prog"
265       ;;
266   "")
267     # If it fails, then pretend we aren't using GCC.
268     ac_prog=ld
269     ;;
270   *)
271     # If it is relative, then search for the first ld in PATH.
272     with_gnu_ld=unknown
273     ;;
274   esac
275 elif test "$with_gnu_ld" = yes; then
276   AC_MSG_CHECKING([for GNU ld])
277 else
278   AC_MSG_CHECKING([for non-GNU ld])
279 fi
280 AC_CACHE_VAL(ac_cv_path_LD,
281 [if test -z "$LD"; then
282   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
283   for ac_dir in $PATH; do
284     test -z "$ac_dir" && ac_dir=.
285     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
286       ac_cv_path_LD="$ac_dir/$ac_prog"
287       # Check to see if the program is GNU ld.  I'd rather use --version,
288       # but apparently some GNU ld's only accept -v.
289       # Break only if it was the GNU/non-GNU ld that we prefer.
290       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
291         test "$with_gnu_ld" != no && break
292       else
293         test "$with_gnu_ld" != yes && break
294       fi
295     fi
296   done
297   IFS="$ac_save_ifs"
298 else
299   ac_cv_path_LD="$LD" # Let the user override the test with a path.
300 fi])
301 LD="$ac_cv_path_LD"
302 if test -n "$LD"; then
303   AC_MSG_RESULT($LD)
304 else
305   AC_MSG_RESULT(no)
306 fi
307 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
308 AC_PROG_LD_GNU
309 ])
310
311 AC_DEFUN(AC_PROG_LD_GNU,
312 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
313 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
314 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
315   ac_cv_prog_gnu_ld=yes
316 else
317   ac_cv_prog_gnu_ld=no
318 fi])
319 ])
320
321 # AC_PROG_NM - find the path to a BSD-compatible name lister
322 AC_DEFUN(AC_PROG_NM,
323 [AC_MSG_CHECKING([for BSD-compatible nm])
324 AC_CACHE_VAL(ac_cv_path_NM,
325 [if test -n "$NM"; then
326   # Let the user override the test.
327   ac_cv_path_NM="$NM"
328 else
329   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
330   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
331     test -z "$ac_dir" && ac_dir=.
332     if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
333       # Check to see if the nm accepts a BSD-compat flag.
334       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
335       #   nm: unknown option "B" ignored
336       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
337         ac_cv_path_NM="$ac_dir/nm -B"
338         break
339       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
340         ac_cv_path_NM="$ac_dir/nm -p"
341         break
342       else
343         ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
344         continue # so that we can try to find one that supports BSD flags
345       fi
346     fi
347   done
348   IFS="$ac_save_ifs"
349   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
350 fi])
351 NM="$ac_cv_path_NM"
352 AC_MSG_RESULT([$NM])
353 ])
354
355 # AC_CHECK_LIBM - check for math library
356 AC_DEFUN(AC_CHECK_LIBM,
357 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
358 LIBM=
359 case "$lt_target" in
360 *-*-beos* | *-*-cygwin*)
361   # These system don't have libm
362   ;;
363 *-ncr-sysv4.3*)
364   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
365   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
366   ;;
367 *)
368   AC_CHECK_LIB(m, main, LIBM="-lm")
369   ;;
370 esac
371 ])
372
373 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
374 # the libltdl convenience library, adds --enable-ltdl-convenience to
375 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
376 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
377 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
378 # '${top_builddir}/' (note the single quotes!) if your package is not
379 # flat, and, if you're not using automake, define top_builddir as
380 # appropriate in the Makefiles.
381 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
382   case "$enable_ltdl_convenience" in
383   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
384   "") enable_ltdl_convenience=yes
385       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
386   esac
387   LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
388   INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
389 ])
390
391 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
392 # the libltdl installable library, and adds --enable-ltdl-install to
393 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
394 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
395 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
396 # '${top_builddir}/' (note the single quotes!) if your package is not
397 # flat, and, if you're not using automake, define top_builddir as
398 # appropriate in the Makefiles.
399 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
400 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
401   AC_CHECK_LIB(ltdl, main,
402   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
403   [if test x"$enable_ltdl_install" = xno; then
404      AC_MSG_WARN([libltdl not installed, but installation disabled])
405    else
406      enable_ltdl_install=yes
407    fi
408   ])
409   if test x"$enable_ltdl_install" = x"yes"; then
410     ac_configure_args="$ac_configure_args --enable-ltdl-install"
411     LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
412     INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
413   else
414     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
415     LIBLTDL="-lltdl"
416     INCLTDL=
417   fi
418 ])
419
420 dnl old names
421 AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
422 AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
423 AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
424 AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
425 AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
426 AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
427 AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
428
429 dnl This is just to silence aclocal about the macro not being used
430 ifelse([AC_DISABLE_FAST_INSTALL])dnl
431
432 dnl See whether we need a declaration for a function.
433 dnl RADIUSD_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
434 AC_DEFUN(RADIUSD_NEED_DECLARATION,
435 [AC_MSG_CHECKING([whether $1 must be declared])
436 AC_CACHE_VAL(radius_cv_decl_needed_$1,
437 [AC_TRY_COMPILE([
438 #include <stdio.h>
439 #include <string.h>
440 #ifdef HAVE_UNISTD_H
441 #include <unistd.h>
442 #endif
443 #ifdef HAVE_CRYPT_H
444 #include <crypt.h>
445 #endif
446 #ifdef HAVE_ERRNO_H
447 #include <errno.h>
448 #endif
449 #ifdef HAVE_RESOURCE_H
450 #include <resource.h>
451 #endif
452 #ifdef HAVE_GETOPT_H
453 #include <getopt.h>
454 #endif
455 #ifdef HAVE_MALLOC_H
456 #include <malloc.h>
457 #endif
458 #ifdef HAVE_UTMP_H
459 #include <utmp.h>
460 #endif
461 #ifdef HAVE_UTMPX_H
462 #include <utmpx.h>
463 #endif
464 #ifdef HAVE_SYS_SELECT_H
465 #include <sys/select.h>
466 #endif
467 #ifdef HAVE_DLFCN_H
468 #include <dlfcn.h>
469 #endif
470 #ifdef HAVE_REGEX_H
471 #include <regex.h>
472 #endif
473 #ifdef HAVE_SYSLOG_H
474 #include <syslog.h>
475 #endif
476 #ifdef HAVE_INTTYPES_H
477 #include <inttypes.h>
478 #endif
479 #ifdef HAVE_STDINT_H
480 #include <stdint.h>
481 #endif
482 #ifdef HAVE_ARPA_INET_H
483 #include <arpa/inet.h>
484 #endif
485 $2],
486 [char *(*pfn) = (char *(*)) $1],
487 eval "radius_cv_decl_needed_$1=no", eval "radius_cv_decl_needed_$1=yes")])
488 if eval "test \"`echo '$radius_cv_decl_needed_'$1`\" = yes"; then
489   AC_MSG_RESULT(yes)
490   radius_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
491   AC_DEFINE_UNQUOTED($radius_tr_decl)
492 else
493   AC_MSG_RESULT(no)
494 fi
495 ])dnl
496
497 dnl Check multiple functions to see whether each needs a declaration.
498 dnl RADIUSD_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
499 AC_DEFUN(RADIUSD_NEED_DECLARATIONS,
500 [for ac_func in $1
501 do
502 RADIUSD_NEED_DECLARATION($ac_func, $2)
503 done
504 ])
505
506 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
507 dnl The program must properly implement --version.
508 AC_DEFUN(AM_MISSING_PROG,
509 [AC_MSG_CHECKING(for working $2)
510 # Run test in a subshell; some versions of sh will print an error if
511 # an executable is not found, even if stderr is redirected.
512 # Redirect stdin to placate older versions of autoconf.  Sigh.
513 if ($2 --version) < /dev/null > /dev/null 2>&1; then
514    $1=$2
515    AC_MSG_RESULT(found)
516 else
517    $1="$3/missing $2"
518    AC_MSG_RESULT(missing)
519 fi
520 AC_SUBST($1)])
521
522
523 dnl Checks to see if this is SUNPro we're building with
524 dnl Usage:
525 dnl AC_PROG_CC_SUNPRO
526 AC_DEFUN(AC_PROG_CC_SUNPRO,
527 [AC_CACHE_CHECK(whether we are using SUNPro C, ac_cv_prog_suncc,
528 [dnl The semicolon is to pacify NeXT's syntax-checking cpp.
529 cat > conftest.c <<EOF
530 #ifdef __SUNPRO_C
531   yes;
532 #endif
533 EOF
534 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
535   ac_cv_prog_suncc=yes
536 else
537   ac_cv_prog_suncc=no
538 fi])])
539
540 dnl #
541 dnl # AC_CHECK_TYPE_INCLUDE([#includes ...], type, default-C-types)
542 dnl #
543 dnl # This function is like AC_CHECK_TYPE, but you can give this one
544 dnl # a list of include files to check.
545 dnl #
546 AC_DEFUN(AC_CHECK_TYPE_INCLUDE,
547 [
548   AC_CACHE_CHECK(for $2, ac_cv_type_$2,
549     [ ac_cv_type_$2=no
550       AC_TRY_COMPILE($1,
551         [$2 foo],
552         ac_cv_type_$2=yes,
553       )
554     ]
555   )
556
557   if test "$ac_cv_type_$2" != "yes"; then
558          AC_DEFINE($2, $3)
559   fi
560 ])
561
562 dnl Check the PostgreSQL installation
563
564 AC_DEFUN(POSTGRESQL_CHECKS, [
565         AC_SUBST(PGROOT)
566         AC_SUBST(PQ_LIBS)
567         AC_SUBST(PG_INCLUDE_DIR)
568
569 AC_CHECKING(for PostgreSQL includes)
570
571 dnl First Check for a local install
572 if test $PGROOT ; then
573         IS_LOCAL=1
574 else
575         dnl Check common local install paths
576         if test -d /usr/local/pgsql ; then 
577                 PGROOT="/usr/local/pgsql"
578                 ISLOCAL=1
579         elif test -d /usr/local/postgresql ; then
580                 PGROOT="/usr/local/postgresql"
581                 ISLOCAL=1
582         elif test -d /opt/pgsql ; then
583                 PGROOT="/opt/pgsql"
584                 ISLOCAL=1
585         elif test -d /opt/postgresql ; then
586                 PGROOT="/opt/postgresql"
587                 ISLOCAL=1
588         fi
589 fi
590 dnl If we have a local install path, check for some files
591 if test $PGROOT && test IS_LOCAL ; then
592         if test -e $PGROOT/lib/libpq.so ; then
593                 if test -e $PGROOT/lib/libpq.a ; then
594                         PQ_LIBS="-L$PGROOT/lib -lpq"
595                 fi
596         fi
597         AC_CHECK_HEADERS($PGROOT/include/libpq-fe.h $PGROOT/include/postgres.h,
598                 FOUND_PG_HEADERS=1)
599         if test $FOUND_PG_HEADERS ; then
600                 PG_INCLUDE_DIR="$PGROOT/include"
601         fi
602 fi
603
604 dnl Now check for the two common distribution installation locations
605 if test "x$PGROOT" = "x" ; then
606         AC_CHECK_LIB(pq,PQconnectdb,FOUND_PQLIB=1)
607         if test $FOUND_PQLIB ; then
608                 PQ_LIBS="-lpq"
609         fi
610         if test -d /usr/include/pgsql ; then
611                 PG_INCLUDE_DIR="/usr/include/pgsql"
612                 PG_INCLUDED_DIR="$PG_INCLUDE_DIR/"
613         elif test -d /usr/include/postgresql ; then
614                 PG_INCLUDE_DIR="/usr/include/postgresql"
615                 PG_INCLUDED_DIR="$PG_INCLUDE_DIR/"
616         fi
617         AC_CHECK_HEADER("${PG_INCLUDED_DIR}libpq-fe.h",AC_DEFINE(HAVE_LIBPQ_FE_H))
618         AC_CHECK_HEADER("${PG_INCLUDED_DIR}postgres.h",AC_DEFINE(HAVE_POSTGRES_H))
619         if test $HAVE_HEADER-LIBPQ-FE.H ; then
620                 PG_INCLUDE_DIR="$PG_INCLUDE_DIR"
621         fi
622         if test -d /usr/lib/pgsql ; then
623                 PGROOT="/usr/lib/pgsql"
624         elif test -d /usr/lib/postgresql ; then
625                 PGROOT="/usr/lib/postgresql"
626         fi
627 fi
628
629 if test "$PGROOT" && test "$PQ_LIBS" && test "$PG_INCLUDE_DIR" ; then
630         echo Postgresql found in $PGROOT.
631 fi
632
633 ])
634
635 dnl #######################################################################
636 dnl #
637 dnl #  Look for Oracle in a variety of places.
638 dnl #
639 AC_DEFUN(ORACLE_CHECKS, [
640         AC_SUBST(ORACLE_LIBS)
641         AC_SUBST(ORACLE_INCLUDE)
642
643 AC_MSG_CHECKING([for oci.h])
644
645 dnl #
646 dnl #  First, see if we can build it WITHOUT using any special includes
647 dnl #
648 AC_TRY_COMPILE([#include <oci.h>],
649                [ int a = 1;],
650                ORACLE_INCLUDE=" ",
651                ORACLE_INCLUDE=)
652
653 dnl #
654 dnl #  If not, look for it in a number of directories.
655 dnl #
656 if test "x$ORACLE_INCLUDE" = "x"; then
657   old_CFLAGS="$CFLAGS"
658
659   AC_LOCATE_DIR(oracle_include_dir,oci.h)
660
661   for try in /usr/local/include/oracle /usr/local/oracle/include $oracle_include_dir; do
662     CFLAGS="$old_CFLAGS -I$try"
663     AC_TRY_COMPILE([#include <oci.h>],
664                    [ int a = 1;],
665                    ORACLE_INCLUDE="-I$try",
666                    ORACLE_INCLUDE=)
667     if test "x$ORACLE_INCLUDE" != "x"; then
668       break;
669     fi
670   done
671   CFLAGS="$old_CFLAGS"
672 fi
673
674 if test "x$ORACLE_INCLUDE" = "x"; then
675   AC_MSG_RESULT(no)
676 else
677   AC_MSG_RESULT(yes)
678   
679 dnl #
680 dnl #  Now do the same thing, looking for the Oracle library directory
681 dnl #
682   AC_MSG_CHECKING([for oracle_init in -loracleclient])
683
684 dnl #
685 dnl #  Look for it in a number of directories.
686 dnl #
687   old_LIBS="$LIBS"
688
689   AC_LOCATE_DIR(oracle_lib_dir,[liboracleclient.so])
690   AC_LOCATE_DIR(oracle_lib_dir,[liboracleclient.a])
691
692   for try in /usr/lib/oracle /usr/local/lib/oracle /usr/local/oracle/lib $oracle_lib_dir; do
693     LIBS="$old_LIBS -L$try -loracleclient"
694     AC_TRY_LINK([extern char oracle_init();],
695                 [ oracle_init()],
696                 ORACLE_LIBS="-L$try -loracleclient",
697                 ORACLE_LIBS=)
698     if test "x$ORACLE_LIBS" != "x"; then
699       break;
700     fi
701   done
702   LIBS="$old_LIBS"
703
704   dnl #
705   dnl #  If one or the other isn't found, disable them both..
706   dnl #  If both are found, enable them both.
707   dnl #
708   if test "x$ORACLE_LIBS" = "x"; then
709     AC_MSG_RESULT(no)
710     ORACLE_INCLUDE=
711   else
712     AC_MSG_RESULT(yes)
713     AC_DEFINE(HAVE_OCI_H)
714   fi
715 fi
716 ])
717
718 dnl #######################################################################
719 dnl #
720 dnl #  Look for ODBC in a variety of places.
721 dnl #
722 AC_DEFUN(ODBC_CHECKS, [
723         AC_SUBST(ODBC_LIBS)
724         AC_SUBST(ODBC_INCLUDE)
725
726 AC_MSG_CHECKING([for isql.h])
727
728 dnl #
729 dnl #  First, see if we can build it WITHOUT using any special includes
730 dnl #
731 AC_TRY_COMPILE([#include <isql.h>],
732                [ int a = 1;],
733                ODBC_INCLUDE=" ",
734                ODBC_INCLUDE=)
735
736 dnl #
737 dnl #  If not, look for it in a number of directories.
738 dnl #
739 if test "x$ODBC_INCLUDE" = "x"; then
740   old_CFLAGS="$CFLAGS"
741
742   AC_LOCATE_DIR(odbc_include_dir, isql.h)
743
744   for try in /usr/include /usr/local/include/odbc /usr/local/odbc/include $odbc_include_dir; do
745     CFLAGS="$old_CFLAGS -I$try"
746     AC_TRY_COMPILE([#include <isql.h>],
747                    [ int a = 1;],
748                    ODBC_INCLUDE="-I$try",
749                    ODBC_INCLUDE=)
750     if test "x$ODBC_INCLUDE" != "x"; then
751       break;
752     fi
753   done
754   CFLAGS="$old_CFLAGS"
755 fi
756
757 if test "x$ODBC_INCLUDE" = "x"; then
758   AC_MSG_RESULT(no)
759 else
760   AC_MSG_RESULT(yes)
761   
762 dnl #
763 dnl #  Now do the same thing, looking for the ODBC library directory
764 dnl #
765   AC_MSG_CHECKING([for odbc_init in -lodbcclient])
766
767 dnl #
768 dnl #  Look for it in a number of directories.
769 dnl #
770   old_LIBS="$LIBS"
771
772   AC_LOCATE_DIR(odbc_lib_dir, [libodbcclient.so])
773   AC_LOCATE_DIR(odbc_lib_dir, [libodbcclient.a])
774
775   for try in /usr/lib /usr/lib/odbc /usr/local/lib/odbc /usr/local/odbc/lib $odbc_lib_dir; do
776     LIBS="$old_LIBS -L$try -lodbcclient"
777     AC_TRY_LINK([extern char odbc_init();],
778                 [ odbc_init()],
779                 ODBC_LIBS="-L$try -lodbcclient",
780                 ODBC_LIBS=)
781     if test "x$ODBC_LIBS" != "x"; then
782       break;
783     fi
784   done
785   LIBS="$old_LIBS"
786
787   dnl #
788   dnl #  If one or the other isn't found, disable them both..
789   dnl #  If both are found, enable them both.
790   dnl #
791   if test "x$ODBC_LIBS" = "x"; then
792     AC_MSG_RESULT(no)
793     ODBC_INCLUDE=
794   else
795     AC_MSG_RESULT(yes)
796     AC_DEFINE(HAVE_ISQL_H)
797   fi
798 fi
799 ])
800
801 dnl #######################################################################
802 dnl #
803 dnl #  Look for SNMP in a variety of places.
804 dnl #
805 AC_DEFUN(SNMP_CHECKS, [
806         AC_SUBST(SNMP_LIBS)
807         AC_SUBST(SNMP_INCLUDE)
808
809 AC_MSG_CHECKING([for asn1.h])
810
811 dnl #
812 dnl #  First, see if we can build it WITHOUT using any special includes
813 dnl #
814 AC_TRY_COMPILE([
815 #ifdef HAVE_SYS_TYPES_H
816 #include <sys/types.h>
817 #endif
818 #ifdef HAVE_STDINT_H
819 #include <stdint.h>
820 #endif
821 #ifdef HAVE_STDIO_H
822 #include <stdio.h>
823 #endif
824 #ifdef HAVE_NETDB_H
825 #include <netdb.h>
826 #endif
827 #ifdef HAVE_UNISTD_H
828 #include <unistd.h>
829 #endif
830 #include <asn1.h>],
831                [ int a = 1;],
832                SNMP_INCLUDE=" ",
833                SNMP_INCLUDE=)
834
835 dnl #
836 dnl #  If not, look for it in a number of directories.
837 dnl #
838 if test "x$SNMP_INCLUDE" = "x"; then
839   old_CFLAGS="$CFLAGS"
840   for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
841     CFLAGS="$old_CFLAGS -I$try"
842     AC_TRY_COMPILE([
843 #ifdef HAVE_SYS_TYPES_H
844 #include <sys/types.h>
845 #endif
846 #ifdef HAVE_STDINT_H
847 #include <stdint.h>
848 #endif
849 #ifdef HAVE_STDIO_H
850 #include <stdio.h>
851 #endif
852 #ifdef HAVE_NETDB_H
853 #include <netdb.h>
854 #endif
855 #ifdef HAVE_UNISTD_H
856 #include <unistd.h>
857 #endif
858 #include <asn1.h>],
859                    [ int a = 1;],
860                    SNMP_INCLUDE="-I$try",
861                    SNMP_INCLUDE=)
862     if test "x$SNMP_INCLUDE" != "x"; then
863       break;
864     fi
865   done
866   CFLAGS="$old_CFLAGS"
867 fi
868
869 if test "x$SNMP_INCLUDE" = "x"; then
870   AC_MSG_RESULT(no)
871 else
872   AC_MSG_RESULT(yes)
873   AC_DEFINE(HAVE_ASN1_H)
874   
875 dnl #
876 dnl #  Check for the rest of the SNMP headers.
877 dnl #
878   old_CFLAGS="$CFLAGS"
879   CFLAGS="$CFLAGS $SNMP_INCLUDE"
880
881   AC_MSG_CHECKING(for snmp.h)
882     AC_TRY_COMPILE([
883 #ifdef HAVE_SYS_TYPES_H
884 #include <sys/types.h>
885 #endif
886 #ifdef HAVE_STDINT_H
887 #include <stdint.h>
888 #endif
889 #ifdef HAVE_STDIO_H
890 #include <stdio.h>
891 #endif
892 #ifdef HAVE_NETDB_H
893 #include <netdb.h>
894 #endif
895 #ifdef HAVE_UNISTD_H
896 #include <unistd.h>
897 #endif
898 #ifdef HAVE_ASN1_H
899 #include <asn1.h>
900 #endif
901 #include <snmp.h>],
902                    [ int a = 1;],
903                    [AC_DEFINE(HAVE_SNMP_H) ac_cv_header_snmp_h=yes])
904     if test "x$ac_cv_header_snmp_h" = "xyes"; then
905       AC_MSG_RESULT(yes)
906     else
907       AC_MSG_RESULT(no)
908     fi
909
910     AC_MSG_CHECKING(for snmp_impl.h)
911     AC_TRY_COMPILE([
912 #ifdef HAVE_SYS_TYPES_H
913 #include <sys/types.h>
914 #endif
915 #ifdef HAVE_STDINT_H
916 #include <stdint.h>
917 #endif
918 #ifdef HAVE_STDIO_H
919 #include <stdio.h>
920 #endif
921 #ifdef HAVE_NETDB_H
922 #include <netdb.h>
923 #endif
924 #ifdef HAVE_UNISTD_H
925 #include <unistd.h>
926 #endif
927 #ifdef HAVE_ASN1_H
928 #include <asn1.h>
929 #endif
930 #ifdef HAVE_SNMP_H
931 #include <snmp.h>
932 #endif
933 #include <snmp_impl.h>],
934                    [ int a = 1;],
935                    [AC_DEFINE(HAVE_SNMP_IMPL_H) ac_cv_header_snmp_impl_h=yes])
936     if test "x$ac_cv_header_snmp_h" = "xyes"; then
937       AC_MSG_RESULT(yes)
938     else
939       AC_MSG_RESULT(no)
940     fi
941
942 dnl #
943 dnl #  Now do the same thing, looking for the SNMP library directory
944 dnl #
945   AC_MSG_CHECKING([for snmp_build_var_op in -lsnmp])
946
947 dnl #
948 dnl #  First, see if we can build it WITHOUT using any special includes
949 dnl #
950   old_LIBS="$LIBS"
951   LIBS="$old_LIBS -lsnmp"
952   AC_TRY_LINK([extern char snmp_build_var_op();],
953               [ snmp_build_var_op()],
954               SNMP_LIBS="-lsnmp",
955               SNMP_LIBS=)
956
957
958   for try in /usr/lib /usr/local/lib /usr/local/snmp/lib $snmp_lib_dir; do
959     LIBS="$old_LIBS -L$try -lsnmp"
960     AC_TRY_LINK([extern char snmp_build_var_op();],
961                 [ snmp_build_var_op()],
962                 SNMP_LIBS="-L$try -lsnmp",
963                 SNMP_LIBS=)
964     if test "x$SNMP_LIBS" != "x"; then
965       break;
966     fi
967
968 dnl #
969 dnl #  That didn't work.  Try adding the '-lcrypto' line.
970 dnl #  Some SNMP libraries are linked against SSL...
971 dnl #
972     LIBS="$old_LIBS -L$try -lsnmp -lcrypto"
973     AC_TRY_LINK([extern char snmp_build_var_op();],
974                 [ snmp_build_var_op()],
975                 SNMP_LIBS="-L$try -lsnmp -lcrypto",
976                 SNMP_LIBS=)
977     if test "x$SNMP_LIBS" != "x"; then
978       break;
979     fi
980   done
981   LIBS="$old_LIBS"
982
983   dnl #
984   dnl #  If one or the other isn't found, disable them both..
985   dnl #  If both are found, enable them both.
986   dnl #
987   CFLAGS="$old_CFLAGS"
988   if test "x$SNMP_LIBS" = "x"; then
989     AC_MSG_RESULT(no)
990     SNMP_INCLUDE=
991   else
992     AC_MSG_RESULT(yes)
993     AC_DEFINE(WITH_SNMP)
994     AC_DEFINE(HAVE_LIBSNMP)
995   fi
996 fi
997 ])
998
999
1000 dnl #
1001 dnl #  Locate the directory in which a particular file is found.
1002 dnl #
1003 dnl #  Usage: AC_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a)
1004 dnl #
1005 dnl #    Defines the variable MYSQLLIB_DIR to be the directory(s) in
1006 dnl #    which the file libmysqlclient.a is to be found.
1007 dnl #
1008 dnl #
1009 AC_DEFUN(AC_LOCATE_DIR,
1010 [
1011 dnl # If we have the program 'locate', then the problem of finding a
1012 dnl # particular file becomes MUCH easier.
1013 dnl #
1014
1015 dnl #
1016 dnl #  No 'locate' defined, do NOT do anything.
1017 dnl #
1018 if test "x$LOCATE" != "x"; then
1019   dnl #
1020   dnl #  Root through a series of directories, looking for the given file.
1021   dnl #
1022   DIRS=
1023   file=$2
1024
1025   for x in `${LOCATE} $file 2>/dev/null`; do
1026     dnl #
1027     dnl #  When asked for 'foo', locate will also find 'foo_bar', which we
1028     dnl #  don't want.  We want that EXACT filename.
1029     dnl #
1030     dnl #  We ALSO want to be able to look for files like 'mysql/mysql.h',
1031     dnl #  and properly match them, too.  So we try to strip off the last
1032     dnl #  part of the filename, using the name of the file we're looking
1033     dnl #  for.  If we CANNOT strip it off, then the name will be unchanged.
1034     dnl #
1035     base=`echo $x | sed "s%/${file}%%"`
1036     if test "x$x" = "x$base"; then
1037       continue;
1038     fi
1039
1040     dir=`${DIRNAME} $x 2>/dev/null`
1041     dnl #
1042     dnl #  Exclude a number of directories.
1043     dnl #
1044     exclude=`echo ${dir} | ${GREP} /home`
1045     if test "x$exclude" != "x"; then
1046       continue
1047     fi
1048
1049     dnl #
1050     dnl #  OK, we have an exact match.  Let's be sure that we only find ONE
1051     dnl #  matching directory.
1052     dnl #
1053     already=`echo \$$1 ${DIRS} | ${GREP} ${dir}`
1054     if test "x$already" = "x"; then
1055       DIRS="$DIRS $dir"
1056     fi
1057   done
1058 fi
1059
1060 dnl #
1061 dnl #  And remember the directory in which we found the file.
1062 dnl #
1063 eval "$1=\"\$$1 $DIRS\""
1064 ])
1065
1066
1067 dnl #######################################################################
1068 dnl #
1069 dnl #  Look for a library in a number of places.
1070 dnl #
1071 AC_DEFUN(AC_SMART_CHECK_LIB, [
1072
1073 AC_MSG_CHECKING([for $2 in -l$1])
1074
1075 smart_lib=
1076 smart_lib_dir=
1077
1078 dnl #
1079 dnl #  Try to link it first, using the default libs && library paths
1080 dnl #
1081   old_LIBS="$LIBS"
1082   LIBS="$LIBS -l$1"
1083   AC_TRY_LINK([extern char $2();],
1084               [ $2()],
1085               smart_lib="-l$1")
1086
1087   if test "x$smart_lib" = "x"; then
1088     AC_LOCATE_DIR(smart_lib_dir,[lib$1.so])
1089     AC_LOCATE_DIR(smart_lib_dir,[lib$1.a])
1090
1091     for try in $smart_lib_dir /usr/local/lib/ /opt/lib; do
1092       LIBS="$old_LIBS -L$try -l$1"
1093
1094       AC_TRY_LINK([extern char $2();],
1095                   [ $2()],
1096                   smart_lib="-L$try -l$1")
1097       if test "x$smart_lib" != "x"; then
1098         break;
1099       fi
1100     done
1101     LIBS="$old_LIBS"
1102   fi
1103
1104   dnl #
1105   dnl #  Found it, set the appropriate variable.
1106   dnl #
1107   if test "x$smart_lib" != "x"; then
1108     AC_MSG_RESULT(yes)
1109     eval "ac_cv_lib_$1_$2=yes"
1110     LIBS="$old_LIBS $smart_lib"
1111     SMART_LIBS="$SMART_LIBS $smart_lib"
1112   else
1113     AC_MSG_RESULT(no) 
1114 fi
1115 ])
1116
1117 dnl #######################################################################
1118 dnl #
1119 dnl #  Look for a header file in a number of places.
1120 dnl #
1121 AC_DEFUN(AC_SMART_CHECK_INCLUDE, [
1122
1123 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
1124 AC_MSG_CHECKING([for $1])
1125
1126 smart_include=
1127 smart_include_dir=
1128
1129 dnl #
1130 dnl #  Try to link it first, using the default includes
1131 dnl #
1132   old_CFLAGS="$CFLAGS"
1133   AC_TRY_COMPILE([#include <$1>],
1134                  [ int a = 1;],
1135                  smart_include=" ",
1136                  smart_include=)
1137
1138   if test "x$smart_include" = "x"; then
1139     AC_LOCATE_DIR(smart_include_dir,$1)
1140
1141     for try in $smart_include_dir /usr/local/include/ /opt/include; do
1142       CFLAGS="$old_CFLAGS -I$try"
1143
1144       AC_TRY_COMPILE([#include <$1>],
1145                      [ int a = 1;],
1146                      smart_include="-I$try",
1147                      smart_include=)
1148
1149       if test "x$smart_include" != "x"; then
1150         break;
1151       fi
1152     done
1153     CFLAGS="$old_CFLAGS"
1154   fi
1155
1156   dnl #
1157   dnl #  Found it, set the appropriate variable.
1158   dnl #
1159   if test "x$smart_include" != "x"; then
1160     AC_MSG_RESULT(yes)
1161     eval "ac_cv_header_$ac_safe=yes"
1162     CFLAGS="$old_CFLAGS $smart_include"
1163     SMART_CFLAGS="$SMART_CFLAGS $smart_include"
1164   else
1165     AC_MSG_RESULT(no) 
1166 fi
1167 ])
1168
1169 dnl #######################################################################
1170 dnl #
1171 dnl #  Look for a header file in a number of places.
1172 dnl #
1173 dnl #  Usage:  AC_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member)
1174 dnl #  If the member is defined, then the variable
1175 dnl #     ac_cv_type_struct_foo_member is set to 'yes'
1176 dnl #
1177 AC_DEFUN(AC_CHECK_STRUCT_HAS_MEMBER, [
1178   AC_MSG_CHECKING([for $3 in $2])
1179
1180 dnl BASED on 'offsetof':
1181 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1182 dnl
1183
1184   AC_TRY_COMPILE([
1185 $1
1186 #ifndef offsetof
1187 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
1188 #endif
1189 ],
1190                  [ int foo = offsetof($2, $3) ],
1191                  has_element=" ",
1192                  has_element=)
1193
1194   ac_safe_type=`echo "$2" | sed 'y% %_%'`
1195   if test "x$has_element" != "x"; then
1196     AC_MSG_RESULT(yes)
1197     eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
1198   else
1199     AC_MSG_RESULT(no) 
1200     eval "ac_cv_type_${ac_safe_type}_has_$3="
1201  fi
1202 ])