Source: ldap2dns
Version: 0.3.1-3.2
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

ldap2dns fails to cross build from source for multiple reasons. For
starters, debian/rules fails to pass cross tools to make. Then the
upstream Makefile stuffs flags into the CC variable which get lost when
dh_auto_build substitutes it. Further down, it has a copy of CC called
LD, which doesn't get substituted. It lists -l flags as Makefile
dependencies. Doing so works fine during native compilation, because
make has an architecture-dependent search path. This is why make is not
marked Multi-Arch: foreign. Such dependencies do break cross building
and need to be avoided. Close to the end it strips with the build
architecture strip during make install. Beyond breaking cross
compilation, this breaks generation of -dbgsym packages as well as
DEB_BUILD_OPTIONS=nostrip (aka #437301). The attached patch fixes all of
that (including #437301).

Helmut
diff -u ldap2dns-0.3.1/Makefile ldap2dns-0.3.1/Makefile
--- ldap2dns-0.3.1/Makefile
+++ ldap2dns-0.3.1/Makefile
@@ -1,12 +1,14 @@
 # $Id: Makefile,v 1.29 2002/08/02 15:19:36 jrief Exp $ 
 VERSION=0.3.1
 RELEASE=1
-CC=gcc -O2
-CCDEBUG=gcc -g
+CC=gcc
+CCRELEASE=$(CC) -O2
+CCDEBUG=$(CC) -g
 CFLAGS=$(INC) -DVERSION='"$(VERSION)"'
 LIBS=-lldap -llber
-LD=gcc 
+LD=$(CC)
 LDFLAGS=
+INSTALL ?= install
 INSTALL_PREFIX=
 PREFIXDIR=$(INSTALL_PREFIX)/usr
 LDAPCONFDIR=$(INSTALL_PREFIX)/etc/ldap
@@ -15,17 +17,17 @@
 
 all: ldap2dns ldap2dnsd ldap2dns-dbg
 
-ldap2dns: ldap2dns.o $(LIBS) 
-       $(LD) $(LDFLAGS) -o $@ $+
+ldap2dns: ldap2dns.o $(filter-out -l%,$(LIBS))
+       $(LD) $(LDFLAGS) -o $@ $+ $(filter -l%,$(LIBS))
 
 ldap2dnsd: ldap2dns
        ln -sf ldap2dns ldap2dnsd
 
-ldap2dns-dbg: ldap2dns.o-dbg $(LIBS) 
-       $(LD) $(LDFLAGS) -o $@ $+
+ldap2dns-dbg: ldap2dns.o-dbg $(filter-out -l%,$(LIBS))
+       $(LD) $(LDFLAGS) -o $@ $+ $(filter -l%,$(LIBS))
 
 ldap2dns.o: ldap2dns.c
-       $(CC) $(CFLAGS) -c $< -o $@
+       $(CCRELEASE) $(CFLAGS) -c $< -o $@
 
 ldap2dns.o-dbg: ldap2dns.c
        $(CCDEBUG) $(CFLAGS) -c $< -o $@
@@ -33,16 +35,16 @@
 install: all
        mkdir -p $(PREFIXDIR)/bin
        mkdir -p $(LDAPCONFDIR)
-       install -s -o root -g root -m 755 ldap2dns $(PREFIXDIR)/bin/
+       $(INSTALL) -s -o root -g root -m 755 ldap2dns $(PREFIXDIR)/bin/
        #ln -sf $(PREFIXDIR)/bin/ldap2dns $(PREFIXDIR)/bin/ldap2dnsd
-       install -o root -g root -m 755 ldap2tinydns-conf $(PREFIXDIR)/bin/
+       $(INSTALL) -o root -g root -m 755 ldap2tinydns-conf $(PREFIXDIR)/bin/
        
        # OpenLDAP2
-       install -o root -g root -m 644 dns.schema $(LDAPCONFDIR)/schema/
+       $(INSTALL) -o root -g root -m 644 dns.schema $(LDAPCONFDIR)/schema/
        
        # OpenLDAP1
-       #install -o root -g root -m 644 dns.at.conf $(LDAPCONFDIR)/
-       #install -o root -g root -m 644 dns.oc.conf $(LDAPCONFDIR)/
+       #$(INSTALL) -o root -g root -m 644 dns.at.conf $(LDAPCONFDIR)/
+       #$(INSTALL) -o root -g root -m 644 dns.oc.conf $(LDAPCONFDIR)/
        
        # README.txt
        links -dump README.html > README.txt
diff -u ldap2dns-0.3.1/debian/changelog ldap2dns-0.3.1/debian/changelog
--- ldap2dns-0.3.1/debian/changelog
+++ ldap2dns-0.3.1/debian/changelog
@@ -1,3 +1,10 @@
+ldap2dns (0.3.1-3.3) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix cross building. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Mon, 16 Sep 2019 17:42:12 +0200
+
 ldap2dns (0.3.1-3.2) unstable; urgency=medium
 
   * Non-maintainer upload.
diff -u ldap2dns-0.3.1/debian/rules ldap2dns-0.3.1/debian/rules
--- ldap2dns-0.3.1/debian/rules
+++ ldap2dns-0.3.1/debian/rules
@@ -14,7 +14,7 @@
 build: configure-stamp build-stamp
 build-stamp:
        dh_testdir
-       $(MAKE)
+       dh_auto_build
        touch build-stamp
 
 clean:
@@ -29,7 +29,7 @@
        dh_testroot
        dh_clean -k
        dh_installdirs
-       $(MAKE) install INSTALL_PREFIX=$(CURDIR)/debian/ldap2dns
+       $(MAKE) install INSTALL_PREFIX=$(CURDIR)/debian/ldap2dns 
INSTALL='install --strip-program=true'
 
 # Build architecture-independent files here.
 binary-indep: build install

Reply via email to