aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/APKBUILD
blob: edb9bffc283833801e71048ab3e25eb9797a84cc (plain) (blame)
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gcc
pkgver=6.1.0
_cross=""
[ "$BOOTSTRAP" = "noheaders" ] && pkgname="gcc-pass1"
[ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2"
[ "$CHOST" != "$CTARGET" ] && [ -n "$CHOST" -a -n "$CTARGET" ] \
	&& _cross="-$CTARGET"

pkgname="$pkgname$_cross"
pkgrel=2
pkgdesc="The GNU Compiler Collection"
url="http://gcc.gnu.org"
arch="all"
license="GPL LGPL"
_gccrel=$pkgver-r$pkgrel
depends="binutils$_cross isl"
makedepends_build="paxmark bison flex texinfo gawk zip gmp-dev mpfr-dev mpc1-dev zlib-dev"
makedepends_host="linux-headers gmp-dev mpfr-dev mpc1-dev zlib-dev !gettext-dev"
makedepends="$makedepends_build $makedepends_host"
subpackages=" "
[ "$CHOST" = "$CTARGET" ] && subpackages="gcc-doc$_cross"
replaces="libstdc++ binutils"

: ${LANG_CXX:=true}
: ${LANG_OBJC:=true}
: ${LANG_JAVA:=true}
: ${LANG_GO:=true}
: ${LANG_FORTRAN:=true}
: ${LANG_ADA:=true}

LIBGOMP=true
LIBGCC=true
LIBATOMIC=true
LIBITM=true
if [ "$CHOST" != "$CTARGET" ] && [ -n "$CHOST" -a -n "$CTARGET" ]; then
	if [ "$BOOTSTRAP" ]; then
		LANG_CXX=false
		LANG_ADA=false
		LIBGCC=false
		_builddir="$srcdir/build-cross-pass2"
	else
		_builddir="$srcdir/build-cross-final"
	fi
	LANG_OBJC=false
	LANG_JAVA=false
	LANG_GO=false
	LANG_FORTRAN=false
	LIBGOMP=false
	LIBATOMIC=false
	LIBITM=false

	# reset target flags (should be set in crosscreate abuild)
	# fixup flags. seems gcc treats CPPFLAGS as global without
	# _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS.
	export CFLAGS="$CPPFLAGS $CFLAGS"
	export CXXFLAGS="$CPPFLAGS $CXXFLAGS"
	unset CPPFLAGS
	export CFLAGS_FOR_TARGET=" "
	export CXXFLAGS_FOR_TARGET=" "
	export LDFLAGS_FOR_TARGET=" "

	STRIP_FOR_TARGET="$CTARGET-strip"
elif [ "$CBUILD" != "$CHOST" ] && [ -n "$CBUILD" -a -n "$CHOST" ]; then
	# fixup flags. seems gcc treats CPPFLAGS as global without
	# _FOR_xxx variants. wrap it in CFLAGS and CXXFLAGS.
	export CFLAGS="$CPPFLAGS $CFLAGS"
	export CXXFLAGS="$CPPFLAGS $CXXFLAGS"
	unset CPPFLAGS

	# reset flags and cc for build
	export CC_FOR_BUILD="gcc"
	export CXX_FOR_BUILD="g++"
	export CFLAGS_FOR_BUILD=" "
	export CXXFLAGS_FOR_BUILD=" "
	export LDFLAGS_FOR_BUILD=" "

	# Languages that do not need bootstrapping
	LANG_OBJC=false
	LANG_JAVA=false
	LANG_GO=false
	LANG_FORTRAN=false

	STRIP_FOR_TARGET=${CROSS_COMPILE}strip
	_builddir="$srcdir/build-cross-native"
else
	STRIP_FOR_TARGET=${CROSS_COMPILE}strip
	_builddir="$srcdir/build"
fi

# Go needs {set,make,swap}context, unimplemented in musl
[ "$CTARGET_LIBC" = musl ] && LANG_GO=false

# libitm has TEXTRELs in ARM build, so disable for now
case "$CTARGET_ARCH" in
arm*)		LIBITM=false ;;
esac

# Fortran uses libquadmath if toolchain has __float128
# currently on x86, x86_64 and ia64
LIBQUADMATH=$LANG_FORTRAN
case "$CTARGET_ARCH" in
x86 | x86_64)	LIBQUADMATH=$LANG_FORTRAN ;;
*)		LIBQUADMATH=false ;;
esac

# libatomic is a dependency for openvswitch
$LIBATOMIC && subpackages="$subpackages libatomic"
$LIBGCC && subpackages="$subpackages libgcc"
$LIBQUADMATH && subpackages="$subpackages libquadmath"
if $LIBGOMP; then
	depends="$depends libgomp=$_gccrel"
	subpackages="$subpackages libgomp"
fi

_languages=c
if $LANG_CXX; then
	subpackages="$subpackages libstdc++:libcxx g++$_cross:gpp"
	_languages="$_languages,c++"
fi
if $LANG_OBJC; then
	subpackages="$subpackages libobjc gcc-objc$_cross:objc"
	_languages="$_languages,objc"
fi
if $LANG_JAVA; then
	subpackages="$subpackages libgcj gcc-java$_cross:java"
	_languages="$_languages,java"
