summaryrefslogtreecommitdiff
path: root/debian/rules.patch
blob: e0d648da788998b473648e34e504f812d20ed50d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# -*- makefile -*-
# rules to patch the unpacked files in the source directory
# ---------------------------------------------------------------------------
# various rules to unpack addons and (un)apply patches.
# 	- patch / apply-patches
#	- unpatch / reverse-patches

.NOTPARALLEL:

patchdir	?= debian/patches
series_file	?= $(patchdir)/series

# which patches should be applied?

debian_patches = \
	svn-updates \
	libiberty-updates \
	$(if $(with_linaro_branch),gcc-linaro-revert-r247639) \
	$(if $(with_linaro_branch),gcc-linaro-revert-r246734) \
	$(if $(with_linaro_branch),gcc-linaro) \
	$(if $(with_linaro_branch),gcc-linaro-no-macros) \

#	svn-updates \

ifeq ($(with_java),yes)
#  debian_patches += \
#	svn-class-updates
endif

ifneq ($(GFDL_INVARIANT_FREE),yes)
  debian_patches += \
	svn-doc-updates \
	$(if $(with_linaro_branch),gcc-linaro-doc) \
	rename-info-files \
	gcc-SOURCE_DATE_EPOCH-doc \
	gcc-SOURCE_DATE_EPOCH-2-doc \
	$(if $(with_linaro_branch),,vulcan-cpu-doc) \
	gcc-fuse-ld-lld-doc \

#	svn-doc-updates \
#	$(if $(with_linaro_branch),,svn-doc-updates) \

else
endif
debian_patches += \
	gcc-gfdl-build

#	boehm-gc-nocheck: seems to work on the buildds \

debian_patches += \
	gcc-textdomain \
	gcc-driver-extra-langs$(if $(with_linaro_branch),-linaro)

ifneq (,$(filter $(distrelease),etch lenny squeeze wheezy dapper hardy intrepid jaunty karmic lucid))
  debian_patches += gcc-hash-style-both
else
  debian_patches += gcc-hash-style-gnu
endif

debian_patches += \
	libstdc++-pic \
	libstdc++-doclink \
	libstdc++-man-3cxx \
	libstdc++-test-installed \
	libjava-stacktrace \
	libjava-jnipath \
	libjava-sjlj \
	libjava-disable-plugin \
	alpha-no-ev4-directive \
	boehm-gc-getnprocs \
	note-gnu-stack \
	libgomp-omp_h-multilib \
	gccgo-version \
	pr47818 \
	gcc-base-version \
	libgo-testsuite \
	gcc-target-include-asm \
	libgo-revert-timeout-exp \
	libgo-setcontext-config \
	gcc-auto-build \
	kfreebsd-unwind \
	libitm-no-fortify-source \
	sparc64-biarch-long-double-128 \
	gcc-ia64-bootstrap-ignore \
	gotools-configury \
	pr66368 \
	pr67590 \
	ada-gnattools-ldflags \
	libjit-ldflags \
	gcc-SOURCE_DATE_EPOCH \
	gcc-SOURCE_DATE_EPOCH-2 \
	cmd-go-combine-gccgo-s-ld-and-ldShared-methods \
	libjava-mips64el \
	gccgo-issue16780 \
	$(if $(with_linaro_branch),,vulcan-cpu) \
	$(if $(with_linaro_branch),,vulcan-costs) \
	libffi-pax \
	libffi-race-condition \
	libgo-add-getrandom-mips-sparc \
	libgo-fix-getrandom-clone-sparc64 \
	libgo-rawClone-no_split_stack \
	libgo-rawClone-no-pt_regs \
	libgo-elf-relocations-sparc64 \
	libobjc-system-gc \
	compress-debug-check \
	pr77267 \
	pr78774 \
	CVE-2016-9840 \
	CVE-2016-9841 \
	CVE-2016-9842 \
	CVE-2016-9843 \
	libcc1-compiler-name \
	mips-pr78176-add-mlxc1-sxc1 \
	mips-loongson3a-use-fused-madd.d \
	mips-madd4 \
	gcc-fuse-ld-lld \
	pr72813 \
	pr70909 \
	pr77857 \
	pr80533 \
	pr60818 \

ifeq ($(libstdcxx_abi),new)
  debian_patches += libstdc++-functexcept
endif

#	$(if $(filter yes, $(DEB_CROSS)),,gcc-print-file-name) \
#	libstdc++-nothumb-check \
# TODO: update ...
#	libjava-rpath \

