[git] GPG-ERROR - branch, gniibe/pkg-config-support, created. libgpg-error-1.32-3-ge91365e
by NIIBE Yutaka
cvs at cvs.gnupg.org
Tue Aug 28 08:41:10 CEST 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Error codes used by GnuPG et al.".
The branch, gniibe/pkg-config-support has been created
at e91365ef38ce020651353691c53c17c662f6c890 (commit)
- Log -----------------------------------------------------------------
commit e91365ef38ce020651353691c53c17c662f6c890
Author: NIIBE Yutaka <gniibe at fsij.org>
Date: Tue Aug 28 15:37:07 2018 +0900
pkg-config compatible .pc file support.
Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>
diff --git a/configure.ac b/configure.ac
index b5c01ba..1ea2135 100644
--- a/configure.ac
+++ b/configure.ac
@@ -491,13 +491,26 @@ else
fi
GPG_ERROR_CONFIG_ISUBDIRAFTER=""
GPG_ERROR_CONFIG_HOST="$host"
+case "$includedir" in
+ '${prefix}/include'|/usr/include|/include) GPG_ERROR_CONFIG_INCLUDEDIR="" ;;
+ *) GPG_ERROR_CONFIG_INCLUDEDIR="-I$includedir" ;;
+esac
+case "$libdir" in
+ '${exec_prefix}/lib'|/usr/lib|/usr/lib64|/lib|/lib64) GPG_ERROR_CONFIG_LIBDIR="" ;;
+ *) GPG_ERROR_CONFIG_LIBDIR="-L$libdir" ;;
+esac
+
+PKGCONF_FUNCS_SH_CONTENT=$(cat $srcdir/src/pkgconf-funcs.sh)
+
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_ISUBDIRAFTER)
AC_SUBST(GPG_ERROR_CONFIG_HOST)
-
+AC_SUBST(GPG_ERROR_CONFIG_INCLUDEDIR)
+AC_SUBST(GPG_ERROR_CONFIG_LIBDIR)
+AC_SUBST(PKGCONF_FUNCS_SH_CONTENT)
#
# Special defines for certain platforms
@@ -625,6 +638,7 @@ 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-config], [chmod +x src/gpg-error-config])
+AC_CONFIG_FILES([src/gpg-error.pc])
AC_OUTPUT
diff --git a/src/gpg-error-config.in b/src/gpg-error-config.in
index aa7cb67..a0a0141 100644
--- a/src/gpg-error-config.in
+++ b/src/gpg-error-config.in
@@ -11,10 +11,11 @@
# SPDX-License-Identifier: FSFULLR
prefix=@prefix@
-exec_prefix=@exec_prefix@
-includedir=@includedir@
-libdir=@libdir@
-isubdirafter="@GPG_ERROR_CONFIG_ISUBDIRAFTER@"
+datarootdir=@datarootdir@
+datadir=@datadir@
+PKG_CONFIG_PATH="${datadir}/pkgconfig"
+
+ at PKGCONF_FUNCS_SH_CONTENT@
if echo "$0" | grep gpg-error-config 2>/dev/null >/dev/null; then
myname="gpg-error-config"
@@ -22,8 +23,14 @@ else
myname="gpgrt-config"
fi
+if find_file_in_path ${myname%-config}.pc $PKG_CONFIG_PATH; then
+ CONFIG_FILE=$RESULT
+else
+ echo "Can't find ${myname%-config}.pc" 1>&2
+ exit 1
+fi
+
output=""
-mt=no
usage()
{
@@ -44,6 +51,15 @@ if test $# -eq 0; then
usage 1 1>&2
fi
+if [ "$1" != "--mt" ]; then
+ mt=no
+else
+ mt=yes
+ shift
+fi
+
+read_config_file < "$CONFIG_FILE"
+
while test $# -gt 0; do
case "$1" in
-*=*)
@@ -55,54 +71,48 @@ while test $# -gt 0; do
esac
case $1 in
- --mt)
- mt=yes
- ;;
- --prefix)
- output="$output $prefix"
+ --prefix)
+ output="$output $(get_var prefix)"
;;
- --exec-prefix)
- output="$output $exec_prefix"
+ --exec-prefix)
+ output="$output $(get_var exec_prefix)"
;;
- --version)
- echo "@PACKAGE_VERSION@"
+ --version)
+ echo "$(get_attr Version)"
exit 0
;;
- --cflags)
- if test "x$includedir" != "x/usr/include" -a "x$includedir" != "x/include"; then
- output="$output -I$includedir"
- fi
- # Note: -idirafter is a gcc extension. It is only used on
- # systems where gcc is the only compiler we support (WindowsCE).
- for i in $isubdirafter; do
- output="$output -idirafter ${includedir}/${i}"
- done
- output="$output @GPG_ERROR_CONFIG_CFLAGS@"
+ --cflags)
+ output="$output $(get_attr Cflags)"
if test $mt = yes ; then
- output="$output @GPG_ERROR_CONFIG_MT_CFLAGS@"
+ output="$output $(get_var mtcflags)"
fi
;;
--libs)
- case "$libdir" in
- /usr/lib|/usr/lib64|/lib|/lib64) ;;
- *)
- output="$output -L$libdir"
- ;;
- esac
- output="$output @GPG_ERROR_CONFIG_LIBS@"
+ output="$output $(get_attr Libs)"
if test $mt = yes ; then
- output="$output @GPG_ERROR_CONFIG_MT_LIBS@"
+ output="$output $(get_var mtlibs)"
fi
;;
- --host)
- echo "@GPG_ERROR_CONFIG_HOST@"
- exit 0
- ;;
+ --variable=*)
+ echo "$(get_var ${1#*=})"
+ exit 0
+ ;;
+ --host)
+ echo "$(get_var host)"
+ exit 0
+ ;;
*)
- usage 1 1>&2
+ usage 1 1>&2
;;
esac
shift
done
+#
+# Clean up
+#
+# eval unset $VAR_list VAR_list
+# eval unset $ATTR_list ATTR_list
+#
+
echo $output
diff --git a/src/gpg-error.pc.in b/src/gpg-error.pc.in
new file mode 100644
index 0000000..fe8b553
--- /dev/null
+++ b/src/gpg-error.pc.in
@@ -0,0 +1,15 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+isubdirafter=@GPG_ERROR_CONFIG_ISUBDIRAFTER@
+host=@GPG_ERROR_CONFIG_HOST@
+mtcflags=@GPG_ERROR_CONFIG_MT_CFLAGS@
+mtlibs=@GPG_ERROR_CONFIG_MT_LIBS@
+
+Name: gpg-error
+Description: GPG Runtime
+Version: @PACKAGE_VERSION@
+Cflags: @GPG_ERROR_CONFIG_INCLUDEDIR@ @GPG_ERROR_CONFIG_CFLAGS@
+Libs: @GPG_ERROR_CONFIG_LIBDIR@ @GPG_ERROR_CONFIG_LIBS@
+URL: https://www.gnupg.org/software/libgpg-error/index.html
diff --git a/src/pkgconf-funcs.sh b/src/pkgconf-funcs.sh
new file mode 100644
index 0000000..381243c
--- /dev/null
+++ b/src/pkgconf-funcs.sh
@@ -0,0 +1,119 @@
+#################### start of pkgconf-funcs
+
+#
+# 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_<NAME>"
+#
+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_<KEY>"
+#
+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 file
+#
+# 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_file () {
+ local line
+ local varname
+ local value
+ local key
+
+ while read line; do
+ case "$line" in
+ *=*)
+ varname="${line%%=*}"
+ value="${line#*=}"
+ VAR_list="$VAR_list VAR_$varname"
+ read VAR_$varname <<EOF1
+$(substitute_vars "$value")
+EOF1
+ ;;
+ *:\ *)
+ key="${line%%:\ *}"
+ value="${line#*:\ }"
+ ATTR_list="$ATTR_list ATTR_$key"
+ read ATTR_$key <<EOF2
+$(substitute_vars "$value")
+EOF2
+ ;;
+ esac
+ done
+}
+
+
+find_file_in_path () {
+ local f=$1
+ local p=$2
+ local IFS=":" # On Windows it should be ";"???
+
+ for d in $p; do
+ if [ -e $d/$f ]; then
+ RESULT="$d/$f"
+ return 0
+ fi
+ done
+ RESULT=""
+ return 1
+}
+#################### end of pkgconf-funcs
-----------------------------------------------------------------------
hooks/post-receive
--
Error codes used by GnuPG et al.
http://git.gnupg.org
More information about the Gnupg-commits
mailing list