fi
if $LANG_GO; then
	subpackages="$subpackages libgo gcc-go$_cross:go"
	_languages="$_languages,go"
fi
if $LANG_FORTRAN; then
	subpackages="$subpackages libgfortran gfortran$_cross:gfortran"
	_languages="$_languages,fortran"
fi
if $LANG_ADA; then
	[ "$CHOST" = "$CTARGET" ] && subpackages="$subpackages libgnat"
	subpackages="$subpackages gcc-gnat$_cross:gnat"
	_languages="$_languages,ada"
	makedepends="$makedepends gcc-gnat"
fi

source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-$pkgver.tar.bz2
	ftp://sourceware.org/pub/java/ecj-4.9.jar

	001_all_default-ssp-strong.patch
	002_all_default-relro.patch
	003_all_default-fortify-source.patch
	004_all_default-hash-gnu.patch
	005_all_default-as-needed.patch
	011_all_default-warn-format-security.patch
	012_all_default-warn-trampolines.patch
	020_all_msgfmt-libstdc++-link.patch
	050_all_libiberty-asprintf.patch
	051_all_libiberty-pic.patch
	053_all_libitm-no-fortify-source.patch
	067_all_gcc-poison-system-directories.patch
	074_all_gcc6_isl-dl.patch
	090_all_pr55930-dependency-tracking.patch

	201-cilkrts.patch
	202-posix_memalign.patch
	203-libgcc_s.patch
	204-linux_libc_has_function.patch
	205-nopie.patch
	207-static-pie.patch

	libgcc-always-build-gcceh.a.patch
	libada-cross-shared.patch
	gcc-4.9-musl-fortify.patch
	gcc-6.1-musl-libssp.patch
	boehm-gc-musl.patch
	gcc-pure64.patch
	fix-gcj-stdgnu14-link.patch
	fix-gcj-musl.patch
	fix-gcj-iconv-musl.patch

	gcc-4.8-build-args.patch
	fix-cxxflags-passing.patch
	ada-fixes.patch
	ada-shared.patch
	ada-musl.patch

	pr70839.patch
	"

# we build out-of-tree
_gccdir="$srcdir"/gcc-$pkgver
_gcclibdir=/usr/lib/gcc/${CTARGET}/$pkgver
_gcclibexec=/usr/libexec/gcc/${CTARGET}/$pkgver

prepare() {
	cd "$_gccdir"
	# verify we have set CHOST
	if [ -z "$CHOST" ]; then
		error "CHOST not set"
		return 1
	fi

	# Gentoo, PIE and uclibc patches
	_err=
	for i in $source; do
		case "$i" in
		*.patch)
			msg "Applying $i"
			patch -p1 -F3 -i "$srcdir"/$i || _err="$_err $i"
			;;
		esac
	done

	if [ -n "$_err" ]; then
		error "The following patches failed:"
		for i in $_err; do
			echo "  $i"
		done
		return 1
	fi

	# genautomata crashes with a "Bus Error" when compiled with PIC
	# mostly affecting cross-builds as on native build bootstrapping
	# somehow seems to build proper genautomata
	sed -i gcc/Makefile.in -e 's|^build/genautomata$(build_exeext) .*|& -fno-PIC|' \
		|| return 1

	# see http://gcc.gnu.org/ml/java/2008-04/msg00027.html
	mv "$srcdir"/ecj-*.jar ecj.jar

	echo ${pkgver} > gcc/BASE-VER
}