hardening_patches =
ifeq ($(with_ssp)-$(with_ssp_default),yes-yes)
  hardening_patches += gcc-default-ssp
  hardening_patches += gcc-default-format-security
  ifeq (,$(filter $(distrelease),dapper hardy lucid maverick natty oneiric precise quantal raring saucy trusty))
    hardening_patches += gcc-default-ssp-strong
  endif
endif
ifneq (,$(filter $(derivative),Ubuntu))
  ifneq (,$(findstring gcc-6, $(PKGSOURCE)))
    hardening_patches += \
	gcc-default-fortify-source \
	gcc-default-relro \
	testsuite-hardening-format \
	testsuite-hardening-printf-types \
	testsuite-hardening-updates \
	testsuite-glibc-warnings
    ifeq ($(with_pie),yes)
      hardening_patches += \
	bind_now_when_pie
    else
      hardening_patches += \
	ignore-pie-specs-when-not-enabled
    endif
  endif
else ifneq (,$(filter $(derivative),Debian))
  ifneq (,$(findstring gcc-6, $(PKGSOURCE)))
#    ifneq ($(with_pie),yes)
#      hardening_patches += \
#	ignore-pie-specs-when-not-enabled
#    endif
  endif
endif

# FIXME 4.5: Drop and adjust symbols files
ifneq (,$(findstring 4.4, $(PKGSOURCE)))
  debian_patches += pr39491
endif

debian_patches += ada-arm
debian_patches += ada-kfreebsd
debian_patches += ada-revert-pr63225

ifeq (,$(DEB_STAGE))
# there should be no harm to always apply these, except for new GCC versions
#ifeq ($(with_ada),yes)
  debian_patches += \
	ada-driver-check \
	ada-default-project-path \
	ada-library-project-files-soname

	# FIXME: needs update
	#ada-symbolic-tracebacks \

  ifeq ($(biarch64),yes)
    debian_patches += \
	ada-nobiarch-check
  endif

  #ifeq ($(with_libgnat),yes)
    debian_patches += \
	ada-link-lib \
	ada-libgnatvsn \
	ada-libgnatprj \
	ada-gnattools-cross \
	ada-acats \
	libgnatprj-cross-hack
    ifneq (,$(filter $(distrelease),lucid precise))
      debian_patches += \
	libgnatprj-link
    endif
  #endif
  #ifeq ($(with_gnatsjlj),yes)
    debian_patches += \
	ada-sjlj
  #endif

  debian_patches += ada-link-shlib
  debian_patches += ada-gcc-name
#endif
endif # DEB_STAGE


ifeq ($(with_d),yes)
  debian_patches += \
	gdc-6 \
	gdc-updates \
	libphobos-zlib \
	gdc-versym-cpu \
	gdc-versym-os \
	gdc-frontend-posix \
	gdc-base-version \
	gdc-profiledbuild \
#	gdc-multiarch
  ifneq ($(GFDL_INVARIANT_FREE),yes)
    debian_patches += gdc-6-doc
  else
    debian_patches += gdc-texinfo
  endif
  ifeq ($(with_libphobos),yes)
    debian_patches += gdc-libphobos-build
  else
    debian_patches += gdc-driver-nophobos
  endif
  ifeq (,$(filter $(DEB_TARGET_ARCH),amd64 i386))
    debian_patches += disable-gdc-tests
  endif
else
  debian_patches += gcc-d-lang
endif

ifeq ($(DEB_TARGET_ARCH),alpha)
  debian_patches += alpha-ieee
  ifneq ($(GFDL_INVARIANT_FREE),yes)
    debian_patches += alpha-ieee-doc
  endif
endif

ifeq (,$(filter $(derivative),Ubuntu))
  debian_patches += pr64735-headers
  ifeq ($(DEB_TARGET_ARCH),armel)
    debian_patches += pr64735
  endif
endif

ifneq (,$(findstring $(DEB_TARGET_ARCH),arm armel armhf))
  debian_patches += libjava-armel-unwind
endif

ifeq ($(DEB_TARGET_ARCH),armhf)
 debian_patches += gcj-arm-mode
else ifeq ($(DEB_TARGET_ARCH),armel)
  ifneq (,$(filter $(distrelease),lucid maverick natty oneiric precise))
    debian_patches += gcj-arm-mode
  endif
endif

ifneq (,$(findstring mips, $(DEB_TARGET_ARCH)))
  debian_patches += pr65618
endif

ifeq ($(DEB_TARGET_ARCH),powerpcspe)
  debian_patches += powerpc_remove_many
  debian_patches += powerpc_nofprs
endif

#debian_patches += link-libs

