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