diff --git a/configure.ac b/configure.ac
index 81b72f0..34ea775 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,698 +1,686 @@
# configure.ac for libgpg-error
# Copyright (C) 2003, 2004, 2006, 2010, 2013-2017 g10 Code GmbH
#
# This file is part of libgpg-error.
#
# libgpg-error is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# libgpg-error 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see .
# SPDX-License-Identifier: LGPL-2.1+
# (Process this file with autoconf to produce a configure script.)
# The following lines are used by ./autogen.sh.
AC_PREREQ(2.59)
min_automake_version="1.14"
# To build a release you need to create a tag with the version number
# (git tag -s libgpg-error-n.m) and run "./autogen.sh --force".
# Please bump the version number immediately after the release, do
# another commit, and a push so that the git magic is able to work.
# See below for the LT versions.
m4_define([mym4_package],[libgpg-error])
m4_define([mym4_major], [1])
m4_define([mym4_minor], [33])
# Below is m4 magic to extract and compute the revision number, the
# decimalized short revision number, a beta version string, and a flag
# indicating a development version (mym4_isgit). Note that the m4
# processing is done by autoconf and not during the configure run.
m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
mym4_package mym4_major mym4_minor),[:]))
m4_define([mym4_isbeta], m4_argn(2, mym4_verslist))
m4_define([mym4_version], m4_argn(4, mym4_verslist))
m4_define([mym4_revision], m4_argn(7, mym4_verslist))
m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
m4_esyscmd([echo ]mym4_version[>VERSION])
AC_INIT([mym4_package],[mym4_version], [https://bugs.gnupg.org])
# LT Version numbers, remember to change them just *before* a release.
# (Code changed: REVISION++)
# (Interfaces added/removed/changed: CURRENT++, REVISION=0)
# (Interfaces added: AGE++)
# (Interfaces removed: AGE=0)
# Note that added error codes don't constitute an interface change.
LIBGPG_ERROR_LT_CURRENT=24
LIBGPG_ERROR_LT_AGE=24
LIBGPG_ERROR_LT_REVISION=3
################################################
AC_SUBST(LIBGPG_ERROR_LT_CURRENT)
AC_SUBST(LIBGPG_ERROR_LT_AGE)
AC_SUBST(LIBGPG_ERROR_LT_REVISION)
VERSION_NUMBER=m4_esyscmd(printf "0x%02x%02x00" mym4_major mym4_minor)
AC_SUBST(VERSION_NUMBER)
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([serial-tests dist-bzip2])
AM_MAINTAINER_MODE
AC_CONFIG_SRCDIR([src/err-sources.h.in])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_SILENT_RULES
# We need to know about the host architecture to avoid spurious
# warnings.
AC_CANONICAL_HOST
AB_INIT
# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_AWK
AC_CHECK_TOOL(AR, ar, :)
AC_GNU_SOURCE
# Set some variables depending on the platform for later use.
have_w32_system=no
have_w64_system=no
have_w32ce_system=no
case "${host}" in
x86_64-*mingw32*)
have_w32_system=yes
have_w64_system=yes
;;
*-mingw32ce*)
have_w32_system=yes
have_w32ce_system=yes
;;
*-mingw32*)
have_w32_system=yes
;;
*-apple-darwin*)
# This is the equivalent of the _GNU_SOURCE feature-test-macro
# on GNU libc systems.
AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
Expose all libc features (__DARWIN_C_FULL).)
;;
*)
;;
esac
if test "$have_w32_system" != yes; then
gl_THREADLIB_EARLY
fi
# We build libgpg-error with large file support so that we have a 64
# bit off_t. Our external interface uses the gpgrt_off_t which is
# anyway specified as 64 bit. Thus the same libgpg-error can be used
# by software which is not build with large file support.
AC_SYS_LARGEFILE
LT_PREREQ([2.2.6])
LT_INIT([win32-dll disable-static])
LT_LANG([Windows Resource])
# We need to compile and run a program on the build machine.
AX_CC_FOR_BUILD
AH_BOTTOM([
/* Force using of NLS for W32 even if no libintl has been found. This is
okay because we have our own gettext implementation for W32. */
#if defined(HAVE_W32_SYSTEM) && !defined(ENABLE_NLS)
#define ENABLE_NLS 1
#endif
/* Connect the generic estream-printf.c to our framework. */
#define _ESTREAM_PRINTF_REALLOC _gpgrt_realloc
#define _ESTREAM_PRINTF_EXTRA_INCLUDE "gpgrt-int.h"
/* For building we need to define these macro. */
#define GPG_ERR_ENABLE_GETTEXT_MACROS 1
#define GPG_ERR_ENABLE_ERRNO_MACROS 1
#define GPGRT_ENABLE_ES_MACROS 1
#define GPGRT_ENABLE_LOG_MACROS 1
#define GPGRT_ENABLE_ARGPARSE_MACROS 1
])
# Note, that autogen.sh greps for the next line.
AM_GNU_GETTEXT_VERSION([0.19.3])
AM_GNU_GETTEXT([external])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h locale.h stdint.h sys/select.h sys/time.h \
signal.h])
AC_FUNC_STRERROR_R
case "${host_os}" in
solaris*)
# All versions of Solaris from 2.4 have a thread-safe strerror().
# Since Solaris 10, in addition strerror_r() exists.
;;
*)
AC_CHECK_FUNC([strerror_r], [],
AC_MSG_WARN([[Without strerror_r, gpg_strerror_r might not be thread-safe]]))
;;
esac
AC_FUNC_FORK
AC_CHECK_FUNCS([flockfile vasprintf mmap rand strlwr stpcpy setenv stat \
getrlimit ])
#
# Checks for typedefs, structures, and compiler characteristics.
#
AC_C_CONST
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_HEADER_TIME
AC_CHECK_SIZEOF(time_t,,[[
#include
#if TIME_WITH_SYS_TIME
# include
# include
#else
# if HAVE_SYS_TIME_H
# include
# else
# include
# endif
#endif
]])
GNUPG_FUNC_MKDIR_TAKES_ONE_ARG
# Find a 64 bit integer type to be used instead of off_t. We prefer
# the standard integer types over int64_t and finally try long long.
if test "$ac_cv_sizeof_int" = "8"; then
replacement_for_off_t="int"
elif test "$ac_cv_sizeof_long" = "8"; then
replacement_for_off_t="long"
elif test "$ac_cv_header_stdint_h" = yes; then
replacement_for_off_t="int64_t"
elif test "$ac_cv_sizeof_long_long" = "8"; then
replacement_for_off_t="long long"
else
AC_MSG_ERROR([[
***
*** No 64 bit signed integer type found. Can't build this library.
***]])
fi
AC_DEFINE_UNQUOTED(REPLACEMENT_FOR_OFF_T, "$replacement_for_off_t",
[Used by mkheader to insert the replacement type.])
#
# Setup gcc specific options
#
AC_MSG_NOTICE([checking for cc features])
if test "$GCC" = yes; then
# Check whether gcc does not emit a diagnostic for unknown -Wno-*
# options. This is the case for gcc >= 4.6
AC_MSG_CHECKING([if gcc ignores unknown -Wno-* options])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6 )
#kickerror
#endif]],[])],[_gcc_silent_wno=yes],[_gcc_silent_wno=no])
AC_MSG_RESULT($_gcc_silent_wno)
# Note that it is okay to use CFLAGS here because these are just
# warning options and the user should have a chance of overriding
# them.
if test "$USE_MAINTAINER_MODE" = "yes"; then
M_CFLAGS="-O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
M_CFLAGS="$M_CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
if test x"$_gcc_silent_wno" = xyes ; then
_gcc_wopt=yes
else
AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
_gcc_cflags_save=$CFLAGS
CFLAGS="-Wno-missing-field-initializers"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
[_gcc_wopt=yes],[_gcc_wopt=no])
AC_MSG_RESULT($_gcc_wopt)
CFLAGS=$_gcc_cflags_save;
fi
if test x"$_gcc_wopt" = xyes ; then
M_CFLAGS="$M_CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers"
fi
AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
_gcc_cflags_save=$CFLAGS
CFLAGS="-Wdeclaration-after-statement"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
AC_MSG_RESULT($_gcc_wopt)
CFLAGS=$_gcc_cflags_save;
if test x"$_gcc_wopt" = xyes ; then
M_CFLAGS="$M_CFLAGS -Wdeclaration-after-statement"
fi
# Prepend the maintainer-cflags so that the user can override
# them, e.g. to override the optimization flags for debugging.
CFLAGS="$M_CFLAGS $CFLAGS"
else
CFLAGS="$CFLAGS -Wall"
fi
AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
_gcc_cflags_save=$CFLAGS
CFLAGS="-Wpointer-arith"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no)
AC_MSG_RESULT($_gcc_psign)
CFLAGS=$_gcc_cflags_save;
if test x"$_gcc_psign" = xyes ; then
CFLAGS="$CFLAGS -Wpointer-arith"
fi
# The undocumented option -Wno-psabi suppresses the annoying
# "the ABI of passing union with long double has changed in GCC 4.4"
# which is emitted in estream-printf.c but entirely irrelvant
# because that union is local to the file.
if test x"$_gcc_silent_wno" = xyes ; then
CFLAGS="$CFLAGS -Wno-psabi"
fi
fi
#
# Check whether the compiler supports the GCC style aligned attribute
#
AC_CACHE_CHECK([whether the GCC style aligned attribute is supported],
[gcry_cv_gcc_attribute_aligned],
[gcry_cv_gcc_attribute_aligned=no
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[struct { int a; } foo __attribute__ ((aligned (16)));]])],
[gcry_cv_gcc_attribute_aligned=yes])])
if test "$gcry_cv_gcc_attribute_aligned" = "yes" ; then
AC_DEFINE(HAVE_GCC_ATTRIBUTE_ALIGNED,1,
[Defined if a GCC style "__attribute__ ((aligned (n))" is supported])
fi
#
# Check for ELF visibility support.
#
AC_CACHE_CHECK(whether the visibility attribute is supported,
gcry_cv_visibility_attribute,
[gcry_cv_visibility_attribute=no
AC_LANG_CONFTEST([AC_LANG_SOURCE(
[[int foo __attribute__ ((visibility ("hidden"))) = 1;
int bar __attribute__ ((visibility ("protected"))) = 1;
]])])
if ${CC-cc} -Werror -S conftest.c -o conftest.s \
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
gcry_cv_visibility_attribute=yes
fi
fi
fi
])
if test "$gcry_cv_visibility_attribute" = "yes"; then
AC_CACHE_CHECK(for broken visibility attribute,
gcry_cv_broken_visibility_attribute,
[gcry_cv_broken_visibility_attribute=yes
AC_LANG_CONFTEST([AC_LANG_SOURCE(
[[int foo (int x);
int bar (int x) __asm__ ("foo")
__attribute__ ((visibility ("hidden")));
int bar (int x) { return x; }
]])])
if ${CC-cc} -Werror -S conftest.c -o conftest.s \
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
if grep '\.hidden@<:@ _@:>@foo' conftest.s >/dev/null 2>&1;
then
gcry_cv_broken_visibility_attribute=no
fi
fi
])
fi
if test "$gcry_cv_visibility_attribute" = "yes"; then
AC_CACHE_CHECK(for broken alias attribute,
gcry_cv_broken_alias_attribute,
[gcry_cv_broken_alias_attribute=yes
AC_LANG_CONFTEST([AC_LANG_SOURCE(
[[extern int foo (int x) __asm ("xyzzy");
int bar (int x) { return x; }
extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
extern int dfoo;
extern __typeof (dfoo) dfoo __asm ("abccb");
int dfoo = 1;
]])])
if ${CC-cc} -Werror -S conftest.c -o conftest.s \
1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
grep 'abccb' conftest.s >/dev/null 2>&1; then
gcry_cv_broken_alias_attribute=no
fi
fi
])
fi
if test "$gcry_cv_visibility_attribute" = "yes"; then
AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
gcry_cv_gcc_has_f_visibility,
[gcry_cv_gcc_has_f_visibility=no
_gcc_cflags_save=$CFLAGS
CFLAGS="-fvisibility=hidden"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
gcry_cv_gcc_has_f_visibility=yes)
CFLAGS=$_gcc_cflags_save;
])
fi
if test "$gcry_cv_visibility_attribute" = "yes" \
&& test "$gcry_cv_broken_visibility_attribute" != "yes" \
&& test "$gcry_cv_broken_alias_attribute" != "yes" \
&& test "$gcry_cv_gcc_has_f_visibility" = "yes"
then
AC_DEFINE(GPGRT_USE_VISIBILITY, 1,
[Define to use the GNU C visibility attribute.])
CFLAGS="$CFLAGS -fvisibility=hidden"
fi
#
# Check whether ld supports a version script.
# (Actually not a check but a list of systems which are known to support it.)
#
have_ld_version_script=no
case "${host}" in
*-*-linux*)
have_ld_version_script=yes
;;
*-*-gnu*)
have_ld_version_script=yes
;;
esac
AC_ARG_ENABLE([ld-version-script],
AC_HELP_STRING([--enable-ld-version-script],
[enable/disable use of linker version script.
(default is system dependent)]),
[have_ld_version_script=$enableval],
[ : ] )
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
#
# Check for thread library.
#
# Windows has always thread support; thus we don't bother to test for
# it as it may lead to false results when cross building.
if test "$have_w32_system" = yes; then
AC_DEFINE([USE_WINDOWS_THREADS], [1])
LIBTHREAD=
LTLIBTHREAD=
LIBMULTITHREAD=
LTLIBMULTITHREAD=
THREADLIB_CPPFLAGS=""
AC_SUBST([LIBTHREAD])
AC_SUBST([LTLIBTHREAD])
AC_SUBST([LIBMULTITHREAD])
AC_SUBST([LTLIBMULTITHREAD])
else
gl_LOCK
if test "$gl_threads_api" = posix; then
AC_CHECK_SIZEOF(pthread_mutex_t,,[AC_INCLUDES_DEFAULT
#include ])
fi
fi
# Default value for GPG_ERROR_CONFIG_LIBS
config_libs="-lgpg-error"
#
# Check for other libraries
#
LIB_SCHED_YIELD=
AC_SUBST([LIB_SCHED_YIELD])
AC_SEARCH_LIBS([sched_yield], [rt posix4],
[if test "$ac_cv_search_sched_yield" != "none required"; then
LIB_SCHED_YIELD=$ac_cv_search_sched_yield
config_libs="$config_libs $LIB_SCHED_YIELD"
fi])
LIB_NETWORK=
AC_SUBST([LIB_NETWORK])
AC_SEARCH_LIBS([inet_addr], [nsl],
[if test "$ac_cv_search_inet_addr" != "none required"; then
LIB_NETWORK=$ac_cv_search_inet_addr
fi])
AC_SEARCH_LIBS([socket], [socket],
[if test "$ac_cv_search_socket" != "none required"; then
LIB_NETWORK="$ac_cv_search_socket $LIB_NETWORK"
fi], [], [$LIB_NETWORK])
if test "x$LIB_NETWORK" != x; then
config_libs="$config_libs $LIB_NETWORK"
fi
# Check for optional readline support
GNUPG_CHECK_READLINE
#
# Prepare building of estream
#
estream_INIT
#
# Substitution used for gpg-error-config
#
GPG_ERROR_CONFIG_LIBS="$config_libs"
if test "x$LIBTHREAD" != x; then
GPG_ERROR_CONFIG_LIBS="${GPG_ERROR_CONFIG_LIBS} ${LIBTHREAD}"
fi
if test "x$LIBMULTITHREAD" != x; then
GPG_ERROR_CONFIG_MT_LIBS="${LIBMULTITHREAD}"
else
GPG_ERROR_CONFIG_MT_LIBS=""
fi
if test "$have_w32ce_system" = yes; then
GPG_ERROR_CONFIG_CFLAGS="-idirafter \${includedir}/gpg-extra"
else
GPG_ERROR_CONFIG_CFLAGS=""
fi
if test "x$THREADLIB_CPPFLAGS" != x; then
GPG_ERROR_CONFIG_MT_CFLAGS="${THREADLIB_CPPFLAGS}"
else
GPG_ERROR_CONFIG_MT_CFLAGS=""
fi
GPG_ERROR_CONFIG_HOST="$host"
case "$includedir" in
/usr/include|/include) ;;
'${prefix}/include')
if test "$prefix" != / -a "$prefix" != /usr; then
if test -z "$GPG_ERROR_CONFIG_CFLAGS"; then
GPG_ERROR_CONFIG_CFLAGS="-I$includedir"
else
GPG_ERROR_CONFIG_CFLAGS="-I$includedir $GPG_ERROR_CONFIG_CFLAGS"
fi
fi
;;
*)
if test -z "$GPG_ERROR_CONFIG_CFLAGS"; then
GPG_ERROR_CONFIG_CFLAGS="-I$includedir"
else
GPG_ERROR_CONFIG_CFLAGS="-I$includedir $GPG_ERROR_CONFIG_CFLAGS"
fi
;;
esac
case "$libdir" in
/usr/lib|/usr/lib64|/lib|/lib64) ;;
'${exec_prefix}/lib')
if test "$exec_prefix" = "NONE"; then
if test "$prefix" != / -a "$prefix" != /usr; then
GPG_ERROR_CONFIG_LIBS="-L$libdir $GPG_ERROR_CONFIG_LIBS"
fi
elif test "$exec_prefix" != / -a "$exec_prefix" != /usr; then
GPG_ERROR_CONFIG_LIBS="-L$libdir $GPG_ERROR_CONFIG_LIBS"
fi
;;
*) GPG_ERROR_CONFIG_LIBS="-L$libdir $GPG_ERROR_CONFIG_LIBS" ;;
esac
AC_SUBST(GPG_ERROR_CONFIG_LIBS)
AC_SUBST(GPG_ERROR_CONFIG_CFLAGS)
AC_SUBST(GPG_ERROR_CONFIG_MT_LIBS)
AC_SUBST(GPG_ERROR_CONFIG_MT_CFLAGS)
AC_SUBST(GPG_ERROR_CONFIG_HOST)
#
# Special defines for certain platforms
#
force_use_syscfg=no
if test "$have_w32_system" = yes; then
AC_DEFINE(HAVE_W32_SYSTEM,1,[Defined if we run on a W32 API based system])
if test "$have_w64_system" = yes; then
AC_DEFINE(HAVE_W64_SYSTEM,1,[Defined if we run on 64 bit W32 API system])
fi
if test "$have_w32ce_system" = yes; then
AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
fi
force_use_syscfg=yes
fi
if test x$cross_compiling = xyes; then
force_use_syscfg=yes
fi
AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
AM_CONDITIONAL(HAVE_W64_SYSTEM, test "$have_w64_system" = yes)
AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
AM_CONDITIONAL(FORCE_USE_SYSCFG, test x$force_use_syscfg = xyes)
AC_DEFINE_UNQUOTED(HOST_TRIPLET_STRING, "$host", [The host triplet])
#
# gpgrt_log_clock may require linking with extra libaries. As long as
# we don't have a good test for this we require the use of this
# configure option to enabling printing of a timestamp.
#
AC_MSG_CHECKING([whether to enable log_clock])
AC_ARG_ENABLE(log_clock,
AC_HELP_STRING([--enable-log-clock],
[enable log_clock timestamps]),
enable_log_clock=$enableval, enable_log_clock=no)
AC_MSG_RESULT($enable_log_clock)
if test "$enable_log_clock" = yes ; then
AC_DEFINE(ENABLE_LOG_CLOCK,1,[Defined to use log_clock timestamps])
fi
#
# For now we do not build gpgscm by default.
# Eventually we will reverse the meaning of that option.
#
build_gpgscm=no
#AC_MSG_CHECKING([whether to build gpgscm])
#AC_ARG_ENABLE(gpgscm,
# AC_HELP_STRING([--enable-gpgscm],
# [build the gpgscm tool]),
# build_gpgscm=$enableval, build_gpgscm=no)
#AC_MSG_RESULT($build_gpgscm)
AM_CONDITIONAL([BUILD_GPGSCM], [test "x$build_gpgscm" != xno])
#
# Add -Werror to CFLAGS. This hack can be used to avoid problems with
# misbehaving autoconf tests in case the user supplied -Werror.
#
AC_ARG_ENABLE(werror,
AC_HELP_STRING([--enable-werror],
[append -Werror to CFLAGS]),
[if test $enableval = yes ; then
CFLAGS="$CFLAGS -Werror"
fi])
#
# Provide information about the build.
#
BUILD_REVISION="mym4_revision"
AC_SUBST(BUILD_REVISION)
AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
[GIT commit id revision used to build this package])
changequote(,)dnl
BUILD_VERSION=`echo "$PACKAGE_VERSION"|sed 's/\([0-9.]*\).*/\1./'`
changequote([,])dnl
BUILD_VERSION="${BUILD_VERSION}0.mym4_revision_dec"
BUILD_FILEVERSION=`echo "${BUILD_VERSION}" | tr . ,`
AC_SUBST(BUILD_VERSION)
AC_SUBST(BUILD_FILEVERSION)
AC_ARG_ENABLE([build-timestamp],
AC_HELP_STRING([--enable-build-timestamp],
[set an explicit build timestamp for reproducibility.
(default is the current time in ISO-8601 format)]),
[if test "$enableval" = "yes"; then
BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
else
BUILD_TIMESTAMP="$enableval"
fi],
[BUILD_TIMESTAMP=""])
AC_SUBST(BUILD_TIMESTAMP)
AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
[The time this package was configured for a build])
AC_ARG_ENABLE(languages, AC_HELP_STRING([--disable-languages],
[do not build support for other languages than C]))
AM_CONDITIONAL([LANGUAGES_SOME], [test "x$enable_languages" != xno])
build_doc=yes
AC_ARG_ENABLE([doc], AC_HELP_STRING([--disable-doc],
[do not build the documentation]),
build_doc=$enableval, build_doc=yes)
AM_CONDITIONAL([BUILD_DOC], [test "x$build_doc" != xno])
build_tests=yes
AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
[do not build the tests]),
build_tests=$enableval, build_tests=yes)
AM_CONDITIONAL([BUILD_TESTS], [test "x$build_tests" != xno])
-case "$libdir" in
- */*-*-*)
- # Looks like it's multiarch, then,
- # let the script detect host architecture at runtime
- pkg_config_libdir=auto
- ;;
- *)
- pkg_config_libdir=$libdir/pkgconfig
- ;;
-esac
-AC_SUBST(pkg_config_libdir)
#
# Substitution
#
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([doc/Makefile po/Makefile.in m4/Makefile])
AC_CONFIG_FILES([src/Makefile tests/Makefile])
AC_CONFIG_FILES([lang/Makefile lang/cl/Makefile lang/cl/gpg-error.asd])
AC_CONFIG_FILES([src/versioninfo.rc src/gpg-error.w32-manifest])
AC_CONFIG_FILES([src/gpg-error.pc])
AC_CONFIG_FILES([src/gpg-error-config-old:src/gpg-error-config.in], [chmod +x src/gpg-error-config-old])
-AC_CONFIG_FILES([src/gpgrt-config], [chmod +x src/gpgrt-config])
AC_OUTPUT
tmp=
if test "$have_w32_system" != yes; then
if test x"$gl_use_threads" = xno; then
tmp=" NO-THREADS"
fi
fi
echo "
$PACKAGE_NAME v$PACKAGE_VERSION has been configured as follows:
Revision: mym4_revision (mym4_revision_dec)
Platform: $host$tmp
"
if test "$gcry_cv_gcc_attribute_aligned" != "yes" ; then
cat <.
# SPDX-License-Identifier: LGPL-2.1+
#
# We distribute the generated sources err-sources.h and err-codes.h,
# because they are needed to build the po directory, and they don't
# depend on the configuration anyway.
#
if HAVE_W32CE_SYSTEM
gpg_extra_headers = gpg-extra/errno.h
extra_cppflags = -idirafter gpg-extra
else
gpg_extra_headers =
extra_cppflags =
endif
localedir = $(datadir)/locale
bin_PROGRAMS = gpg-error
if HAVE_W32_SYSTEM
noinst_PROGRAMS = gen-w32-lock-obj
else
noinst_PROGRAMS = gen-posix-lock-obj
endif
# Distributed lock object definitions for cross compilation.
lock_obj_pub = \
syscfg/lock-obj-pub.aarch64-unknown-linux-gnu.h \
syscfg/lock-obj-pub.aarch64-unknown-linux-gnu_ilp32.h \
syscfg/lock-obj-pub.aarch64-apple-darwin.h \
syscfg/lock-obj-pub.alpha-unknown-linux-gnu.h \
syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h \
syscfg/lock-obj-pub.arm-unknown-linux-gnueabi.h \
syscfg/lock-obj-pub.arm-apple-darwin.h \
syscfg/lock-obj-pub.hppa-unknown-linux-gnu.h \
syscfg/lock-obj-pub.i386-apple-darwin.h \
syscfg/lock-obj-pub.i686-unknown-gnu.h \
syscfg/lock-obj-pub.i686-unknown-kfreebsd-gnu.h \
syscfg/lock-obj-pub.i686-unknown-linux-gnu.h \
syscfg/lock-obj-pub.m68k-unknown-linux-gnu.h \
syscfg/lock-obj-pub.mips-unknown-linux-gnu.h \
syscfg/lock-obj-pub.mips64el-unknown-linux-gnuabi64.h \
syscfg/lock-obj-pub.mipsel-unknown-linux-gnu.h \
syscfg/lock-obj-pub.nios2-unknown-linux-gnu.h \
syscfg/lock-obj-pub.or1k-unknown-linux-gnu.h \
syscfg/lock-obj-pub.powerpc-unknown-linux-gnu.h \
syscfg/lock-obj-pub.powerpc64-unknown-linux-gnu.h \
syscfg/lock-obj-pub.powerpc64le-unknown-linux-gnu.h \
syscfg/lock-obj-pub.powerpc-unknown-linux-gnuspe.h \
syscfg/lock-obj-pub.riscv64-unknown-linux-gnu.h \
syscfg/lock-obj-pub.s390x-unknown-linux-gnu.h \
syscfg/lock-obj-pub.sh3-unknown-linux-gnu.h \
syscfg/lock-obj-pub.sh4-unknown-linux-gnu.h \
syscfg/lock-obj-pub.sparc-unknown-linux-gnu.h \
syscfg/lock-obj-pub.sparc64-unknown-linux-gnu.h \
syscfg/lock-obj-pub.x86_64-apple-darwin.h \
syscfg/lock-obj-pub.x86_64-unknown-kfreebsd-gnu.h \
syscfg/lock-obj-pub.x86_64-unknown-linux-gnu.h \
syscfg/lock-obj-pub.x86_64-unknown-linux-gnux32.h \
syscfg/lock-obj-pub.x86_64-unknown-linux-musl.h \
syscfg/lock-obj-pub.tilegx-unknown-linux-gnu.h \
syscfg/lock-obj-pub.ia64-unknown-linux-gnu.h \
syscfg/lock-obj-pub.mingw32.h
lib_LTLIBRARIES = libgpg-error.la
nodist_include_HEADERS = gpg-error.h gpgrt.h
bin_SCRIPTS = gpgrt-config gpg-error-config
m4datadir = $(datadir)/aclocal
m4data_DATA = gpg-error.m4 gpgrt.m4
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gpg-error.pc
EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
mkerrnos.awk errnos.in README \
mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \
mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \
err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 gpgrt.m4 \
gpg-error.vers gpg-error.def.in \
versioninfo.rc.in gpg-error.w32-manifest.in \
- gpgrt-config.in gpg-error-config-test.sh gpg-error.pc.in \
+ gpg-error-config-test.sh gpg-error.pc.in \
$(lock_obj_pub)
BUILT_SOURCES = $(srcdir)/err-sources.h $(srcdir)/err-codes.h \
code-to-errno.h code-from-errno.h \
err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h gpgrt.h \
gpg-error.def mkw32errmap.map.c
tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
CLEANFILES = code-to-errno.h code-from-errno.h \
gpg-error.h gpgrt.h \
mkerrcodes$(EXEEXT_FOR_BUILD) mkerrcodes.h gpg-error.def mkw32errmap.tab.h \
mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \
gpg-extra/errno.h mkheader$(EXEEXT_FOR_BUILD) \
gpg-error-config gpg-error-config-test.log \
$(tmp_files) lock-obj-pub.native.h
MAINTAINERCLEANFILES = $(srcdir)/err-sources.h $(srcdir)/err-codes.h
TESTS = gpg-error-config-test.sh
#
# {{{ Begin Windows part
#
if HAVE_W32_SYSTEM
arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c \
w32-iconv.c w32-estream.c w32-reg.c spawn-w32.c
RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS)
LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE)
SUFFIXES = .rc .lo
.rc.lo:
$(LTRCCOMPILE) -i "$<" -o "$@"
gpg_error_res = versioninfo.lo
no_undefined = -no-undefined
export_symbols = -export-symbols gpg-error.def
# i686-w64-mingw32.gcc version 4.9.1 takes the long long helper
# functions from libgcc_s_sjlj-1.dll and not from a static libgcc. As
# a plain C program we do not use exception handler and thus there is
# no need to use this DLL. Thus we force gcc to link that statically.
extra_ltoptions = -XCClinker -static-libgcc
versioninfo.lo : gpg-error.w32-manifest
install-def-file: gpg-error.def
-$(INSTALL) -d $(DESTDIR)$(libdir)
$(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def
uninstall-def-file:
-rm $(DESTDIR)$(libdir)/gpg-error.def
libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def
intllibs =
socklibs = -lws2_32
#
# }}} End Windows part
#
else
#
# {{{ Begin Unix part
#
arch_sources = posix-lock.c posix-lock-obj.h posix-thread.c spawn-posix.c
gpg_error_res =
no_undefined =
export_symbols =
extra_ltoptions =
install-def-file:
uninstall-def-file:
intllibs = @LTLIBINTL@
socklibs =
endif
#
# }}} End Unix part
#
if HAVE_LD_VERSION_SCRIPT
libgpg_error_vers_opt = -Wl,--version-script=$(srcdir)/gpg-error.vers
else
libgpg_error_vers_opt =
endif
libgpg_error_la_LDFLAGS = \
$(no_undefined) $(export_symbols) $(libgpg_error_vers_opt) \
$(extra_ltoptions) -version-info \
@LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@
libgpg_error_la_SOURCES = gettext.h $(arch_sources) \
gpgrt-int.h init.c init.h version.c lock.h thread.h \
estream.c estream-printf.c estream-printf.h \
strsource.c strerror.c code-to-errno.c code-from-errno.c \
visibility.c visibility.h \
sysutils.c \
syscall-clamp.c \
logging.c \
b64dec.c b64enc.c \
argparse.c
nodist_libgpg_error_la_SOURCES = gpg-error.h
# libgpg_error_la_DEPENDENCIES = \
# $(srcdir)/gpg-error.vers
# Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but
# without the extra_cppflags because they may include am -idirafter
# which is not supported by the RC compiler.
libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(socklibs) $(LIBTHREAD)
gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
gpg_error_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" \
-DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
gpg_error_LDADD = libgpg-error.la $(LTLIBINTL)
# We build err-sources.h and err-codes.h in the source directory.
# This is needed because gettext does only look into the source
# directory to find the files listed in po/POTFILE.in. To make these
# rules work we also need to depend on Makefile.am and not on the
# generated files Makefile.in or Makefile.
$(srcdir)/err-sources.h: Makefile.am mkstrtable.awk err-sources.h.in
$(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
$(srcdir)/err-sources.h.in >$@
err-sources-sym.h: Makefile mkstrtable.awk err-sources.h.in
$(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
$(srcdir)/err-sources.h.in >$@
$(srcdir)/err-codes.h: Makefile.am mkstrtable.awk err-codes.h.in
$(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
$(srcdir)/err-codes.h.in >$@
err-codes-sym.h: Makefile mkstrtable.awk err-codes.h.in
$(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
$(srcdir)/err-codes.h.in >$@
code-to-errno.h: Makefile mkerrnos.awk errnos.in
$(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@
# It is correct to use $(CPP). We want the host's idea of the error codes.
mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers)
$(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@
$(CPP) $(CPPFLAGS) $(extra_cppflags) -P _$@ | grep GPG_ERR_ | \
$(AWK) -f $(srcdir)/mkerrcodes.awk >$@
-rm _$@
if HAVE_W32CE_SYSTEM
# It is correct to use $(CPP). We want the host's idea of the error codes.
mkw32errmap.tab.h: Makefile mkw32errmap.c
$(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \
grep '{&mkw32errmap_marker' >$@
mkw32errmap.map.c: mkw32errmap$(EXEEXT_FOR_BUILD)
./mkw32errmap$(EXEEXT_FOR_BUILD) --map > $@
gpg-extra/errno.h: mkw32errmap$(EXEEXT_FOR_BUILD)
-$(MKDIR_P) gpg-extra
./mkw32errmap$(EXEEXT_FOR_BUILD) > $@
else
mkw32errmap.map.c:
echo "/*dummy*/" > $@
endif
# We use CC proper for preprocessing thus we have to convince it that
# the data is really to be preprocessed.
gpg-error.def: Makefile gpg-error.def.in
cat $(srcdir)/gpg-error.def.in >_$@.h
$(CPP) $(DEFAULT_INCLUDES) $(INCLUDES) $(extra_cppflags) _$@.h | \
grep -v '^#' >$@
-rm _$@.h
# It is correct to use $(CC_FOR_BUILD) here. We want to run the
# program at build time.
mkerrcodes$(EXEEXT_FOR_BUILD): mkerrcodes.c mkerrcodes.h Makefile
$(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c
if HAVE_W32CE_SYSTEM
# It is correct to use $(CC_FOR_BUILD) here. We want to run the
# program at build time.
mkw32errmap$(EXEEXT_FOR_BUILD): mkw32errmap.c mkw32errmap.tab.h Makefile
$(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c
endif
code-from-errno.h: mkerrcodes$(EXEEXT_FOR_BUILD) Makefile
./mkerrcodes$(EXEEXT_FOR_BUILD) | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@
errnos-sym.h: Makefile mkstrtable.awk errnos.in
$(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
-v prefix=GPG_ERR_ -v namespace=errnos_ \
$(srcdir)/errnos.in >$@
mkheader$(EXEEXT_FOR_BUILD): mkheader.c Makefile
$(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c
parts_of_gpg_error_h = \
gpg-error.h.in \
err-sources.h.in \
err-codes.h.in \
errnos.in \
w32-add.h \
w32ce-add.h \
$(lock_obj_pub)
# If we are cross-compiling or building on Windows we better make sure
# that no stale native lock include file will be found by mkheader.
if FORCE_USE_SYSCFG
pre_mkheader_cmds = if test -f lock-obj-pub.native.h; \
then rm lock-obj-pub.native.h; fi
mkheader_opts = --cross
else
pre_mkheader_cmds = :
mkheader_opts =
parts_of_gpg_error_h += ./lock-obj-pub.native.h
./lock-obj-pub.native.h: Makefile gen-posix-lock-obj$(EXEEXT) posix-lock-obj.h
./gen-posix-lock-obj >$@
endif
# We also depend on versioninfo.rc because that is build by
# config.status and thus has up-to-date version numbers.
gpg-error.h: Makefile mkheader$(EXEEXT_FOR_BUILD) $(parts_of_gpg_error_h) \
versioninfo.rc ../config.h
$(pre_mkheader_cmds)
./mkheader$(EXEEXT_FOR_BUILD) $(mkheader_opts) \
$(host_triplet) $(srcdir)/gpg-error.h.in \
../config.h $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@
gpgrt.h: gpg-error.h
cp gpg-error.h gpgrt.h
gpg-error-config: gpgrt-config gpg-error-config-old
@echo $(ECHO_N) "Confirm gpg-error-config works... $(ECHO_C)"
@if $(srcdir)/gpg-error-config-test.sh --old-new; then \
echo "good"; \
else \
echo "no"; \
echo "*** Please report to with gpg-error-config-test.log"; \
fi
cp gpg-error-config-old $@
install-data-local:
if HAVE_W32CE_SYSTEM
-$(MKDIR_P) "$(DESTDIR)$(includedir)/gpg-extra"
$(INSTALL_DATA) gpg-extra/errno.h \
"$(DESTDIR)$(includedir)/gpg-extra/errno.h"
else
:
endif
diff --git a/src/gpg-error-config-test.sh b/src/gpg-error-config-test.sh
index 2d8b94b..7125e10 100755
--- a/src/gpg-error-config-test.sh
+++ b/src/gpg-error-config-test.sh
@@ -1,88 +1,90 @@
#!/bin/sh
+srcdir=${0%/*}
+
PKG_CONFIG_PATH="."
export PKG_CONFIG_PATH
if [ "$1" = --old-new ]; then
PKG_CONFIG_CMD=./gpg-error-config-old
else
PKG_CONFIG_SYSROOT_DIR="/var/example-target"
export PKG_CONFIG_SYSROOT_DIR
PKG_CONFIG_CMD="pkg-config gpg-error"
if ! $PKG_CONFIG_CMD --exists >/dev/null; then
exit 77 # Skip tests
fi
fi
test_failed=""
failure () {
(
echo "Test result: $*"
echo "====================: $PKG_CONFIG_CMD"
echo "$OUTPUT_OLD"
echo "====================: gpgrt-config"
echo "$OUTPUT_NEW"
echo "===================="
) >> gpg-error-config-test.log
test_failed=yes
}
rm -f gpg-error-config-test.log
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --libs))
-OUTPUT_NEW=$(./gpgrt-config --libs)
+OUTPUT_NEW=$($srcdir/gpgrt-config --libs)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --libs
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --cflags))
-OUTPUT_NEW=$(./gpgrt-config --cflags)
+OUTPUT_NEW=$($srcdir/gpgrt-config --cflags)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --cflags
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --cflags --libs))
-OUTPUT_NEW=$(./gpgrt-config --cflags --libs)
+OUTPUT_NEW=$($srcdir/gpgrt-config --cflags --libs)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --cflags --libs
if [ "$PKG_CONFIG_CMD" = ./gpg-error-config-old ]; then
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --version))
- OUTPUT_NEW=$(./gpgrt-config --version)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --version)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --version
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --mt --libs))
- OUTPUT_NEW=$(./gpgrt-config --mt --libs)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --mt --libs)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --mt --libs
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --mt --cflags))
- OUTPUT_NEW=$(./gpgrt-config --mt --cflags)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --mt --cflags)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --mt --cflags
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --cflags --libs))
- OUTPUT_NEW=$(./gpgrt-config --cflags --libs)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --cflags --libs)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --cflags --libs
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --mt --cflags --libs))
- OUTPUT_NEW=$(./gpgrt-config --mt --cflags --libs)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --mt --cflags --libs)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --mt --cflags --libs
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --variable=mtcflags))
- OUTPUT_NEW=$(./gpgrt-config --variable=mtcflags)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --variable=mtcflags)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --variable=mtcflags
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --variable=mtlibs))
- OUTPUT_NEW=$(./gpgrt-config --variable=mtlibs)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --variable=mtlibs)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --variable=mtlibs
OUTPUT_OLD=$(echo $($PKG_CONFIG_CMD --variable=host))
- OUTPUT_NEW=$(./gpgrt-config --variable=host)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --variable=host)
[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || failure --variable=host
fi
if [ -n "$test_failed" ]; then
OUTPUT_OLD=$($PKG_CONFIG_CMD --version)
- OUTPUT_NEW=$(./gpgrt-config --version)
+ OUTPUT_NEW=$($srcdir/gpgrt-config --version)
failure --version
exit 99
fi
exit 0
diff --git a/src/gpg-error.m4 b/src/gpg-error.m4
index 70dc501..0964a26 100644
--- a/src/gpg-error.m4
+++ b/src/gpg-error.m4
@@ -1,149 +1,155 @@
# gpg-error.m4 - autoconf macro to detect libgpg-error.
# Copyright (C) 2002, 2003, 2004, 2011, 2014, 2018 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.
#
-# Last-changed: 2018-10-26
+# Last-changed: 2018-10-29
dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
dnl
dnl Test for libgpg-error and define GPG_ERROR_CFLAGS, GPG_ERROR_LIBS,
dnl GPG_ERROR_MT_CFLAGS, and GPG_ERROR_MT_LIBS. The _MT_ variants are
dnl used for programs requireing real multi thread support.
dnl
dnl If a prefix option is not used, the config script is first
dnl searched in $SYSROOT/bin and then along $PATH. If the used
dnl config script does not match the host specification the script
dnl is added to the gpg_config_script_warn variable.
dnl
AC_DEFUN([AM_PATH_GPG_ERROR],
[ AC_REQUIRE([AC_CANONICAL_HOST])
gpg_error_config_prefix=""
dnl --with-libgpg-error-prefix=PFX is the preferred name for this option,
dnl since that is consistent with how our three siblings use the directory/
dnl package name in --with-$dir_name-prefix=PFX.
AC_ARG_WITH(libgpg-error-prefix,
AC_HELP_STRING([--with-libgpg-error-prefix=PFX],
[prefix where GPG Error is installed (optional)]),
[gpg_error_config_prefix="$withval"])
dnl Accept --with-gpg-error-prefix and make it work the same as
dnl --with-libgpg-error-prefix above, for backwards compatibility,
dnl but do not document this old, inconsistently-named option.
AC_ARG_WITH(gpg-error-prefix,,
[gpg_error_config_prefix="$withval"])
if test x"${GPG_ERROR_CONFIG}" = x ; then
if test x"${gpg_error_config_prefix}" != x ; then
GPG_ERROR_CONFIG="${gpg_error_config_prefix}/bin/gpg-error-config"
else
case "${SYSROOT}" in
/*)
if test -x "${SYSROOT}/bin/gpg-error-config" ; then
GPG_ERROR_CONFIG="${SYSROOT}/bin/gpg-error-config"
fi
;;
'')
;;
*)
AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
;;
esac
fi
fi
AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
min_gpg_error_version=ifelse([$1], ,1.33,$1)
ok=no
use_gpgrt_config=""
if test "$GPG_ERROR_CONFIG" = "no"; then
AC_PATH_PROG(GPGRT_CONFIG, gpgrt-config, no)
- if CC=$CC $GPGRT_CONFIG gpg-error >/dev/null 2>&1; then
- GPG_ERROR_CONFIG="$GPGRT_CONFIG gpg-error"
- use_gpgrt_config=yes
- gpg_error_config_version=`CC=$CC $GPG_ERROR_CONFIG --modversion`
+ if test "$GPGRT_CONFIG" != "no"; then
+ GPGRT_CONFIG="$GPGRT_CONFIG --prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir"
+ if $GPGRT_CONFIG gpg-error >/dev/null 2>&1; then
+ GPG_ERROR_CONFIG="$GPGRT_CONFIG gpg-error"
+ use_gpgrt_config=yes
+ gpg_error_config_version=`$GPG_ERROR_CONFIG --modversion`
+ fi
fi
else
- gpg_error_config_version=`CC=$CC $GPG_ERROR_CONFIG --version`
+ gpg_error_config_version=`$GPG_ERROR_CONFIG --version`
fi
if test "$GPG_ERROR_CONFIG" != "no"; then
req_major=`echo $min_gpg_error_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
req_minor=`echo $min_gpg_error_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
major=`echo $gpg_error_config_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
minor=`echo $gpg_error_config_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
if test "$major" -gt "$req_major"; then
ok=yes
else
if test "$major" -eq "$req_major"; then
if test "$minor" -ge "$req_minor"; then
ok=yes
fi
fi
fi
if test -z "$GPGRT_CONFIG"; then
if test "$major" -gt 1 -o "$major" -eq 1 -a "$minor" -ge 33; then
AC_PATH_PROG(GPGRT_CONFIG, gpgrt-config, no)
- GPG_ERROR_CONFIG="$GPGRT_CONFIG gpg-error"
- use_gpgrt_config=yes
+ if test "$GPGRT_CONFIG" != "no"; then
+ GPGRT_CONFIG="$GPGRT_CONFIG --prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir"
+ GPG_ERROR_CONFIG="$GPGRT_CONFIG gpg-error"
+ use_gpgrt_config=yes
+ fi
fi
fi
fi
AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
if test $ok = yes; then
- GPG_ERROR_CFLAGS=`CC=$CC $GPG_ERROR_CONFIG --cflags`
- GPG_ERROR_LIBS=`CC=$CC $GPG_ERROR_CONFIG --libs`
+ GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG --cflags`
+ GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG --libs`
if test -z "$use_gpgrt_config"; then
- GPG_ERROR_MT_CFLAGS=`CC=$CC $GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null`
- GPG_ERROR_MT_LIBS=`CC=$CC $GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null`
+ GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG --mt --cflags 2>/dev/null`
+ GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG --mt --libs 2>/dev/null`
else
- GPG_ERROR_MT_CFLAGS=`CC=$CC $GPG_ERROR_CONFIG --variable=mtcflags 2>/dev/null`
+ GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG --variable=mtcflags 2>/dev/null`
GPG_ERROR_MT_CFLAGS="$GPG_ERROR_CFLAGS${GPG_ERROR_CFLAGS:+ }$GPG_ERROR_MT_CFLAGS"
- GPG_ERROR_MT_LIBS=`CC=$CC $GPG_ERROR_CONFIG --variable=mtlibs 2>/dev/null`
+ GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG --variable=mtlibs 2>/dev/null`
GPG_ERROR_MT_LIBS="$GPG_ERROR_LIBS${GPG_ERROR_LIBS:+ }$GPG_ERROR_MT_LIBS"
fi
AC_MSG_RESULT([yes ($gpg_error_config_version)])
ifelse([$2], , :, [$2])
if test -z "$use_gpgrt_config"; then
- gpg_error_config_host=`CC=$CC $GPG_ERROR_CONFIG --host 2>/dev/null || echo none`
+ gpg_error_config_host=`$GPG_ERROR_CONFIG --host 2>/dev/null || echo none`
else
- gpg_error_config_host=`CC=$CC $GPG_ERROR_CONFIG --variable=host 2>/dev/null || echo none`
+ gpg_error_config_host=`$GPG_ERROR_CONFIG --variable=host 2>/dev/null || echo none`
fi
if test x"$gpg_error_config_host" != xnone ; then
if test x"$gpg_error_config_host" != x"$host" ; then
AC_MSG_WARN([[
***
*** The config script "$GPG_ERROR_CONFIG" was
*** built for $gpg_error_config_host and thus may not match the
*** used host $host.
*** You may want to use the configure option --with-libgpg-error-prefix
*** to specify a matching config script or use \$SYSROOT.
***]])
gpg_config_script_warn="$gpg_config_script_warn libgpg-error"
fi
fi
else
GPG_ERROR_CFLAGS=""
GPG_ERROR_LIBS=""
GPG_ERROR_MT_CFLAGS=""
GPG_ERROR_MT_LIBS=""
AC_MSG_RESULT(no)
ifelse([$3], , :, [$3])
fi
AC_SUBST(GPG_ERROR_CFLAGS)
AC_SUBST(GPG_ERROR_LIBS)
AC_SUBST(GPG_ERROR_MT_CFLAGS)
AC_SUBST(GPG_ERROR_MT_LIBS)
])
diff --git a/src/gpgrt-config.in b/src/gpgrt-config
old mode 100644
new mode 100755
similarity index 88%
rename from src/gpgrt-config.in
rename to src/gpgrt-config
index 9df01b7..1524677
--- a/src/gpgrt-config.in
+++ b/src/gpgrt-config
@@ -1,628 +1,643 @@
#!/bin/sh
# Copyright (C) 2018 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.
# SPDX-License-Identifier: FSFULLR
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-pkg_config_libdir=@pkg_config_libdir@
-if [ x"${PKG_CONFIG_LIBDIR+set}" = x ]; then
- # If PKG_CONFIG_LIBDIR is not specified, detect the directory.
-
- # We supports standard cross build with $CC
- triplet=""
- case "$CC" in
- *-*-*) triplet=${CC%-*} ;;
- *) ;;
- esac
- if [ "$pkg_config_libdir" = auto ]; then
- # It's multiarch environment.
- # It may be standard cross build, native multiarch build, or
- # multiarch-cross build
- multiarch=""
- if [ -n "$triplet" ]; then
- triplet1=$triplet
- else
- triplet1=$(gcc -dumpmachine)
- fi
- # Follow existing practice for multiarch name
- if expr $triplet1 : "^i[4567]86-" >/dev/null; then
- multiarch="i386-${triplet1#*-}"
- else
- multiarch=$triplet1
- fi
- if [ -n "$triplet" ]; then
- PKG_CONFIG_LIBDIR="@exec_prefix@/$triplet/lib/pkgconfig:@exec_prefix@/lib/$multiarch/pkgconfig"
- else
- PKG_CONFIG_LIBDIR="@exec_prefix@/lib/$multiarch/pkgconfig"
- fi
- unset multiarch triplet1
- elif [ -n "$triplet" ]; then
- # It's cross build
- PKG_CONFIG_LIBDIR="@exec_prefix@/$triplet/lib/pkgconfig"
- else
- # Native build in standard (non-multiarch) environment
- PKG_CONFIG_LIBDIR="$pkg_config_libdir"
- fi
- unset triplet
-fi
-PKG_CONFIG_PATH="$PKG_CONFIG_PATH${PKG_CONFIG_PATH:+:}$PKG_CONFIG_LIBDIR"
-#
-
#### start of functions for this script
#
# Bourne shell functions for config file in pkg-config style, so that
# we can share such a config file between pkg-config and script
#
#
# get_var: Get the variable value of NAME
#
# Variables are recorded in the shell variables named "VAR_"
#
get_var () {
___name=$1
eval echo \$VAR_$___name
}
#
# get_attr: Get the attribute value of KEY
#
# Attributes are recorded in the shell variables named "ATTR_"
#
get_attr () {
___name=$1
eval echo \$ATTR_$___name
}
# Remove ${varname} part in the beginning of a string.
remove_var_expr () {
___varname=$1
shift
expr "$*" : "\${$___varname}\\(.*\\)"
}
# Given a string, substitute variables.
substitute_vars () {
__string="$1"
__varname=""
__result=""
while [ -n "$__string" ]; do
case "$__string" in
\$\$*)
__result="$__result\$"
__string="${__string#\$\$}"
;;
\${*}*)
__varname="${__string#\$\{}"
__varname="${__varname%%\}*}"
__result="$__result$(get_var $__varname)"
__string=$(remove_var_expr $__varname $__string)
;;
*)
__result="$__result$(printf %c "$__string")"
__string="${__string#$(printf %c "$__string")}"
;;
esac
done
echo "$__result"
}
#
# Read a config from stdin
#
# Variables:
# For VAR=VALUE, value is stored in the shell variable VAR_*.
#
# Attributes:
# For KEY: VALUE, value is stored in the shell variable ATTR_*.
#
read_config_from_stdin () {
_filename=$1
_line=""
_varname=""
_value=""
_key=""
_reading_attrs=""
while read _line; do
if [ -z "$_line" ]; then
_reading_attrs=yes
continue
elif [ -z "$_reading_attrs" ]; then
case "$_line" in
*=*)
_varname="${_line%%=*}"
_value="${_line#*=}"
VAR_list="$VAR_list${VAR_list:+ }VAR_$_varname"
read VAR_$_varname <&2
exit 1
;;
esac
fi
done
}
find_file_in_path () {
_f=$1
_p=$2
_saved_IFS="$IFS"
_arg=""
IFS=":" # On Windows it should be ";"???
for _arg in $_p; do
if [ -r $_arg/$_f ]; then
RESULT="$_arg/$_f"
IFS="$_saved_IFS"
return 0
fi
done
IFS="$_saved_IFS"
RESULT=""
return 1
}
read_config_file () {
if ! find_file_in_path $1.pc $2; then
if [ -z "$want_exists" ]; then
echo "Can't find $1.pc" 1>&2
fi
exit 1
fi
read_config_from_stdin $RESULT < $RESULT
}
cleanup_vars_attrs () {
eval unset $VAR_list VAR_list
eval unset $ATTR_list ATTR_list
}
not_listed_yet () {
___m=$1
___arg=""
shift
for ___arg; do
if [ $___m = $___arg ]; then
return 1
fi
done
return 0
}
list_only_once () {
__result=""
__arg=""
for __arg; do
if not_listed_yet $__arg $__result; then
__result="$__result${__result:+ }$__arg"
fi
done
echo $__result
}
list_only_once_for_libs () {
__result=""
__rev_list=""
__arg=""
# Scan the list and eliminate duplicates for non-"-lxxx"
# the resulted list is in reverse order
for __arg; do
case "$__arg" in
-l*)
# As-is
__rev_list="$__arg${__rev_list:+ }$__rev_list"
;;
*)
if not_listed_yet $__arg $__rev_list; then
__rev_list="$__arg${__rev_list:+ }$__rev_list"
fi
;;
esac
done
# Scan again
for __arg in $__rev_list; do
case "$__arg" in
-l*)
if not_listed_yet $__arg $__result; then
__result="$__arg${__result:+ }$__result"
fi
;;
*)
# As-is
__result="$__arg${__result:+ }$__result"
;;
esac
done
echo $__result
}
arg1_is_same () {
[ "$1" = "=" -o "$1" = ">=" -o "$1" = "<=" ]
}
arg1_is_less () {
[ "$1" = "!=" -o "$1" = "<" -o "$1" = "<=" ]
}
arg1_is_great () {
[ "$1" = "!=" -o "$1" = ">" -o "$1" = ">=" ]
}
#
# Evaluate comparison between versions in RPM way
#
eval_compare_version () {
___str1="$1"
___cmp="$2"
___str2="$3"
___char1=""
___char2=""
___chunk1=""
___chunk2=""
while [ -n "$___str1" -a -n "$___str2" ]; do
# Trim anything that's not alnum or tilde from the front
___str1="$(expr "$___str1" : '[^0-9A-Za-z~]*\(.*\)')"
___str2="$(expr "$___str2" : '[^0-9A-Za-z~]*\(.*\)')"
# Get the first character
___char1=${___str1%${___str1#?}}
___char2=${___str2%${___str2#?}}
if [ "$___char1" = ~ -o "$___char2" = ~ ]; then
if [ "$___char1" != ~ ]; then
arg1_is_great $___cmp
return
fi
if [ "$___char2" != ~ ]; then
arg1_is_less $___cmp
return
fi
___str1=${___str1#~}
___str2=${___str2#~}
continue
fi
if [ -z "$___char1" -o -z "$___char2" ]; then
break
fi
case "$___char1$___char2" in
[0-9][A-Za-z])
arg1_is_great $___cmp
return
;;
[A-Za-z][0-9])
arg1_is_less $___cmp
return
;;
[0-9][0-9])
___chunk1="$(expr "$___str1" : '\([0-9]*\)')"
___chunk2="$(expr "$___str2" : '\([0-9]*\)')"
;;
[A-Za-z][A-Za-z])
___chunk1="$(expr "$___str1" : '\([A-Za-z]*\)')"
___chunk2="$(expr "$___str2" : '\([A-Za-z]*\)')"
;;
esac
# Compare chunks numerically if digits, or lexicographically
if expr "$___chunk1" "!=" "$___chunk2" >/dev/null; then
if expr "$___chunk1" ">" "$___chunk2" >/dev/null; then
arg1_is_great $___cmp
return
else
arg1_is_less $___cmp
return
fi
fi
# Remove the chunk
___str1="${___str1#$___chunk1}"
___str2="${___str2#$___chunk2}"
done
# Either STR1, STR2 or both is empty here
if [ -n "$___str1" ]; then
case "$___str1" in
~*) arg1_is_less $___cmp ;;
*) arg1_is_great $___cmp ;;
esac
elif [ -n "$___str2" ]; then
case "$___str2" in
~*) arg1_is_great $___cmp ;;
*) arg1_is_less $___cmp ;;
esac
else
arg1_is_same $___cmp
fi
}
#
# Recursively solve package dependencies
#
# Result is in the PKG_LIST variable
#
all_required_config_files () {
all_list=""
new_list=""
p=""
pkg=""
cmp=""
list=$*
while [ -n "$list" ]; do
for p in $list; do
if [ -z "$pkg" ]; then
pkg=$p
elif [ -z "$cmp" ]; then
case "$p" in
"="|"!="|"<"|">"|"<="|">=") cmp=$p ;;
*)
read_config_file $pkg $PKG_CONFIG_PATH
all_list="$all_list${all_list:+ }$pkg"
new_list="$new_list${new_list:+ }$(get_attr Requires)"
cleanup_vars_attrs
pkg=$p
;;
esac
else
read_config_file $pkg $PKG_CONFIG_PATH
if ! eval_compare_version "$(get_attr Version)" $cmp $p; then
echo "Version mismatch for $pkg $cmp $p: $(get_attr Version)" 1>&2
exit 1
fi
all_list="$all_list${all_list:+ }$pkg"
new_list="$new_list${new_list:+ }$(get_attr Requires)"
cleanup_vars_attrs
pkg=""
cmp=""
fi
done
if [ -n "$cmp" ]; then
echo "No version after comparison operator ($cmp): $pkg" 1>&2
exit 1
elif [ -n "$pkg" ]; then
read_config_file $pkg $PKG_CONFIG_PATH
all_list="$all_list${all_list:+ }$pkg"
new_list="$new_list${new_list:+ }$(get_attr Requires)"
cleanup_vars_attrs
fi
list="$new_list"
new_list=""
done
PKG_LIST=$(list_only_once $all_list)
}
#
# Modify -I or -L by PKG_CONFIG_SYSROOT_DIR variable
#
sysroot () {
_opt="$1"
_result=""
shift
while [ $# -gt 0 ]; do
if [ $1 = $_opt ]; then
_result="$_result${_result:+ }$_opt"
shift
_result="$_result $PKG_CONFIG_SYSROOT_DIR$1"
elif expr "$1" : "^$_opt" >/dev/null; then
_result="$_result${_result:+ }$_opt$PKG_CONFIG_SYSROOT_DIR$(expr "$1" : "^$_opt\(.*\)")"
else
_result="$_result${_result:+ }$1"
fi
shift
done
echo "$_result"
}
-#### end of functions for this script
-
-myname=${0##*/}
-if [ $myname = gpgrt-config ]; then
- default_module="gpg-error"
-else
- default_module=${myname%-config}
-fi
-
-usage()
-{
+# Show usage
+usage () {
cat <&2
+ echo "When LIBDIR has variable references for prefix and/or exec_prefix," 1>&2
+ echo "you should provide --prefix=PREFIX option and/or" 1>&2
+ echo "--exec-prefix=EXEC_PREFIX option, too" 1>&2
+ exit 1
+fi
+
+PKG_CONFIG_PATH="$PKG_CONFIG_PATH${PKG_CONFIG_PATH:+:}$PKG_CONFIG_LIBDIR"
+#
if test $# -eq 0; then
usage 1 1>&2
fi
+# Second stage to do the main functionality
+
module_list=""
want_var=""
want_attr=""
want_cflags=""
want_libs=""
want_exists=""
cflags=""
libs=""
mtcflags=""
mtlibs=""
delimiter=" "
output=""
mt="no"
VAR_list=VAR_pc_sysrootdir
if [ -z "$PKG_CONFIG_SYSROOT_DIR" ]; then
VAR_pc_sysrootdir="/"
else
VAR_pc_sysrootdir="$PKG_CONFIG_SYSROOT_DIR"
fi
while test $# -gt 0; do
case $1 in
#### pkg-config incompatible options: begin
--prefix)
# In future, use --variable=prefix instead.
want_var=prefix
;;
--exec-prefix)
# In future, use --variable=exec_prefix instead.
want_var=exec_prefix
;;
--version)
# In future, use --modversion instead.
want_attr=Version
delimiter="
"
;;
--api-version)
# In future, use --variable=api_version instead.
want_var=api_version
;;
--host)
# In future, use --variable=host instead.
want_var=host
;;
--mt)
# In future, use --variable=mtcflags or --variable=mtlibs.
mt=yes
;;
#### pkg-config incompatible options: end
--modversion)
want_attr=Version
delimiter="
"
;;
--exists)
want_exists=yes
;;
--cflags)
want_cflags=yes
;;
--libs)
want_libs=yes
;;
--variable=*)
want_var=${1#*=}
;;
--help)
usage 0
;;
--*)
usage 1 1>&2
;;
*)
# Modules
module_list="$module_list${module_list:+ }$1"
;;
esac
shift
done
if [ -z "$module_list" ]; then
module_list=$default_module
elif expr match "$module_list" "=\|!=\|<\|>\|<=\|>=" >/dev/null; then
module_list="$default_module $module_list"
fi
all_required_config_files $module_list
for p in $PKG_LIST; do
read_config_file $p $PKG_CONFIG_PATH
# For want_var or want_attr, get it from the first package
if [ -n "$want_var" ]; then
output="$(get_var $want_var)"
break
elif [ -n "$want_attr" ]; then
output="$(get_attr $want_attr)"
break
else
cflags="$cflags${cflags:+ }$(get_attr Cflags)"
libs="$libs${libs:+ }$(get_attr Libs)"
if [ $p = "gpg-error" ]; then
mtcflags="$(get_var mtcflags)"
mtlibs="$(get_var mtlibs)"
fi
fi
cleanup_vars_attrs
done
if [ -z "$want_var" -a -z "$want_attr" ]; then
if [ -n "$want_cflags" ]; then
output="$output${output:+ }$(sysroot -I $(list_only_once $cflags))"
# Backward compatibility to old gpg-error-config
if [ $mt = yes -a -n "$mtcflags" ]; then
output="$output${output:+ }$mtcflags"
fi
fi
if [ -n "$want_libs" ]; then
output="$output${output:+ }$(sysroot -L $(list_only_once_for_libs $libs))"
# Backward compatibility to old gpg-error-config
if [ $mt = yes -a -n "$mtlibs" ]; then
output="$output${output:+ }$mtlibs"
fi
fi
fi
if [ -z "$want_exists" ]; then
echo "$output"
fi
exit 0
diff --git a/src/gpgrt.m4 b/src/gpgrt.m4
index fab1eb4..7f92a22 100644
--- a/src/gpgrt.m4
+++ b/src/gpgrt.m4
@@ -1,132 +1,135 @@
# gpgrt.m4 - autoconf macro to detect libgpgrt
# Copyright (C) 2002, 2003, 2004, 2011, 2014, 2017, 2018 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.
# SPDX-License-Identifier: FSFULLR
#
-# Last-changed: 2018-10-25
+# Last-changed: 2018-10-29
# Note: This is a kind of duplicate of gpg-error.m4 with uses the
# future name of libgpg-error to prepare for a smooth migration in
# some distant time.
dnl AM_PATH_GPGRT([MINIMUM-VERSION,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
dnl
dnl Test for libgpgrt and define GPGRT_CFLAGS, GPGRT_LIBS,
dnl GPGRT_MT_CFLAGS, and GPGRT_MT_LIBS. The _MT_ variants are
dnl used for programs requiring real multi thread support.
dnl
dnl If a prefix option is not used, the config script is first
dnl searched in $SYSROOT/bin and then along $PATH. If the used
dnl config script does not match the host specification the script
dnl is added to the gpg_config_script_warn variable.
dnl
AC_DEFUN([AM_PATH_GPGRT],
[ AC_REQUIRE([AC_CANONICAL_HOST])
gpgrt_config_prefix=""
dnl --with-libgpg-error-prefix=PFX is the preferred name for this option,
dnl since that is consistent with how our three siblings use the directory/
dnl package name in --with-$dir_name-prefix=PFX.
AC_ARG_WITH(libgpg-error-prefix,
AC_HELP_STRING([--with-libgpg-error-prefix=PFX],
[prefix where GPG Error is installed (optional)]),
[gpgrt_config_prefix="$withval"])
dnl Accept --with-gpg-error-prefix and make it work the same as
dnl --with-libgpg-error-prefix above, for backwards compatibility,
dnl but do not document this old, inconsistently-named option.
AC_ARG_WITH(gpg-error-prefix,,
[gpgrt_config_prefix="$withval"])
dnl Also accept libgpgrt-prefix
AC_ARG_WITH(libgpgrt-prefix,
AC_HELP_STRING([--with-libgpgrt-prefix=PFX],
[prefix where GPG Runtime is installed (optional)]),
[gpgrt_config_prefix="$withval"])
if test x"${GPGRT_CONFIG}" = x ; then
if test x"${gpgrt_config_prefix}" != x ; then
GPGRT_CONFIG="${gpgrt_config_prefix}/bin/gpgrt-config"
else
case "${SYSROOT}" in
/*)
if test -x "${SYSROOT}/bin/gpgrt-config" ; then
GPGRT_CONFIG="${SYSROOT}/bin/gpgrt-config"
fi
;;
'')
;;
*)
AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
;;
esac
fi
fi
AC_PATH_PROG(GPGRT_CONFIG, gpgrt-config, no)
+ if test "$GPGRT_CONFIG" != "no"; then
+ GPGRT_CONFIG="$GPGRT_CONFIG --prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir"
+ fi
min_gpgrt_version=ifelse([$1], ,1.33,$1)
AC_MSG_CHECKING(for GPG Runtime - version >= $min_gpgrt_version)
ok=no
if test "$GPGRT_CONFIG" != "no" \
&& test -f "$GPGRT_CONFIG" ; then
req_major=`echo $min_gpgrt_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
req_minor=`echo $min_gpgrt_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
- gpgrt_config_version=`CC=$CC $GPGRT_CONFIG --version`
+ gpgrt_config_version=`$GPGRT_CONFIG --version`
major=`echo $gpgrt_config_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
minor=`echo $gpgrt_config_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'`
if test "$major" -gt "$req_major"; then
ok=yes
else
if test "$major" -eq "$req_major"; then
if test "$minor" -ge "$req_minor"; then
ok=yes
fi
fi
fi
fi
if test $ok = yes; then
- GPGRT_CFLAGS=`CC=$CC $GPGRT_CONFIG --cflags`
- GPGRT_LIBS=`CC=$CC $GPGRT_CONFIG --libs`
- GPGRT_MT_CFLAGS=`CC=$CC $GPGRT_CONFIG --variable=mtcflags 2>/dev/null`
+ GPGRT_CFLAGS=`$GPGRT_CONFIG --cflags`
+ GPGRT_LIBS=`$GPGRT_CONFIG --libs`
+ GPGRT_MT_CFLAGS=`$GPGRT_CONFIG --variable=mtcflags 2>/dev/null`
GPGRT_MT_CFLAGS="$GPGRT_CFLAGS${GPGRT_CFLAGS:+ }$GPGRT_MT_CFLAGS"
- GPGRT_MT_LIBS=`CC=$CC $GPGRT_CONFIG --variable=mtlibs 2>/dev/null`
+ GPGRT_MT_LIBS=`$GPGRT_CONFIG --variable=mtlibs 2>/dev/null`
GPGRT_MT_LIBS="$GPGRT_LIBS${GPGRT_LIBS:+ }$GPGRT_MT_LIBS"
AC_MSG_RESULT([yes ($gpgrt_config_version)])
ifelse([$2], , :, [$2])
- gpgrt_config_host=`CC=$CC $GPGRT_CONFIG --variable=host 2>/dev/null || echo none`
+ gpgrt_config_host=`$GPGRT_CONFIG --variable=host 2>/dev/null || echo none`
if test x"$gpgrt_config_host" != xnone ; then
if test x"$gpgrt_config_host" != x"$host" ; then
AC_MSG_WARN([[
***
*** The config script $GPGRT_CONFIG was
*** built for $gpgrt_config_host and thus may not match the
*** used host $host.
*** You may want to use the configure option --with-libgpgrt-prefix
*** to specify a matching config script or use \$SYSROOT.
***]])
gpg_config_script_warn="$gpg_config_script_warn libgpgrt"
fi
fi
else
GPGRT_CFLAGS=""
GPGRT_LIBS=""
GPGRT_MT_CFLAGS=""
GPGRT_MT_LIBS=""
AC_MSG_RESULT(no)
ifelse([$3], , :, [$3])
fi
AC_SUBST(GPGRT_CFLAGS)
AC_SUBST(GPGRT_LIBS)
AC_SUBST(GPGRT_MT_CFLAGS)
AC_SUBST(GPGRT_MT_LIBS)
])