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