-dnl Check if we can build and use 64-bit libraries
-AC_DEFUN(AC_CHECK_64BIT_LIBS,
-[
- AC_ARG_ENABLE(64bit-libs,
- [ --enable-64bit-libs build 64-bit libraries [default=yes]],
- [ENABLE_64BIT_LIBS=${enableval}],
- [ENABLE_64BIT_LIBS=yes]
- )
- dnl These results can't be cached because is sets compiler flags.
- AC_MSG_CHECKING([for 64-bit executable support])
- if test "$ENABLE_64BIT_LIBS" != no; then
- case "${host}" in
- *-*-solaris*)
- SPARCV9=`isainfo -n 2>&1 | grep sparcv9`
- if test "$GCC" = yes; then
- # We could add a check for -m64 depending on the gcc version.
- ENABLE_64BIT_LIBS=no
- else
- SOL64=`$CXX -xarch=v9 2>&1 && $CC -xarch=v9 2>&1 | grep -v usage:`
- if test -z "$SOL64" && test -n "$SPARCV9"; then
- CFLAGS="${CFLAGS} -xtarget=ultra -xarch=v9"
- CXXFLAGS="${CXXFLAGS} -xtarget=ultra -xarch=v9"
- LDFLAGS="${LDFLAGS} -xtarget=ultra -xarch=v9"
- ENABLE_64BIT_LIBS=yes
- else
- ENABLE_64BIT_LIBS=no
- fi
- fi
- ;;
- ia64-*-linux*)
- if test "$GCC" = yes; then
- # gcc compiler support
- if test -n "`$CXX -dumpspecs 2>&1 && $CC -dumpspecs 2>&1 | grep -v __LP64__`"; then
- ENABLE_64BIT_LIBS=yes
- else
- ENABLE_64BIT_LIBS=no
- fi
- else
- # check for ecc/ecpc compiler support
- if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Intel`"; then
- if test -n "`$CXX --help 2>&1 && $CC --help 2>&1 | grep -v Itanium`"; then
- ENABLE_64BIT_LIBS=yes
- else
- ENABLE_64BIT_LIBS=no
- fi
- else
- # unknown
- ENABLE_64BIT_LIBS=no
- fi
- fi
- ;;
- x86_64-*-linux*)
- if test "$GCC" = yes; then
- if test -n "`$CXX -dumpspecs 2>&1 && $CC -dumpspecs 2>&1 | grep -v __LP64__`"; then
- ENABLE_64BIT_LIBS=yes
- else
- ENABLE_64BIT_LIBS=no
- fi
- else
- # unknown
- ENABLE_64BIT_LIBS=no
- fi
- ;;
- x86_64-*-cygwin)
- if test "$GCC" = yes; then
- if test -n "`$CXX -dumpspecs 2>&1 && $CC -dumpspecs 2>&1 | grep -v __LP64__`"; then
- ENABLE_64BIT_LIBS=yes
- else
- ENABLE_64BIT_LIBS=no
- fi
- else
- ENABLE_64BIT_LIBS=no
- OLD_CPPFLAGS="${CPPFLAGS}"
- OLD_LDFLAGS="${LDFLAGS}"
- CPPFLAGS="${CPPFLAGS} /DWIN64"
- LDFLAGS="${LDFLAGS} /MACHINE:AMD64"
- AC_TRY_RUN(int main(void) {return 0;},
- ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
- if test "$ENABLE_64BIT_LIBS" = no; then
- CPPFLAGS="${OLD_CPPFLAGS}"
- LDFLAGS="${OLD_LDFLAGS}"
- fi
- fi
- ;;
- *-*-aix*|powerpc64-*-linux*)
- if test "$ac_cv_prog_gcc" = no; then
- # Note: Have not tested 64-bitness with gcc.
- # Maybe the flag "-maix64" could be used with gcc?
- OLD_CFLAGS="${CFLAGS}"
- OLD_CXXFLAGS="${CXXFLAGS}"
- OLD_LDFLAGS="${LDFLAGS}"
- CFLAGS="${CFLAGS} -q64"
- CXXFLAGS="${CXXFLAGS} -q64"
- LDFLAGS="${LDFLAGS} -q64"
- AC_TRY_RUN(int main(void) {return 0;},
- ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
- if test "$ENABLE_64BIT_LIBS" = no; then
- CFLAGS="${OLD_CFLAGS}"
- CXXFLAGS="${OLD_CXXFLAGS}"
- LDFLAGS="${OLD_LDFLAGS}"
- else
- case "${host}" in
- *-*-aix*)
- ARFLAGS="${ARFLAGS} -X64"
- esac
- fi
- fi
- ;;
- *-*-hpux*)
- dnl First we try the newer +DD64, if that doesn't work,
- dnl try other options.
-
- OLD_CFLAGS="${CFLAGS}"
- OLD_CXXFLAGS="${CXXFLAGS}"
- CFLAGS="${CFLAGS} +DD64"
- CXXFLAGS="${CXXFLAGS} +DD64"
- AC_TRY_RUN(int main(void) {return 0;},
- ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
- if test "$ENABLE_64BIT_LIBS" = no; then
- CFLAGS="${OLD_CFLAGS}"
- CXXFLAGS="${OLD_CXXFLAGS}"
- CFLAGS="${CFLAGS} +DA2.0W"
- CXXFLAGS="${CXXFLAGS} +DA2.0W"
- AC_TRY_RUN(int main(void) {return 0;},
- ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
- if test "$ENABLE_64BIT_LIBS" = no; then
- CFLAGS="${OLD_CFLAGS}"
- CXXFLAGS="${OLD_CXXFLAGS}"
- fi
- fi
- ;;
- *-*ibm-openedition*|*-*-os390*)
- OLD_CFLAGS="${CFLAGS}"
- OLD_CXXFLAGS="${CXXFLAGS}"
- OLD_LDFLAGS="${LDFLAGS}"
- CFLAGS="${CFLAGS} -Wc,lp64"
- CXXFLAGS="${CXXFLAGS} -Wc,lp64"
- LDFLAGS="${LDFLAGS} -Wl,lp64"
- AC_TRY_RUN(int main(void) {return 0;},
- ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=no)
- if test "$ENABLE_64BIT_LIBS" = no; then
- CFLAGS="${OLD_CFLAGS}"
- CXXFLAGS="${OLD_CXXFLAGS}"
- LDFLAGS="${OLD_LDFLAGS}"
- fi
- ;;
- *)
- ENABLE_64BIT_LIBS=no
- ;;
- esac
- else
- if test "$GCC" = yes; then
- OLD_CFLAGS="${CFLAGS}"
- OLD_CXXFLAGS="${CXXFLAGS}"
- CFLAGS="${CFLAGS} -m32"
- CXXFLAGS="${CXXFLAGS} -m32"
- AC_TRY_RUN(int main(void) {return 0;},
- ENABLE_64BIT_LIBS=no, ENABLE_64BIT_LIBS=yes, ENABLE_64BIT_LIBS=yes)
- if test "$ENABLE_64BIT_LIBS" = yes; then
- CFLAGS="${OLD_CFLAGS}"
- CXXFLAGS="${OLD_CXXFLAGS}"
- fi
- fi
- fi
- dnl Individual tests that fail should reset their own flags.
- AC_MSG_RESULT($ENABLE_64BIT_LIBS)
-])
-
-dnl Strict compilation options.
-AC_DEFUN(AC_CHECK_STRICT_COMPILE,
-[
- AC_MSG_CHECKING([whether strict compiling is on])
- AC_ARG_ENABLE(strict,[ --enable-strict compile with strict compiler options [default=no]], [
- if test "$enableval" = no
- then
- ac_use_strict_options=no
- else
- ac_use_strict_options=yes
- fi
- ], [ac_use_strict_options=no])
- AC_MSG_RESULT($ac_use_strict_options)
-
- if test "$ac_use_strict_options" = yes
- then
- if test "$GCC" = yes
- then
- CFLAGS="$CFLAGS -Wall -ansi -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -Wno-long-long"
- case "${host}" in
- *-*-solaris*)
- CFLAGS="$CFLAGS -D__STDC__=0";;
- esac
- else
- case "${host}" in
- *-*-cygwin)
- if test "`$CC /help 2>&1 | head -c9`" = "Microsoft"
- then
- CFLAGS="$CFLAGS /W4"
- fi
- esac
- fi
- if test "$GXX" = yes
- then
- CXXFLAGS="$CXXFLAGS -W -Wall -ansi -pedantic -Wpointer-arith -Wwrite-strings -Wno-long-long"
- case "${host}" in
- *-*-solaris*)
- CXXFLAGS="$CXXFLAGS -D__STDC__=0";;
- esac
- else
- case "${host}" in
- *-*-cygwin)
- if test "`$CXX /help 2>&1 | head -c9`" = "Microsoft"
- then
- CXXFLAGS="$CXXFLAGS /W4"
- fi
- esac
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes ],
+ [pkg_failed=yes])
+ else
+ pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ AC_MSG_RESULT([no])
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`