[PATCH 2/2] add pkg-config support

Mike Frysinger vapier at gentoo.org
Fri Sep 23 05:37:22 CEST 2011


This moves gpg-error into the pkg-config world which is a lot easier
to work with than random foo-config scripts.  This also implicitly
fixes the -L behavior regardless of the ABI in use which the previous
commit to this file tried to do but failed.

The old config script is kept due to the number of packages out there
that still rely on it, but it is just a wrapper to the pkg-config file.
Once we get those packages updated to use pkg-config too, we can drop
this wrapper.

Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 .gitignore              |    1 +
 configure.ac            |    7 ++++
 src/Makefile.am         |    4 ++-
 src/gpg-error-config.in |   90 +++++++++-------------------------------------
 src/gpg-error.pc.in     |   20 ++++++++++
 5 files changed, 49 insertions(+), 73 deletions(-)
 create mode 100644 src/gpg-error.pc.in

diff --git a/.gitignore b/.gitignore
index 377a67d..9e58db5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,7 @@ src/gpg-error
 src/gpg-error-config
 src/gpg-error.def
 src/gpg-error.h
+src/gpg-error.pc
 src/mkerrcodes
 src/mkerrcodes.h
 src/mkw32errmap.map.c
diff --git a/configure.ac b/configure.ac
index a2ad1dd..987811c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -151,6 +151,7 @@ AC_SUBST(GPG_ERROR_CONFIG_CFLAGS)
 AC_SUBST(GPG_ERROR_CONFIG_ISUBDIRAFTER)
 AC_SUBST(GPG_ERROR_CONFIG_HOST)
 AC_CONFIG_FILES([src/gpg-error-config], [chmod +x src/gpg-error-config])
+AC_CONFIG_FILES([src/gpg-error.pc])
 
 
 # Special defines for certain platforms
@@ -181,6 +182,12 @@ 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)
 
+# Note: -idirafter is a gcc extension.  It is only used on
+#       systems where gcc is the only compiler we support.
+if test "$GPG_ERROR_CONFIG_ISUBDIRAFTER" != ""; then
+    GPG_ERROR_CONFIG_CFLAGS=`printf ' -idirafter ${includedir}/%s' $GPG_ERROR_CONFIG_ISUBDIRAFTER`
+fi
+
 
 AC_ARG_ENABLE(languages,
 [  --disable-languages     do not build support for other languages than C])
diff --git a/src/Makefile.am b/src/Makefile.am
index 518a4c0..6a36a00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,8 @@ bin_PROGRAMS = gpg-error
 lib_LTLIBRARIES = libgpg-error.la
 include_HEADERS = gpg-error.h
 bin_SCRIPTS = gpg-error-config
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gpg-error.pc
 m4datadir = $(datadir)/aclocal
 m4data_DATA = gpg-error.m4
 
@@ -43,7 +45,7 @@ EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
 	mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \
 	mkheader.awk 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 \
-	gpg-error.def.in versioninfo.rc.in
+	gpg-error.def.in versioninfo.rc.in gpg-error.pc.in
 
 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 \
diff --git a/src/gpg-error-config.in b/src/gpg-error-config.in
index df27f0a..b6d7c57 100644
--- a/src/gpg-error-config.in
+++ b/src/gpg-error-config.in
@@ -9,18 +9,20 @@
 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
-
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-includedir=@includedir@
-libdir=@libdir@
-isubdirafter="@GPG_ERROR_CONFIG_ISUBDIRAFTER@"
-
-output=""
-
-usage()
-{
-    cat <<EOF
+# glue gpg-error-config flags to pkg-config during migration
+case $1 in
+--host)
+	exec echo "@GPG_ERROR_CONFIG_HOST@" ;;
+--version)
+	flag="--modversion" ;;
+--libs|--cflags)
+	flag="$1" ;;
+--prefix)
+	flag="--variable=prefix" ;;
+--exec-prefix)
+	flag="--variable=exec_prefix" ;;
+*)
+	cat <<EOF
 Usage: gpg-error-config [OPTIONS]
 Options:
 	[--prefix]
@@ -29,63 +31,7 @@ Options:
 	[--libs]
 	[--cflags]
 EOF
-    exit $1
-}
-
-if test $# -eq 0; then
-    usage 1 1>&2
-fi
-
-while test $# -gt 0; do
-    case "$1" in
-	-*=*)
-	    optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
-	    ;;
-	*)
-	    optarg=
-	    ;;
-    esac
-
-    case $1 in
-        --prefix)
-	    output="$output $prefix"
-	    ;;
-        --exec-prefix)
-	    output="$output $exec_prefix"
-	    ;;
-        --version)
-            echo "@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.
-            for i in $isubdirafter; do
-                output="$output -idirafter ${includedir}/${i}"
-            done
-	    output="$output @GPG_ERROR_CONFIG_CFLAGS@"
-	    ;;
-	--libs)
-	    case "$libdir" in
-		/usr/lib|/usr/lib64|/lib|/lib64) ;;
-		*)
-		    output="$output -L$libdir"
-		    ;;
-	    esac
-	    output="$output @GPG_ERROR_CONFIG_LIBS@"
-	    ;;
-        --host)
-            echo "@GPG_ERROR_CONFIG_HOST@"
-            exit 0
-            ;;
-	*)
-            usage 1 1>&2
-	    ;;
-    esac
-    shift
-done
-
-echo $output
+	exit 1
+	;;
+esac
+exec ${PKG_CONFIG:-pkg-config} gpg-error ${flag}
diff --git a/src/gpg-error.pc.in b/src/gpg-error.pc.in
new file mode 100644
index 0000000..64278d2
--- /dev/null
+++ b/src/gpg-error.pc.in
@@ -0,0 +1,20 @@
+# Copyright (C) 1999, 2002, 2003, 2011 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.
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+
+Name: @PACKAGE_NAME@
+Description: small library that defines common error values for all GnuPG components
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} @GPG_ERROR_CONFIG_LIBS@
+Cflags: -I${includedir} @GPG_ERROR_CONFIG_CFLAGS@
-- 
1.7.6.1




More information about the Gnupg-devel mailing list