Package: src:binutils
Version: 2.24.51.20140411-2
Severity: wishlist
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

While trying to work on binutils I got severely confused by its
debian/rules. This is why I start out with this patch, that (to the best
of my knowledge) aims to improve the situation in the following ways:

 * Some places use "usr" and others use "$(PF)". Thus changing the PF
   variable does no longer work. The patch restores $(PF) to working
   order. If that variable is no longer useful, then maybe using its
   only working value "usr" in all places is a better solution.
 
 * If $(TARGET) is non-empty, it contains what should be called
   DEB_TARGET_GNU_TYPE. I therefore introduce this new variable for both
   native and cross builds. All places that really want to know the
   target gnu type now use DEB_TARGET_GNU_TYPE. There are two kinds of
   variables being converted:
    + TARGET when it is not used to branch on being non-empty
    + DEB_HOST_GNU_TYPE when it DEB_TARGET_GNU_TYPE was meant

Please consider applying this patch or taking those parts that are
useful. If the patch is not deemed useful, please just close this
bugreport.

Thanks

Helmut
diff -u binutils-2.24.51.20140411/debian/changelog 
binutils-2.24.51.20140411/debian/changelog
--- binutils-2.24.51.20140411/debian/changelog
+++ binutils-2.24.51.20140411/debian/changelog
@@ -1,3 +1,10 @@
+binutils (2.24.51.20140411-2.1) UNRELEASED; urgency=low
+
+  * Non-maintainer upload.
+  * Refactor rules for consistent usage of DEB_TARGET_GNU_TYPE and PF.
+
+ -- Helmut Grohne <hel...@subdivi.de>  Fri, 25 Apr 2014 21:03:37 +0200
+
 binutils (2.24.51.20140411-2) unstable; urgency=medium
 
   * No-change rebuild to get rid off ftp-master mail storm.
diff -u binutils-2.24.51.20140411/debian/rules 
binutils-2.24.51.20140411/debian/rules
--- binutils-2.24.51.20140411/debian/rules
+++ binutils-2.24.51.20140411/debian/rules
@@ -68,9 +68,11 @@
   DPKG_TARGET_VARS := $(shell dpkg-architecture -f -t$(TARGET))
   DEB_TARGET_MULTIARCH = $(call vafilt,$(DPKG_TARGET_VARS),DEB_HOST_MULTIARCH)
   DEB_TARGET_ARCH      = $(call vafilt,$(DPKG_TARGET_VARS),DEB_HOST_ARCH)
+  DEB_TARGET_GNU_TYPE  = $(call vafilt,$(DPKG_TARGET_VARS),DEB_HOST_GNU_TYPE)
 else
   DEB_TARGET_MULTIARCH = $(DEB_HOST_MULTIARCH)
   DEB_TARGET_ARCH      = $(DEB_HOST_ARCH)
+  DEB_TARGET_GNU_TYPE  = $(DEB_HOST_GNU_TYPE)
 endif
 
 ifneq (,$(TARGET))
