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