File: rules

package info (click to toggle)
binutils-mipsen 7%2Bc2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 148 kB
  • sloc: sh: 2,916; makefile: 104
file content (119 lines) | stat: -rwxr-xr-x 5,169 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/make -f
#export DH_VERBOSE = 1

VER := $(shell dpkg-query -W binutils-source | cut -f2 | cut -d'-' -f1 | cut -d'.' -f1-3)
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/+b.*//g; 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 mips64el mipsel mips64r6el arm64 ppc64el

ARCHS = mips mipsel mips64 mips64el mipsn32 mipsn32el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el
ARCHSF = $(filter-out $(DEB_HOST_ARCH), $(ARCHS))
ARCHS_MAP = $(foreach a,$(ARCHS),$(shell echo -n "$(a)="; dpkg-architecture -f -a$(a) -qDEB_HOST_GNU_TYPE))

TRIPLE = $(foreach a,$(ARCHS),$(shell dpkg-architecture -f -a$(a) -qDEB_HOST_GNU_TYPE))

stamp-dir/control: stamp-dir/prepare
	cat debian/control.in > debian/control.tmp
	nl=""; IFS= ; while read -r line; do \
	   if [ "$$line" = "" ];then \
	     nl=""; \
	     continue; \
	   fi; \
	   for a in $(ARCHS); do \
	     t=`echo $(ARCHS_MAP) | sed "s/.*$${a}=//g" | sed 's/ .*//g'`; \
	     tmp=`echo $$line | grep "Package: binutils-$$t"`; \
	     if [ -n "$$tmp" ];then \
	       echo ""; \
	       echo $$line; \
	       nl="$$a"; \
	       continue 2; \
	     fi; \
	   done; \
	   if [ "$$nl" != "" ] && [ "$$line" != "" ];then \
	     tmp=`echo $$line | grep '^Architecture: '`; \
	     if [ -n "$$tmp" ];then \
	       line=`echo "Architecture: $(HOST_ARCH)" | sed "s/ $$nl / /g" | sed "s/ $$nl$$//g"`; \
	     fi; \
	     echo $$line; \
	   fi; \
	done < binutils-$(VER)/debian/control >> 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 debian/files

stamp-dir/prepare:
	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
	set -e; \
	cd binutils-$(VER) ;\
	  for i in `ls $(CURDIR)/debian/patches/binutils/*.patch 2>/dev/null`; do \
	    patch -p1 < $$i; \
	  done; \
	  for a in $(ARCHS);do \
	    tmp=`echo $(HOST_ARCH) | sed "s/ $$a / /g" | sed "s/ $$a$$//g"`; \
	    sed -i "s/^HOST_ARCHS_$$a = .*/HOST_ARCHS_$$a = $$tmp/g" debian/rules; \
	  done
	sed -i 's/src_name := .*/src_name := $(DEB_NAME_ACT)/g' binutils-$(VER)/debian/rules
	env -i CROSS_ARCHS="$(ARCHSF)" 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 $(filter nocheck parallel=%,$(DEB_BUILD_OPTIONS))" CROSS_ARCHS="$(ARCHSF)" dpkg-buildpackage -B -d -uc -us -a$(DEB_HOST_ARCH)
	touch $@

$(ARCHSF): 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: $(ARCHSF) 
binary-indep:

binary: binary-arch binary-indep

.PHONY: binary binary-arch binary-indep clean checkroot $(ARCHS) build-arch build-indep