summaryrefslogtreecommitdiffstats
path: root/m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4')
-rw-r--r--m4/acinclude.m4170
-rw-r--r--m4/gpgme.m4307
-rw-r--r--m4/libcurl.m4250
-rw-r--r--m4/pkg.m4159
4 files changed, 636 insertions, 250 deletions
diff --git a/m4/acinclude.m4 b/m4/acinclude.m4
new file mode 100644
index 00000000..4455d261
--- /dev/null
+++ b/m4/acinclude.m4
@@ -0,0 +1,170 @@
+dnl acinclude.m4 - configure macros used by pacman and libalpm
+dnl Add some custom macros for pacman and libalpm
+
+dnl GCC_STACK_PROTECT_LIB
+dnl adds -lssp to LIBS if it is available
+dnl ssp is usually provided as part of libc, but was previously a separate lib
+dnl It does not hurt to add -lssp even if libc provides SSP - in that case
+dnl libssp will simply be ignored.
+AC_DEFUN([GCC_STACK_PROTECT_LIB],[
+ AC_CACHE_CHECK([whether libssp exists], ssp_cv_lib,
+ [ssp_old_libs="$LIBS"
+ LIBS="$LIBS -lssp"
+ AC_TRY_LINK(,, ssp_cv_lib=yes, ssp_cv_lib=no)
+ LIBS="$ssp_old_libs"
+ ])
+ if test $ssp_cv_lib = yes; then
+ LIBS="$LIBS -lssp"
+ fi
+])
+
+dnl GCC_STACK_PROTECT_CC
+dnl checks -fstack-protector-all with the C compiler, if it exists then updates
+dnl CFLAGS and defines ENABLE_SSP_CC
+AC_DEFUN([GCC_STACK_PROTECT_CC],[
+ AC_LANG_ASSERT(C)
+ if test "X$CC" != "X"; then
+ AC_CACHE_CHECK([whether ${CC} accepts -fstack-protector-all],
+ ssp_cv_cc,
+ [ssp_old_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -fstack-protector-all"
+ AC_TRY_COMPILE(,, ssp_cv_cc=yes, ssp_cv_cc=no)
+ CFLAGS="$ssp_old_cflags"
+ ])
+ if test $ssp_cv_cc = yes; then
+ CFLAGS="$CFLAGS -fstack-protector-all"
+ AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
+ fi
+ fi
+])
+
+dnl GCC_FORTIFY_SOURCE_CC
+dnl checks -D_FORTIFY_SOURCE with the C compiler, if it exists then updates
+dnl CFLAGS
+AC_DEFUN([GCC_FORTIFY_SOURCE_CC],[
+ AC_LANG_ASSERT(C)
+ if test "X$CC" != "X"; then
+ AC_MSG_CHECKING(for FORTIFY_SOURCE support)
+ AC_TRY_COMPILE([#include <features.h>], [
+ int main() {
+ #if !(__GNUC_PREREQ (4, 1) )
+ #error No FORTIFY_SOURCE support
+ #endif
+ return 0;
+ }
+ ], [
+ AC_MSG_RESULT(yes)
+ CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+ fi
+])
+
+dnl GCC_VISIBILITY_CC
+dnl checks -fvisibility=internal with the C compiler, if it exists then
+dnl defines ENABLE_VISIBILITY_CC in both configure script and Makefiles
+AC_DEFUN([GCC_VISIBILITY_CC],[
+ AC_LANG_ASSERT(C)
+ if test "X$CC" != "X"; then
+ AC_CACHE_CHECK([whether ${CC} accepts -fvisibility=internal],
+ visibility_cv_cc,
+ [visibility_old_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -fvisibility=internal"
+ AC_TRY_COMPILE(,, visibility_cv_cc=yes, visibility_cv_cc=no)
+ CFLAGS="$visibility_old_cflags"
+ ])
+ if test $visibility_cv_cc = yes; then
+ AC_DEFINE([ENABLE_VISIBILITY_CC], 1, [Define if symbol visibility C support is enabled.])
+ fi
+ AM_CONDITIONAL([ENABLE_VISIBILITY_CC], test "x$visibility_cv_cc" = "xyes")
+ fi
+])
+
+dnl GCC_GNU89_INLINE_CC
+dnl checks -fgnu89-inline with the C compiler, if it exists then defines
+dnl ENABLE_GNU89_INLINE_CC in both configure script and Makefiles
+AC_DEFUN([GCC_GNU89_INLINE_CC],[
+ AC_LANG_ASSERT(C)
+ if test "X$CC" != "X"; then
+ AC_CACHE_CHECK([for -fgnu89-inline],
+ gnu89_inline_cv_cc,
+ [ gnu89_inline_old_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -fgnu89-inline"
+ AC_TRY_COMPILE(,, gnu89_inline_cv_cc=yes, gnu89_inline_cv_cc=no)
+ CFLAGS="$gnu89_inline_old_cflags"
+ ])
+ if test $gnu89_inline_cv_cc = yes; then
+ AC_DEFINE([ENABLE_GNU89_INLINE_CC], 1, [Define if gnu89 inlining semantics should be used.])
+ fi
+ AM_CONDITIONAL([ENABLE_GNU89_INLINE_CC], test "x$gnu89_inline_cv_cc" = "xyes")
+ fi
+])
+
+dnl CFLAGS_ADD(PARAMETER, VARIABLE)
+dnl Adds parameter to VARIABLE if the compiler supports it. For example,
+dnl CFLAGS_ADD([-Wall],[WARN_FLAGS]).
+AC_DEFUN([CFLAGS_ADD],
+[AS_VAR_PUSHDEF([my_cflags], [cflags_cv_warn_$1])dnl
+AC_CACHE_CHECK([whether compiler handles $1], [my_cflags], [
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="${CFLAGS} $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
+ [AS_VAR_SET([my_cflags], [yes])],
+ [AS_VAR_SET([my_cflags], [no])])
+ CFLAGS="$save_CFLAGS"
+])
+AS_VAR_PUSHDEF([new_cflags], [[$2]])dnl
+AS_VAR_IF([my_cflags], [yes], [AS_VAR_APPEND([new_cflags], [" $1"])])
+AS_VAR_POPDEF([new_cflags])dnl
+AS_VAR_POPDEF([my_cflags])dnl
+m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
+])
+
+dnl Checks for getmntinfo and determines whether it uses statfs or statvfs
+AC_DEFUN([FS_STATS_TYPE],
+ [AC_CACHE_CHECK([filesystem statistics type], fs_stats_cv_type,
+ [AC_CHECK_FUNC(getmntinfo,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+# include <sys/param.h>
+# include <sys/mount.h>
+#if HAVE_SYS_UCRED_H
+#include <sys/ucred.h>
+#endif
+extern int getmntinfo (struct statfs **, int);
+]],
+ [])],
+ [fs_stats_cv_type="struct statfs"],
+ [fs_stats_cv_type="struct statvfs"])],
+ [AC_CHECK_FUNC(getmntent,
+ [fs_stats_cv_type="struct statvfs"])]
+ )]
+ )
+ AC_DEFINE_UNQUOTED(FSSTATSTYPE, [$fs_stats_cv_type],
+ [Defined as the filesystem stats type ('statvfs' or 'statfs')])
+ if test $ac_cv_func_getmntinfo = yes; then
+ if test "$fs_stats_cv_type" = "struct statvfs"; then
+ AC_DEFINE([HAVE_GETMNTINFO_STATVFS], 1, [Define if getmntinfo() uses statvfs.])
+ else
+ AC_DEFINE([HAVE_GETMNTINFO_STATFS], 1, [Define if getmntinfo() uses statfs.])
+ fi
+ fi
+])
+
+dnl Checks for PATH_MAX and defines it if not present
+AC_DEFUN([PATH_MAX_DEFINED],
+ [AC_CACHE_CHECK([PATH_MAX defined], path_max_cv_defined,
+ [AC_EGREP_CPP(yes, [[
+#include <limits.h>
+#if defined(PATH_MAX)
+yes
+#endif
+]],
+ [path_max_cv_defined=yes],
+ [path_max_cv_defined=no])]
+ )
+ if test $path_max_cv_defined = no; then
+ AC_DEFINE([PATH_MAX], 4096, [Define if PATH_MAX is undefined by limits.h.])
+ fi
+])
diff --git a/m4/gpgme.m4 b/m4/gpgme.m4
new file mode 100644
index 00000000..44bf43cb
--- /dev/null
+++ b/m4/gpgme.m4
@@ -0,0 +1,307 @@
+# gpgme.m4 - autoconf macro to detect GPGME.
+# Copyright (C) 2002, 2003, 2004 g10 Code GmbH
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+
+AC_DEFUN([_AM_PATH_GPGME_CONFIG],
+[ AC_ARG_WITH(gpgme-prefix,
+ AC_HELP_STRING([--with-gpgme-prefix=PFX],
+ [prefix where GPGME is installed (optional)]),
+ gpgme_config_prefix="$withval", gpgme_config_prefix="")
+ if test "x$gpgme_config_prefix" != x ; then
+ GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
+ fi
+ AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
+
+ if test "$GPGME_CONFIG" != "no" ; then
+ gpgme_version=`$GPGME_CONFIG --version`
+ fi
+ gpgme_version_major=`echo $gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
+ gpgme_version_minor=`echo $gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
+ gpgme_version_micro=`echo $gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'`
+])
+
+dnl AM_PATH_GPGME([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgpgme and define GPGME_CFLAGS and GPGME_LIBS.
+dnl
+AC_DEFUN([AM_PATH_GPGME],
+[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
+ tmp=ifelse([$1], ,1:0.4.2,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_gpgme_api=0
+ min_gpgme_version="$tmp"
+ fi
+
+ AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
+ ok=no
+ if test "$GPGME_CONFIG" != "no" ; then
+ req_major=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ if test "$gpgme_version_major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$gpgme_version_major" -eq "$req_major"; then
+ if test "$gpgme_version_minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$gpgme_version_minor" -eq "$req_minor"; then
+ if test "$gpgme_version_micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ # If we have a recent GPGME, we should also check that the
+ # API is compatible.
+ if test "$req_gpgme_api" -gt 0 ; then
+ tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ if test "$req_gpgme_api" -ne "$tmp" ; then
+ ok=no
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ GPGME_CFLAGS=`$GPGME_CONFIG --cflags`
+ GPGME_LIBS=`$GPGME_CONFIG --libs`
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ GPGME_CFLAGS=""
+ GPGME_LIBS=""
+ AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(GPGME_CFLAGS)
+ AC_SUBST(GPGME_LIBS)
+])
+
+dnl AM_PATH_GPGME_PTH([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgpgme and define GPGME_PTH_CFLAGS and GPGME_PTH_LIBS.
+dnl
+AC_DEFUN([AM_PATH_GPGME_PTH],
+[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
+ tmp=ifelse([$1], ,1:0.4.2,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_gpgme_api=0
+ min_gpgme_version="$tmp"
+ fi
+
+ AC_MSG_CHECKING(for GPGME Pth - version >= $min_gpgme_version)
+ ok=no
+ if test "$GPGME_CONFIG" != "no" ; then
+ if `$GPGME_CONFIG --thread=pth 2> /dev/null` ; then
+ req_major=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ if test "$gpgme_version_major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$gpgme_version_major" -eq "$req_major"; then
+ if test "$gpgme_version_minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$gpgme_version_minor" -eq "$req_minor"; then
+ if test "$gpgme_version_micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ # If we have a recent GPGME, we should also check that the
+ # API is compatible.
+ if test "$req_gpgme_api" -gt 0 ; then
+ tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ if test "$req_gpgme_api" -ne "$tmp" ; then
+ ok=no
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ GPGME_PTH_CFLAGS=`$GPGME_CONFIG --thread=pth --cflags`
+ GPGME_PTH_LIBS=`$GPGME_CONFIG --thread=pth --libs`
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ GPGME_PTH_CFLAGS=""
+ GPGME_PTH_LIBS=""
+ AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(GPGME_PTH_CFLAGS)
+ AC_SUBST(GPGME_PTH_LIBS)
+])
+
+dnl AM_PATH_GPGME_PTHREAD([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgpgme and define GPGME_PTHREAD_CFLAGS
+dnl and GPGME_PTHREAD_LIBS.
+dnl
+AC_DEFUN([AM_PATH_GPGME_PTHREAD],
+[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
+ tmp=ifelse([$1], ,1:0.4.2,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_gpgme_api=0
+ min_gpgme_version="$tmp"
+ fi
+
+ AC_MSG_CHECKING(for GPGME pthread - version >= $min_gpgme_version)
+ ok=no
+ if test "$GPGME_CONFIG" != "no" ; then
+ if `$GPGME_CONFIG --thread=pthread 2> /dev/null` ; then
+ req_major=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ if test "$gpgme_version_major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$gpgme_version_major" -eq "$req_major"; then
+ if test "$gpgme_version_minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$gpgme_version_minor" -eq "$req_minor"; then
+ if test "$gpgme_version_micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ # If we have a recent GPGME, we should also check that the
+ # API is compatible.
+ if test "$req_gpgme_api" -gt 0 ; then
+ tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ if test "$req_gpgme_api" -ne "$tmp" ; then
+ ok=no
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ GPGME_PTHREAD_CFLAGS=`$GPGME_CONFIG --thread=pthread --cflags`
+ GPGME_PTHREAD_LIBS=`$GPGME_CONFIG --thread=pthread --libs`
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ GPGME_PTHREAD_CFLAGS=""
+ GPGME_PTHREAD_LIBS=""
+ AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(GPGME_PTHREAD_CFLAGS)
+ AC_SUBST(GPGME_PTHREAD_LIBS)
+])
+
+
+dnl AM_PATH_GPGME_GLIB([MINIMUM-VERSION,
+dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
+dnl Test for libgpgme-glib and define GPGME_GLIB_CFLAGS and GPGME_GLIB_LIBS.
+dnl
+AC_DEFUN([AM_PATH_GPGME_GLIB],
+[ AC_REQUIRE([_AM_PATH_GPGME_CONFIG])dnl
+ tmp=ifelse([$1], ,1:0.4.2,$1)
+ if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
+ req_gpgme_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'`
+ min_gpgme_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'`
+ else
+ req_gpgme_api=0
+ min_gpgme_version="$tmp"
+ fi
+
+ AC_MSG_CHECKING(for GPGME - version >= $min_gpgme_version)
+ ok=no
+ if test "$GPGME_CONFIG" != "no" ; then
+ req_major=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
+ req_minor=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
+ req_micro=`echo $min_gpgme_version | \
+ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'`
+ if test "$gpgme_version_major" -gt "$req_major"; then
+ ok=yes
+ else
+ if test "$gpgme_version_major" -eq "$req_major"; then
+ if test "$gpgme_version_minor" -gt "$req_minor"; then
+ ok=yes
+ else
+ if test "$gpgme_version_minor" -eq "$req_minor"; then
+ if test "$gpgme_version_micro" -ge "$req_micro"; then
+ ok=yes
+ fi
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ # If we have a recent GPGME, we should also check that the
+ # API is compatible.
+ if test "$req_gpgme_api" -gt 0 ; then
+ tmp=`$GPGME_CONFIG --api-version 2>/dev/null || echo 0`
+ if test "$tmp" -gt 0 ; then
+ if test "$req_gpgme_api" -ne "$tmp" ; then
+ ok=no
+ fi
+ fi
+ fi
+ fi
+ if test $ok = yes; then
+ GPGME_GLIB_CFLAGS=`$GPGME_CONFIG --glib --cflags`
+ GPGME_GLIB_LIBS=`$GPGME_CONFIG --glib --libs`
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+ else
+ GPGME_GLIB_CFLAGS=""
+ GPGME_GLIB_LIBS=""
+ AC_MSG_RESULT(no)
+ ifelse([$3], , :, [$3])
+ fi
+ AC_SUBST(GPGME_GLIB_CFLAGS)
+ AC_SUBST(GPGME_GLIB_LIBS)
+])
+
diff --git a/m4/libcurl.m4 b/m4/libcurl.m4
deleted file mode 100644
index 01a0575c..00000000
--- a/m4/libcurl.m4
+++ /dev/null
@@ -1,250 +0,0 @@
-# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
-# [ACTION-IF-YES], [ACTION-IF-NO])
-# ----------------------------------------------------------
-# David Shaw <dshaw@jabberwocky.com> May-09-2006
-#
-# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
-# specify whether to default to --with-libcurl or --without-libcurl.
-# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
-# minimum version of libcurl to accept. Pass the version as a regular
-# version number like 7.10.1. If not supplied, any version is
-# accepted. ACTION-IF-YES is a list of shell commands to run if
-# libcurl was successfully found and passed the various tests.
-# ACTION-IF-NO is a list of shell commands that are run otherwise.
-# Note that using --without-libcurl does run ACTION-IF-NO.
-#
-# This macro #defines HAVE_LIBCURL if a working libcurl setup is
-# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
-# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
-# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
-# where yyy are the various protocols supported by libcurl. Both xxx
-# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
-# the macro for the complete list of possible defines. Shell
-# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
-# defined to 'yes' for those features and protocols that were found.
-# Note that xxx and yyy keep the same capitalization as in the
-# curl-config list (e.g. it's "HTTP" and not "http").
-#
-# Users may override the detected values by doing something like:
-# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
-#
-# For the sake of sanity, this macro assumes that any libcurl that is
-# found is after version 7.7.2, the first version that included the
-# curl-config script. Note that it is very important for people
-# packaging binary versions of libcurl to include this script!
-# Without curl-config, we can only guess what protocols are available,
-# or use curl_version_info to figure it out at runtime.
-
-AC_DEFUN([LIBCURL_CHECK_CONFIG],
-[
- AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
- AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
- AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
- AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
- AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
- AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
- AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
- AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
-
- AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
- AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
- AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
- AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
- AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
- AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
- AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
- AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
- AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
- AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP])
- AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3])
- AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP])
- AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
-
- AC_ARG_WITH(libcurl,
- AC_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
- [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
-
- if test "$_libcurl_with" != "no" ; then
-
- AC_PROG_AWK
-
- _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
-
- _libcurl_try_link=yes
-
- if test -d "$_libcurl_with" ; then
- LIBCURL_CPPFLAGS="-I$withval/include"
- _libcurl_ldflags="-L$withval/lib"
- AC_PATH_PROG([_libcurl_config],[curl-config],[],
- ["$withval/bin"])
- else
- AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH])
- fi
-
- if test x$_libcurl_config != "x" ; then
- AC_CACHE_CHECK([for the version of libcurl],
- [libcurl_cv_lib_curl_version],
- [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
-
- _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
- _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
-
- if test $_libcurl_wanted -gt 0 ; then
- AC_CACHE_CHECK([for libcurl >= version $2],
- [libcurl_cv_lib_version_ok],
- [
- if test $_libcurl_version -ge $_libcurl_wanted ; then
- libcurl_cv_lib_version_ok=yes
- else
- libcurl_cv_lib_version_ok=no
- fi
- ])
- fi
-
- if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
- if test x"$LIBCURL_CPPFLAGS" = "x" ; then
- LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
- fi
- if test x"$LIBCURL" = "x" ; then
- LIBCURL=`$_libcurl_config --libs`
-
- # This is so silly, but Apple actually has a bug in their
- # curl-config script. Fixed in Tiger, but there are still
- # lots of Panther installs around.
- case "${host}" in
- powerpc-apple-darwin7*)
- LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
- ;;
- esac
- fi
-
- # All curl-config scripts support --feature
- _libcurl_features=`$_libcurl_config --feature`
-
- # Is it modern enough to have --protocols? (7.12.4)
- if test $_libcurl_version -ge 461828 ; then
- _libcurl_protocols=`$_libcurl_config --protocols`
- fi
- else
- _libcurl_try_link=no
- fi
-
- unset _libcurl_wanted
- fi
-
- if test $_libcurl_try_link = yes ; then
-
- # we didn't find curl-config, so let's see if the user-supplied
- # link line (or failing that, "-lcurl") is enough.
- LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
-
- AC_CACHE_CHECK([whether libcurl is usable],
- [libcurl_cv_lib_curl_usable],
- [
- _libcurl_save_cppflags=$CPPFLAGS
- CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
- _libcurl_save_libs=$LIBS
- LIBS="$LIBCURL $LIBS"
-
- AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <curl/curl.h>],[
-/* Try and use a few common options to force a failure if we are
- missing symbols or can't link. */
-int x;
-curl_easy_setopt(NULL,CURLOPT_URL,NULL);
-x=CURL_ERROR_SIZE;
-x=CURLOPT_WRITEFUNCTION;
-x=CURLOPT_FILE;
-x=CURLOPT_ERRORBUFFER;
-x=CURLOPT_STDERR;
-x=CURLOPT_VERBOSE;
-])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
-
- CPPFLAGS=$_libcurl_save_cppflags
- LIBS=$_libcurl_save_libs
- unset _libcurl_save_cppflags
- unset _libcurl_save_libs
- ])
-
- if test $libcurl_cv_lib_curl_usable = yes ; then
-
- # Does curl_free() exist in this version of libcurl?
- # If not, fake it with free()
-
- _libcurl_save_cppflags=$CPPFLAGS
- CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
- _libcurl_save_libs=$LIBS
- LIBS="$LIBS $LIBCURL"
-
- AC_CHECK_FUNC(curl_free,,
- AC_DEFINE(curl_free,free,
- [Define curl_free() as free() if our version of curl lacks curl_free.]))
-
- CPPFLAGS=$_libcurl_save_cppflags
- LIBS=$_libcurl_save_libs
- unset _libcurl_save_cppflags
- unset _libcurl_save_libs
-
- AC_DEFINE(HAVE_LIBCURL,1,
- [Define to 1 if you have a functional curl library.])
- AC_SUBST(LIBCURL_CPPFLAGS)
- AC_SUBST(LIBCURL)
-
- for _libcurl_feature in $_libcurl_features ; do
- AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
- eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
- done
-
- if test "x$_libcurl_protocols" = "x" ; then
-
- # We don't have --protocols, so just assume that all
- # protocols are available
- _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
-
- if test x$libcurl_feature_SSL = xyes ; then
- _libcurl_protocols="$_libcurl_protocols HTTPS"
-
- # FTPS wasn't standards-compliant until version
- # 7.11.0 (0x070b00 == 461568)
- if test $_libcurl_version -ge 461568; then
- _libcurl_protocols="$_libcurl_protocols FTPS"
- fi
- fi
-
- # RTSP, IMAP, POP3 and SMTP were added in
- # 7.20.0 (0x071400 == 463872)
- if test $_libcurl_version -ge 463872; then
- _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
- fi
- fi
-
- for _libcurl_protocol in $_libcurl_protocols ; do
- AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
- eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
- done
- else
- unset LIBCURL
- unset LIBCURL_CPPFLAGS
- fi
- fi
-
- unset _libcurl_try_link
- unset _libcurl_version_parse
- unset _libcurl_config
- unset _libcurl_feature
- unset _libcurl_features
- unset _libcurl_protocol
- unset _libcurl_protocols
- unset _libcurl_version
- unset _libcurl_ldflags
- fi
-
- if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
- # This is the IF-NO path
- ifelse([$4],,:,[$4])
- else
- # This is the IF-YES path
- ifelse([$3],,:,[$3])
- fi
-
- unset _libcurl_with
-])dnl
diff --git a/m4/pkg.m4 b/m4/pkg.m4
new file mode 100644
index 00000000..5152a4b1
--- /dev/null
+++ b/m4/pkg.m4
@@ -0,0 +1,159 @@
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+#
+# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_default([$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+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
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+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
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# 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`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+ ])
+elif test $pkg_failed = untried; then
+ AC_MSG_RESULT([no])
+ m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ $3
+fi[]dnl
+])# PKG_CHECK_MODULES