build() {
	local _arch_configure=
	local _libc_configure=
	local _cross_configure=
	local _bootstrap_configure=
	local _symvers=

	cd "$_gccdir"

	case "$CTARGET" in
	armv7-*-*-*eabihf)	_arch_configure="--with-arch=armv7-a --with-tune=generic-armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-abi=aapcs-linux --with-mode=thumb";;
	armv6-*-*-*eabihf)	_arch_configure="--with-arch=armv6zk --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=hard --with-abi=aapcs-linux";;
	mipsel-*-*-*)		_arch_configure="--with-arch-32=mips2 --with-tune-32=mips32 --with-fp-32=32 --with-mips-plt --with-float=hard --with-abi=32";;
	i486-*-*-*)		_arch_configure="--with-arch=i486 --with-tune=generic --enable-cld";;
	i586-*-*-*)		_arch_configure="--with-arch=i586 --with-tune=generic --enable-cld";;
	esac

	case "$CTARGET_LIBC" in
	musl)
		# musl does not support mudflap, or libsanitizer
		# libmpx uses secure_getenv and struct _libc_fpstate not present in musl
		# alpine musl provides libssp_nonshared.a, so we don't need libssp either
		_libc_configure="--disable-libssp --disable-libmpx --disable-libmudflap --disable-libsanitizer"
		_symvers="--disable-symvers"
		export libat_cv_have_ifunc=no
		;;
	esac

	[ "$CBUILD" != "$CHOST"   ] && _cross_configure="--disable-bootstrap"
	[ "$CHOST"  != "$CTARGET" ] && _cross_configure="--disable-bootstrap --with-sysroot=$CBUILDROOT"

	case "$BOOTSTRAP" in
	noheaders)
		_bootstrap_configure="--with-newlib --without-headers --disable-shared --enable-threads=no"
		;;
	nolibc)
		_bootstrap_configure="--with-newlib --disable-shared --enable-threads=no"
		;;
	*)
		_bootstrap_configure="--enable-shared --enable-threads --enable-tls"
		;;
	esac

	$LIBGOMP	|| _bootstrap_configure="$_bootstrap_configure --disable-libgomp"
	$LIBATOMIC	|| _bootstrap_configure="$_bootstrap_configure --disable-libatomic"
	$LIBITM		|| _bootstrap_configure="$_bootstrap_configure --disable-libitm"
	$LIBQUADMATH	|| _arch_configure="$_arch_configure --disable-libquadmath"

	msg "Building the following:"
	echo ""
	echo "  CBUILD=$CBUILD"
	echo "  CHOST=$CHOST"
	echo "  CTARGET=$CTARGET"
	echo "  CTARGET_ARCH=$CTARGET_ARCH"
	echo "  CTARGET_LIBC=$CTARGET_LIBC"
	echo "  languages=$_languages"
	echo "  arch_configure=$_arch_configure"
	echo "  libc_configure=$_libc_configure"
	echo "  cross_configure=$_cross_configure"
	echo "  bootstrap_configure=$_bootstrap_configure"
	echo ""

	mkdir -p "$_builddir"
	cd "$_builddir"
	"$_gccdir"/configure --prefix=/usr \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--build=${CBUILD} \
		--host=${CHOST} \
		--target=${CTARGET} \
		--with-pkgversion="Alpine ${pkgver}" \
		--enable-checking=release \
		--disable-fixed-point \
		--disable-libstdcxx-pch \
		--disable-multilib \
		--disable-nls \
		--disable-werror \
		$_symvers \
		--enable-__cxa_atexit \
		--enable-default-pie \
		--enable-cloog-backend \
		--enable-languages=$_languages \
		$_arch_configure \
		$_libc_configure \
		$_cross_configure \
		$_bootstrap_configure \
		--with-system-zlib \
		|| return 1

	make || return 1
}

package() {
	cd "$_builddir"
	make -j1 DESTDIR="${pkgdir}" install || return 1

	ln -s gcc "$pkgdir"/usr/bin/cc

	# we dont support gcj -static
	# and saving 35MB is not bad.
	find "$pkgdir" -name libgcj.a -o -name libgtkpeer.a \
		-o -name libgjsmalsa.a -o -name libgcj-tools.a \
		-o -name libjvm.a -o -name libgij.a -o -name libgcj_bc.a \
		-o -name libjavamath.a \
		| xargs rm -f \
		|| return 1

	# strip debug info from some statib libs
	${STRIP_FOR_TARGET} -g `find "$pkgdir" \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \
		-o -name libmudflap.a -o -name libmudflapth.a \
		-o -name libgcc.a -o -name libgcov.a -o -name libquadmath.a \
		-o -name libitm.a -o -name libgo.a -o -name libcaf\*.a \
		-o -name libatomic.a -o -name libasan.a -o -name libtsan.a \) \
		-a -type f` || return 1

	if $LANG_JAVA; then
		sed -i -e 's/lib: /&%{static:%eJava programs cannot be linked statically}/' \
			"$pkgdir"/usr/lib/libgcj.spec
	fi

	if $LIBGOMP; then
		mv "$pkgdir"/usr/lib/libgomp.spec "$pkgdir"/$_gcclibdir || return 1
	fi
	if $LIBITM; then
		mv "$pkgdir"/usr/lib/libitm.spec "$pkgdir"/$_gcclibdir || return 1
	fi

	# remove ffi
	rm -f "$pkgdir"/usr/lib/libffi* "$pkgdir"/usr/share/man/man3/ffi*
	find "$pkgdir" -name 'ffi*.h' | xargs rm -f

	mkdir -p "$pkgdir"/usr/share/gdb/python/auto-load/usr/lib
	mv "$pkgdir"/usr/lib/*-gdb.py \
		"$pkgdir"/usr/share/gdb/python/auto-load/usr/lib/

	paxmark -pmrs "$pkgdir"/$_gcclibexec/cc1 || return 1

	# move ada runtime libs
	if $LANG_ADA; then
		for i in $(find "$pkgdir"/$_gcclibdir/adalib/ -type f -maxdepth 1 -name "libgna*.so"); do
			mv "$i" "$pkgdir"/usr/lib/ || return 1
			ln -s ../../../../${i##*/} $i || return 1
		done
	fi

	if [ "$CHOST" != "$CTARGET" ]; then
		# cross-gcc: remove any files that would conflict with the
		# native gcc package
		rm -rf "$pkgdir"/usr/bin/cc "$pkgdir"/usr/include "$pkgdir"/usr/share
		# libcc1 does not depend on target, don't ship it
		rm -rf "$pkgdir"/usr/lib/libcc1.so*
	fi
}

libatomic() {
        pkgdesc="GCC Atomic library"
        depends=
	replaces="gcc"
        CARCH="$CTARGET_ARCH"

        mkdir -p "$subpkgdir"/usr/lib
        mv "$pkgdir"/usr/lib/libatomic.so.* "$subpkgdir"/usr/lib/ || \
                cp -a "$pkgdir"/usr/$CTARGET/lib/libatomic.so.* "$subpkgdir"/usr/lib/ || \
                return 1
}

