aboutsummaryrefslogtreecommitdiffstats
path: root/testing/gcc-cross-embedded-stage1/APKBUILD
blob: e16f75422f1a6834f5e60323a3043cb64ae9d1b8 (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
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Based upon Alpine's avr-gcc and Arch Linux's arm-none-eabi-gcc, to which
# the following people contributed:
# Contributor: Pedro Filipe <xpecex@outlook.com>
# Contributor: Stefan Wagner <stw@bit-strickerei.de>
# Contributor: Anatol Pomozov <anatol.pomozov@gmail.com>
# Contributor: Martin Schmölzer <mschmoelzer@gmail.com>
_pkgbase=gcc
_targets="
	arm-none-eabi
	mips-mti-elf
	msp430-elf
	"
pkgname="$_pkgbase-cross-embedded-stage1"
pkgver=9.2.0
pkgrel=0
pkgdesc="The GNU Compiler Collection for embedded targets"
url="http://gcc.gnu.org"
depends="gcc"
makedepends="bash linux-headers gmp-dev mpfr-dev mpc1-dev zlib-dev"
arch="all"
license="GPL-3.0+"
for target in $_targets; do
	targetnorm="${target//-/_}"
	subpackages="$_pkgbase-$target-stage1:$targetnorm $subpackages"
	makedepends="$makedepends binutils-$target"
done

_islver=0.20
source="
	https://mirrors.kernel.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz
	http://isl.gforge.inria.fr/isl-$_islver.tar.bz2
	"
options="!check"

builddir="$srcdir/$_pkgbase-$pkgver"

prepare() {
	# link isl for in-tree build
	ln -s "$srcdir"/isl-"$_islver" isl

	# hack! - some configure tests for header files using "$CPP $CPPFLAGS"
	for dir in libiberty gcc; do
		sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" $dir/configure
	done
}

_build_gcc() {
	"$builddir"/configure \
		--target=$target \
		--prefix=/usr \
		--with-sysroot=/usr/$target \
		--with-native-system-header-dir=/include \
		--with-headers=/usr/$target/include \
		--with-python-dir=share/gcc-$target \
		--libexecdir=/usr/lib \
		--infodir=/deleteme/info \
		--htmldir=/deleteme/html \
		--pdfdir=/deleteme/pdf \
		--mandir=/deleteme/man \
		--enable-languages=c \
		--enable-plugins \
		--enable-gnu-indirect-function \
		--disable-decimal-float \
		--disable-libffi \
		--disable-libgomp \
		--disable-libmudflap \
		--disable-libquadmath \
		--disable-libssp \
		--disable-libstdcxx-pch \
		--disable-multilib \
		--disable-nls \
		--disable-shared \
		--disable-threads \
		--disable-tls \
		--disable-werror \
		--with-gmp \
		--with-gnu-as \
		--with-gnu-ld \
		--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
		--with-isl \
		--with-libelf \
		--with-mpc \
		--with-mpfr \
		--with-newlib \
		--with-system-zlib \
		--with-pkgversion='Alpine Linux' \
		--without-headers
	make INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0' -j8
}

build() {
	for target in $_targets; do
		workingdir="$srcdir/build-$target"
		mkdir "$workingdir"
		cd "$workingdir"
		export CFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections'
		export CXXFLAGS_FOR_TARGET='-pipe -Os -ffunction-sections -fdata-sections'
		_build_gcc
	done
}

package() {
	for target in $_targets; do
		depends="$depends $_pkgbase-$target"
	done
	mkdir -p "$pkgdir"
}

_install_subpkg() {
	target="${subpkgname#$_pkgbase-}"
	target="${target%-stage1}"
	pkgdesc="The GNU Compiler Collection for $target targets"
	depends="$depends binutils-$target"
	workingdir="$srcdir/build-$target"
	cd "$workingdir"
	make install DESTDIR="$subpkgdir" -j1

	# Delete documentation. (The user can use the host GCC doc instead)
	rm -rf "$subpkgdir"/deleteme
	# Delete libcc1.so*, which is already part of the host's gcc
	rm -f "$subpkgdir"/usr/lib/libcc1.so*

	# Strip libs using target binutils
	find "$subpkgdir"/usr/lib -type f -name "*.a" -exec /usr/bin/$target-strip --strip-debug '{}' \;

	# Strip executables using host binutils
	find "$subpkgdir"/usr/bin -type f -executable -exec strip '{}' \;
}

arm_none_eabi() {
	_install_subpkg
}

mips_mti_elf() {
	_install_subpkg
}

msp430_elf() {
	_install_subpkg
}

sha512sums="a12dff52af876aee0fd89a8d09cdc455f35ec46845e154023202392adc164848faf8ee881b59b681b696e27c69fd143a214014db4214db62f9891a1c8365c040  gcc-9.2.0.tar.xz
afe2e159b74646a26449268637403d271f9e3f6410d8cc1c9cffca41370c4357b165dea844db0c2a654591f954e54710dda650c8088abd4711406aa6302da950  isl-0.20.tar.bz2"