First, note that this issue is more serious in jessie and stretch than
it was in wheezy, because in wheezy, libcurl4-*-dev Depended on a
bunch of packages that were not multiarch-compatible (and thus,
libcurl4-*-dev was not co-installable in practice.)  In jessie,
however, those other packages are merely Suggested.

Here are patches that should fix the issue (for the jessie version;
the same changes ought to work for the stretch/sid versions but I
haven't tried.)

(When I actually tried building these packages, for amd64 and i386, I
found that the curl-config scripts still differed, which was
apparently because I had 'libnghttp2-dev' installed in the amd64 build
system for some reason - it seems curl will use that package if it's
available.  I'm pretty sure that if both builds are done in clean
environments, the curl-config scripts will be identical.  But that's
something to be aware of, and maybe the package should either support
and build-depend on libnghttp2-dev, or explicitly disable it.)

One side issue that I didn't address is that `pkg-config --cflags
libcurl` will now output -I/usr/include/<triplet>, which is not ideal,
but acceptable (if you're using pkg-config and building for a
"foreign" architecture, you'll probably need to set appropriate
pkg-config environment variables anyway.)
In order to (partially) multi-arch-ify curl-config, remove all mention
of @includedir@ and @libdir@ from the script.  On Debian, the actual
header and library directories are architecture-dependent, but will
always be in the C compiler's default search path, so -I and -L
options are not necessary (and may be harmful in multi-arch
environments.)

Index: curl-7.38.0/curl-config.in
===================================================================
--- curl-7.38.0.orig/curl-config.in
+++ curl-7.38.0/curl-config.in
@@ -23,7 +23,6 @@
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
-includedir=@includedir@
 cppflag_curl_staticlib=@CPPFLAG_CURL_STATICLIB@
 
 usage()
@@ -134,19 +133,11 @@ while test $# -gt 0; do
         else
           CPPFLAG_CURL_STATICLIB=""
         fi
-        if test "X@includedir@" = "X/usr/include"; then
-          echo "$CPPFLAG_CURL_STATICLIB"
-        else
-          echo "${CPPFLAG_CURL_STATICLIB}-I@includedir@"
-        fi
+        echo "$CPPFLAG_CURL_STATICLIB"
         ;;
 
     --libs)
-        if test "X@libdir@" != "X/usr/lib" -a "X@libdir@" != "X/usr/lib64"; then
-           CURLLIBDIR="-L@libdir@ "
-        else
-           CURLLIBDIR=""
-        fi
+        CURLLIBDIR=""
         if test "X@REQUIRE_LIB_DEPS@" = "Xyes"; then
           echo ${CURLLIBDIR}-lcurl @LIBCURL_LIBS@
         else
@@ -156,7 +147,7 @@ while test $# -gt 0; do
 
     --static-libs)
         if test "X@ENABLE_STATIC@" != "Xno" ; then
-          echo @libdir@/libcurl.@libext@ @LDFLAGS@ @LIBCURL_LIBS@
+          echo -Wl,-Bstatic -lcurl -Wl,-Bdynamic @LDFLAGS@ @LIBCURL_LIBS@
         else
           echo "curl was built with static libraries disabled" >&2
           exit 1
--- curl-7.38.0.orig/debian/rules	2016-11-01 17:38:10.000000000 -0400
+++ curl-7.38.0/debian/rules	2016-12-14 16:15:53.852000000 -0500
@@ -9,9 +9,13 @@
 # enable all hardening options (see #763372)
 export DEB_BUILD_MAINT_OPTIONS:=hardening=+all
 
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+
 CONFIGURE_ARGS = -- --disable-dependency-tracking		\
 	--disable-symbol-hiding --enable-versioned-symbols	\
-	--enable-threaded-resolver --with-lber-lib=lber --with-gssapi=/usr
+	--enable-threaded-resolver --with-lber-lib=lber --with-gssapi=/usr \
+	--includedir=/usr/include/$(DEB_HOST_MULTIARCH)
 
 %:
 	dh $@
@@ -72,6 +76,27 @@
 	dh_install -pcurl -plibcurl3 -plibcurl4-openssl-dev -plibcurl4-doc \
 		--sourcedir=debian/tmp
 	sed -i "/dependency_libs/ s/'.*'/''/" `find . -name '*.la'`
+# Modify curl-config to make it architecture-independent:
+# 1. In --static-libs output, replace the output of krb5-config (which
+#    currently includes architecture-specific paths) with a call at
+#    runtime to krb5-config.  Of course, this will only work correctly
+#    if the installed libkrb5-dev matches the architecture of the
+#    program you're linking, or if libkrb5-dev is made
+#    multiarch-compatible at some point in the future.  For dynamic
+#    linking this has no impact.
+# 2. In --configure output, replace the architecture-specific paths
+#    used for --libdir and --libexecdir with a literal backquoted call
+#    to dpkg-architecture.  This is functionally equivalent to the way
+#    debhelper actually invokes configure, and indicates to the user
+#    (who runs curl-config --configure in order to learn about how the
+#    library was compiled) that they are in fact using a multi-arch
+#    package.
+# 3. Likewise, replace the architecture name used for --build (and
+#    build_alias) with a literal backquoted call to dpkg-architecture.
+	sed -e "/-lcurl /s|`krb5-config --libs gssapi`|\`krb5-config --libs gssapi\`|" \
+	    -e "/--prefix/s|/$(DEB_HOST_MULTIARCH)'|/'\\\\\`dpkg-architecture -qDEB_HOST_MULTIARCH\\\\\`|g" \
+	    -e "/--prefix/s|=$(DEB_BUILD_GNU_TYPE)'|='\\\\\`dpkg-architecture -qDEB_BUILD_GNU_TYPE\\\\\`|g" \
+	    -i `find . -name curl-config`
 
 override_dh_installchangelogs:
 	dh_installchangelogs CHANGES

Reply via email to