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
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.
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.
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.
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.
26 # serial 40 AC_PROG_LIBTOOL
27 AC_DEFUN(AC_PROG_LIBTOOL,
28 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
30 # Save cache, so that ltconfig can load it
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])
42 # Reload cache, that may have been modified by ltconfig
45 # This can be used to rebuild libtool when needed
46 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
48 # Always use our own libtool.
49 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
52 # Redirect the config.log output again, so that the ltconfig log is not
53 # clobbered by the next message.
57 AC_DEFUN(AC_LIBTOOL_SETUP,
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
72 NONE) lt_target="$host" ;;
73 *) lt_target="$target" ;;
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"
92 # Some flags need to be propagated to the compiler or linker for good
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
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"
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)
136 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
137 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
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])])
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
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],
152 [p=${PACKAGE-default}
154 yes) enable_shared=yes ;;
155 no) 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
168 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
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)])
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
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],
185 [p=${PACKAGE-default}
187 yes) enable_static=yes ;;
188 no) 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
201 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
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)])
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
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],
219 [p=${PACKAGE-default}
221 yes) enable_fast_install=yes ;;
222 no) enable_fast_install=no ;;
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
235 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
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)])
242 # AC_PROG_LD - find the path to the GNU or non-GNU linker
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
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`
256 # Accept absolute paths.
258 [\\/]* | [A-Za-z]:[\\/]*)
259 re_direlt='/[^/][^/]*/\.\./'
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%/%"`
266 test -z "$LD" && LD="$ac_prog"
269 # If it fails, then pretend we aren't using GCC.
273 # If it is relative, then search for the first ld in PATH.
277 elif test "$with_gnu_ld" = yes; then
278 AC_MSG_CHECKING([for GNU ld])
280 AC_MSG_CHECKING([for non-GNU ld])
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
295 test "$with_gnu_ld" != yes && break
301 ac_cv_path_LD="$LD" # Let the user override the test with a path.
304 if test -n "$LD"; then
309 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
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
323 # AC_PROG_NM - find the path to a BSD-compatible name lister
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.
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"
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"
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
351 test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
357 # AC_CHECK_LIBM - check for math library
358 AC_DEFUN(AC_CHECK_LIBM,
359 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
362 *-*-beos* | *-*-cygwin*)
363 # These system don't have libm
366 AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
367 AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
370 AC_CHECK_LIB(m, main, LIBM="-lm")
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" ;;
389 LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
390 INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
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])
408 enable_ltdl_install=yes
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'])
416 ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
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
431 dnl This is just to silence aclocal about the macro not being used
432 ifelse([AC_DISABLE_FAST_INSTALL])dnl
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,
451 #ifdef HAVE_RESOURCE_H
452 #include <resource.h>
466 #ifdef HAVE_SYS_SELECT_H
467 #include <sys/select.h>
478 #ifdef HAVE_INTTYPES_H
479 #include <inttypes.h>
484 #ifdef HAVE_ARPA_INET_H
485 #include <arpa/inet.h>
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
492 radius_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
493 AC_DEFINE_UNQUOTED($radius_tr_decl)
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,
504 RADIUSD_NEED_DECLARATION($ac_func, $2)
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
520 AC_MSG_RESULT(missing)
525 dnl Checks to see if this is SUNPro we're building with
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
536 if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
543 dnl # AC_CHECK_TYPE_INCLUDE([#includes ...], type, default-C-types)
545 dnl # This function is like AC_CHECK_TYPE, but you can give this one
546 dnl # a list of include files to check.
548 AC_DEFUN(AC_CHECK_TYPE_INCLUDE,
550 AC_CACHE_CHECK(for $2, ac_cv_type_$2,
559 if test "$ac_cv_type_$2" != "yes"; then
564 dnl Check the PostgreSQL installation
566 AC_DEFUN(POSTGRESQL_CHECKS, [
569 AC_SUBST(PG_INCLUDE_DIR)
571 AC_CHECKING(for PostgreSQL includes)
573 dnl First Check for a local install
574 if test "x$PGROOT" != "x" ; then
577 dnl Check common local install paths
578 if test -d /usr/local/pgsql ; then
579 PGROOT="/usr/local/pgsql"
581 elif test -d /usr/local/postgresql ; then
582 PGROOT="/usr/local/postgresql"
584 elif test -d /opt/pgsql ; then
587 elif test -d /opt/postgresql ; then
588 PGROOT="/opt/postgresql"
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"
599 AC_CHECK_HEADERS($PGROOT/include/libpq-fe.h $PGROOT/include/postgres.h,
601 if test "x$FOUND_PG_HEADERS" != "x" ; then
602 PG_INCLUDE_DIR="$PGROOT/include"
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
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/"
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"
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"
631 if test "x$PGROOT" != "x" && test "x$PQ_LIBS" != "x" && test "x$PG_INCLUDE_DIR" != "x"; then
632 echo Postgresql found in $PGROOT.
637 dnl #######################################################################
639 dnl # Look for ODBC in a variety of places.
641 AC_DEFUN(ODBC_CHECKS, [
643 AC_SUBST(ODBC_INCLUDE)
645 AC_MSG_CHECKING([for isql.h])
648 dnl # First, see if we can build it WITHOUT using any special includes
650 AC_TRY_COMPILE([#include <isql.h>],
656 dnl # If not, look for it in a number of directories.
658 if test "x$ODBC_INCLUDE" = "x"; then
661 AC_LOCATE_DIR(odbc_include_dir, isql.h)
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>],
667 ODBC_INCLUDE="-I$try",
669 if test "x$ODBC_INCLUDE" != "x"; then
676 if test "x$ODBC_INCLUDE" = "x"; then
682 dnl # Now do the same thing, looking for the ODBC library directory
684 AC_MSG_CHECKING([for odbc_init in -lodbcclient])
687 dnl # Look for it in a number of directories.
691 AC_LOCATE_DIR(odbc_lib_dir, [libodbcclient${libltdl_cv_shlibext}])
692 AC_LOCATE_DIR(odbc_lib_dir, [libodbcclient.a])
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();],
698 ODBC_LIBS="-L$try -lodbcclient",
700 if test "x$ODBC_LIBS" != "x"; then
707 dnl # If one or the other isn't found, disable them both..
708 dnl # If both are found, enable them both.
710 if test "x$ODBC_LIBS" = "x"; then
715 AC_DEFINE(HAVE_ISQL_H)
720 dnl #######################################################################
722 dnl # Look for SNMP in a variety of places.
724 AC_DEFUN(SNMP_CHECKS, [
726 AC_SUBST(SNMP_INCLUDE)
728 AC_MSG_CHECKING([for asn1.h])
731 dnl # First, see if we can build it WITHOUT using any special includes
734 #ifdef HAVE_SYS_TYPES_H
735 #include <sys/types.h>
755 dnl # If not, look for it in a number of directories.
757 if test "x$SNMP_INCLUDE" = "x"; then
759 for try in /usr/include/ucd-snmp /usr/local/include/ucd-snmp $snmp_include_dir; do
760 CFLAGS="$old_CFLAGS -I$try"
762 #ifdef HAVE_SYS_TYPES_H
763 #include <sys/types.h>
779 SNMP_INCLUDE="-I$try",
781 if test "x$SNMP_INCLUDE" != "x"; then
788 if test "x$SNMP_INCLUDE" = "x"; then
792 AC_DEFINE(HAVE_ASN1_H)
795 dnl # Check for the rest of the SNMP headers.
798 CFLAGS="$CFLAGS $SNMP_INCLUDE"
800 AC_MSG_CHECKING(for snmp.h)
802 #ifdef HAVE_SYS_TYPES_H
803 #include <sys/types.h>
822 [AC_DEFINE(HAVE_SNMP_H) ac_cv_header_snmp_h=yes])
823 if test "x$ac_cv_header_snmp_h" = "xyes"; then
829 AC_MSG_CHECKING(for snmp_impl.h)
831 #ifdef HAVE_SYS_TYPES_H
832 #include <sys/types.h>
852 #include <snmp_impl.h>],
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
862 dnl # Now do the same thing, looking for the SNMP library directory
864 AC_MSG_CHECKING([for snmp_build_var_op in -lsnmp])
867 dnl # First, see if we can build it WITHOUT using any special includes
870 LIBS="$old_LIBS -lsnmp"
871 AC_TRY_LINK([extern char snmp_build_var_op();],
872 [ snmp_build_var_op()],
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",
883 if test "x$SNMP_LIBS" != "x"; then
888 dnl # That didn't work. Try adding the '-lcrypto' line.
889 dnl # Some SNMP libraries are linked against SSL...
891 LIBS="$old_LIBS -L$try -lsnmp -lcrypto"
892 AC_TRY_LINK([extern char snmp_build_var_op();],
893 [ snmp_build_var_op()],
894 SNMP_LIBS="-L$try -lsnmp -lcrypto",
896 if test "x$SNMP_LIBS" != "x"; then
903 dnl # If one or the other isn't found, disable them both..
904 dnl # If both are found, enable them both.
907 if test "x$SNMP_LIBS" = "x"; then
913 AC_DEFINE(HAVE_LIBSNMP)
920 dnl # Locate the directory in which a particular file is found.
922 dnl # Usage: AC_LOCATE_DIR(MYSQLLIB_DIR, libmysqlclient.a)
924 dnl # Defines the variable MYSQLLIB_DIR to be the directory(s) in
925 dnl # which the file libmysqlclient.a is to be found.
928 AC_DEFUN(AC_LOCATE_DIR,
930 dnl # If we have the program 'locate', then the problem of finding a
931 dnl # particular file becomes MUCH easier.
935 dnl # No 'locate' defined, do NOT do anything.
937 if test "x$LOCATE" != "x"; then
939 dnl # Root through a series of directories, looking for the given file.
944 for x in `${LOCATE} $file 2>/dev/null`; do
946 dnl # When asked for 'foo', locate will also find 'foo_bar', which we
947 dnl # don't want. We want that EXACT filename.
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.
954 base=`echo $x | sed "s%/${file}%%"`
955 if test "x$x" = "x$base"; then
959 dir=`${DIRNAME} $x 2>/dev/null`
961 dnl # Exclude a number of directories.
963 exclude=`echo ${dir} | ${GREP} /home`
964 if test "x$exclude" != "x"; then
969 dnl # OK, we have an exact match. Let's be sure that we only find ONE
970 dnl # matching directory.
972 already=`echo \$$1 ${DIRS} | ${GREP} ${dir}`
973 if test "x$already" = "x"; then
980 dnl # And remember the directory in which we found the file.
982 eval "$1=\"\$$1 $DIRS\""
986 dnl #######################################################################
988 dnl # Look for a library in a number of places.
990 AC_DEFUN(AC_SMART_CHECK_LIB, [
992 AC_MSG_CHECKING([for $2 in -l$1])
998 dnl # Try to link it first, using the default libs && library paths
1002 AC_TRY_LINK([extern char $2();],
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])
1010 for try in $smart_try_dir $smart_lib_dir /usr/local/lib/ /opt/lib; do
1011 LIBS="$old_LIBS -L$try -l$1"
1013 AC_TRY_LINK([extern char $2();],
1015 smart_lib="-L$try -l$1")
1016 if test "x$smart_lib" != "x"; then
1024 dnl # Found it, set the appropriate variable.
1026 if test "x$smart_lib" != "x"; then
1028 eval "ac_cv_lib_$1_$2=yes"
1029 LIBS="$old_LIBS $smart_lib"
1030 SMART_LIBS="$SMART_LIBS $smart_lib"
1036 dnl #######################################################################
1038 dnl # Look for a header file in a number of places.
1040 AC_DEFUN(AC_SMART_CHECK_INCLUDE, [
1042 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
1043 AC_MSG_CHECKING([for $1])
1049 dnl # Try to link it first, using the default includes
1051 old_CFLAGS="$CFLAGS"
1052 AC_TRY_COMPILE([#include <$1>],
1057 if test "x$smart_include" = "x"; then
1058 AC_LOCATE_DIR(smart_include_dir,$1)
1060 for try in $smart_try_dir $smart_include_dir /usr/local/include/ /opt/include; do
1061 CFLAGS="$old_CFLAGS -I$try"
1063 AC_TRY_COMPILE([#include <$1>],
1065 smart_include="-I$try",
1068 if test "x$smart_include" != "x"; then
1072 CFLAGS="$old_CFLAGS"
1076 dnl # Found it, set the appropriate variable.
1078 if test "x$smart_include" != "x"; then
1080 eval "ac_cv_header_$ac_safe=yes"
1081 CFLAGS="$old_CFLAGS $smart_include"
1082 SMART_CFLAGS="$SMART_CFLAGS $smart_include"
1088 dnl #######################################################################
1090 dnl # Look for a header file in a number of places.
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'
1096 AC_DEFUN(AC_CHECK_STRUCT_HAS_MEMBER, [
1097 AC_MSG_CHECKING([for $3 in $2])
1099 dnl BASED on 'offsetof':
1100 dnl #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
1106 #define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER)
1109 [ int foo = offsetof($2, $3) ],
1113 ac_safe_type=`echo "$2" | sed 'y% %_%'`
1114 if test "x$has_element" != "x"; then
1116 eval "ac_cv_type_${ac_safe_type}_has_$3=yes"
1119 eval "ac_cv_type_${ac_safe_type}_has_$3="