libcxx() {
	pkgdesc="GNU C++ standard runtime library"
	depends=
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libstdc++.so.* "$subpkgdir"/usr/lib/ || \
		cp -a "$pkgdir"/usr/$CTARGET/lib/libstdc++.so.* "$subpkgdir"/usr/lib/ || \
		return 1
}

gpp() {
	pkgdesc="GNU C++ standard library and compiler"
	depends="libstdc++=$_gccrel gcc=$_gccrel libc-dev"
	mkdir -p "$subpkgdir/$_gcclibexec" \
		"$subpkgdir"/usr/bin \
		"$subpkgdir"/usr/include \
		"$subpkgdir"/usr/lib \

	mv "$pkgdir/$_gcclibexec/cc1plus" "$subpkgdir/$_gcclibexec/"
	paxmark -pmrs "$subpkgdir/$_gcclibexec/cc1plus" || return 1

	mv "$pkgdir"/usr/lib/*++* "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/include/c++ "$subpkgdir"/usr/include/
	mv "$pkgdir"/usr/bin/*++ "$subpkgdir"/usr/bin/
}

libobjc() {
	pkgdesc="GNU Objective-C runtime"
	replaces="objc"
	depends=
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libobjc.so.* "$subpkgdir"/usr/lib/
}

objc() {
	pkgdesc="GNU Objective-C"
	replaces="gcc"
	depends="libc-dev gcc=$_gccrel libobjc=$_gccrel"

	mkdir -p "$subpkgdir"/$_gcclibdir/include \
		"$subpkgdir"/usr/lib \
		|| return 1
	mv "$pkgdir"/$_gcclibdir/include/objc "$subpkgdir"/$_gcclibdir/include/ \
		|| return 1
	mv "$pkgdir"/usr/lib/libobjc.so "$pkgdir"/usr/lib/libobjc.a \
		"$subpkgdir"/usr/lib/ || return 1
}

libgcc() {
	pkgdesc="GNU C compiler runtime libraries"
	depends=
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgcc_s.so.* "$subpkgdir"/usr/lib/ || \
		cp -a "$pkgdir"/usr/$CTARGET/lib/libgcc_s.so.* "$subpkgdir"/usr/lib/ || \
		return 1
}

libgomp() {
	pkgdesc="GCC shared-memory parallel programming API library"
	depends=
	replaces="gcc"
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgomp.so.* "$subpkgdir"/usr/lib/
}

java() {
	pkgdesc="Java support for GCC"
	depends="zlib-dev gcc=$_gccrel libgcj=$_gccrel"

	paxmark -pm "$pkgdir"/$_gcclibexec/ecj1 || return 1
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib "$subpkgdir"/$_gcclibdir/
	cd "$pkgdir"/usr/bin
	mv gcj gcj-dbtool gjavah gcjh jcf-dump "$subpkgdir"/usr/bin/
	cd "$pkgdir"
	for i in $(find usr/ -name ecj1 -o -name jc1 -o -name jvgenmain); do
		mkdir -p "$subpkgdir"/${i%/*}
		mv "$pkgdir"/$i "$subpkgdir"/$i || return 1
	done
	for i in "$pkgdir"/usr/lib/libgcj*.so; do
		if [ -L "$i" ]; then
			mv "$i" "$subpkgdir"/usr/lib/ || return 1
		fi
	done
	mv "$pkgdir"/usr/lib/libgij.so "$subpkgdir"/usr/lib/ || return 1
	mv "$pkgdir"/usr/lib/libgcj.spec "$subpkgdir"/$_gcclibdir/ || return 1
}

libgcj() {
	pkgdesc="Java runtime library for gcc"
	# libgcj_bc.so moved from gcc-java to libgcj
	replaces="gcc-java"
	depends=
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/bin
	cd "$pkgdir"/usr/bin
	paxmark -pmse "$pkgdir"/usr/bin/gij || return 1
	mv aot-compile gappletviewer gc-analyze gij gjar gjarsigner gkeytool\
		gnative2ascii gorbd grmic grmid grmiregistry gserialver \
		gtnameserv jv-convert rebuild-gcj-db \
		"$subpkgdir"/usr/bin/
	cd "$pkgdir"
	for i in $(find usr/lib -name jc1 -o -name jvgenmain); do
		mkdir -p "$subpkgdir"/${i%/*}
		mv "$pkgdir"/$i "$subpkgdir"/$i || return 1
	done
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/gcj-* \
		"$pkgdir"/usr/lib/libgcj_bc.so \
		"$pkgdir"/usr/lib/libgcj*.so.* \
		"$pkgdir"/usr/lib/libgij.so.* \
		"$pkgdir"/usr/lib/logging.properties \
		"$pkgdir"/usr/lib/security \
		"$subpkgdir"/usr/lib/ \
		|| return 1

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/java "$subpkgdir"/usr/share/
}

libgo() {
	pkgdesc="Go runtime library for GCC"
	depends=
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgo.so.* "$subpkgdir"/usr/lib/
}

go() {
	pkgdesc="Go support for GCC"
	depends="gcc=$_gccrel libgo=$_gccrel"

	mkdir -p "$subpkgdir"/$_gcclibexec \
		"$subpkgdir"/usr/lib \
		"$subpkgdir"/usr/bin || return 1
	mv "$pkgdir"/usr/lib/go "$subpkgdir"/usr/lib/ || return 1
	mv "$pkgdir"/usr/bin/*gccgo "$subpkgdir"/usr/bin/ || return 1
	mv "$pkgdir"/$_gcclibexec/go1 "$subpkgdir"/$_gcclibexec/ || return 1
	mv "$pkgdir"/usr/lib/libgo.a \
		"$pkgdir"/usr/lib/libgo.so \
		"$pkgdir"/usr/lib/libgobegin.a \
		"$subpkgdir"/usr/lib/ || return 1
}

libgfortran() {
	pkgdesc="Fortran runtime library for GCC"
	depends=
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgfortran.so.* "$subpkgdir"/usr/lib/
}

libquadmath() {
	replaces="gcc"
	pkgdesc="128-bit math library for GCC"
	depends=
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libquadmath.so.* "$subpkgdir"/usr/lib/
}

gfortran() {
	pkgdesc="GNU Fortran Compiler"
	depends="gcc=$_gccrel libgfortran=$_gccrel"
	$LIBQUADMATH && depends="$depends libquadmath=$_gccrel"
	replaces="gcc"

	mkdir -p "$subpkgdir"/$_gcclibexec \
		"$subpkgdir"/$_gcclibdir \
		"$subpkgdir"/usr/lib \
		"$subpkgdir"/usr/bin || return 1
	mv "$pkgdir"/usr/bin/*gfortran "$subpkgdir"/usr/bin/ || return 1
	mv "$pkgdir"/usr/lib/libgfortran.a \
		"$pkgdir"/usr/lib/libgfortran.so \
		"$subpkgdir"/usr/lib/ || return 1
	if $LIBQUADMATH; then
		mv "$pkgdir"/usr/lib/libquadmath.a \
			"$pkgdir"/usr/lib/libquadmath.so \
			"$subpkgdir"/usr/lib/ || return 1
	fi
	mv "$pkgdir"/$_gcclibexec/f951 "$subpkgdir"/$_gcclibexec || return 1
	mv "$pkgdir"/usr/lib/libgfortran.spec "$subpkgdir"/$_gcclibdir || return 1
}

libgnat() {
	pkgdesc="GNU Ada runtime shared libraries"
	depends=
	CARCH="$CTARGET_ARCH"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libgna*.so "$subpkgdir"/usr/lib/
}

gnat() {
	pkgdesc="Ada support for GCC"
	depends="gcc=$_gccrel"
	[ "$CHOST" = "$CTARGET" ] && depends="$depends libgnat=$_gccrel"

	mkdir -p "$subpkgdir"/$_gcclibexec \
		"$subpkgdir"/$_gcclibdir \
		"$subpkgdir"/usr/bin \
		|| return 1
	mv "$pkgdir"/$_gcclibexec/*gnat* "$subpkgdir"/$_gcclibexec/ \
		|| return 1
	mv "$pkgdir"/$_gcclibdir/*ada* "$subpkgdir"/$_gcclibdir/ || return 1
	mv "$pkgdir"/usr/bin/*gnat* "$subpkgdir"/usr/bin/ || return 1
}

md5sums="8fb6cb98b8459f5863328380fbf06bd1  gcc-6.1.0.tar.bz2
7339f199ba11c941890031fd9981d7be  ecj-4.9.jar
3634a8f58065805809273b105071c1f3  001_all_default-ssp-strong.patch
28ca9eac639e88869ac975d593ff7a89  002_all_default-relro.patch
b7235f279097e28295b6bbaa0804302f  003_all_default-fortify-source.patch
d4e31fe787e2fc1cb8afdd3815e9d28a  004_all_default-hash-gnu.patch
ed9ebe1548ea27147b5742a24d480fcd  005_all_default-as-needed.patch
614776347743e17651c778f1c6a9fa2e  011_all_default-warn-format-security.patch
55afcb3f072a6ffaff8ce03f310ae57f  012_all_default-warn-trampolines.patch
c324e6e3204a39334aa559329592bde3  020_all_msgfmt-libstdc++-link.patch
a99126f384a2899ff2716ad7389b784b  050_all_libiberty-asprintf.patch
d8692c56f04b92667096f59d843e95c5  051_all_libiberty-pic.patch
9cb2d475322dc61a1fe35054257001c5  053_all_libitm-no-fortify-source.patch
0a1ebe8be16b36c4ddd07859f0e9f427  067_all_gcc-poison-system-directories.patch
b8c2226a789be9f11a8dc3a54e9865bc  074_all_gcc6_isl-dl.patch
7d4c5c1becd11ab4fe0ef9088f96e638  090_all_pr55930-dependency-tracking.patch
19dab52bc9aab374041fca80f1479a47  201-cilkrts.patch
63658f05abe13649dba516ae44dde01f  202-posix_memalign.patch
12e816fc89aabb03e1ae72ebd479c89d  203-libgcc_s.patch
feaddd681acded33c22fd92ad8819982  204-linux_libc_has_function.patch
a7836fe20d35f91ddf623e3c62a920fe  205-nopie.patch
0b0a4f54760e0e368e4113dc9bd04d7b  207-static-pie.patch
504c7dd8651c5d98229892c4cd9ea591  libgcc-always-build-gcceh.a.patch
a56fb2cf67ae619f22e0d21f378ff704  libada-cross-shared.patch
9e658e590bc51be611f39945183f6aa2  gcc-4.9-musl-fortify.patch
32c40cd9c22a01621c2b7d60ac4255a0  gcc-6.1-musl-libssp.patch
0ea0f556d4ef9c260d1353b7fd33970c  boehm-gc-musl.patch
2e2b787bb988d9007c9f7ce42178dfe6  gcc-pure64.patch
1e143d6a88cdcbc4e3266b19208df0fd  fix-gcj-stdgnu14-link.patch
14fc0a0b925ef911ce78cd030fe58902  fix-gcj-musl.patch
e17bbb0fe802974e20645b4182b4c410  fix-gcj-iconv-musl.patch
0a2041bbf83648e6c4f6d3484f7249ca  gcc-4.8-build-args.patch
4aea37d334ab00bb6bba37cd8c481367  fix-cxxflags-passing.patch
d00d7e4b0c00cb7448576af9cd7fcea8  ada-fixes.patch
20e2731c02ce50739ebdead2795f9c41  ada-shared.patch
221773e09429ae2aba03780fb1089290  ada-musl.patch
243bf5804799d2e70c4e51d3a6ca9d1a  pr70839.patch"
sha256sums="09c4c85cabebb971b1de732a0219609f93fc0af5f86f6e437fd8d7f832f1a351  gcc-6.1.0.tar.bz2
9506e75b862f782213df61af67338eb7a23c35ff425d328affc65585477d34cd  ecj-4.9.jar
deb22792f37e107d0afff5f4ea6b2a9fc9de4f48e1c7133bf658b6e0d057b1d6  001_all_default-ssp-strong.patch
2c7fcbc3879cce0775e37306441110dc63e7f457e2e5ad890f6b0800eb520ef6  002_all_default-relro.patch
611d3d101351c134d3c03f6d8265a90268cef71c682bf72e02a6cd2d99315ef8  003_all_default-fortify-source.patch
549ad945d43370994ae8b8b0921b703efff71857e7669eff804f976bba3f5ae7  004_all_default-hash-gnu.patch
302c868dd7559ba01a38fea32c313d492403d02c8a3cebd51bb7be5988aee7f9  005_all_default-as-needed.patch
5ba3639e8834f2e8b59c51c567d1084dfff7ed27c84565dee8ed769b63c90936  011_all_default-warn-format-security.patch
da1fae26d6a387aa216af1816f241d141d8d4f158b1e5c3c827643ab8b491f3e  012_all_default-warn-trampolines.patch
c080f458c95dd0cbcc1322edc35890da892c3aaa7944c4eceb6319ca412cff02  020_all_msgfmt-libstdc++-link.patch
7e19261e2b5a5b9e518f6fd6844c1f0f5d0306de8bc1537c7c5cc4992a391049  050_all_libiberty-asprintf.patch
da6bbb5dc654d5e1df8ecae5c9ebb56265426c405931f14f5878248b8c79f78d  051_all_libiberty-pic.patch
545a0ffcf70fdd712c7e881cbd29e657f499b5e13cec5d0516b9fa277cefe67b  053_all_libitm-no-fortify-source.patch
44ab02edeaebd85fe5ccba5e87342ad50b53171fbd45be78a3e7684d94b742a1  067_all_gcc-poison-system-directories.patch
72b0c21995a811ba9bc70d1f0f5723e46aab4f5054761379304fad8ce2b56afe  074_all_gcc6_isl-dl.patch
f108fdc8bb62aea4245ff9ad3d314603c69f7993f4c81de3a4c92a44b80b206e  090_all_pr55930-dependency-tracking.patch
e564d0c93e8e6afb5fbd5640822fef14f41aec53a1f2fbea5cd59d6bdf0a2652  201-cilkrts.patch
a5de063de487d944443901cdfa398e1614edbf2e62b7d633f78da1be222a2b05  202-posix_memalign.patch
6a640a2e6a3820a24e6079f26146f3919a2bc484f3c6abebd2c7d9e502c92d2c  203-libgcc_s.patch
40b48315791dbdcd5b09af2ffc14454d75d50dd0ecc0a353df7b686a19e06c1e  204-linux_libc_has_function.patch
2427b5a0e564af84c6569921a31a277d07b739a4a4d924057ce725136cc5d355  205-nopie.patch
df92e2f03615c1591278c132cd38ee0ed2c576cd942d8ea751a44d0521057e6b  207-static-pie.patch
1975189156d70f5428cb7f1516533965d1c8734f3009fc89a9b8e289b72326f1  libgcc-always-build-gcceh.a.patch
b07b999e3d3fdeff6aa925535949cb90bc7b11546b415288e5097c8877e5e8d1  libada-cross-shared.patch
dc93f97dff28b872f9c7e241fb87a3eca0271f706534d196b3517781b05667fa  gcc-4.9-musl-fortify.patch
4ece19529edb8e681e1778e977e2ba1d47984ccfcb82505e8b898bb29d659625  gcc-6.1-musl-libssp.patch
6ccca88695ef84c0d038cd315cad5ae5b799672ecb009fdaab34e68ba60b733c  boehm-gc-musl.patch
f5473c6aea96d5137defd68898ba31042944a3f3ed26c05b964a40bd876c6f47  gcc-pure64.patch
c03165e7ce812c93a33fdb0893847b4f9eb892e353d32d85b23249610fb24396  fix-gcj-stdgnu14-link.patch
22c78cc4a2658ff574e7ded1e5bc765a4f81f730d12e72d5883fe0bf73e71220  fix-gcj-musl.patch
51782c972ab828eb4ccb3ca3570341d025b2ae9a8e8fd8188cefb29c5f87401b  fix-gcj-iconv-musl.patch
bd7a6f514fcc457f29e5fda157203f3bcd013aeba5d53b3459196eef3ce752ab  gcc-4.8-build-args.patch
a395ba4cf047c48cac56985726fddf0948f4425c9f1a0c9ddba1812b2b3d8300  fix-cxxflags-passing.patch
d2a67a7ae0304cd10532883df19923b98dbc9b7a24957b619d4a6e04f19c5507  ada-fixes.patch
d6c7fc1820a4fa285297c299c255fe2f19ce1695486f20edd098252a97545e6a  ada-shared.patch
23d99e94060972bb25de4687da88ecb4fce9a7f0afa4b71a05161246917cd75d  ada-musl.patch
2c4836eeac884e96fbf35c01862820efd0ff08fa73b580e2747d457f761fe80e  pr70839.patch"
sha512sums="eeed3e2018b8c012aabce419e8d718fde701e5c3c179b4486c61ba46e5736eecc8fccdd18b01fcd973a42c6ad3116dbbe2ee247fe3757d622d373f93ebaf8d2e  gcc-6.1.0.tar.bz2
28f8c6fdbcb19e950b1d0bafb3bcc7a8cba87bc673aa6027cece116599cdee80f0cf5e95a1440544890239f5c754e8a93ab46d9daedd937faef445d7ea33b226  ecj-4.9.jar
a1335adc2fbee98e36c4437ff2587771b98ed4180726779020f65039498235626a411cdb0100dbd20cd19d12f0d94f9a21af179ff624676c28cead9d60598b5d  001_all_default-ssp-strong.patch
e36e95b81489163abd6fe9d58f7867bdca43e61143afacbfb17f4698c0b16ec5fd0061d8fab7b2ae615540bebd721c2e2227f80401b4e7fc253da9da62e6b513  002_all_default-relro.patch
f86466c62b8291fac46f9c250c7ad8fa5ab7b1cce2504442fd07ddc4543665b317ae28951f244e39aba29aeaf3fff252ec4f6a147aa16adb2b7aed747dd89188  003_all_default-fortify-source.patch
1d186d4fba52d8f650df02466e49a8bf9cdcd8423f37a3ba5282b6e965b52cb5b6adb9dfd2f7010b6c4aa3fcbf048b8a87a9d383e4645d813d532ba9c88c8aa0  004_all_default-hash-gnu.patch
a10e1909eb80ca15178ceac2caf7388e18839d0c61106d7f0d29c2be097c17a83854972028c2678e7355bd6cb71a465f6b703c19783549aa906990973af303fc  005_all_default-as-needed.patch
3398386dd1e079d6545dd9799adc799c6b80e3984fac6899d0e1a7ee21b66d0c7e53cddf17a65d590c883db750f9f79aaedd857355a8b9f7fb9476c906237919  011_all_default-warn-format-security.patch
9adb0d2b9b67dd957df6c609b8714c7c078efb52cd88770905c37c67827be8fc83d1125037b9c29d77db21ce78756aa2bb0bacdb0b98d869ac126da76a298e21  012_all_default-warn-trampolines.patch
d35a3ac7e13a4446921a90e1ff3eec1079840c845f9d523c868e24ae21f94cf69ba041de5341ebef96432a6f57598e223381d4286e8fb8baaa25906707f29fbd  020_all_msgfmt-libstdc++-link.patch
840070a3c423e6206aaa6e63e1d9a0fcd6efd53626cd1240a193f0b60aa5d84216acc4a2a4fa8bce74549b07e6a316b01d638f20cea13dc62473491a302fb3d6  050_all_libiberty-asprintf.patch
0a0bc72b9366158f5d23fff1928e756fdd212433bac6ab1f00d632f241382820db8db5d475ddf11ea020eaf7e2e71b12fb9b1c3c870cf84adf6c2b16f15aabca  051_all_libiberty-pic.patch
e7a2eb1b1870e199d6fd753d065781575656fa12baa264f96c5d179689d88c31b8a3f92a5dae96088c05e96aa2bda138364ad7dbcc79e1819a102f192cbb7bab  053_all_libitm-no-fortify-source.patch
e87da18aa7ab92b02b06168658c63b42a6c73a08fad2a30f81ef6296100fdbe3c3a91548fd0cb24eaf591e862bb08e4b67249bc4b977b07da33523aee0c686bc  067_all_gcc-poison-system-directories.patch
5b87a1de0061163eec3710d4e888fe575b466912cfe39e7f561dbe46f6cbf7069dbca29b7116f0610dc4c7bdd4634504716fb188e3a61367ebf61c6c933d27d2  074_all_gcc6_isl-dl.patch
4a328d1e1a56c20166307edcfa322068915784d9c08025b7f81cf69714da48fc266b6d34f77b9135c2f10da830d9df408276a1b78d1fd218637c2823506593c2  090_all_pr55930-dependency-tracking.patch
ef052d0c3c9642fcb5ed570069c5a49c8ef523c47ac8ce3f201a801766f72ae4ff7c3725a70ee66e52c0fb559621e35fe0cf5b88b901d71ceadd381f49653a08  201-cilkrts.patch
40b7f2fc44fbe8125027c424f9ef3e6b89129ee4c6d47f3f3075f28979bcece2a3bc0ddd17df6bae77960db773f48fba2eb252923063ac81788340e7ec575d99  202-posix_memalign.patch
808e206f5e107084156fba333d4e091dcbd62f5d7756142bc292d4b0a52619f8c2aaca3617defc2f5b6552ba0439aebd33f4141329d88eab6ddf2dd637d92c08  203-libgcc_s.patch
fc0de05b36613b732a0222ea005c90653c6a40d6761b6894af2419272f4e74875f37e26af33a9b9940669ef89269c44c46d17ca5bcd54b5cd1176e5eaf2992c1  204-linux_libc_has_function.patch
98473bcaa77903a223ca9b0d2087c0921b287a2816d308cc32c8fe009e6cbf5dd1ae7fba27794ab8d9c09e117fe534413d91a464d1218474fc123ce0adfdc2c1  205-nopie.patch
cf6f9814dee8c524b13f455106e1b92ad4bcbd998bf56bdb0858d1c6c89bfaf7ee8f75514d3e7092137f06d40b8419b6a5d2434e48d2ec32a83aa9c2ced45558  207-static-pie.patch
d08d7ead2de0429e5c9055d5b029ec2be9a8c821d22cecaf9b51f633652c493333f98963d9267fa2fa63850c50ae5eefd5f59e5910ec10d20044dac082182a8b  libgcc-always-build-gcceh.a.patch
e5ee0d18eb58e2624e745986ded7eb310fcda4dccca6c8fb368c6c9bdd98f0d54771fdfc3ab3315f09d1f22d400cf30d4b807afdbcd963cc9aa6cd60df2afa87  libada-cross-shared.patch
600fe5098dc54edaa9808fd5717af9dec058953f9ad37d49cfba1db4f7e9a7a8f02019342f75157fc575946fa693259422184de27b7ecc8386d9f3ecc0f7cc5d  gcc-4.9-musl-fortify.patch
dbe0ee917fc7668571722364ab7c806731e3a31e8bfa30b4941b28b16b877d2a32b4a3897ef533399a28f82d43cac9b28e92de0493f0e779046db56584e07fa4  gcc-6.1-musl-libssp.patch
bda845a6aa1854d2c883910b115f79ccfa93dfc2b5eac69a3a236d83eb34cadc140731d616ffc24698c7abc8878dd15f231bcc5119f1860e575a120b311706c7  boehm-gc-musl.patch
4a5aeff0399782c752e6e3f2f48d984b2056dfb5d229b23a24eee1562d241339989b2203f139821cfc03c9b25c9bd7da6ccbbdc7a09d242e4de7f0d606c6f63c  gcc-pure64.patch
2253941f3d19b6d08801d3782f5f5ed56c3b73fbc9d3561a8f01c702963ac4fab91599c686076e7081eb6a80c37ccd33591ae978996d6eee1dc0ce0f1c50259a  fix-gcj-stdgnu14-link.patch
f89ddeb21bc8f97e6a850a6b70b4501a8f3e49a4bc8cc82897488decda5d98ad01cb7f6c8b392d452e9579924a523bc75da6e0648c1c976d42e40af48b10343b  fix-gcj-musl.patch
54d67cc008b735e47771314171930c5d8b8f5f5dc97fcf4214824c105c808f3e75d22d5a4fdf5068ed0457fa0d46c60cfb442e276259a4a5e9b8722a027d18e6  fix-gcj-iconv-musl.patch
abe9aaf9aa956058d0386a4396a511d176a46bb3906b90e952383646cdc158cbeb0a5dc616a1ccb1ca7d49fd0b5e351532aa15a3b13362abbf1ca4266f54a687  gcc-4.8-build-args.patch
35d6d59f0b7b968f282f56767c9e0823a7bdc5aa0d450aca50fbd802649a7ca608b47671244a3faa208a9b0d6832cabb5a22724157dc817b2c0ad63d09f93282  fix-cxxflags-passing.patch
9016b257abd8fa981de44a49512e35db814d1cbb47c1a87cd31c12d4ae20b13e9e149fe41691a7ec3c95bbcfde8a79194a8d2eaf547ceade3a246fad67c47dd8  ada-fixes.patch
3f5bc334d9f73d06f5f7c876738d02356acdd08958bea0e4d2095ebf15c2c2ec4e411abdae0297505ae9a1699ca01b17338e853184e84663203b192b0d35fc19  ada-shared.patch
a13c6acd864933bd7b12501686da57b09cbff9471c7f630f5bc9a92902a4006a9024a08ee41574707e4c232a754a21633ea89e0bb45dc0d5967e50b299ef6a5e  ada-musl.patch
15f91fe67939e153ac096c4cc64600a457b637c9e8a96b0e691c89f2339821b0c7b32477e0f66bf27ed8650d5c5a7e9cbae4006ea4639a386d47bf66a8a1ecc7  pr70839.patch"