Removed iodbc configuration checks from the top-level 'configure'
[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 #######################################################################
565 dnl #
566 dnl #  Look for SNMP in a variety of places.
567 dnl #
568 AC_DEFUN(SNMP_CHECKS, [
569         AC_SUBST(SNMP_LIBS)
570         AC_SUBST(SNMP_INCLUDE)
571
572 AC_MSG_CHECKING([for asn1.h])
573
574 dnl #
575 dnl #  First, see if we can build it WITHOUT using any special includes
576 dnl #
577 AC_TRY_COMPILE([
578 #ifdef HAVE_SYS_TYPES_H
579 #include <sys/types.h>
580 #endif
581 #ifdef HAVE_STDINT_H
582 #include <stdint.h>
583 #endif
584 #ifdef HAVE_STDIO_H
585 #include <stdio.h>
586 #endif
587 #ifdef HAVE_NETDB_H
588 #include <netdb.h>
589 #endif
590 #ifdef HAVE_UNISTD_H
591 #include <unistd.h>
592 #endif
593 #include <asn1.h>],
594                [ int a = 1;],
595                SNMP_INCLUDE="",
596                SNMP_INCLUDE=)
597
598 dnl #
599 dnl #  If not, look for it in a number of directories.
600 dnl #
601 if test "x$SNMP_INCLUDE" = "x"; then
602   old_CFLAGS="$CFLAGS"
603   for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
604     CFLAGS="$old_CFLAGS -I$try"
605     AC_TRY_COMPILE([
606 #ifdef HAVE_SYS_TYPES_H
607 #include <sys/types.h>
608 #endif
609 #ifdef HAVE_STDINT_H
610 #include <stdint.h>
611 #endif
612 #ifdef HAVE_STDIO_H
613 #include <stdio.h>
614 #endif
615 #ifdef HAVE_NETDB_H
616 #include <netdb.h>
617 #endif
618 #ifdef HAVE_UNISTD_H
619 #include <unistd.h>
620 #endif
621 #include <asn1.h>],
622                    [ int a = 1;],
623                    SNMP_INCLUDE="-I$try",
624                    SNMP_INCLUDE=)
625     if test "x$SNMP_INCLUDE" != "x"; then
626       break;
627     fi
628   done
629   CFLAGS="$old_CFLAGS"
630 fi
631
632 if test "x$SNMP_INCLUDE" = "x"; then
633   AC_MSG_RESULT(no)
634 else
635   AC_MSG_RESULT(yes)
636   AC_DEFINE(HAVE_ASN1_H)
637   
638 dnl #
639 dnl #  Check for the rest of the SNMP headers.
640 dnl #
641   old_CFLAGS="$CFLAGS"
642   CFLAGS="$CFLAGS $SNMP_INCLUDE"
643
644   AC_MSG_CHECKING(for snmp.h)
645     AC_TRY_COMPILE([
646 #ifdef HAVE_SYS_TYPES_H
647 #include <sys/types.h>
648 #endif
649 #ifdef HAVE_STDINT_H
650 #include <stdint.h>
651 #endif
652 #ifdef HAVE_STDIO_H
653 #include <stdio.h>
654 #endif
655 #ifdef HAVE_NETDB_H
656 #include <netdb.h>
657 #endif
658 #ifdef HAVE_UNISTD_H
659 #include <unistd.h>
660 #endif
661 #ifdef HAVE_ASN1_H
662 #include <asn1.h>
663 #endif
664 #include <snmp.h>],
665                    [ int a = 1;],
666                    [AC_DEFINE(HAVE_SNMP_H) ac_cv_header_snmp_h=yes])
667     if test "x$ac_cv_header_snmp_h" = "xyes"; then
668       AC_MSG_RESULT(yes)
669     else
670       AC_MSG_RESULT(no)
671     fi
672
673     AC_MSG_CHECKING(for snmp_impl.h)
674     AC_TRY_COMPILE([
675 #ifdef HAVE_SYS_TYPES_H
676 #include <sys/types.h>
677 #endif
678 #ifdef HAVE_STDINT_H
679 #include <stdint.h>
680 #endif
681 #ifdef HAVE_STDIO_H
682 #include <stdio.h>
683 #endif
684 #ifdef HAVE_NETDB_H
685 #include <netdb.h>
686 #endif
687 #ifdef HAVE_UNISTD_H
688 #include <unistd.h>
689 #endif
690 #ifdef HAVE_ASN1_H
691 #include <asn1.h>
692 #endif
693 #ifdef HAVE_SNMP_H
694 #include <snmp.h>
695 #endif
696 #include <snmp_impl.h>],
697                    [ int a = 1;],
698                    [AC_DEFINE(HAVE_SNMP_IMPL_H) ac_cv_header_snmp_impl_h=yes])
699     if test "x$ac_cv_header_snmp_h" = "xyes"; then
700       AC_MSG_RESULT(yes)
701     else
702       AC_MSG_RESULT(no)
703     fi
704
705 dnl #
706 dnl #  Now do the same thing, looking for the SNMP library directory
707 dnl #
708   AC_MSG_CHECKING([for snmp_build_var_op in -lsnmp])
709
710 dnl #
711 dnl #  First, see if we can build it WITHOUT using any special includes
712 dnl #
713   old_LIBS="$LIBS"
714   LIBS="$old_LIBS -lsnmp"
715   AC_TRY_LINK([extern char snmp_build_var_op();],
716               [ snmp_build_var_op()],
717               SNMP_LIBS="-lsnmp",
718               SNMP_LIBS=)
719
720   if test "x$SNMP_LIBS" = "x"; then
721     for try in /usr/lib /usr/local/lib /usr/local/snmp/lib $snmp_lib_dir; do
722       LIBS="$old_LIBS -L$try -lsnmp"
723       AC_TRY_LINK([extern char snmp_build_var_op();],
724                   [ snmp_build_var_op()],
725                   SNMP_LIBS="-L$try -lsnmp",
726                   SNMP_LIBS=)
727       if test "x$SNMP_LIBS" != "x"; then
728         break;
729       fi
730 dnl   #
731 dnl   #  That didn't work.  Try adding the '-lcrypto' line.
732 dnl   #  Some SNMP libraries are linked against SSL...
733 dnl   #
734       LIBS="$old_LIBS -L$try -lsnmp -lcrypto"
735       AC_TRY_LINK([extern char snmp_build_var_op();],
736                   [ snmp_build_var_op()],
737                   SNMP_LIBS="-L$try -lsnmp -lcrypto",
738                   SNMP_LIBS=)
739       if test "x$SNMP_LIBS" != "x"; then
740         break;
741       fi
742     done
743   fi
744   LIBS="$old_LIBS"
745
746   dnl #
747   dnl #  If one or the other isn't found, disable them both..
748   dnl #  If both are found, enable them both.
749   dnl #
750   CFLAGS="$old_CFLAGS"
751   if test "x$SNMP_LIBS" = "x"; then
752     AC_MSG_RESULT(no)
753     SNMP_INCLUDE=
754   else
755     AC_MSG_RESULT(yes)
756     AC_DEFINE(WITH_SNMP)
757     AC_DEFINE(HAVE_LIBSNMP)
758   fi
759 fi
760 ])
761
762
763 dnl #
764 dnl #  Locate the directory in which a particular file is found.
765 dnl #
766 dnl #  Usage: AC_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a)
767 dnl #
768 dnl #    Defines the variable MYSQLLIB_DIR to be the directory(s) in
769 dnl #    which the file libmysqlclient.a is to be found.
770 dnl #
771 dnl #
772 AC_DEFUN(AC_LOCATE_DIR,
773 [
774 dnl # If we have the program 'locate', then the problem of finding a
775 dnl # particular file becomes MUCH easier.
776 dnl #
777
778 dnl #
779 dnl #  No 'locate' defined, do NOT do anything.
780 dnl #
781 if test "x$LOCATE" != "x"; then
782   dnl #
783   dnl #  Root through a series of directories, looking for the given file.
784   dnl #
785   DIRS=
786   file=$2
787
788   for x in `${LOCATE} $file 2>/dev/null`; do
789     dnl #
790     dnl #  When asked for 'foo', locate will also find 'foo_bar', which we
791     dnl #  don't want.  We want that EXACT filename.
792     dnl #
793     dnl #  We ALSO want to be able to look for files like 'mysql/mysql.h',
794     dnl #  and properly match them, too.  So we try to strip off the last
795     dnl #  part of the filename, using the name of the file we're looking
796     dnl #  for.  If we CANNOT strip it off, then the name will be unchanged.
797     dnl #
798     base=`echo $x | sed "s%/${file}%%"`
799     if test "x$x" = "x$base"; then
800       continue;
801     fi
802
803     dir=`${DIRNAME} $x 2>/dev/null`
804     dnl #
805     dnl #  Exclude a number of directories.
806     dnl #
807     exclude=`echo ${dir} | ${GREP} /home`
808     if test "x$exclude" != "x"; then
809       continue
810     fi
811
812     dnl #
813     dnl #  OK, we have an exact match.  Let's be sure that we only find ONE
814     dnl #  matching directory.
815     dnl #
816     already=`echo \$$1 ${DIRS} | ${GREP} ${dir}`
817     if test "x$already" = "x"; then
818       DIRS="$DIRS $dir"
819     fi
820   done
821 fi
822
823 dnl #
824 dnl #  And remember the directory in which we found the file.
825 dnl #
826 eval "$1=\"\$$1 $DIRS\""
827 ])
828
829
830 dnl #######################################################################
831 dnl #
832 dnl #  Look for a library in a number of places.
833 dnl #
834 AC_DEFUN(AC_SMART_CHECK_LIB, [
835
836 sm_lib_safe=`echo "$1" | sed 'y%./+-%__p_%'`
837 sm_func_safe=`echo "$2" | sed 'y%./+-%__p_%'`
838 AC_MSG_CHECKING([for $2 in -l$1])
839
840 smart_lib=
841 smart_lib_dir=
842
843 dnl #
844 dnl #  Try to link it first, using the default libs && library paths
845 dnl #
846   old_LIBS="$LIBS"
847   LIBS="$LIBS -l$1"
848   AC_TRY_LINK([extern char $2();],
849               [ $2()],
850               smart_lib="-l$1")
851
852   if test "x$smart_lib" = "x"; then
853     AC_LOCATE_DIR(smart_lib_dir,[lib$1${libltdl_cv_shlibext}])
854     AC_LOCATE_DIR(smart_lib_dir,[lib$1.a])
855
856     for try in $smart_try_dir $smart_lib_dir /usr/local/lib/ /opt/lib; do
857       LIBS="$old_LIBS -L$try -l$1"
858
859       AC_TRY_LINK([extern char $2();],
860                   [ $2()],
861                   smart_lib="-L$try -l$1")
862       if test "x$smart_lib" != "x"; then
863         break;
864       fi
865     done
866     LIBS="$old_LIBS"
867   fi
868
869   dnl #
870   dnl #  Found it, set the appropriate variable.
871   dnl #
872   if test "x$smart_lib" != "x"; then
873     AC_MSG_RESULT(yes)
874     eval "ac_cv_lib_${sm_lib_safe}_${sm_func_safe}=yes"
875     LIBS="$old_LIBS $smart_lib"
876     SMART_LIBS="$SMART_LIBS $smart_lib"
877   else
878     AC_MSG_RESULT(no) 
879 fi
880 ])
881
882 dnl #######################################################################
883 dnl #
884 dnl #  Look for a header file in a number of places.
885 dnl #
886 AC_DEFUN(AC_SMART_CHECK_INCLUDE, [
887
888 ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
889 AC_MSG_CHECKING([for $1])
890
891 smart_include=
892 smart_include_dir=
893
894 dnl #
895 dnl #  Try to link it first, using the default includes
896 dnl #
897   old_CFLAGS="$CFLAGS"
898   AC_TRY_COMPILE([#include <$1>],
899                  [ int a = 1;],
900                  smart_include=" ",
901                  smart_include=)
902
903   if test "x$smart_include" = "x"; then
904     AC_LOCATE_DIR(smart_include_dir,$1)
905
906     for try in $smart_try_dir $smart_include_dir /usr/local/include/ /opt/include; do
907       CFLAGS="$old_CFLAGS -I$try"
908
909       AC_TRY_COMPILE([#include <$1>],
910                      [ int a = 1;],
911                      smart_include="-I$try",
912                      smart_include=)
913
914       if test "x$smart_include" != "x"; then
915         break;
916       fi
917     done
918     CFLAGS="$old_CFLAGS"
919   fi
920
921   dnl #
922   dnl #  Found it, set the appropriate variable.
923   dnl #
924   if test "x$smart_include" != "x"; then
925     AC_MSG_RESULT(yes)
926     eval "ac_cv_header_$ac_safe=yes"
927     CFLAGS="$old_CFLAGS $smart_include"
928     SMART_CFLAGS="$SMART_CFLAGS $smart_include"
929   else
930     AC_MSG_RESULT(no) 
931 fi
932 ])
933
934 dnl #######################################################################
935 dnl #
936 dnl #  Look for a header file in a number of places.
937 dnl #
938 dnl #  Usage:  AC_CHECK_STRUCT_HAS_MEMBER([#include <foo.h>], [struct foo], member)
939 dnl #  If the member is defined, then the variable
940 dnl #     ac_cv_type_struct_foo_member is set to 'yes'
941 dnl #
942 AC_DEFUN(AC_CHECK_STRUCT_HAS_MEMBER, [
943   AC_MSG_CHECKING([for $3 in $2])
944
945 dnl BASED on 'offsetof':
946 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
947 dnl
948
949   AC_TRY_COMPILE([
950 $1
951 #ifndef offsetof
952 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
953 #endif
954 ],
955                  [ int foo = offsetof($2, $3) ],
956                  has_element=" ",
957                  has_element=)
958
959   ac_safe_type=`echo "$2" | sed 'y% %_%'`
960   if test "x$has_element" != "x"; then
961     AC_MSG_RESULT(yes)
962     eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
963   else
964     AC_MSG_RESULT(no) 
965     eval "ac_cv_type_${ac_safe_type}_has_$3="
966  fi
967 ])