#!/usr/bin/make -f #export DH_VERBOSE = 1 VER := $(shell dpkg-query -W binutils-source | cut -f2 | cut -d'-' -f1) DVER := $(shell dpkg-query -W binutils-source | cut -f2) DEB_NAME_ACT := $(shell dpkg-parsechangelog| sed -n 's/-*//; s/^Source: \(.*\)/\1/p') DEB_SVER_ACT := $(shell dpkg-parsechangelog| sed -n 's/-*//; s/^Version: \(.*\)/\1/p') DEB_CVER_ACT := $(shell dpkg-parsechangelog |egrep ^Version:| sed 's/.*c[ros]*\(.*\)/\1/') CROSS_EXT := cross$(DEB_CVER_ACT) DVER_T = $(DVER)$(CROSS_EXT) ARCHIVE_VER := $(shell apt-cache show --no-all-versions binutils-mipsisa64r6-linux-gnuabi64 2>/dev/null| awk '/^Version:/ { print $$2 }') ifeq (,$(ARCHIVE_VER)) ARCHIVE_VER := 0 endif ifeq (error,$(shell dpkg --compare-versions $(ARCHIVE_VER) ge $(DVER_T) && echo "error")) $(warning Version in Debian Archive >= Version in debian/changelog) endif HOST_ARCH = amd64 i386 x32 ARCHS = mips64 mipsn32 mipsn32el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el TRIPLE = $(foreach a,$(ARCHS),$(shell dpkg-architecture -f -a$(a) -qDEB_HOST_GNU_TYPE)) stamp-dir/control: cat debian/control.in > debian/control.tmp nl=0; IFS= ; while read -r line; do \ if [ "$$line" = "" ];then \ nl=0; \ continue; \ fi; \ for t in $(TRIPLE); do \ tmp=`echo $$line | grep "Package: binutils-$$t"`; \ if [ -n "$$tmp" ];then \ echo ""; \ echo $$line; \ nl=1; \ continue 2; \ fi; \ done; \ if [ $$nl -eq 1 ] && [ "$$line" != "" ];then \ echo $$line; \ fi; \ done < /usr/src/binutils/debian/control >> debian/control.tmp sed -i 's/^Architecture: .*/Architecture: $(HOST_ARCH)/g' debian/control.tmp sed -i 's/binutils-common (= [^ ]*)/binutils-common/g' debian/control.tmp sed -i 's/binutils-doc (= [^ ]*)/binutils-doc/g' debian/control.tmp mv debian/control.tmp debian/control touch $@ clean: rm -rf binutils* libbinutils* stamp-dir/* debian/control.tmp stamp-dir/prepare: stamp-dir/control rm -rf binutils* libbinutils* rm -f debian/files tar xf /usr/src/binutils/binutils-$(VER).tar.xz cp -r /usr/src/binutils/debian binutils-$(VER)/ cp -r /usr/src/binutils/patches binutils-$(VER)/debian sed -i '/.*ps aux.*/d' binutils-$(VER)/debian/rules sed -i 's/amd64 i386 x32 arm64 ppc64el))/amd64 i386 x32))/' binutils-$(VER)/debian/rules sed -i 's/src_name := .*/src_name := $(DEB_NAME_ACT)/g' binutils-$(VER)/debian/rules env -i make -C binutils-$(VER) -f debian/rules stamps/control ## don't try to make it simpler .... touch $@ stamp-dir/build: stamp-dir/prepare cd binutils-$(VER); \ DEB_BUILD_OPTIONS="nomult nohppa" CROSS_ARCHS="$(ARCHS)" dpkg-buildpackage -B -d -uc -us touch $@ $(ARCHS): build-arch gnu_type=`dpkg-architecture -f -a$@ -qDEB_HOST_GNU_TYPE`; \ for type in $$gnu_type $${gnu_type}-dbg; do \ pkg="binutils-$${type}_$(DVER)_$(DEB_HOST_ARCH).deb"; \ pkg_d=binutils-$${type}_$(DVER_T)_$(DEB_HOST_ARCH); \ rm -rf $$pkg_d; \ echo dpkg-deb -R $$pkg $$pkg_d; \ dpkg-deb -R $$pkg $$pkg_d; \ sed -i 's/Source: binutils/Source: $(DEB_NAME_ACT) ($(DEB_SVER_ACT))/g' $$pkg_d/DEBIAN/control; \ sed -i 's/Version: .*/Version: $(DVER_T)/g' $$pkg_d/DEBIAN/control; \ sed -i '/^Built-Using/! s/ (= $(DVER))/ (>= $(DVER))/g' $$pkg_d/DEBIAN/control; \ if [ -f "$$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz" ]; then \ mv -f $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.binutils.gz; \ gzip -c9n debian/changelog > $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz; \ chmod 0644 $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz; \ rm -f $$pkg_d/DEBIAN/md5sums; \ (cd $$pkg_d && find usr -type f | LC_ALL=C sort | xargs -r md5sum >>DEBIAN/md5sums); \ fi; \ dpkg-deb -b $$pkg_d ../$${pkg_d}.deb; \ echo -n "$${pkg_d}.deb " >> debian/files; \ dpkg-deb -I ../$${pkg_d}.deb | grep Section | cut -d ' ' -f 3 | tr "\n" ' ' >>debian/files; \ dpkg-deb -I ../$${pkg_d}.deb | grep Priority | cut -d ' ' -f 3 | tr -d "\n" >>debian/files; \ echo "" >> debian/files; \ done build-arch: stamp-dir/build build-indep: build: build-arch build-indep binary-arch: $(ARCHS) binary-indep: binary: binary-arch binary-indep .PHONY: binary binary-arch binary-indep clean checkroot $(ARCHS) build-arch build-indep