diff --git a/src/Makefile.am b/src/Makefile.am
index c1efb94..5ba1496 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,340 +1,341 @@
# Makefile.am for libgpg-error.
# Copyright (C) 2003, 2004, 2014 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 Lesser General Public
# License along with this program; if not, see .
# 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-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-pc-gnu.h \
syscfg/lock-obj-pub.i686-pc-kfreebsd-gnu.h \
syscfg/lock-obj-pub.i686-pc-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-ibm-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-pc-kfreebsd-gnu.h \
syscfg/lock-obj-pub.x86_64-pc-linux-gnu.h \
syscfg/lock-obj-pub.x86_64-pc-linux-gnux32.h \
syscfg/lock-obj-pub.x86_64-pc-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 = gpg-error-config
nodist_bin_SCRIPTS = gpgrt-config
m4datadir = $(datadir)/aclocal
m4data_DATA = gpg-error.m4 gpgrt.m4
pkgconfigdir = $(datadir)/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.pc.in \
gpg-error.m4 gpgrt.m4 \
gpg-error.vers gpg-error.def.in \
versioninfo.rc.in gpg-error.w32-manifest.in \
$(lock_obj_pub)
BUILT_SOURCES = err-sources.h 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 \
gpgrt-config gpg-error.def mkw32errmap.map.c
tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
gpg-error.h gpgrt.h gpgrt-config \
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) $(tmp_files) lock-obj-pub.native.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
else
pre_mkheader_cmds = :
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) $(host_os) $(host_triplet) $(srcdir)/gpg-error.h.in \
../config.h $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@
gpgrt.h: gpg-error.h
cp gpg-error.h gpgrt.h
gpgrt-config: gpg-error-config
cp gpg-error-config gpgrt-config
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-new.in b/src/gpg-error-config-new.in
index 307b3df..ddf6af2 100644
--- a/src/gpg-error-config-new.in
+++ b/src/gpg-error-config-new.in
@@ -1,538 +1,541 @@
#!/bin/sh
# Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
#
# 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@
datarootdir=@datarootdir@
datadir=@datadir@
PKG_CONFIG_PATH="$PKG_CONFIG_PATH${PKG_CONFIG_PATH:+:}${datadir}/pkgconfig"
#
-#### start of pkgconf-funcs
+#### 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 () {
local 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 () {
local name=$1
eval echo \$ATTR_$name
}
# Remove ${varname} part in the beginning of a string.
remove_var_expr () {
local varname=$1
shift
eval echo \"\${@#\\\$\\\{$varname\\\}}\"
}
# Given a string, substitute variables.
substitute_vars () {
local string="$1"
local line
local varname
local 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 () {
local filename=$1
local line
local varname
local value
local key
local 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_$varname"
read VAR_$varname <&2
exit 1
;;
esac
fi
done
}
find_file_in_path () {
local f=$1
local p=$2
local IFS=":" # On Windows it should be ";"???
for d in $p; do
if [ -r $d/$f ]; then
RESULT="$d/$f"
return 0
fi
done
RESULT=""
return 1
}
read_config_file () {
local config_file
local RESULT
if find_file_in_path $1.pc $2; then
config_file=$RESULT
else
echo "Can't find $1.pc" 1>&2
exit 1
fi
read_config_from_stdin $config_file < $config_file
}
cleanup_vars_attrs () {
eval unset $VAR_list VAR_list
eval unset $ATTR_list ATTR_list
}
not_listed_yet () {
local m=$1
local arg
shift
for arg; do
if [ $m = $arg ]; then
return 1
fi
done
return 0
}
list_only_once () {
local result=""
local arg
for arg; do
if not_listed_yet $arg $result; then
result="$result $arg"
fi
done
echo $result
}
list_only_once_for_libs () {
local result=""
local rev_list=""
local 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"
;;
*)
if not_listed_yet $arg $rev_list; then
rev_list="$arg $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"
fi
;;
*)
# As-is
result="$arg $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 () {
local str1="$1"
local cmp="$2"
local str2="$3"
local char1 char2
local 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 () {
local list
local all_list
local new_list
local p pkg cmp ver
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 $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 $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 $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)
}
-#### end of pkgconf-funcs
+#### end of functions for this script
myname=${0##*/}
+# Just for a while for testing
+myname=${myname%-new}
+##############################
if [ $myname = gpgrt-config ]; then
myname="gpg-error-config"
fi
usage()
{
cat <&2
fi
if [ "$1" != "--mt" ]; then
mt=no
else
# In future, use --variable=mtcflags or --variable=mtlibs
mt=yes
shift
fi
modules=""
want_var=""
want_attr=""
want_cflags=""
want_libs=""
cflags=""
libs=""
mtcflags=""
mtlibs=""
delimiter=" "
output=""
while test $# -gt 0; do
case $1 in
--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="
"
;;
--modversion)
want_attr=Version
delimiter="
"
;;
--cflags)
want_cflags=yes
;;
--libs)
want_libs=yes
;;
--variable=*)
want_var=${1#*=}
;;
--host)
# In future, use --variable=host instead.
want_var=host
;;
--help)
usage 0
;;
--*)
usage 1 1>&2
;;
*)
# Modules
modules="$modules${modules:+ }$1"
;;
esac
shift
done
if [ -z "$modules" ]; then
modules=${myname%-config}
elif expr match "$modules" "=\|!=\|<\|>\|<=\|>=" >/dev/null; then
modules="${myname%-config} $modules"
fi
all_required_config_files $modules
for p in $pkg_list; do
read_config_file $p $PKG_CONFIG_PATH
if [ -n "$want_var" ]; then
output="$output${output:+$delimiter}$(get_var $want_var)"
elif [ -n "$want_attr" ]; then
output="$output${output:+$delimiter}$(get_attr $want_attr)"
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:+ }$(list_only_once $cflags)"
# Backward compatibility to old gpg-error-config
- if [ $mt = yes ]; then
- output="$output $mtcflags"
+ if [ $mt = yes -a -n "$mtcflags" ]; then
+ output="$output${output:+ }$mtcflags"
fi
fi
if [ -n "$want_libs" ]; then
output="$output${output:+ }$(list_only_once_for_libs $libs)"
# Backward compatibility to old gpg-error-config
- if [ $mt = yes ]; then
- output="$output $mtlibs"
+ if [ $mt = yes -a -n "$mtlibs" ]; then
+ output="$output${output:+ }$mtlibs"
fi
fi
fi
echo "$output"
diff --git a/src/gpg-error-config-test.sh b/src/gpg-error-config-test.sh
new file mode 100755
index 0000000..d65c06d
--- /dev/null
+++ b/src/gpg-error-config-test.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+PKG_CONFIG_PATH="."
+
+export PKG_CONFIG_PATH
+
+OUTPUT_OLD=$(./gpg-error-config --version)
+OUTPUT_NEW=$(./gpg-error-config-new --version)
+[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || exit 99
+
+OUTPUT_OLD=$(./gpg-error-config --libs)
+OUTPUT_NEW=$(./gpg-error-config-new --libs)
+[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || exit 99
+
+OUTPUT_OLD=$(./gpg-error-config --cflags)
+OUTPUT_NEW=$(./gpg-error-config-new --cflags)
+[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || exit 99
+
+OUTPUT_OLD=$(./gpg-error-config --mt --libs)
+OUTPUT_NEW=$(./gpg-error-config-new --mt --libs)
+[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || exit 99
+
+OUTPUT_OLD=$(./gpg-error-config --mt --cflags)
+OUTPUT_NEW=$(./gpg-error-config-new --mt --cflags)
+[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || exit 99
+
+OUTPUT_OLD=$(./gpg-error-config --cflags --libs)
+OUTPUT_NEW=$(./gpg-error-config-new --cflags --libs)
+[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || exit 99
+
+OUTPUT_OLD=$(./gpg-error-config --mt --cflags --libs)
+OUTPUT_NEW=$(./gpg-error-config-new --mt --cflags --libs)
+[ "$OUTPUT_OLD" = "$OUTPUT_NEW" ] || exit 99
+
+exit 0