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