Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 , := ,
4 space := $(EMPTY) $(EMPTY)
5
6 NJOBS =
7 # Support parallel=<n> in DEB_BUILD_OPTIONS (see #209008)
8 ifneq (,$(filter parallel=%,$(subst $(,), ,$(DEB_BUILD_OPTIONS))))
9 NJOBS := -j $(subst parallel=,,$(filter parallel=%,$(subst $(,),$(space),$(DEB_BUILD_OPTIONS))))
10 endif
11
12 vendor := $(shell if dpkg-vendor --derives-from Ubuntu; then echo Ubuntu; else echo Debian; fi)
13 distrelease := $(shell lsb_release -cs)
14
15 GCC_VER := $(shell dpkg-parsechangelog |egrep ^Source:|cut -f2 -d' '|cut -f2 -d'-')
16
17 ifeq ($(GCC_VER),11)
18 MIN_VER_GCC := 11.5.0-11~
19 PPA_VER_GCC := 11.5.0-11~
20 endif
21
22 ifndef MIN_VER_GCC
23 MIN_VER_GCC := ${GCC_VER}.0.1-0~
24 #MIN_VER_GCC := ${GCC_VER}-20160225-0~
25 endif
26
27 DEB_NAME_ACT := $(shell dpkg-parsechangelog| sed -n 's/-*//; s/^Source: \(.*\)/\1/p')
28 DEB_SVER_ACT := $(shell dpkg-parsechangelog| sed -n 's/-*//; s/^Version: \(.*\)/\1/p')
29 ifeq ($(DEB_NAME_ACT),gcc-$(GCC_VER)-cross-mipsen)
30 DEB_VER_ACT := $(shell /bin/sh debian/new_cross_version.sh mipsr6el)
31 else
32 DEB_VER_ACT := $(shell /bin/sh debian/new_cross_version.sh $(if $(filter $(DEB_NAME_ACT), gcc-$(GCC_VER)-cross),arm64,ppc64))
33 endif
34 CROSS_EXT := cross$(DEB_VER_ACT)
35
36 VER_GCC := $(shell dpkg-parsechangelog -l/usr/src/gcc-${GCC_VER}/debian/changelog | awk '/^Version:/ {print $$2}' | sed 's/-[^-]*$$//')
37 GCC_DIR := /usr/src/gcc-${GCC_VER}
38 GCC_TARBALL := $(wildcard $(GCC_DIR)/gcc-*.xz)
39 VER_BINUTILS := 2.39-6
40 MIN_VER_BINUTILS := 2.39-6
41 VER_ISL := 0.22.1-1~
42 MIN_VER_GLIBC := 2.32
43
44 DEB_VER_GCC := $(shell dpkg-parsechangelog -l${GCC_DIR}/debian/changelog | egrep '^Version:' | cut -f 2 -d ' ')
45
46 CROSS_BIARCH_armhf:=armel
47 CROSS_BIARCH_armel:=armhf
48 CROSS_BIARCH_powerpc:=ppc64
49 CROSS_BIARCH_s390x:=s390
50
51 HOST_ARCHS_alpha = amd64 i386 x32
52 # FIXME: adding amd64 in HOST_ARCHS_amd64 hard codes the indep build
53 # to amd64 buildds ...
54 HOST_ARCHS_amd64 = amd64 arm64 i386 ppc64el x32
55 HOST_ARCHS_arc = amd64 i386 x32
56 HOST_ARCHS_armhf = amd64 i386 x32 arm64 ppc64el
57 HOST_ARCHS_armel = amd64 i386 x32 arm64 ppc64el
58 HOST_ARCHS_arm64 = amd64 i386 x32 ppc64el
59 HOST_ARCHS_hppa = amd64 i386 x32
60 HOST_ARCHS_i386 = amd64 arm64 ppc64el x32
61 HOST_ARCHS_m68k = amd64 i386 x32
62 HOST_ARCHS_powerpc = amd64 i386 x32 ppc64el
63 HOST_ARCHS_ppc64 = amd64 i386 x32
64 HOST_ARCHS_ppc64el = amd64 i386 x32 ppc64 arm64
65 HOST_ARCHS_riscv64 = amd64 i386 x32 arm64 ppc64el
66 HOST_ARCHS_s390x = amd64 i386 x32 arm64 ppc64el
67 HOST_ARCHS_sh4 = amd64 i386 x32
68 HOST_ARCHS_sparc64 = amd64 i386 x32
69 HOST_ARCHS_x32 = amd64 arm64 i386 ppc64el
70
71 all_archs_mips = mips mipsel mipsn32 mipsn32el mips64 mips64el mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el
72 mipsen_archs = amd64 i386 x32 mips64el mipsel mips64r6el arm64 ppc64el
73 $(foreach a, $(all_archs_mips), \
74 $(eval HOST_ARCHS_$(a) = $(filter-out $(a), $(mipsen_archs))) \
75 )
76
77 HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
78 HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
79 HOST_ARCH_EXT := $(if $(DEB_HOST_ARCH_VARIANT),$(DEB_HOST_ARCH_VARIANT),$(HOST_ARCH))
80 stamp := stamp-dir/
81
82 # package metadata information
83 ifeq (,$(ELF_PACKAGE_METADATA))
84 ELF_PACKAGE_METADATA := $(subst $(space),,{ \
85 "type":"deb", \
86 "os":"$(shell awk -F= '/^ID=/ {print $$2}' /etc/os-release)", \
87 "name":"$(DEB_NAME_ACT)", \
88 "version":"$(DEB_SVER_ACT)", \
89 "architecture":"$(HOST_ARCH)" \
90 $(if $(DEB_BUILD_DEBUG_INFO_URL),$(,)"debugInfoUrl":"$(DEB_BUILD_DEBUG_INFO_URL)") \
91 })
92 export ELF_PACKAGE_METADATA
93 endif
94
95 ifeq (,$(CROSS_ARCHS))
96 ifeq ($(DEB_NAME_ACT),gcc-11-cross)
97 ifneq (,$(filter $(HOST_ARCH),amd64 i386 x32))
98 CROSS_ARCHS = amd64
99 CROSS_ARCHS += s390x ppc64el arm64 armhf armel \
100 $(if $(filter $(vendor), Ubuntu), powerpc) \
101 $(if $(filter $(HOST_ARCH), amd64 x32), i386)
102 else ifeq ($(HOST_ARCH),arm64)
103 CROSS_ARCHS = amd64 armel armhf i386 ppc64el s390x
104 else ifeq ($(HOST_ARCH),ppc64)
105 CROSS_ARCHS = ppc64el
106 else ifeq ($(HOST_ARCH),ppc64el)
107 CROSS_ARCHS = amd64 i386 $(if $(filter $(vendor), Ubuntu), powerpc) \
108 armel armhf arm64 s390x
109 else
110 CROSS_ARCHS =
111 endif
112 GCC_PORTS_BUILD=
113 else ifeq ($(DEB_NAME_ACT),gcc-11-cross-mipsen)
114 ifneq (,$(filter $(HOST_ARCH),$(mipsen_archs)))
115 CROSS_ARCHS ?= mipsel mips64el mips64 \
116 mipsr6 mipsr6el mips64r6 mips64r6el
117 # n32: mipsn32 mipsn32el mipsn32r6 mipsn32r6el
118 # have problem on ada
119 endif
120 GCC_PORTS_BUILD=-mipsen
121 else # -ports package
122 ifneq (,$(filter $(HOST_ARCH),amd64 i386 x32))
123 CROSS_ARCHS ?= alpha arc hppa m68k ppc64 riscv64 sh4 sparc64 \
124 $(if $(filter $(vendor), Ubuntu),, powerpc) \
125 $(if $(filter $(HOST_ARCH), amd64 i386), x32)
126 else ifeq ($(HOST_ARCH),arm64)
127 CROSS_ARCHS = x32 riscv64
128 else ifeq ($(HOST_ARCH),ppc64el)
129 CROSS_ARCHS = x32 riscv64 $(if $(filter $(vendor), Ubuntu),, powerpc)
130 else
131 CROSS_ARCHS =
132 endif
133 GCC_PORTS_BUILD=-ports
134 endif
135 endif
136
137 CROSS_ARCH = $(subst .,,$(suffix $@))
138 KERNEL_ARCH = $(KERNEL_ARCH_$(CROSS_ARCH))
139 CROSS_BIARCH = $(CROSS_BIARCH_$(CROSS_ARCH))
140 _gnu_type = $(shell dpkg-architecture -a$(1) -qDEB_HOST_GNU_TYPE -f)
141 _pkg_gnu_type = $(shell dpkg-architecture -a$(1) -qDEB_HOST_GNU_TYPE -f | tr _ -)
142 CROSS_GNU_TYPE = $(call _gnu_type,${CROSS_ARCH})
143 HOST_ARCHS = $(HOST_ARCH_$(CROSS_ARCH))
144 ADA_HOST_ARCHS = $(HOST_ARCH_$(CROSS_ARCH))
145 ADA64_HOST_ARCHS = $(filter-out i386,$(HOST_ARCH_$(CROSS_ARCH)))
146
147 ARM32_MULTILIBS :=
148 ifeq ($(vendor),Ubuntu)
149 ifneq (,$(filter $(distrelease), precise trusty xenial bionic focal groovy hirsute))
150 ARM32_MULTILIBS := yes
151 endif
152 endif
153
154 ifeq ($(vendor),Debian)
155 skip_dbg_packages = yes
156 skip_arm32ml_packages = yes
157 else ifeq ($(vendor),Ubuntu)
158 ifeq (,$(filter $(distrelease), precise trusty xenial bionic focal groovy hirsute))
159 skip_arm32ml_packages = yes
160 endif
161 endif
162
163 libgcc_source := $(shell apt-cache show --no-all-versions libgcc-s1-arm64-cross | awk '/^Source:/ { print $$2 }')
164 #ifneq ($(DEB_NAME_ACT),$(libgcc_source))
165 skip_common_packages = yes
166 #endif
167
168 BINUTILS_BUILD_DEPS = $(foreach a,$(CROSS_ARCHS),binutils-$(call _pkg_gnu_type,$(a)) (>= $(MIN_VER_BINUTILS)) [$(HOST_ARCHS_$(a))]$(,))
169 GLIBC_BUILD_DEPS = $(foreach a,$(CROSS_ARCHS),libc6$(if $(filter $(a),alpha ia64),.1)-dev-$(a)-cross (>= $(MIN_VER_GLIBC)) [$(HOST_ARCHS_$(a))]$(,))
170 LINUX_BUILD_DEPS = $(foreach a,$(CROSS_ARCHS),linux-libc-dev-$(a)-cross [$(HOST_ARCHS_$(a))]$(,))
171
172 # build multilib cross compilers
173 ifeq ($(ARM32_MULTILIBS),yes)
174 ifneq (,$(filter armel, $(CROSS_ARCHS)))
175 EXTRA_BUILD_DEPS += libc6-dev-armhf-cross [$(HOST_ARCHS_armel)],
176 ifeq ($(skip_common_packages),yes)
177 GCC_BUILD_DEPS += libhfgcc-s1-armel-cross [$(HOST_ARCHS_armel)],
178 endif
179 endif
180
181 ifneq (,$(filter armhf, $(CROSS_ARCHS)))
182 EXTRA_BUILD_DEPS += libc6-dev-armel-cross [$(HOST_ARCHS_armhf)],
183 ifeq ($(skip_common_packages),yes)
184 GCC_BUILD_DEPS += libsfgcc-s1-armhf-cross [$(HOST_ARCHS_armhf)],
185 endif
186 endif
187 endif
188
189 ifneq (,$(filter amd64, $(CROSS_ARCHS)))
190 EXTRA_BUILD_DEPS += libc6-dev-i386-amd64-cross [$(HOST_ARCHS_amd64)],
191 EXTRA_BUILD_DEPS += libc6-dev-x32-amd64-cross [$(HOST_ARCHS_amd64)],
192 ifeq ($(skip_common_packages),yes)
193 GCC_BUILD_DEPS += lib32gcc-s1-amd64-cross [$(HOST_ARCHS_amd64)],
194 GCC_BUILD_DEPS += libx32gcc-s1-amd64-cross [$(HOST_ARCHS_amd64)],
195 endif
196 endif
197
198 ifneq (,$(filter i386, $(CROSS_ARCHS)))
199 EXTRA_BUILD_DEPS += libc6-dev-amd64-i386-cross [$(HOST_ARCHS_i386)],
200 EXTRA_BUILD_DEPS += libc6-dev-x32-i386-cross [$(HOST_ARCHS_i386)],
201 ifeq ($(skip_common_packages),yes)
202 GCC_BUILD_DEPS += lib64gcc-s1-i386-cross [$(HOST_ARCHS_i386)],
203 GCC_BUILD_DEPS += libx32gcc-s1-i386-cross [$(HOST_ARCHS_i386)],
204 endif
205 endif
206
207 ifneq (,$(filter x32, $(CROSS_ARCHS)))
208 EXTRA_BUILD_DEPS += libc6-dev-i386-x32-cross [$(HOST_ARCHS_x32)],
209 EXTRA_BUILD_DEPS += libc6-dev-amd64-x32-cross [$(HOST_ARCHS_x32)],
210 ifeq ($(skip_common_packages),yes)
211 GCC_BUILD_DEPS += lib32gcc-s1-x32-cross [$(HOST_ARCHS_x32)],
212 GCC_BUILD_DEPS += lib64gcc-s1-x32-cross [$(HOST_ARCHS_x32)],
213 endif
214 endif
215
216 ifneq (,$(filter ppc64, $(CROSS_ARCHS)))
217 EXTRA_BUILD_DEPS += libc6-dev-powerpc-ppc64-cross [$(HOST_ARCHS_ppc64)],
218 ifeq ($(skip_common_packages),yes)
219 GCC_BUILD_DEPS += lib32gcc-s1-ppc64-cross [$(HOST_ARCHS_ppc64)],
220 endif
221 endif
222
223 ifneq ($(vendor),Ubuntu)
224 ifneq (,$(filter s390x, $(CROSS_ARCHS)))
225 EXTRA_BUILD_DEPS += libc6-dev-s390-s390x-cross [$(HOST_ARCHS_s390x)],
226 ifeq ($(skip_common_packages),yes)
227 GCC_BUILD_DEPS += lib32gcc-s1-s390x-cross [$(HOST_ARCHS_s390x)],
228 endif
229 endif
230 endif
231
232 ifneq (,$(filter sparc64, $(CROSS_ARCHS)))
233 EXTRA_BUILD_DEPS += libc6-dev-sparc-sparc64-cross [$(HOST_ARCHS_sparc64)],
234 ifeq ($(skip_common_packages),yes)
235 GCC_BUILD_DEPS += lib32gcc-s1-sparc64-cross [$(HOST_ARCHS_sparc64)],
236 endif
237 endif
238
239 ifneq (,$(filter powerpc, $(CROSS_ARCHS)))
240 EXTRA_BUILD_DEPS += libc6-dev-ppc64-powerpc-cross [$(HOST_ARCHS_powerpc)],
241 ifeq ($(skip_common_packages),yes)
242 GCC_BUILD_DEPS += lib64gcc-s1-powerpc-cross [$(HOST_ARCHS_powerpc)],
243 endif
244 endif
245
246 ifneq (,$(filter mips, $(CROSS_ARCHS)))
247 EXTRA_BUILD_DEPS += libc6-dev-mips64-mips-cross [$(HOST_ARCHS_mips)],
248 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips-cross [$(HOST_ARCHS_mips)],
249 ifeq ($(skip_common_packages),yes)
250 GCC_BUILD_DEPS += lib64gcc-s1-mips-cross [$(HOST_ARCHS_mips)],
251 GCC_BUILD_DEPS += libn32gcc-s1-mips-cross [$(HOST_ARCHS_mips)],
252 endif
253 endif
254
255 ifneq (,$(filter mipsel, $(CROSS_ARCHS)))
256 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsel-cross [$(HOST_ARCHS_mipsel)],
257 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mipsel-cross [$(HOST_ARCHS_mipsel)],
258 ifeq ($(skip_common_packages),yes)
259 GCC_BUILD_DEPS += lib64gcc-s1-mipsel-cross [$(HOST_ARCHS_mipsel)],
260 GCC_BUILD_DEPS += libn32gcc-s1-mipsel-cross [$(HOST_ARCHS_mipsel)],
261 endif
262 endif
263
264 ifneq (,$(filter mipsn32, $(CROSS_ARCHS)))
265 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
266 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
267 ifeq ($(skip_common_packages),yes)
268 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
269 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
270 endif
271 endif
272
273 ifneq (,$(filter mipsn32el, $(CROSS_ARCHS)))
274 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
275 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
276 ifeq ($(skip_common_packages),yes)
277 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
278 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
279 endif
280 endif
281
282 ifneq (,$(filter mips64, $(CROSS_ARCHS)))
283 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64-cross [$(HOST_ARCHS_mips64)],
284 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64-cross [$(HOST_ARCHS_mips64)],
285 ifeq ($(skip_common_packages),yes)
286 GCC_BUILD_DEPS += lib32gcc-s1-mips64-cross [$(HOST_ARCHS_mips64)],
287 GCC_BUILD_DEPS += libn32gcc-s1-mips64-cross [$(HOST_ARCHS_mips64)],
288 endif
289 endif
290
291 ifneq (,$(filter mips64el, $(CROSS_ARCHS)))
292 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64el-cross [$(HOST_ARCHS_mips64el)],
293 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64el-cross [$(HOST_ARCHS_mips64el)],
294 ifeq ($(skip_common_packages),yes)
295 GCC_BUILD_DEPS += lib32gcc-s1-mips64el-cross [$(HOST_ARCHS_mips64el)],
296 GCC_BUILD_DEPS += libn32gcc-s1-mips64el-cross [$(HOST_ARCHS_mips64el)],
297 endif
298 endif
299
300 ifneq (,$(filter mipsr6, $(CROSS_ARCHS)))
301 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
302 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
303 ifeq ($(skip_common_packages),yes)
304 GCC_BUILD_DEPS += lib64gcc-s1-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
305 GCC_BUILD_DEPS += libn32gcc-s1-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
306 endif
307 endif
308
309 ifneq (,$(filter mipsr6el, $(CROSS_ARCHS)))
310 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
311 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
312 ifeq ($(skip_common_packages),yes)
313 GCC_BUILD_DEPS += lib64gcc-s1-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
314 GCC_BUILD_DEPS += libn32gcc-s1-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
315 endif
316 endif
317
318 ifneq (,$(filter mipsn32r6, $(CROSS_ARCHS)))
319 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
320 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
321 ifeq ($(skip_common_packages),yes)
322 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
323 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
324 endif
325 endif
326
327 ifneq (,$(filter mipsn32r6el, $(CROSS_ARCHS)))
328 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
329 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
330 ifeq ($(skip_common_packages),yes)
331 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
332 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
333 endif
334 endif
335
336 ifneq (,$(filter mips64r6, $(CROSS_ARCHS)))
337 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
338 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
339 ifeq ($(skip_common_packages),yes)
340 GCC_BUILD_DEPS += lib32gcc-s1-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
341 GCC_BUILD_DEPS += libn32gcc-s1-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
342 endif
343 endif
344
345 ifneq (,$(filter mips64r6el, $(CROSS_ARCHS)))
346 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
347 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
348 ifeq ($(skip_common_packages),yes)
349 GCC_BUILD_DEPS += lib32gcc-s1-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
350 GCC_BUILD_DEPS += libn32gcc-s1-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
351 endif
352 endif
353
354 PHOBOS_ARCHS = amd64 armel armhf arm64 i386 x32 kfreebsd-amd64 kfreebsd-i386 \
355 hppa ppc64el riscv64 s390x sparc64 \
356 mips mips64 mipsel mips64el mipsn32 mipsn32el \
357 mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el
358
359 PHOBOS_DEP = libgphobos-GCC_VER-dev-CROSS_ARCH-cross (= $${gcc:Version}),
360 # FIXME: Set correctly ...
361 PHOBOS_ML_DEP = libgphobos-GCC_VER-dev-CROSS_ARCH-cross (= $${gcc:Version}),
362
363
364 info:
365 @echo "Package name: ${DEB_NAME_ACT} ${DEB_VER_ACT}"
366 @echo 'Package metadata: $(ELF_PACKAGE_METADATA)'
367 @echo
368 @echo "GCC ${GCC_VER} version: ${VER_GCC} ${DEB_VER_GCC}"
369 @echo
370 @echo "Target architecture: ${CROSS_ARCH}"
371 @echo "Target GNU type: ${CROSS_GNU_TYPE}"
372 @echo "Host architecture: ${HOST_ARCH}"
373 @echo "Host GNU type: ${HOST_GNU_TYPE}"
374 @echo "skips (debug/common/armml): $(skip_dbg_packages)/$(skip_common_packages)/$(skip_arm32ml_packages)"
375
376 $(stamp)init-gcc:
377 @echo START $@
378 mkdir -p gcc
379 set -ex; \
380 cd gcc ; \
381 ln -sf $(GCC_TARBALL) $(notdir $(GCC_TARBALL)) ;\
382 cp -a $(GCC_DIR)/debian/ . ; \
383 if [ -n "$$(grep -v '^\#' $(CURDIR)/debian/patches/gcc/series)" ]; then \
384 QUILT_PATCHES=$(CURDIR)/debian/patches/gcc quilt push --quiltrc /dev/null -a ; \
385 fi
386 # set -ex; \
387 # if dpkg --compare-versions $(DEB_VER_GCC) lt 12.2.0-5; then \
388 # cd gcc; \
389 # patch -p1 < ../debian/patches/gcc/updates.diff; \
390 # fi
391 touch $@
392
393 $(stamp)build-gcc.%: $(stamp)init-gcc
394 @echo START $@
395 @if [ "$(HOST_ARCH)" = "$(CROSS_ARCH)" ] && [ "X$(dbp_flag)" = X-B ]; then \
396 echo "Skipping binary-arch build for $(CROSS_ARCH)"; \
397 else \
398 set -x; \
399 echo ${CROSS_ARCH} >gcc/debian/target; \
400 cd gcc && \
401 WITH_SYSROOT=/ \
402 PKG_IGNORE_CURRENTLY_BUILDING=1 \
403 BACKPORT=false \
404 WITHOUT_LANG="hppa64 jit nvptx" \
405 $(if $(filter $(HOST_ARCH),$(CROSS_ARCH)),FORCE_CROSS_LAYOUT=yes WITH_BOOTSTRAP=off) \
406 GCC_PORTS_BUILD=$(GCC_PORTS_BUILD) \
407 dpkg-buildpackage $(if $(filter $(HOST_ARCH),$(CROSS_ARCH)),$(subst -b,-A,$(dbp_flag)),$(dbp_flag)) -uc -us -d; \
408 fi
409 rm -vf *-for-host_*.deb
410 touch $@
411
412 clean:
413 rm -rf gcc tmp-*
414 rm -f *.*deb *.changes *.buildinfo debian/files
415 rm -rf $(stamp)
416 mkdir $(stamp)
417 dh_clean
418
419
420 $(stamp)repack-%:
421 @umask 022; \
422 if [ -z "$(TARGET_ARCH)" ]; then \
423 echo >&2 "repack: macro TARGET_ARCH not set"; \
424 exit 1; \
425 fi; \
426 t_arch=$(TARGET_ARCH); \
427 t_gnu_type=$(call _gnu_type,$(TARGET_ARCH)); \
428 deb=$*; \
429 pkgname=`echo $$deb | cut -d'_' -f1`; \
430 tmp=tmp-$$pkgname; \
431 if [ "$(skip_dbg_packages)" = yes ]; then \
432 case $$deb in *-dbg*) exit 0; esac; \
433 fi; \
434 echo "repack $$pkgname ($$deb) ..."; \
435 rm -rf $$tmp; \
436 mkdir -p $$tmp; \
437 dpkg-deb -x $$deb $$tmp; \
438 dpkg-deb -e $$deb $$tmp/DEBIAN; \
439 sed -i -e's/^Source:.*/Source: $(DEB_NAME_ACT) ($(DEB_SVER_ACT))/' \
440 -e "/^Depends:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/g" \
441 -e "/^Recommends:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/g" \
442 -e "/^Suggests:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/g" \
443 -e "/^Version:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/" \
444 $$tmp/DEBIAN/control ; \
445 sed -i -e "/^Depends:/s/\(libgnat-[0-9]*\) (>= $(DEB_VER_GCC)$(CROSS_EXT))/\1 (>= $(VER_GCC))/g" \
446 $$tmp/DEBIAN/control ; \
447 sed -i -e "/^Depends:/s/\(libgnat-util[0-9]*\) (>= $(DEB_VER_GCC)$(CROSS_EXT))/\1 (>= $(VER_GCC))/g" \
448 $$tmp/DEBIAN/control ; \
449 case $$pkgname in \
450 gcc-$(GCC_VER)-$${t_gnu_type}) \
451 sed -i -e '/Depends/s/\(libcc1[^,]*\)$(CROSS_EXT)/\1/' \
452 $$tmp/DEBIAN/control;; \
453 *-cross) \
454 sed -i -e '/^Depends:/s/\(-base *( *\)=\([^)]*\)cross[^)]*)/\1>=\2)/' \
455 $$tmp/DEBIAN/control;; \
456 esac; \
457 install -d -m 755 $$tmp/usr/share/lintian/overrides; \
458 if [ -e debian/overrides/$$pkgname ]; then \
459 cp debian/overrides/$$pkgname $$tmp/usr/share/lintian/overrides/; \
460 fi; \
461 case "$$pkgname" in \
462 gcc-$(GCC_VER)-cross-base*) \
463 echo "$$pkgname binary: wrong-name-for-changelog-of-native-package" \
464 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
465 ;; \
466 gcc-$(GCC_VER)-*-base) \
467 echo "$$pkgname binary: wrong-name-for-changelog-of-native-package" \
468 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
469 ;; \
470 gcc-$(GCC_VER)-multilib) \
471 echo "$$pkgname binary: binary-from-other-architecture" \
472 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
473 ;; \
474 gccgo-$(GCC_VER)*) \
475 echo "$$pkgname binary: binary-from-other-architecture" \
476 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
477 echo "$$pkgname binary: non-standard-dir-in-usr" \
478 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
479 ;; \
480 *-multilib-*) \
481 ;; \
482 cpp-*|g++-*|gcc-*|gccgo-*|gdc-*|gfortran-*|gobjc*|gm2-*|gnat-$(GCC_VER)-sjlj-*) \
483 echo "$$pkgname binary: binary-from-other-architecture" \
484 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
485 ;; \
486 gnat-$(GCC_VER)-*) \
487 echo "$$pkgname binary: binary-from-other-architecture" \
488 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
489 echo "$$pkgname binary: non-standard-dir-in-usr" \
490 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
491 ;; \
492 *-dev-$${t_arch}-cross) \
493 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
494 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
495 echo "$$pkgname binary: non-standard-dir-in-usr" \
496 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
497 ;; \
498 *-dbg-$${t_arch}-cross) \
499 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
500 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
501 echo "$$pkgname binary: debug-package-should-be-named-dbg" \
502 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
503 echo "$$pkgname binary: non-standard-dir-in-usr" \
504 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
505 ;; \
506 *-pic-$${t_arch}-cross) \
507 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
508 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
509 ;; \
510 *-$${t_arch}-cross) \
511 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
512 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
513 echo "$$pkgname binary: non-standard-dir-in-usr" \
514 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
515 echo "$$pkgname binary: shlibs-declares-dependency-on-other-package" \
516 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
517 case "$$pkgname" in \
518 lib*gphobos*) \
519 echo "$$pkgname binary: embedded-library" \
520 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
521 *-hppa-cross) \
522 echo "$$pkgname binary: binary-compiled-with-profiling-enabled" \
523 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
524 esac; \
525 ;; \
526 esac; \
527 case $$pkgname in \
528 lib*san*-cross) \
529 echo "$$pkgname binary: custom-library-search-path" \
530 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
531 libstdc++-*-dev-amd64-cross) \
532 sed -i -e "/^Depends:/s/libc6 /libc6-amd64-cross /g" \
533 -e "/^Depends:/s/libgcc-s1 /libgcc-s1-amd64-cross /g" \
534 $$tmp/DEBIAN/control; \
535 echo "$$pkgname binary: missing-dependency-on-libc" \
536 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
537 lib64stdc++-*-dev-i386-cross) \
538 sed -i -e "/^Depends:/s/libc6 /libc6-amd64-i386-cross /g" \
539 -e "/^Depends:/s/libgcc-s1 /lib64gcc-s1-i386-cross /g" \
540 $$tmp/DEBIAN/control; \
541 echo "$$pkgname binary: missing-dependency-on-libc" \
542 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
543 lib64stdc++-*-dev-x32-cross) \
544 sed -i -e "/^Depends:/s/libc6 /libc6-amd64-x32-cross /g" \
545 -e "/^Depends:/s/libgcc-s1 /lib64gcc-s1-x32-cross /g" \
546 $$tmp/DEBIAN/control; \
547 echo "$$pkgname binary: missing-dependency-on-libc" \
548 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
549 lib??*stdc++-*-dev-*-cross) \
550 sed -i -e "/^Depends:/s/\(libc6-[[a-z0-9]*\):\([a-z0-9]*\)/\1-\2-cross/g" \
551 $$tmp/DEBIAN/control; \
552 echo "$$pkgname binary: missing-dependency-on-libc" \
553 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
554 libstdc++-*-dev-*-cross) \
555 sed -i -e "/^Depends:/s/\(libc6[.1]*\):\([a-z0-9]*\)/\1-\2-cross/g" \
556 $$tmp/DEBIAN/control; \
557 echo "$$pkgname binary: missing-dependency-on-libc" \
558 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
559 esac; \
560 if [ -e $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gz ]; then \
561 mv $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gz \
562 $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gcc-${GCC_VER}.gz; \
563 gzip -c9n debian/changelog \
564 > $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gz;\
565 fi ; \
566 rm -f $$tmp/DEBIAN/md5sums; \
567 (cd $$tmp && find usr -type f | LC_ALL=C sort | xargs -r md5sum >>DEBIAN/md5sums); \
568 find $$tmp/DEBIAN -name md5sums -empty | xargs -r rm -f; \
569 newdeb=`echo $$deb|sed -e "s/\(.*\)_\(.*\)_\(.*\)/\1_\2$(CROSS_EXT)_\3/g"`; \
570 NO_PKG_MANGLE=1 dpkg-deb -b $$tmp ../$$newdeb; \
571 rm -rf $$tmp
572 touch $@
573
574 $(stamp)repack-debs-arch: $(stamp)build
575 @echo START $@
576 dh_testroot
577 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(HOST_ARCH) \
578 $(addprefix $(stamp)repack-,$(wildcard *_$(HOST_ARCH_EXT).deb))
579 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(HOST_ARCH) \
580 $(addprefix $(stamp)repack-,$(wildcard *$(DEB_VER_GCC)_$(HOST_ARCH_EXT).ddeb))
581 rm -f *$(DEB_VER_GCC)_$(HOST_ARCH_EXT).ddeb
582 if [ -f ../gcc-$(GCC_VER)-$(call _gnu_type,$(HOST_ARCH))-dbgsym_${DEB_VER_GCC}$(CROSS_EXT)_$(HOST_ARCH).ddeb ]; then mv -f ../*.ddeb . ; fi
583 touch $@
584
585 $(stamp)repack-debs-indep: $(stamp)build
586 @echo START $@
587 dh_testroot
588 set -e; \
589 $(foreach arch,$(CROSS_ARCHS), \
590 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(arch) \
591 $(addprefix $(stamp)repack-,$(wildcard *-$(arch)-cross_*_all.deb)); \
592 )
593 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(HOST_ARCH) \
594 $(addprefix $(stamp)repack-,$(wildcard gcc-$(GCC_VER)-cross-base$(GCC_PORTS_BUILD)_*_all.deb))
595 touch $@
596
597 build: $(stamp)build
598 $(stamp)build: $(foreach arch,$(CROSS_ARCHS),$(addsuffix .$(arch),$(stamp)build-gcc))
599 @echo START $@
600 touch $@
601
602 build: dbp_flag = -b
603 build-arch: dbp_flag = -B
604 build-indep: dbp_flag = -b
605
606 build-arch: $(stamp)build
607 build-indep: $(stamp)build
608
609 binary: binary-arch binary-indep
610 binary-arch: build-arch $(stamp)build $(stamp)repack-debs-arch $(stamp)mangle-debian-files-arch
611 binary-indep: build-indep $(stamp)build $(stamp)repack-debs-indep $(stamp)mangle-debian-files-indep
612
613 define generate_debian_files
614 touch debian/files
615 for deb in $1; do \
616 [ -f "$$deb" ] || continue; \
617 pkg=`basename $$deb`; \
618 if [ "$(skip_dbg_packages)" = yes ]; then \
619 case $$pkg in *-dbg*) continue; esac; \
620 fi; \
621 if [ "$(skip_arm32ml_packages)" = yes ] && grep -q "^$$pkg$$" debian/packages.arm32ml; then \
622 continue; \
623 fi; \
624 if [ "$(skip_common_packages)" = yes ] && grep -q "^$$pkg$$" debian/packages.common; then \
625 continue; \
626 fi; \
627 echo -n "$$pkg " >>debian/files; \
628 dpkg-deb -I $$deb | grep Section | cut -d ' ' -f 3 | tr "\n" ' ' >>debian/files; \
629 dpkg-deb -I $$deb | grep Priority | cut -d ' ' -f 3 | tr "\n" ' ' >>debian/files; \
630 dpkg-deb -I $$deb | awk '/^ Architecture:/ {printf "architecture=%s", $$2}' >>debian/files; \
631 echo "" >>debian/files; \
632 done
633 endef
634
635 $(stamp)mangle-debian-files-arch: build $(stamp)repack-debs-arch $(stamp)debian-files-base
636 @echo START $@
637 $(call generate_debian_files, *_$(HOST_ARCH_EXT).deb)
638 sed -i -e "s/${DEB_VER_GCC}_/${DEB_VER_GCC}$(CROSS_EXT)_/g" debian/files
639 touch $@
640
641 $(stamp)mangle-debian-files-indep: $(stamp)repack-debs-indep $(stamp)debian-files-base
642 @echo START $@
643 $(call generate_debian_files, *_all.deb)
644 sed -i -e "s/${DEB_VER_GCC}_/${DEB_VER_GCC}$(CROSS_EXT)_/g" debian/files
645 touch $@
646
647 $(stamp)debian-files-base:
648 @echo START $@
649 rm -f debian/files
650 touch $@
651
652
653 control:
654 sed -e "s/MIN_VER_GCC/${MIN_VER_GCC}/g" \
655 -e "s/GCC_BUILD_DEPS/$(GCC_BUILD_DEPS)/g" \
656 -e "s/BINUTILS_BUILD_DEPS/$(BINUTILS_BUILD_DEPS)/g" \
657 -e "s/GLIBC_BUILD_DEPS/$(GLIBC_BUILD_DEPS)/g" \
658 -e "s/EXTRA_BUILD_DEPS/${EXTRA_BUILD_DEPS}/g" \
659 -e "s/LINUX_BUILD_DEPS/$(LINUX_BUILD_DEPS)/g" \
660 -e "s/GCC_VER/${GCC_VER}/g" \
661 -e "s/MIN_VER_BINUTILS/${MIN_VER_BINUTILS}/g" \
662 -e "s/VER_BINUTILS/${VER_BINUTILS}/g" \
663 -e "s/VER_ISL/${VER_ISL}/g" \
664 -e "s/GCC_PORTS_BUILD/$(GCC_PORTS_BUILD)/g" \
665 $(CURDIR)/debian/control.source.in >$(CURDIR)/debian/control
666
667 $(foreach a,$(CROSS_ARCHS), \
668 sed \
669 -e 's/PHOBOS_DEP/$(if $(filter $(a),$(PHOBOS_ARCHS)),${PHOBOS_DEP})/g' \
670 -e 's/PHOBOS_ML_DEP/$(if $(filter $(a),$(PHOBOS_ARCHS)),${PHOBOS_ML_DEP})/g' \
671 -e 's/CROSS_ARCH/$(a)/g' \
672 -e 's/CROSS_GNU_TYPE/$(call _pkg_gnu_type,$(a))/g' \
673 -e 's/MIN_VER_GCC/${MIN_VER_GCC}/g' \
674 -e 's/GCC_VER/${GCC_VER}/g' \
675 -e 's/MIN_VER_BINUTILS/${MIN_VER_BINUTILS}/g' \
676 -e 's/@host_archs@/$(filter-out $(a),$(HOST_ARCHS_$(a)))/g' \
677 -e 's/@ada_host_archs@/$(filter-out $(a),$(HOST_ARCHS_$(a)))/g' \
678 -e 's/@ada64_host_archs@/$(filter-out $(a),$(filter-out XXXi386,$(HOST_ARCHS_$(a))))/g' \
679 $(CURDIR)/debian/control.arch.in >>$(CURDIR)/debian/control; )
680
681 cp debian/packages.invalid debian/packages.invalid-all
682 ifeq ($(vendor),Ubuntu)
683 ifeq (,$(filter $(distrelease), trusty xenial bionic focal jammy mantic noble))
684 cat debian/packages.invalid-s390x >> debian/packages.invalid-all
685 endif
686 endif
687 python3 debian/remove-unbuilt \
688 $(if $(filter yes,$(skip_dbg_packages)), --skip-dbg-packages) \
689 $(if $(filter yes,$(skip_arm32ml_packages)), --skip-arm32ml-packages) \
690 $(if $(filter yes,$(skip_common_packages)), --skip-common-packages) \
691 debian/control debian/packages.invalid-all debian/packages.arm32ml debian/packages.common \
692 > debian/control.new && mv debian/control.new debian/control
693 rm -f debian/packages.invalid-all
694
695 sort-pkgfiles:
696 for i in packages.arm32ml packages.common packages.invalid; do \
697 LC_ALL=C sort -u debian/$$i > debian/$$i.tmp; \
698 mv -f debian/$$i.tmp debian/$$i; \
699 done
700
701 .PRECIOUS: $(stamp)init-dirs \
702 $(stamp)init-gcc \
703 $(stamp)build \
704 $(stamp)build-gcc.% \
705 $(stamp)debian-files-base \
706 $(stamp)repack-debs-arch \
707 $(stamp)repack-debs-indep \
708 $(stamp)repack-debs-indep.% \
709 $(stamp)mangle-debian-files-arch
710 $(stamp)mangle-debian-files-indep \
711 build build-arch build-indep binary binary-arch binary-indep