# all patches below this line are applied for gcc-snapshot builds as well

ifeq ($(single_package),yes)
  debian_patches =
endif

debian_patches += \
	sys-auxv-header \
	libcilkrts-targets \

ifeq ($(with_ibm_branch),yes)
  debian_patches += ibm-branch
endif

ifeq ($(with_softfloat),yes)
  debian_patches += arm-multilib-soft-float
else ifeq ($(multilib),yes)
  ifneq (,$(filter $(distrelease),lucid maverick natty oneiric precise))
    debian_patches += arm-multilib-softfp$(if $(filter yes,$(DEB_CROSS)),-cross)
  else
    debian_patches += arm-multilib-soft$(if $(filter yes,$(DEB_CROSS)),-cross)
  endif
endif
debian_patches += arm-multilib-defaults

ifeq ($(DEB_CROSS),yes)
  debian_patches += cross-fixes
  debian_patches += cross-install-location
  ifeq ($(with_d),yes)
    debian_patches += gdc-cross-install-location
  endif
endif

ifeq ($(DEB_TARGET_ARCH_OS),hurd)
  debian_patches += hurd-changes
  debian_patches += \
		src_gcc_config_i386_gnu.h \
		src_libgo_configure.ac \
		src_libgo_runtime_go-caller.c \
		src_libgo_go_net_sendfile_gnu.go \
		src_libgo_go_net_sock_gnu.go \
		src_libgo_go_net_sockopt_gnu.go \
		src_libgo_go_net_sockoptip_gnu.go \
		src_libgo_go_syscall_libcall_gnu_386.go \
		src_libgo_go_syscall_libcall_gnu.go \
		src_libgo_go_syscall_libcall_posix-1.go \
		src_libgo_go_syscall_socket_gnu.go \
		src_libgo_go_syscall_wait.c \
		src_libgo_Makefile.am \
		src_libgo_Makefile.in \
		src_libgo_mksysinfo.sh \
		src_libgo_runtime_getncpu-gnu.c \
		src_libgo_runtime_netpoll.goc \
		src_libgo_go_os_os_test.go \
		src_libgo_go_syscall_syscall_gnu_test.go \
		src_libgo_testsuite_gotest \
		add-gnu-to-libgo-headers
endif

debian_patches += gcc-ice-dump
debian_patches += gcc-ice-apport
debian_patches += skip-bootstrap-multilib
debian_patches += libjava-fixed-symlinks
debian_patches += libffi-ro-eh_frame_sect
debian_patches += libffi-mips

# sigaction on sparc changed between glibc 2.19 and 2.21
ifeq (,$(filter 2.1%, $(shell dpkg-query -l libc-bin | awk '/^.i/ {print $$3}')))
  debian_patches += pr67899
endif

debian_patches += gcc-multiarch
ifeq ($(with_multiarch_lib),yes)
  ifneq ($(single_package),yes)
    debian_patches += libjava-multiarch
  endif
endif
debian_patches += libjava-nobiarch-check
debian_patches += config-ml
ifneq ($(single_package),yes)
  ifeq ($(with_multiarch_cxxheaders),yes)
    debian_patches += g++-multiarch-incdir
    debian_patches += canonical-cpppath
  endif
endif
ifneq (,$(filter $(build_type), build-cross cross-build-cross))
  debian_patches += cross-no-locale-include
  debian_patches += cross-biarch
  ifeq ($(with_libphobos),yes)
    debian_patches += gdc-cross-biarch
  endif
endif
debian_patches += gcc-multilib-multiarch

ifneq (,$(filter $(derivative),Ubuntu))
  ifeq (,$(filter $(distrelease),dapper hardy intrepid jaunty karmic lucid maverick))
    debian_patches += gcc-as-needed
    ifeq (,$(filter $(distrelease),dapper hardy intrepid jaunty karmic lucid maverick precise trusty utopic vivid wily xenial yakkety))
      debian_patches += gcc-as-needed-gold
    endif
  endif
else # Debian
    #debian_patches += gcc-as-needed
endif

debian_patches += libgomp-kfreebsd-testsuite
debian_patches += go-testsuite

# Ada patches needed for both the stable package and snapshot builds
debian_patches += ada-749574
debian_patches += ada-mips
ifeq ($(DEB_TARGET_ARCH),m68k)
  debian_patches += ada-m68k
  ifeq ($(with_ada),yes)
    debian_patches += m68k-revert-pr45144
  endif
endif