@@ -358,7 +360,7 @@
        -rm -rf debian/patched debian/tmp debian/files* debian/substvars
        -rm -f debian/*.orig debian/*.rej
        -rm -rf $(d_cross) debian/files debian/substvars 
-       -rm -rf builddir-$(TARGET) {configure,build,install}-cross-stamp
+       -rm -rf builddir-$(DEB_TARGET_GNU_TYPE) 
{configure,build,install}-cross-stamp
        for i in debian/*.in; do \
            case "$$i" in debian/control*.in) continue; esac; \
            rm -f $${i%*.in}; \
@@ -371,7 +373,7 @@
 control-stamp: debian/control.in $(if $(TARGET),debian/control.cross.in)
 ifneq (,$(TARGET))
        sed "/^$$/ q" < debian/control.in > debian/control
-       sed -e "s/__TARGET__/$$(echo -n $(TARGET) | sed s/_/-/g)/" \
+       sed -e "s/__TARGET__/$$(echo -n $(DEB_TARGET_GNU_TYPE) | sed s/_/-/g)/" 
\
                  < debian/control.cross.in >> debian/control
 else
        cp debian/control.in debian/control
@@ -766,19 +768,19 @@
          $(if $(with_gold),ld.gold dwp) \
          nm objcopy objdump ranlib readelf size strings strip; \
        do \
-         ln -sf $$i $(d_bin)/usr/bin/$(DEB_HOST_GNU_TYPE)-$$i; \
-         ln -sf $$i.1.gz 
$(d_bin)/usr/share/man/man1/$(DEB_HOST_GNU_TYPE)-$$i.1.gz; \
+         ln -sf $$i $(d_bin)/$(PF)/bin/$(DEB_TARGET_GNU_TYPE)-$$i; \
+         ln -sf $$i.1.gz 
$(d_bin)/$(PF)/share/man/man1/$(DEB_TARGET_GNU_TYPE)-$$i.1.gz; \
        done
 
-ifeq ($(DEB_HOST_ARCH),i386)
-  ifneq ($(DEB_HOST_GNU_TYPE),i586-linux-gnu)
+ifeq ($(DEB_TARGET_ARCH),i386)
+  ifneq ($(DEB_TARGET_GNU_TYPE),i586-linux-gnu)
        for i in \
          addr2line ar as c++filt elfedit gprof ld ld.bfd \
          $(if $(with_gold),ld.gold dwp) \
          nm objcopy objdump ranlib readelf size strings strip; \
        do \
-         ln -sf $$i $(d_bin)/usr/bin/i586-linux-gnu-$$i; \
-         ln -sf $$i.1.gz $(d_bin)/usr/share/man/man1/i586-linux-gnu-$$i.1.gz; \
+         ln -sf $$i $(d_bin)/$(PF)/bin/i586-linux-gnu-$$i; \
+         ln -sf $$i.1.gz 
$(d_bin)/$(PF)/share/man/man1/i586-linux-gnu-$$i.1.gz; \
        done
   endif
 endif
@@ -855,9 +857,9 @@
        $(install_dir) $(d_doc)/DEBIAN
 
 ifeq ($(GFDL_INVARIANT_FREE),yes)
-       rm -f $(d_doc)//usr/share/info/bfd.info*
-       rm -f $(d_doc)//usr/share/info/bfdint.info*
-       rm -f $(d_doc)//usr/share/info/ldint.info*
+       rm -f $(d_doc)//$(PF)/share/info/bfd.info*
+       rm -f $(d_doc)//$(PF)/share/info/bfdint.info*
+       rm -f $(d_doc)//$(PF)/share/info/ldint.info*
 endif
 
 ifneq ($(BACKPORT),true)
@@ -1117,7 +1119,7 @@
 # Process the following only if $(TARGET) is set
 ifneq (,$(TARGET))
 
-p_cross = $(subst _,-,binutils-$(TARGET))
+p_cross = $(subst _,-,binutils-$(DEB_TARGET_GNU_TYPE))
 d_cross = debian/$(p_cross)
 
 #-----------------------------------------------------------------
@@ -1142,33 +1144,33 @@
 configure-cross-stamp: patch-stamp control-stamp
        $(checkdir)
        test "" != "$(TARGET)"
-       rm -rf configure-cross-stamp builddir-$(TARGET)
-       mkdir builddir-$(TARGET)
-       cd builddir-$(TARGET) \
+       rm -rf configure-cross-stamp builddir-$(DEB_TARGET_GNU_TYPE)
+       mkdir builddir-$(DEB_TARGET_GNU_TYPE)
+       cd builddir-$(DEB_TARGET_GNU_TYPE) \
            && env CC="$(CC)" CXX="$(CXX)" ../configure \
                $(CONFARGS) \
-               --target=$(TARGET)
+               --target=$(DEB_TARGET_GNU_TYPE)
        touch $@
 
 build-cross-stamp: configure-cross-stamp
        $(checkdir)
        test "" != "$(TARGET)"
-       $(MAKE) -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)"
+       $(MAKE) -C builddir-$(DEB_TARGET_GNU_TYPE) $(NJOBS) CFLAGS="$(CFLAGS)"
        touch $@
 
 install-cross-stamp: build-cross-stamp
        $(checkdir)
        test "" != "$(TARGET)"
        rm -rf $(d_cross)
-       $(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/$(PF) \
+       $(MAKE) -C builddir-$(DEB_TARGET_GNU_TYPE) 
prefix=$(pwd)/$(d_cross)/$(PF) \
                mandir=$(pwd)/$(d_cross)/$(PF)/share/man install
        rm -rf $(d_cross)/$(PF)/lib* $(d_cross)/$(PF)/info 
$(d_cross)/$(PF)/share/locale
 
-       $(call strip_package, $(p_cross), 
$(d_cross),$(DEB_HOST_GNU_TYPE)/$(TARGET))
-       chmod ugo-x $(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(TARGET)/lib/*.so
+       $(call strip_package, $(p_cross), 
$(d_cross),$(DEB_HOST_GNU_TYPE)/$(DEB_TARGET_GNU_TYPE))
+       chmod ugo-x 
$(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(DEB_TARGET_GNU_TYPE)/lib/*.so
 
        : # Get rid of .la files since libtool obviously has no idea about 
transient paths
-       rm -f $(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(TARGET)/lib/*.la
+       rm -f 
$(d_cross)/$(PF)/$(DEB_HOST_GNU_TYPE)/$(DEB_TARGET_GNU_TYPE)/lib/*.la
 
        gzip -9 $(d_cross)/$(PF)/share/man/man1/*
        touch $@
@@ -1176,13 +1178,13 @@
 configure-host-cross-stamp: configure-cross-stamp
        $(checkdir)
        test "" != "$(TARGET)"
-       $(MAKE) configure-host -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)"
+       $(MAKE) configure-host -C builddir-$(DEB_TARGET_GNU_TYPE) $(NJOBS) 
CFLAGS="$(CFLAGS)"
        touch $@
 
 build-static-cross-stamp: configure-host-cross-stamp
        $(checkdir)
        test "" != "$(TARGET)"
-       $(MAKE) -C builddir-$(TARGET) $(NJOBS) CFLAGS="$(CFLAGS)" 
LDFLAGS="-all-static"
+       $(MAKE) -C builddir-$(DEB_TARGET_GNU_TYPE) $(NJOBS) CFLAGS="$(CFLAGS)" 
LDFLAGS="-all-static"
        touch $@
 
 install-static-cross-stamp: build-static-cross-stamp install-cross-stamp

Reply via email to