summaryrefslogtreecommitdiffstats
path: root/main/gcc/APKBUILD
blob: 488dde45dd99dd325fa8f3133241044beeb99846 (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
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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gcc
pkgver=4.8.1
_piepatchver=0.5.6
_specs_ver=0.2.0
_specs_gcc_ver=4.4.3
_uclibc_abiver=0.9.32
_cross=""
[ "$BOOTSTRAP" = "noheaders" ] && pkgname="gcc-pass1"
[ "$BOOTSTRAP" = "nolibc" ] && pkgname="gcc-pass2"
[ "$CHOST" != "$CTARGET" ] && [ -n "$CHOST" -a -n "$CTARGET" ] \
	&& _cross="-$CTARGET"

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

: ${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

$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"
	makedepends="$makedepends paxctl"
	_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
	subpackages="$subpackages libgnat 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
	http://distfiles.gentoo.org/distfiles/gcc-$pkgver-piepatches-v${_piepatchver}.tar.bz2
	http://distfiles.gentoo.org/distfiles/gcc-$_specs_gcc_ver-specs-$_specs_ver.tar.bz2
	ftp://sourceware.org/pub/java/ecj-latest.jar

	12_all_default-warn-trampolines.patch
	15_all_libgfortran-Werror.patch
	16_all_libgomp-Werror.patch
	48_all_x86_pr53113_libitm-avx.patch
	50_all_libiberty-asprintf.patch
	51_all_libiberty-pic.patch
	67_all_gcc-poison-system-directories.patch
	74_all_gcc48_cloog-dl.patch

	gcc-ice-hack.patch
	gcc-spec-env.patch
	libgcc-always-build-gcceh.a.patch
	pt_gnu_eh_frame.patch
	uclibc-getipinfo.patch
	gcc-4.6-pr32219.patch
	gcc-4.8-dynamic-linker.patch
	gcc-4.8-musl.patch
	gcc-4.8-musl-fix-iteratephdr.patch
	gcc-4.8-musl-libssp.patch
	boehm-gc-uclibc.patch
	boehm-gc-musl.patch
	gcc-pure64.patch
	pr49423.patch
	pr57748.patch

	gcc-4.8-build-args.patch
	fix-cxxflags-passing.patch
	fix-cxxflags-for-target.patch
	ada-no-pie.patch
	ada-fixes.patch
	ada-crossbuild.patch
	ada-shared.patch
	ada-musl.patch
	"

#	gcc-go.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

	# PIE patches from gentoo
	# thanks to Zorry for hard work on those patches
	for i in "$srcdir"/piepatch/*.patch; do
		msg "Applying $i"
		patch -t -p0 -i $i || patch -t -p1 -i $i || return 1
	done

	sed -i -e 's/stage1_cflags="$stage1_cflags -fno-stack-protector"/stage1_cflags="$stage1_cflags -fno-stack-protector -fno-stack-check"/g' \
		configure

	# Gentoo 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

	# enable hardened cflags by default
	# building gcc wih PIE seem to hit some strange bug. we probably run
	# out of some resource. so we disable PIE for gcc while enabling it
	# by default for everything else.
	local _hard_cflags="-DEFAULT_PIE_SSP -DEFAULT_RELRO -DEFAULT_BIND_NOW"
	sed -e "/^ALL_CFLAGS/iHARD_CFLAGS = ${_hard_cflags}" \
		-e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
		-e 's|^ALL_CXXFLAGS = |ALL_CXXFLAGS = $(HARD_CFLAGS) |' \
		-i gcc/Makefile.in || return 1

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

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

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

	cd "$_gccdir"

	case "$CTARGET" in
	x86_64-*-uclibc)	_dynamic_linker="--with-dynamic-linker=ld64-uClibc.so.$_uclibc_abiver" ;;
	*-uclibc)		_dynamic_linker="--with-dynamic-linker=ld-uClibc.so.$_uclibc_abiver" ;;
	x86_64-*-gnu)		_dynamic_linker="--with-dynamic-linker=ld-linux-x86-64.so.2" ;;
	*-gnu)			_dynamic_linker="--with-dynamic-linker=ld-linux.so.2" ;;
	esac
	[ -n "$_dynamic_linker" ] && _dynamic_linker="--with-dynamic-linker-prefix=/lib $_dynamic_linker"

	case "$CTARGET" in
	armv7-*-*-*eabihf)	_arch_configure="--with-arch=armv7-a --with-tune=cortex-a15 --with-fpu=vfpv3-d16 --with-float=hard --with-abi=aapcs-linux";;
	armv6-*-*-*eabihf)	_arch_configure="--with-arch=armv6zk --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=hard --with-abi=aapcs-linux";;
	i486-*-*-*)		_arch_configure="--with-arch=i486 --with-tune=generic --enable-cld";;
	esac

	case "$CTARGET_LIBC" in
	musl)
		# musl does not support mudflap, or libsanitizer
		# alpine musl provides libssp_nonshared.a, so we don't need libssp either
		_libc_configure="--disable-libssp --disable-libmudflap --disable-libsanitizer"
		_symvers="--disable-symvers"
		export libat_cv_have_ifunc=no
		;;
	uclibc)
		_libc_configure="--disable-libssp --without-system-libunwind"
		export gcc_cv_libc_provides_ssp=yes
		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 "  dynamic_linker=$_dynamic_linker"
	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-esp \
		--enable-cloog-backend \
		--enable-languages=$_languages \
		$_arch_configure \
		$_libc_configure \
		$_cross_configure \
		$_bootstrap_configure \
		$_dynamic_linker \
		--with-system-zlib \
		|| return 1

	make || return 1
}

package() {
	cd "$_builddir"
	make -j1 DESTDIR="${pkgdir}" install || return 1
	find "$pkgdir" -name '*.la' -delete || return 1

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

	# binutils provides libiberty.a
	rm -f "$pkgdir"/usr/lib/libiberty.a

	# install the specs
	cd "$srcdir"/specs
	install -d "$pkgdir"/$_gcclibdir
	for i in *.specs; do
		install -m644 $i "$pkgdir"/$_gcclibdir/$i || return 1
	done

	# 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}/' \
		"$pkdir"/usr/lib/libgcj.spec
	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/

	paxctl -c -pmrs "$pkgdir"/$_gcclibexec/cc1 || return 1

	# move ada runtime libs
	if $LANG_ADA; then
		for i in "$pkgdir"/$_gcclibdir/adalib/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
	fi
}

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/"
	paxctl -c -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"

	paxctl -c -pm "$pkgdir"/$_gcclibexec/ecj1 || return 1
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib
	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/
		fi
	done
	mv \
		"$pkgdir"/usr/lib/libgij.so \
		"$pkgdir"/usr/lib/libgcj.spec \
		"$subpkgdir"/usr/lib/
}

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
	paxctl -c -pmse "$pkgdir"/usr/bin/gij || return 1
	mv aot-compile gappletviewer gc-analyze gij gjar gjarsigner gkeytool\
		gnative2ascii gorbd grmic grmid grmiregistry gserialver \
		gtnameserv i486-alpine-linux-uclibc-gcj 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
	mv "$pkgdir"/$_gcclibdir/libgfortranbegin.a \
		"$subpkgdir"/$_gcclibdir
}

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

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

gnat() {
	pkgdesc="Ada 95 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="3b2386c114cd74185aa3754b58a79304  gcc-4.8.1.tar.bz2
f8ab875eee18868b319ad04dc19adcf6  gcc-4.8.1-piepatches-v0.5.6.tar.bz2
441c76504e1d97170117c294e65c7a72  gcc-4.4.3-specs-0.2.0.tar.bz2
d7cd6a27c8801e66cbaa964a039ecfdb  ecj-latest.jar
f28e9334c58ce14f69a9e988026bc772  12_all_default-warn-trampolines.patch
7eb9ad894dfdf1b3d4a8a407a339a6f1  15_all_libgfortran-Werror.patch
452e457a0ac45e6f8f75eb6d6ba4d04b  16_all_libgomp-Werror.patch
8975abab9ee8ae5028a55e84b930cf02  48_all_x86_pr53113_libitm-avx.patch
326fa30475ba206cc2ef1666ec4314c8  50_all_libiberty-asprintf.patch
d8692c56f04b92667096f59d843e95c5  51_all_libiberty-pic.patch
ca4f395856bbb80d23398246572c30fa  67_all_gcc-poison-system-directories.patch
9c443d9d0fba2ce97b12f674b7d14c7e  74_all_gcc48_cloog-dl.patch
ea0fdebab6c660635736d27f4ea2f113  gcc-ice-hack.patch
a695d7648509b4f8e18b389a19e6037c  gcc-spec-env.patch
504c7dd8651c5d98229892c4cd9ea591  libgcc-always-build-gcceh.a.patch
ab83248e10b2bf4b3d9240de0fefb52b  pt_gnu_eh_frame.patch
6cc2385c5bbd6d0da6eaedd53c8bf547  uclibc-getipinfo.patch
32e8e4c0e23ed8f5de95a591cb30f1da  gcc-4.6-pr32219.patch
79d00ee1284fac5192456f7f7d3908aa  gcc-4.8-dynamic-linker.patch
ae660a0cb265b3115cde8f7efb41f7cc  gcc-4.8-musl.patch
6e5c32243a86ff35b7b47d18c95b31bd  gcc-4.8-musl-fix-iteratephdr.patch
60de2c9f78f00b8b0ba5d24fb44ea592  gcc-4.8-musl-libssp.patch
2c6cb49bb9bfd8b6e690222e66ccc901  boehm-gc-uclibc.patch
ea2749b1337a5d850a8f463071cc4747  boehm-gc-musl.patch
2e2b787bb988d9007c9f7ce42178dfe6  gcc-pure64.patch
762a7134017fe1056aaa6388b9b3a2d5  pr49423.patch
fb28fd941c110627b7b9ca523d66b8d6  pr57748.patch
0a2041bbf83648e6c4f6d3484f7249ca  gcc-4.8-build-args.patch
4aea37d334ab00bb6bba37cd8c481367  fix-cxxflags-passing.patch
87684048ecaaf0e046983bc2782292dd  fix-cxxflags-for-target.patch
750e903d5a53ba32618c2142cdd914e1  ada-no-pie.patch
2b4235111d2e66f2c690eb340cb4178b  ada-fixes.patch
d77c99bf7c03d082a540aaba1193be40  ada-crossbuild.patch
20e2731c02ce50739ebdead2795f9c41  ada-shared.patch
4e47bdae120129462244da0d89a573b3  ada-musl.patch"
sha256sums="545b44be3ad9f2c4e90e6880f5c9d4f0a8f0e5f67e1ffb0d45da9fa01bb05813  gcc-4.8.1.tar.bz2
4aa0ab0f114b0ff8af5d0c19c18930e3fcd5e5b0956f56ca24e58e5a243964b1  gcc-4.8.1-piepatches-v0.5.6.tar.bz2
f6c7cb99beead66dd4d06f7004c5731a9360330cbe878ce79792c618e008eed2  gcc-4.4.3-specs-0.2.0.tar.bz2
98fd128f1d374d9e42fd9d4836bdd249c6d511ebc6c0df17fbc1b9df96c3d781  ecj-latest.jar
ce7774aa13be5da274220258772ccbdd6f54abdad97a3798ba282865c809f042  12_all_default-warn-trampolines.patch
8b1450d5a7756af2b890588005690785a663601e2b1533671b609aa8cce0f718  15_all_libgfortran-Werror.patch
1f106fe03cede7c697bde7d81732e0d3bb2c7197e4967789182a5fd8db532900  16_all_libgomp-Werror.patch
cead5b092ab4881e8b830d51c0037a8fb149bab632e7661aa505ba574295e0e4  48_all_x86_pr53113_libitm-avx.patch
38f7c0841d99c6dd3610cd5618b68dd6579713c018eaed856217fc4263bcf6a6  50_all_libiberty-asprintf.patch
da6bbb5dc654d5e1df8ecae5c9ebb56265426c405931f14f5878248b8c79f78d  51_all_libiberty-pic.patch
8ba9dec0ecc2620c8ab1dfbeb0708dd4c29021e57d2e0ea23720108b1db3462e  67_all_gcc-poison-system-directories.patch
7d129093a6682418da9313611a90e3052855d8af4505d401f7b8b6a64e8f7b17  74_all_gcc48_cloog-dl.patch
8f7efd182fd7517fdcd8b78de11b75bfd9f2fa623ffec3d762ae6ff9ab77a476  gcc-ice-hack.patch
64b01f29fb853fee5ecda998b66eeaa7ec86ff1fc3b21432bfd69eb543c93e6a  gcc-spec-env.patch
1975189156d70f5428cb7f1516533965d1c8734f3009fc89a9b8e289b72326f1  libgcc-always-build-gcceh.a.patch
78e75cb378bdfe870c98ab3cffef37f54be729d3912979191f27ca00651ad6c4  pt_gnu_eh_frame.patch
53184f842477569973c232dac7c85e71b0018cbe5c4962f95dd9e0273f42083e  uclibc-getipinfo.patch
89207a8b62137a857ee2c43499d6b5247d37b530d1338844dbb330a6846b2ad2  gcc-4.6-pr32219.patch
f3863b997acf8fdf5ad1d3626b41a8a0670b896505e9b7afb517916c7599fb1c  gcc-4.8-dynamic-linker.patch
847075eb79c94e062ab8fb566f3bbea007875e2fde6fe2ddf51a18e731796a67  gcc-4.8-musl.patch
151c11c3303233e6ff06e27aa6dc889140bc46a7b5e4870587c40e37d36ede2c  gcc-4.8-musl-fix-iteratephdr.patch
ce0168ce009d77ce5831cb71739675cad6d68283b6e57fa8f2e559d65502022d  gcc-4.8-musl-libssp.patch
02751ccf223dcfc898c0ce2214cd0859d275e90b742f1a66e38db5c50f94b38c  boehm-gc-uclibc.patch
6adcddbc9d52b4e39878155bc7ff0114c322e0f05c0c82dff8c06c7278313f73  boehm-gc-musl.patch
f5473c6aea96d5137defd68898ba31042944a3f3ed26c05b964a40bd876c6f47  gcc-pure64.patch
d68d6680b3ab996b4b8dde2ddc351cecb46b560dc743d112e682c596696b67bb  pr49423.patch
999fdf60b3a51435e7485a57e12c1110a2af3965e14528f77d5dd0917115011d  pr57748.patch
bd7a6f514fcc457f29e5fda157203f3bcd013aeba5d53b3459196eef3ce752ab  gcc-4.8-build-args.patch
a395ba4cf047c48cac56985726fddf0948f4425c9f1a0c9ddba1812b2b3d8300  fix-cxxflags-passing.patch
a5678380e887dbf600c59273d382e81c10f89d28e422238a617d0a43ad5c5a69  fix-cxxflags-for-target.patch
de3c8606015ebda0dc574f904aa4d23c44c5e261b34dce2ef4d08eed21cb99b9  ada-no-pie.patch
ca0db7f59e7af0c621751eee9e3775d4c00c4b663f82f9e04c53a2efb16edca1  ada-fixes.patch
324524490c60d84ef040f79589e0f93fbaeb253dbe031484afaf963b881047e9  ada-crossbuild.patch
d6c7fc1820a4fa285297c299c255fe2f19ce1695486f20edd098252a97545e6a  ada-shared.patch
f20c34f3e0a1bf717f5e22fd66b57c8b69f0411d063203c017ed8209f349e1d4  ada-musl.patch"
sha512sums="1becc874aad77a469069b6d9da4158aae9e013e24afa9364fe4feff9a5094d0673ee7694b3840e892c860f73a56b3ece6174338a8214438c42b9f86dd6c35ea7  gcc-4.8.1.tar.bz2
274e16ef5136348415898d4e5a3bc71763078de8ae7c18645e8b07f54d705609b08c0efadbdb55117fdfb5f6490529b446d09def448174c2747372829d029a9d  gcc-4.8.1-piepatches-v0.5.6.tar.bz2
779ecb0a064d2138b54569c8ae501975b8a6b72e5a3acbf8597619a8db77ee42ef9b0e62608d5192a15e4393e7dfc009bb50b994782236faa744b2c46b5fe517  gcc-4.4.3-specs-0.2.0.tar.bz2
d4e1bf7538ace56e3d69fa91da5bbd16c272923b4de0a9d8dee23ea2b75f9f38c603de72fc4061df49285c450b63f3df211cee5270e9fffc5447445d1a9c9e4e  ecj-latest.jar
5069e4b741488913a646a9b5d871af8e7f7a606158ea09305d0ddd46257c5b659770627bc2ca3abeaae039da1717b3ba6c9cd90554a441da74eb4ecf24c13074  12_all_default-warn-trampolines.patch
c18a99b7303a734fe4dca9d4e90e21d18e5bd71c7d91e1a26c86b1354c73f567590a875941bfe64ce59f0393023b91c606c96b30885c55b98a790c3ab0c84ca7  15_all_libgfortran-Werror.patch
433404fd9bfa172d69fff4a5505e8648cbbbf5f052d2b4235608ff7af0c4063d557d25d80c85c5bd0d1e1ed64b568e7bbc0cdbce11cc74db4c0189af3a01634a  16_all_libgomp-Werror.patch
ff16f259fff8d78230593eee8641eab5a72c5c517c6ac5f09597edbc624d964b33f185a0dd5772d6029f757a5edb66431b3eab77dac71e76a0ef155bb7443d2c  48_all_x86_pr53113_libitm-avx.patch
c6c314a2d24531b4286436dec7189f83e443c4cfa9b88339a4c324c2d40812d766ed44dcfd4a0c3b67695bb76969a4d8a9784ff95876ceba23def305ef8a48f8  50_all_libiberty-asprintf.patch
0a0bc72b9366158f5d23fff1928e756fdd212433bac6ab1f00d632f241382820db8db5d475ddf11ea020eaf7e2e71b12fb9b1c3c870cf84adf6c2b16f15aabca  51_all_libiberty-pic.patch
47331f034e44aea16f1cbb67d9176f8ce8832d6cb7c13a8d3b438efaa3269cee177bd1dd8a9f353ac19cc6b3db436a995de9ae66d493d2772188630b09fbff51  67_all_gcc-poison-system-directories.patch
6e19b2dc43cff03a6b3ca4e18f76dcfd5b0682c15aac493e94f5c679f5b0a585fbaa09345d200182c0f47541ced2d714b78d65da130bc7d2e9f810362e07037d  74_all_gcc48_cloog-dl.patch
7242876e4bba34235f6f3ea960d72439638bd31547284ca96cb94c97a2d46dd7b38a3709fd159cf86efa1e8a44e3e9125fe82bc3a1cc71153591755827d6c9fd  gcc-ice-hack.patch
ce9c1f923e2c6d17347ec2d3d8482351a9644194b2753627389294d43bb4f11b9c2ef41eda1b46ad83d09901a0bedebd5b6b8a57a198646030ab61e8d2d8cb48  gcc-spec-env.patch
d08d7ead2de0429e5c9055d5b029ec2be9a8c821d22cecaf9b51f633652c493333f98963d9267fa2fa63850c50ae5eefd5f59e5910ec10d20044dac082182a8b  libgcc-always-build-gcceh.a.patch
8464197f01d107872dfa6b47e86e95ae8d75c053527bafbdb7a86bcc7aff4bc5b20a8ec40d6e48d1ad455b0187a3cba9db337cff6c0a6245507c4533e4832d99  pt_gnu_eh_frame.patch
e3edf75df1f27af8771bd263e1bd607f6207c4eb5b2a5e11032577deba43ea201825e3b5008a720105f24e49d2821dd77a61c7ceba7ed91b3621c0dbd9292fc6  uclibc-getipinfo.patch
9fc5e32f2573ae67b6cf22119d636d10a47c42718635bceff7d457a93a3f664ae1ed10e154f70964ba2d26b0de04f879a8c05de6411112760d40433373dd0a80  gcc-4.6-pr32219.patch
db84b6582950378116723116be4f277881f7bdd05add216c58c2b86c0fb3a70abeb7798507a74a64b9b949d5b311167bd4df84a048d2d2d32f5836ea1d34c42e  gcc-4.8-dynamic-linker.patch
12871b62d31a8e524547f2f0b37e711bae027aaadc487d893f8dc4cef2c2fee09f5c558cd7e1d28e0c687bc3be0465d1088c5ef7b87e8ac43ac06d86dc455761  gcc-4.8-musl.patch
b5b0210dfaccfe0b06f0a9090666b1fae2a3faa4140b7930146b29531f0da9beb1f2c1f7e7bc2bd29179f9fe05dc30e246e96220b8ff75a90f75e8350c9058a1  gcc-4.8-musl-fix-iteratephdr.patch
701c79ea7b90e622facb16fc71902aec25c443e376d675fc3f07cd55eff7a6b95ca365b2c60fff1dad3c3dc02b96c4c2ebbb45e4d2895496137e060443ae3e79  gcc-4.8-musl-libssp.patch
e1d6a450dfb40b134ad7f759c4c10174d2490b0093fe47cb33479245f26a3a8c54ebcf6255943c0ccfcb5095600d1c05e530baeed35609c8ffe75caac8e57c49  boehm-gc-uclibc.patch
7db904f83546edb4f7e54d3eaa0a8ab3235bca69e03a35000f083d26626bff92713f73150935c89f51e47c952bf29c36ec7d2fc8fedcde38048975e3e590faf9  boehm-gc-musl.patch
4a5aeff0399782c752e6e3f2f48d984b2056dfb5d229b23a24eee1562d241339989b2203f139821cfc03c9b25c9bd7da6ccbbdc7a09d242e4de7f0d606c6f63c  gcc-pure64.patch
b01ec5b2718e74048102d4a8e0a851f63524c9b9a70631ec93467b2e6080e8db2c500040572f64dce8161ef2c955bc1a7abd77d0e7970143967f9c8e0e3de948  pr49423.patch
018a9f2b7b490066a02671be38e1a4f18caeff98210027e68a1d4bd3d78ff810aa45a5cca163f4c46ee0d120715541a95a6e2487e17f4bb923459dec8edf8f8f  pr57748.patch
abe9aaf9aa956058d0386a4396a511d176a46bb3906b90e952383646cdc158cbeb0a5dc616a1ccb1ca7d49fd0b5e351532aa15a3b13362abbf1ca4266f54a687  gcc-4.8-build-args.patch
35d6d59f0b7b968f282f56767c9e0823a7bdc5aa0d450aca50fbd802649a7ca608b47671244a3faa208a9b0d6832cabb5a22724157dc817b2c0ad63d09f93282  fix-cxxflags-passing.patch
c731f4aaaa65c8950e1b2bd9331410f92d378fd8c7e718532dccaa27ee11984d51d74216c3611e89a802325b81d7f184116839dce2dab50cae9b643c20a82fe7  fix-cxxflags-for-target.patch
4938a38d6ffebebcd8b07a60e7d300935ef57056e5820145c6668dd5141e272d73a67a1bfe84dafda77212058eee768a03aba4356e52867b40a9ba9216a96714  ada-no-pie.patch
b37195a126476775e2ef16e0adc9173664c514339fb319f628debd8a4133fa53e022278387c68fc260cf813e58602617e9e629ea8177133bfdf5972398fe1c55  ada-fixes.patch
4d411563f6a3ea06bc3a1f4fa77d10250cc275e2496df6039d93f9b2229bc1f5334e484494dbd08881cf046f98aaca8bdddaa6b4a8f947b936d0bdc9e91f2f2b  ada-crossbuild.patch
3f5bc334d9f73d06f5f7c876738d02356acdd08958bea0e4d2095ebf15c2c2ec4e411abdae0297505ae9a1699ca01b17338e853184e84663203b192b0d35fc19  ada-shared.patch
7f6dc922a2c80b1c8c5ed0b6d6e4c1e672984f54bb217f28517929af129892e42c45f7aea4b9c50d8bbc008384b7ae19e1475c79f08b78775709720fe317c8f3  ada-musl.patch"