| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
VER := $(shell dpkg-query -W binutils-source | cut -f2 | cut -d'-' -f1 | cut -d'.' -f1-3) |
| 5 |
DVER := $(shell dpkg-query -W binutils-source | cut -f2) |
| 6 |
DEB_NAME_ACT := $(shell dpkg-parsechangelog| sed -n 's/-*//; s/^Source: \(.*\)/\1/p') |
| 7 |
DEB_SVER_ACT := $(shell dpkg-parsechangelog| sed -n 's/-*//; s/+b.*//g; s/^Version: \(.*\)/\1/p') |
| 8 |
DEB_CVER_ACT := $(shell dpkg-parsechangelog |egrep ^Version:| sed 's/.*c[ros]*\(.*\)/\1/') |
| 9 |
CROSS_EXT := cross$(DEB_CVER_ACT) |
| 10 |
DVER_T = $(DVER)$(CROSS_EXT) |
| 11 |
ARCHIVE_VER := $(shell apt-cache show --no-all-versions binutils-mipsisa64r6-linux-gnuabi64 2>/dev/null| awk '/^Version:/ { print $$2 }') |
| 12 |
ifeq (,$(ARCHIVE_VER)) |
| 13 |
ARCHIVE_VER := 0 |
| 14 |
endif |
| 15 |
ifeq (error,$(shell dpkg --compare-versions $(ARCHIVE_VER) ge $(DVER_T) && echo "error")) |
| 16 |
$(warning Version in Debian Archive >= Version in debian/changelog) |
| 17 |
endif |
| 18 |
|
| 19 |
HOST_ARCH = amd64 i386 x32 mips64el mipsel mips64r6el arm64 ppc64el |
| 20 |
|
| 21 |
ARCHS = mips mipsel mips64 mips64el mipsn32 mipsn32el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el |
| 22 |
ARCHSF = $(filter-out $(DEB_HOST_ARCH), $(ARCHS)) |
| 23 |
ARCHS_MAP = $(foreach a,$(ARCHS),$(shell echo -n "$(a)="; dpkg-architecture -f -a$(a) -qDEB_HOST_GNU_TYPE)) |
| 24 |
|
| 25 |
TRIPLE = $(foreach a,$(ARCHS),$(shell dpkg-architecture -f -a$(a) -qDEB_HOST_GNU_TYPE)) |
| 26 |
|
| 27 |
stamp-dir/control: stamp-dir/prepare |
| 28 |
cat debian/control.in > debian/control.tmp |
| 29 |
echo $(ARCHS_MAP) > stamp-dir/archmap.tmp |
| 30 |
echo $(HOST_ARCH) >> stamp-dir/archmap.tmp |
| 31 |
cp binutils-$(VER)/debian/control stamp-dir/fullc.tmp |
| 32 |
python3 debian/binary-control.py >> debian/control.tmp |
| 33 |
sed -i 's/binutils-common (= [^ ]*)/binutils-common/g' debian/control.tmp |
| 34 |
sed -i 's/binutils-doc (= [^ ]*)/binutils-doc/g' debian/control.tmp |
| 35 |
mv debian/control.tmp debian/control |
| 36 |
touch $@ |
| 37 |
|
| 38 |
clean: |
| 39 |
rm -rf binutils* libbinutils* stamp-dir/* debian/control.tmp debian/files *.deb |
| 40 |
|
| 41 |
stamp-dir/prepare: |
| 42 |
rm -rf binutils* libbinutils* |
| 43 |
rm -f debian/files |
| 44 |
tar xf /usr/src/binutils/binutils-$(VER).tar.xz |
| 45 |
cp -r /usr/src/binutils/debian binutils-$(VER)/ |
| 46 |
cp -r /usr/src/binutils/patches binutils-$(VER)/debian |
| 47 |
sed -i '/.*ps aux.*/d' binutils-$(VER)/debian/rules |
| 48 |
set -e; \ |
| 49 |
cd binutils-$(VER) ;\ |
| 50 |
for i in `ls $(CURDIR)/debian/patches/binutils/*.patch 2>/dev/null`; do \ |
| 51 |
patch -p1 < $$i; \ |
| 52 |
done; \ |
| 53 |
for a in $(ARCHS);do \ |
| 54 |
tmp=`echo $(HOST_ARCH) | sed "s/ $$a / /g" | sed "s/ $$a$$//g"`; \ |
| 55 |
sed -i "s/^HOST_ARCHS_$$a = .*/HOST_ARCHS_$$a = $$tmp/g" debian/rules; \ |
| 56 |
done |
| 57 |
sed -i '1 s/binutils /binutils-mipsen /g' binutils-$(VER)/debian/changelog |
| 58 |
sed -i '1 s/Source: binutils/Source: binutils-mipsen/g' binutils-$(VER)/debian/control.in |
| 59 |
env -i CROSS_ARCHS="$(ARCHSF)" PATH="/usr/bin:/bin" make -C binutils-$(VER) -f debian/rules stamps/control ## don't try to make it simpler .... |
| 60 |
touch $@ |
| 61 |
|
| 62 |
stamp-dir/build: stamp-dir/prepare |
| 63 |
cd binutils-$(VER); \ |
| 64 |
DEB_BUILD_OPTIONS="nomult nohppa $(filter nocheck parallel=%,$(DEB_BUILD_OPTIONS))" CROSS_ARCHS="$(ARCHSF)" dpkg-buildpackage -B -d -uc -us -a$(DEB_HOST_ARCH) |
| 65 |
touch $@ |
| 66 |
|
| 67 |
$(ARCHSF): build-arch |
| 68 |
gnu_type=`dpkg-architecture -f -a$@ -qDEB_HOST_GNU_TYPE`; \ |
| 69 |
for type in $$gnu_type $${gnu_type}-dbg; do \ |
| 70 |
pkg="binutils-$${type}_$(DVER)_$(DEB_HOST_ARCH).deb"; \ |
| 71 |
pkg_d=binutils-$${type}_$(DVER_T)_$(DEB_HOST_ARCH); \ |
| 72 |
rm -rf $$pkg_d; \ |
| 73 |
echo dpkg-deb -R $$pkg $$pkg_d; \ |
| 74 |
dpkg-deb -R $$pkg $$pkg_d; \ |
| 75 |
sed -i 's/Source: binutils.*/Source: $(DEB_NAME_ACT) ($(DEB_SVER_ACT))/g' $$pkg_d/DEBIAN/control; \ |
| 76 |
sed -i 's/Version: .*/Version: $(DVER_T)/g' $$pkg_d/DEBIAN/control; \ |
| 77 |
sed -i '/^Built-Using/! s/ (= $(DVER))/ (>= $(DVER))/g' $$pkg_d/DEBIAN/control; \ |
| 78 |
if [ -f "$$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz" ]; then \ |
| 79 |
mv -f $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.binutils.gz; \ |
| 80 |
gzip -c9n debian/changelog > $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz; \ |
| 81 |
chmod 0644 $$pkg_d/usr/share/doc/binutils-$${type}/changelog.Debian.gz; \ |
| 82 |
rm -f $$pkg_d/DEBIAN/md5sums; \ |
| 83 |
(cd $$pkg_d && find usr -type f | LC_ALL=C sort | xargs -r md5sum >>DEBIAN/md5sums); \ |
| 84 |
fi; \ |
| 85 |
dpkg-deb --root-owner-group -b $$pkg_d ../$${pkg_d}.deb; \ |
| 86 |
echo -n "$${pkg_d}.deb " >> debian/files; \ |
| 87 |
dpkg-deb -I ../$${pkg_d}.deb | grep Section | cut -d ' ' -f 3 | tr "\n" ' ' >>debian/files; \ |
| 88 |
dpkg-deb -I ../$${pkg_d}.deb | grep Priority | cut -d ' ' -f 3 | tr -d "\n" >>debian/files; \ |
| 89 |
echo "" >> debian/files; \ |
| 90 |
done |
| 91 |
|
| 92 |
build-arch: stamp-dir/build |
| 93 |
build-indep: |
| 94 |
build: build-arch build-indep |
| 95 |
|
| 96 |
binary-arch: $(ARCHSF) |
| 97 |
binary-indep: |
| 98 |
|
| 99 |
binary: binary-arch binary-indep |
| 100 |
|
| 101 |
.PHONY: binary binary-arch binary-indep clean checkroot $(ARCHS) build-arch build-indep |