ifeq ($(DEB_TARGET_ARCH_OS), illumos)
	debian_patches += illumos-multiarch
	debian_patches += illumos-spec
	debian_patches += illumos-use_libgcj_bc
	debian_patches += illumos-pragma-align
	debian_patches += illumos-fclone-functions
	debian_patches += illumos-strict-calling-conventions
	debian_patches += illumos-boehm-gc
	debian_patches += illumos-libgcc-regs
	debian_patches += illumos-sysdep-unix.c
endif

# don't remove, this is regularly overwritten, see PR sanitizer/63958.
#debian_patches += libasan-sparc

series_stamp = $(stampdir)/02-series-stamp
series: $(series_stamp)
$(series_stamp):
	echo $(strip $(addsuffix .diff,$(debian_patches))) \
	  | sed -r 's/  +/ /g' | tr " " "\n" > $(series_file)
ifneq (,$(strip $(hardening_patches)))
  ifneq ($(trunk_build),yes)
	echo $(strip $(addsuffix .diff,$(hardening_patches))) \
	  | sed -r 's/  +/ /g' | tr " " "\n" >> $(series_file)
  endif
endif
	sed -r 's/(.)$$/\1 -p1/' -i $(series_file)
	touch $@

autoconf_files = $(filter-out src/libjava/classpath/m4/acinclude.m4, \
	  $(shell lsdiff --no-filename $(foreach patch,$(debian_patches),$(patchdir)/$(patch).diff) \
	    | sed -rn '/(configure\.ac|acinclude.m4)$$/s:[^/]+/src/:src/:p' | sort -u))
autoconf_dirs = $(sort $(dir $(autoconf_files)))

automake_files = $(addprefix ./, $(filter-out none, \
	  $(shell lsdiff --no-filename $(foreach patch,$(debian_patches),$(patchdir)/$(patch).diff) \
	    | sed -rn '/Makefile\.(am|in)$$/s:[^/]+/src/:src/:p' | sort -u)))

autoconf_version = 2.64
ifeq ($(trunk_build),yes)
  # The actual version depends on the build-dependencies set by
  # variable AUTO_BUILD_DEP in rules.conf.  Here, we assume the
  # correct version is installed.
  #autoconf_version =
endif

# FIXME: the auto* stuff is done every time for every subdir, which
# leads to build errors. Idea: record the auto* calls in the patch
# files (AUTO <dir> <auto-command with options>) and run them separately,
# maybe only once per directory).
$(patch_stamp): $(unpack_stamp) $(series_stamp)
	sync
	QUILT_PATCHES=$(patchdir) \
	  quilt --quiltrc /dev/null push -a || test $$? = 2

ifneq (,$(filter svn-updates, $(debian_patches)))
	awk '/^EOF/ {exit} p==1 {print} /EOF$$/ {p=1}' \
	  $(patchdir)/svn-updates.diff > src/LAST_UPDATED
endif

ifneq (,$(filter libgo-elf-relocations-sparc64, $(debian_patches)))
	uudecode $(patchdir)/../go-relocation-test-gcc620-sparc64.obj.uue
endif

	: # only needed when we have changes, and currently fails with autogen 5.18
	: #cd $(srcdir)/fixincludes && ./genfixes

	sync
	echo -n $(autoconf_dirs) | xargs -d ' ' -L 1 -P $(USE_CPUS) -I{} \
	  sh -c 'echo "Running autoconf$(autoconf_version) in {}..." ; \
	  cd $(CURDIR)/{} && \
	  AUTOM4TE=/usr/bin/autom4te$(autoconf_version) autoconf$(autoconf_version)'

	for i in $(debian_patches) $(hardening_patches); do \
	  echo -e "\n$$i:" >> pxxx; \
	  sed -n 's/^# *DP: */  /p' $(patchdir)/$$i.diff >> pxxx; \
	done
#	-$(srcdir)/move-if-change pxxx $@
	mv pxxx $@

unpatch:
ifneq (,$(filter libgo-elf-relocations-sparc64, $(debian_patches)))
	# uudecoded in $(patch_stamp) rule
	rm -f $(srcdir)/libgo/go/debug/elf/testdata/go-relocation-test-gcc620-sparc64.obj
endif

	QUILT_PATCHES=$(patchdir) \
	  quilt --quiltrc /dev/null pop -a -R || test $$? = 2
	rm -rf .pc

update-patches: $(series_stamp)
	export QUILT_PATCHES=$(patchdir); \
	export QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab"; \
	export QUILT_DIFF_ARGS="--no-timestamps --no-index -pab"; \
	while quilt push; do quilt refresh; done

patch: $(patch_stamp)
.PHONY: patch series quilt autotools