Debian Codegraph @

debian/rules

raw symbols SCIP
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 (,$(filter sparc64, $(CROSS_ARCHS)))
224 EXTRA_BUILD_DEPS += libc6-dev-sparc-sparc64-cross [$(HOST_ARCHS_sparc64)],
225 ifeq ($(skip_common_packages),yes)
226 GCC_BUILD_DEPS += lib32gcc-s1-sparc64-cross [$(HOST_ARCHS_sparc64)],
227 endif
228 endif
229
230 ifneq (,$(filter powerpc, $(CROSS_ARCHS)))
231 EXTRA_BUILD_DEPS += libc6-dev-ppc64-powerpc-cross [$(HOST_ARCHS_powerpc)],
232 ifeq ($(skip_common_packages),yes)
233 GCC_BUILD_DEPS += lib64gcc-s1-powerpc-cross [$(HOST_ARCHS_powerpc)],
234 endif
235 endif
236
237 ifneq (,$(filter mips, $(CROSS_ARCHS)))
238 EXTRA_BUILD_DEPS += libc6-dev-mips64-mips-cross [$(HOST_ARCHS_mips)],
239 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips-cross [$(HOST_ARCHS_mips)],
240 ifeq ($(skip_common_packages),yes)
241 GCC_BUILD_DEPS += lib64gcc-s1-mips-cross [$(HOST_ARCHS_mips)],
242 GCC_BUILD_DEPS += libn32gcc-s1-mips-cross [$(HOST_ARCHS_mips)],
243 endif
244 endif
245
246 ifneq (,$(filter mipsel, $(CROSS_ARCHS)))
247 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsel-cross [$(HOST_ARCHS_mipsel)],
248 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mipsel-cross [$(HOST_ARCHS_mipsel)],
249 ifeq ($(skip_common_packages),yes)
250 GCC_BUILD_DEPS += lib64gcc-s1-mipsel-cross [$(HOST_ARCHS_mipsel)],
251 GCC_BUILD_DEPS += libn32gcc-s1-mipsel-cross [$(HOST_ARCHS_mipsel)],
252 endif
253 endif
254
255 ifneq (,$(filter mipsn32, $(CROSS_ARCHS)))
256 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
257 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
258 ifeq ($(skip_common_packages),yes)
259 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
260 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32-cross [$(HOST_ARCHS_mipsn32)],
261 endif
262 endif
263
264 ifneq (,$(filter mipsn32el, $(CROSS_ARCHS)))
265 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
266 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
267 ifeq ($(skip_common_packages),yes)
268 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
269 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32el-cross [$(HOST_ARCHS_mipsn32el)],
270 endif
271 endif
272
273 ifneq (,$(filter mips64, $(CROSS_ARCHS)))
274 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64-cross [$(HOST_ARCHS_mips64)],
275 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64-cross [$(HOST_ARCHS_mips64)],
276 ifeq ($(skip_common_packages),yes)
277 GCC_BUILD_DEPS += lib32gcc-s1-mips64-cross [$(HOST_ARCHS_mips64)],
278 GCC_BUILD_DEPS += libn32gcc-s1-mips64-cross [$(HOST_ARCHS_mips64)],
279 endif
280 endif
281
282 ifneq (,$(filter mips64el, $(CROSS_ARCHS)))
283 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64el-cross [$(HOST_ARCHS_mips64el)],
284 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64el-cross [$(HOST_ARCHS_mips64el)],
285 ifeq ($(skip_common_packages),yes)
286 GCC_BUILD_DEPS += lib32gcc-s1-mips64el-cross [$(HOST_ARCHS_mips64el)],
287 GCC_BUILD_DEPS += libn32gcc-s1-mips64el-cross [$(HOST_ARCHS_mips64el)],
288 endif
289 endif
290
291 ifneq (,$(filter mipsr6, $(CROSS_ARCHS)))
292 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
293 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
294 ifeq ($(skip_common_packages),yes)
295 GCC_BUILD_DEPS += lib64gcc-s1-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
296 GCC_BUILD_DEPS += libn32gcc-s1-mipsr6-cross [$(HOST_ARCHS_mipsr6)],
297 endif
298 endif
299
300 ifneq (,$(filter mipsr6el, $(CROSS_ARCHS)))
301 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
302 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
303 ifeq ($(skip_common_packages),yes)
304 GCC_BUILD_DEPS += lib64gcc-s1-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
305 GCC_BUILD_DEPS += libn32gcc-s1-mipsr6el-cross [$(HOST_ARCHS_mipsr6el)],
306 endif
307 endif
308
309 ifneq (,$(filter mipsn32r6, $(CROSS_ARCHS)))
310 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
311 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
312 ifeq ($(skip_common_packages),yes)
313 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
314 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32r6-cross [$(HOST_ARCHS_mipsn32r6)],
315 endif
316 endif
317
318 ifneq (,$(filter mipsn32r6el, $(CROSS_ARCHS)))
319 EXTRA_BUILD_DEPS += libc6-dev-mips32-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
320 EXTRA_BUILD_DEPS += libc6-dev-mips64-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
321 ifeq ($(skip_common_packages),yes)
322 GCC_BUILD_DEPS += lib32gcc-s1-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
323 GCC_BUILD_DEPS += lib64gcc-s1-mipsn32r6el-cross [$(HOST_ARCHS_mipsn32r6el)],
324 endif
325 endif
326
327 ifneq (,$(filter mips64r6, $(CROSS_ARCHS)))
328 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
329 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
330 ifeq ($(skip_common_packages),yes)
331 GCC_BUILD_DEPS += lib32gcc-s1-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
332 GCC_BUILD_DEPS += libn32gcc-s1-mips64r6-cross [$(HOST_ARCHS_mips64r6)],
333 endif
334 endif
335
336 ifneq (,$(filter mips64r6el, $(CROSS_ARCHS)))
337 EXTRA_BUILD_DEPS += libc6-dev-mips32-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
338 EXTRA_BUILD_DEPS += libc6-dev-mipsn32-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
339 ifeq ($(skip_common_packages),yes)
340 GCC_BUILD_DEPS += lib32gcc-s1-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
341 GCC_BUILD_DEPS += libn32gcc-s1-mips64r6el-cross [$(HOST_ARCHS_mips64r6el)],
342 endif
343 endif
344
345 PHOBOS_ARCHS = amd64 armel armhf arm64 i386 x32 kfreebsd-amd64 kfreebsd-i386 \
346 hppa ppc64el riscv64 s390x sparc64 \
347 mips mips64 mipsel mips64el mipsn32 mipsn32el \
348 mipsr6 mipsr6el mipsn32r6 mipsn32r6el mips64r6 mips64r6el
349
350 PHOBOS_DEP = libgphobos-GCC_VER-dev-CROSS_ARCH-cross (= $${gcc:Version}),
351 # FIXME: Set correctly ...
352 PHOBOS_ML_DEP = libgphobos-GCC_VER-dev-CROSS_ARCH-cross (= $${gcc:Version}),
353
354
355 info:
356 @echo "Package name: ${DEB_NAME_ACT} ${DEB_VER_ACT}"
357 @echo 'Package metadata: $(ELF_PACKAGE_METADATA)'
358 @echo
359 @echo "GCC ${GCC_VER} version: ${VER_GCC} ${DEB_VER_GCC}"
360 @echo
361 @echo "Target architecture: ${CROSS_ARCH}"
362 @echo "Target GNU type: ${CROSS_GNU_TYPE}"
363 @echo "Host architecture: ${HOST_ARCH}"
364 @echo "Host GNU type: ${HOST_GNU_TYPE}"
365 @echo "skips (debug/common/armml): $(skip_dbg_packages)/$(skip_common_packages)/$(skip_arm32ml_packages)"
366
367 $(stamp)init-gcc:
368 @echo START $@
369 mkdir -p gcc
370 set -ex; \
371 cd gcc ; \
372 ln -sf $(GCC_TARBALL) $(notdir $(GCC_TARBALL)) ;\
373 cp -a $(GCC_DIR)/debian/ . ; \
374 if [ -n "$$(grep -v '^\#' $(CURDIR)/debian/patches/gcc/series)" ]; then \
375 QUILT_PATCHES=$(CURDIR)/debian/patches/gcc quilt push --quiltrc /dev/null -a ; \
376 fi
377 # set -ex; \
378 # if dpkg --compare-versions $(DEB_VER_GCC) lt 12.2.0-5; then \
379 # cd gcc; \
380 # patch -p1 < ../debian/patches/gcc/updates.diff; \
381 # fi
382 touch $@
383
384 $(stamp)build-gcc.%: $(stamp)init-gcc
385 @echo START $@
386 @if [ "$(HOST_ARCH)" = "$(CROSS_ARCH)" ] && [ "X$(dbp_flag)" = X-B ]; then \
387 echo "Skipping binary-arch build for $(CROSS_ARCH)"; \
388 else \
389 set -x; \
390 echo ${CROSS_ARCH} >gcc/debian/target; \
391 cd gcc && \
392 WITH_SYSROOT=/ \
393 PKG_IGNORE_CURRENTLY_BUILDING=1 \
394 BACKPORT=false \
395 WITHOUT_LANG="hppa64 jit nvptx" \
396 $(if $(filter $(HOST_ARCH),$(CROSS_ARCH)),FORCE_CROSS_LAYOUT=yes WITH_BOOTSTRAP=off) \
397 GCC_PORTS_BUILD=$(GCC_PORTS_BUILD) \
398 dpkg-buildpackage $(if $(filter $(HOST_ARCH),$(CROSS_ARCH)),$(subst -b,-A,$(dbp_flag)),$(dbp_flag)) -uc -us -d; \
399 fi
400 rm -vf *-for-host_*.deb
401 touch $@
402
403 clean:
404 rm -rf gcc tmp-*
405 rm -f *.*deb *.changes *.buildinfo debian/files
406 rm -rf $(stamp)
407 mkdir $(stamp)
408 dh_clean
409
410
411 $(stamp)repack-%:
412 @umask 022; \
413 if [ -z "$(TARGET_ARCH)" ]; then \
414 echo >&2 "repack: macro TARGET_ARCH not set"; \
415 exit 1; \
416 fi; \
417 t_arch=$(TARGET_ARCH); \
418 t_gnu_type=$(call _gnu_type,$(TARGET_ARCH)); \
419 deb=$*; \
420 pkgname=`echo $$deb | cut -d'_' -f1`; \
421 tmp=tmp-$$pkgname; \
422 if [ "$(skip_dbg_packages)" = yes ]; then \
423 case $$deb in *-dbg*) exit 0; esac; \
424 fi; \
425 echo "repack $$pkgname ($$deb) ..."; \
426 rm -rf $$tmp; \
427 mkdir -p $$tmp; \
428 dpkg-deb -x $$deb $$tmp; \
429 dpkg-deb -e $$deb $$tmp/DEBIAN; \
430 sed -i -e's/^Source:.*/Source: $(DEB_NAME_ACT) ($(DEB_SVER_ACT))/' \
431 -e "/^Depends:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/g" \
432 -e "/^Recommends:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/g" \
433 -e "/^Suggests:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/g" \
434 -e "/^Version:/s/$(DEB_VER_GCC)/$(DEB_VER_GCC)$(CROSS_EXT)/" \
435 $$tmp/DEBIAN/control ; \
436 sed -i -e "/^Depends:/s/\(libgnat-[0-9]*\) (>= $(DEB_VER_GCC)$(CROSS_EXT))/\1 (>= $(VER_GCC))/g" \
437 $$tmp/DEBIAN/control ; \
438 sed -i -e "/^Depends:/s/\(libgnat-util[0-9]*\) (>= $(DEB_VER_GCC)$(CROSS_EXT))/\1 (>= $(VER_GCC))/g" \
439 $$tmp/DEBIAN/control ; \
440 case $$pkgname in \
441 gcc-$(GCC_VER)-$${t_gnu_type}) \
442 sed -i -e '/Depends/s/\(libcc1[^,]*\)$(CROSS_EXT)/\1/' \
443 $$tmp/DEBIAN/control;; \
444 *-cross) \
445 sed -i -e '/^Depends:/s/\(-base *( *\)=\([^)]*\)cross[^)]*)/\1>=\2)/' \
446 $$tmp/DEBIAN/control;; \
447 esac; \
448 install -d -m 755 $$tmp/usr/share/lintian/overrides; \
449 if [ -e debian/overrides/$$pkgname ]; then \
450 cp debian/overrides/$$pkgname $$tmp/usr/share/lintian/overrides/; \
451 fi; \
452 case "$$pkgname" in \
453 gcc-$(GCC_VER)-cross-base*) \
454 echo "$$pkgname binary: wrong-name-for-changelog-of-native-package" \
455 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
456 ;; \
457 gcc-$(GCC_VER)-*-base) \
458 echo "$$pkgname binary: wrong-name-for-changelog-of-native-package" \
459 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
460 ;; \
461 gcc-$(GCC_VER)-multilib) \
462 echo "$$pkgname binary: binary-from-other-architecture" \
463 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
464 ;; \
465 gccgo-$(GCC_VER)*) \
466 echo "$$pkgname binary: binary-from-other-architecture" \
467 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
468 echo "$$pkgname binary: non-standard-dir-in-usr" \
469 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
470 ;; \
471 *-multilib-*) \
472 ;; \
473 cpp-*|g++-*|gcc-*|gccgo-*|gdc-*|gfortran-*|gobjc*|gm2-*|gnat-$(GCC_VER)-sjlj-*) \
474 echo "$$pkgname binary: binary-from-other-architecture" \
475 >> $$tmp/usr/share/lintian/overrides/$$pkgname \
476 ;; \
477 gnat-$(GCC_VER)-*) \
478 echo "$$pkgname binary: binary-from-other-architecture" \
479 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
480 echo "$$pkgname binary: non-standard-dir-in-usr" \
481 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
482 ;; \
483 *-dev-$${t_arch}-cross) \
484 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
485 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
486 echo "$$pkgname binary: non-standard-dir-in-usr" \
487 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
488 ;; \
489 *-dbg-$${t_arch}-cross) \
490 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
491 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
492 echo "$$pkgname binary: debug-package-should-be-named-dbg" \
493 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
494 echo "$$pkgname binary: non-standard-dir-in-usr" \
495 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
496 ;; \
497 *-pic-$${t_arch}-cross) \
498 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
499 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
500 ;; \
501 *-$${t_arch}-cross) \
502 echo "$$pkgname binary: arch-independent-package-contains-binary-or-object" \
503 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
504 echo "$$pkgname binary: non-standard-dir-in-usr" \
505 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
506 echo "$$pkgname binary: shlibs-declares-dependency-on-other-package" \
507 >> $$tmp/usr/share/lintian/overrides/$$pkgname; \
508 case "$$pkgname" in \
509 lib*gphobos*) \
510 echo "$$pkgname binary: embedded-library" \
511 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
512 *-hppa-cross) \
513 echo "$$pkgname binary: binary-compiled-with-profiling-enabled" \
514 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
515 esac; \
516 ;; \
517 esac; \
518 case $$pkgname in \
519 lib*san*-cross) \
520 echo "$$pkgname binary: custom-library-search-path" \
521 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
522 libstdc++-*-dev-amd64-cross) \
523 sed -i -e "/^Depends:/s/libc6 /libc6-amd64-cross /g" \
524 -e "/^Depends:/s/libgcc-s1 /libgcc-s1-amd64-cross /g" \
525 $$tmp/DEBIAN/control; \
526 echo "$$pkgname binary: missing-dependency-on-libc" \
527 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
528 lib64stdc++-*-dev-i386-cross) \
529 sed -i -e "/^Depends:/s/libc6 /libc6-amd64-i386-cross /g" \
530 -e "/^Depends:/s/libgcc-s1 /lib64gcc-s1-i386-cross /g" \
531 $$tmp/DEBIAN/control; \
532 echo "$$pkgname binary: missing-dependency-on-libc" \
533 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
534 lib64stdc++-*-dev-x32-cross) \
535 sed -i -e "/^Depends:/s/libc6 /libc6-amd64-x32-cross /g" \
536 -e "/^Depends:/s/libgcc-s1 /lib64gcc-s1-x32-cross /g" \
537 $$tmp/DEBIAN/control; \
538 echo "$$pkgname binary: missing-dependency-on-libc" \
539 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
540 lib??*stdc++-*-dev-*-cross) \
541 sed -i -e "/^Depends:/s/\(libc6-[[a-z0-9]*\):\([a-z0-9]*\)/\1-\2-cross/g" \
542 $$tmp/DEBIAN/control; \
543 echo "$$pkgname binary: missing-dependency-on-libc" \
544 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
545 libstdc++-*-dev-*-cross) \
546 sed -i -e "/^Depends:/s/\(libc6[.1]*\):\([a-z0-9]*\)/\1-\2-cross/g" \
547 $$tmp/DEBIAN/control; \
548 echo "$$pkgname binary: missing-dependency-on-libc" \
549 >> $$tmp/usr/share/lintian/overrides/$$pkgname;; \
550 esac; \
551 if [ -e $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gz ]; then \
552 mv $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gz \
553 $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gcc-${GCC_VER}.gz; \
554 gzip -c9n debian/changelog \
555 > $$tmp/usr/share/doc/gcc-${GCC_VER}-$${t_gnu_type}-base/changelog.Debian.gz;\
556 fi ; \
557 rm -f $$tmp/DEBIAN/md5sums; \
558 (cd $$tmp && find usr -type f | LC_ALL=C sort | xargs -r md5sum >>DEBIAN/md5sums); \
559 find $$tmp/DEBIAN -name md5sums -empty | xargs -r rm -f; \
560 newdeb=`echo $$deb|sed -e "s/\(.*\)_\(.*\)_\(.*\)/\1_\2$(CROSS_EXT)_\3/g"`; \
561 NO_PKG_MANGLE=1 dpkg-deb -b $$tmp ../$$newdeb; \
562 rm -rf $$tmp
563 touch $@
564
565 $(stamp)repack-debs-arch: $(stamp)build
566 @echo START $@
567 dh_testroot
568 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(HOST_ARCH) \
569 $(addprefix $(stamp)repack-,$(wildcard *_$(HOST_ARCH_EXT).deb))
570 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(HOST_ARCH) \
571 $(addprefix $(stamp)repack-,$(wildcard *$(DEB_VER_GCC)_$(HOST_ARCH_EXT).ddeb))
572 rm -f *$(DEB_VER_GCC)_$(HOST_ARCH_EXT).ddeb
573 if [ -f ../gcc-$(GCC_VER)-$(call _gnu_type,$(HOST_ARCH))-dbgsym_${DEB_VER_GCC}$(CROSS_EXT)_$(HOST_ARCH).ddeb ]; then mv -f ../*.ddeb . ; fi
574 touch $@
575
576 $(stamp)repack-debs-indep: $(stamp)build
577 @echo START $@
578 dh_testroot
579 set -e; \
580 $(foreach arch,$(CROSS_ARCHS), \
581 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(arch) \
582 $(addprefix $(stamp)repack-,$(wildcard *-$(arch)-cross_*_all.deb)); \
583 )
584 $(MAKE) $(NJOBS) -f debian/rules TARGET_ARCH=$(HOST_ARCH) \
585 $(addprefix $(stamp)repack-,$(wildcard gcc-$(GCC_VER)-cross-base$(GCC_PORTS_BUILD)_*_all.deb))
586 touch $@
587
588 build: $(stamp)build
589 $(stamp)build: $(foreach arch,$(CROSS_ARCHS),$(addsuffix .$(arch),$(stamp)build-gcc))
590 @echo START $@
591 touch $@
592
593 build: dbp_flag = -b
594 build-arch: dbp_flag = -B
595 build-indep: dbp_flag = -b
596
597 build-arch: $(stamp)build
598 build-indep: $(stamp)build
599
600 binary: binary-arch binary-indep
601 binary-arch: build-arch $(stamp)build $(stamp)repack-debs-arch $(stamp)mangle-debian-files-arch
602 binary-indep: build-indep $(stamp)build $(stamp)repack-debs-indep $(stamp)mangle-debian-files-indep
603
604 define generate_debian_files
605 touch debian/files
606 for deb in $1; do \
607 [ -f "$$deb" ] || continue; \
608 pkg=`basename $$deb`; \
609 if [ "$(skip_dbg_packages)" = yes ]; then \
610 case $$pkg in *-dbg*) continue; esac; \
611 fi; \
612 if [ "$(skip_arm32ml_packages)" = yes ] && grep -q "^$$pkg$$" debian/packages.arm32ml; then \
613 continue; \
614 fi; \
615 if [ "$(skip_common_packages)" = yes ] && grep -q "^$$pkg$$" debian/packages.common; then \
616 continue; \
617 fi; \
618 echo -n "$$pkg " >>debian/files; \
619 dpkg-deb -I $$deb | grep Section | cut -d ' ' -f 3 | tr "\n" ' ' >>debian/files; \
620 dpkg-deb -I $$deb | grep Priority | cut -d ' ' -f 3 | tr "\n" ' ' >>debian/files; \
621 dpkg-deb -I $$deb | awk '/^ Architecture:/ {printf "architecture=%s", $$2}' >>debian/files; \
622 echo "" >>debian/files; \
623 done
624 endef
625
626 $(stamp)mangle-debian-files-arch: build $(stamp)repack-debs-arch $(stamp)debian-files-base
627 @echo START $@
628 $(call generate_debian_files, *_$(HOST_ARCH_EXT).deb)
629 sed -i -e "s/${DEB_VER_GCC}_/${DEB_VER_GCC}$(CROSS_EXT)_/g" debian/files
630 touch $@
631
632 $(stamp)mangle-debian-files-indep: $(stamp)repack-debs-indep $(stamp)debian-files-base
633 @echo START $@
634 $(call generate_debian_files, *_all.deb)
635 sed -i -e "s/${DEB_VER_GCC}_/${DEB_VER_GCC}$(CROSS_EXT)_/g" debian/files
636 touch $@
637
638 $(stamp)debian-files-base:
639 @echo START $@
640 rm -f debian/files
641 touch $@
642
643
644 control:
645 sed -e "s/MIN_VER_GCC/${MIN_VER_GCC}/g" \
646 -e "s/GCC_BUILD_DEPS/$(GCC_BUILD_DEPS)/g" \
647 -e "s/BINUTILS_BUILD_DEPS/$(BINUTILS_BUILD_DEPS)/g" \
648 -e "s/GLIBC_BUILD_DEPS/$(GLIBC_BUILD_DEPS)/g" \
649 -e "s/EXTRA_BUILD_DEPS/${EXTRA_BUILD_DEPS}/g" \
650 -e "s/LINUX_BUILD_DEPS/$(LINUX_BUILD_DEPS)/g" \
651 -e "s/GCC_VER/${GCC_VER}/g" \
652 -e "s/MIN_VER_BINUTILS/${MIN_VER_BINUTILS}/g" \
653 -e "s/VER_BINUTILS/${VER_BINUTILS}/g" \
654 -e "s/VER_ISL/${VER_ISL}/g" \
655 -e "s/GCC_PORTS_BUILD/$(GCC_PORTS_BUILD)/g" \
656 $(CURDIR)/debian/control.source.in >$(CURDIR)/debian/control
657
658 $(foreach a,$(CROSS_ARCHS), \
659 sed \
660 -e 's/PHOBOS_DEP/$(if $(filter $(a),$(PHOBOS_ARCHS)),${PHOBOS_DEP})/g' \
661 -e 's/PHOBOS_ML_DEP/$(if $(filter $(a),$(PHOBOS_ARCHS)),${PHOBOS_ML_DEP})/g' \
662 -e 's/CROSS_ARCH/$(a)/g' \
663 -e 's/CROSS_GNU_TYPE/$(call _pkg_gnu_type,$(a))/g' \
664 -e 's/MIN_VER_GCC/${MIN_VER_GCC}/g' \
665 -e 's/GCC_VER/${GCC_VER}/g' \
666 -e 's/MIN_VER_BINUTILS/${MIN_VER_BINUTILS}/g' \
667 -e 's/@host_archs@/$(filter-out $(a),$(HOST_ARCHS_$(a)))/g' \
668 -e 's/@ada_host_archs@/$(filter-out $(a),$(HOST_ARCHS_$(a)))/g' \
669 -e 's/@ada64_host_archs@/$(filter-out $(a),$(filter-out XXXi386,$(HOST_ARCHS_$(a))))/g' \
670 $(CURDIR)/debian/control.arch.in >>$(CURDIR)/debian/control; )
671
672 cp debian/packages.invalid debian/packages.invalid-all
673 ifeq (,$(filter $(distrelease), buster bullseye bookworm trixie trusty xenial bionic focal jammy mantic noble))
674 cat debian/packages.invalid-s390x >> debian/packages.invalid-all
675 endif
676 python3 debian/remove-unbuilt \
677 $(if $(filter yes,$(skip_dbg_packages)), --skip-dbg-packages) \
678 $(if $(filter yes,$(skip_arm32ml_packages)), --skip-arm32ml-packages) \
679 $(if $(filter yes,$(skip_common_packages)), --skip-common-packages) \
680 debian/control debian/packages.invalid-all debian/packages.arm32ml debian/packages.common \
681 > debian/control.new && mv debian/control.new debian/control
682 rm -f debian/packages.invalid-all
683
684 sort-pkgfiles:
685 for i in packages.arm32ml packages.common packages.invalid; do \
686 LC_ALL=C sort -u debian/$$i > debian/$$i.tmp; \
687 mv -f debian/$$i.tmp debian/$$i; \
688 done
689
690 .PRECIOUS: $(stamp)init-dirs \
691 $(stamp)init-gcc \
692 $(stamp)build \
693 $(stamp)build-gcc.% \
694 $(stamp)debian-files-base \
695 $(stamp)repack-debs-arch \
696 $(stamp)repack-debs-indep \
697 $(stamp)repack-debs-indep.% \
698 $(stamp)mangle-debian-files-arch
699 $(stamp)mangle-debian-files-indep \
700 build build-arch build-indep binary binary-arch binary-indep