1SUMMARY="C/C++ cross-compiler for ARM"
2DESCRIPTION="Compiler for ARM processors."
3HOMEPAGE="http://gcc.gnu.org"
4
5SOURCE_URI="http://ftpmirror.gnu.org/gcc/gcc-$portVersion/gcc-$portVersion.tar.xz"
6SOURCE_DIR="gcc-$portVersion"
7CHECKSUM_SHA256="61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86"
8REVISION="1"
9LICENSE="
10	GNU GPL v2
11	GNU LGPL v2
12"
13COPYRIGHT="1988-2023 Free Software Foundation, Inc."
14
15ARCHITECTURES="all !x86_gcc2"
16SECONDARY_ARCHITECTURES="x86"
17
18targetArch="arm-none-eabi"
19targetU="arm_none_eabi"
20
21PROVIDES="
22	${targetU}_gcc_nolibc$secondaryArchSuffix = $portVersion compat >= 4
23	cmd:${targetU}_c++ = $portVersion compat >= 4
24	cmd:${targetU}_cc = $portVersion compat >= 4
25	cmd:${targetU}_cpp = $portVersion compat >= 4
26	cmd:${targetU}_g++ = $portVersion compat >= 4
27	cmd:${targetU}_gcc = $portVersion compat >= 4
28	cmd:${targetU}_gcc_$portVersion = $portVersion compat >= 4
29	cmd:${targetU}_gcov = $portVersion compat >= 4
30	lib:${targetU}_libstdc++$secondaryArchSuffix = $portVersion compat >= 4
31	"
32
33REQUIRES="
34	haiku$secondaryArchSuffix
35	cmd:${targetU}_as
36	lib:libgmp$secondaryArchSuffix
37	lib:libmpfr$secondaryArchSuffix
38	lib:libmpc$secondaryArchSuffix
39	"
40BUILD_REQUIRES="
41	cmd:${targetU}_as >= 2.40
42	devel:libgmp$secondaryArchSuffix
43	devel:libmpfr$secondaryArchSuffix
44	devel:libmpc$secondaryArchSuffix
45	"
46BUILD_PREREQUIRES="
47	haiku${secondaryArchSuffix}_devel
48	cmd:autoconf
49	cmd:awk
50	cmd:bison
51	cmd:find
52	cmd:flex
53	cmd:gcc$secondaryArchSuffix
54	cmd:ld$secondaryArchSuffix
55	cmd:make
56	cmd:makeinfo
57	cmd:sed
58	cmd:strip
59	cmd:tar
60	cmd:xargs
61	"
62
63sourceDir=$(pwd)
64relativeInstallDir="develop/tools/${targetArch}"
65installDir="$prefix/$relativeInstallDir"
66objectsDir=$(pwd)/../${portVersionedName}-obj
67
68BUILD()
69{
70	rm -rf $objectsDir
71
72	# Touch some files generated by bison, so that bison won't run to update
73	# them. Fixes issues with newer bison versions.
74	# And while at it, touch gperf target, too (as gperf may not be installed).
75	(cd $sourceDir/gcc; touch c-parse.c c-parse.h cexp.c cp/parse.c \
76		cp/parse.h c-gperf.h)
77
78	mkdir -p $objectsDir
79	cd $objectsDir
80
81	# Setting a quoted string in an environment variable is ugly (the quotes
82	# are removed at various stages and need an absurd amount of escaping), so
83	# let's use a file and --include instead.
84	echo '#define LIBRARY_PATH_ENV "ARM_LIBRARY_PATH"' > haiku_host.h
85
86	CXXFLAGS="-O2 -include $objectsDir/haiku_host.h -fPIC" \
87	CFLAGS="-O2 -U_FORTIFY_SOURCE -fPIC" "$sourceDir/configure" \
88		--build=$effectiveTargetMachineTriple \
89		--prefix=$installDir --libexecdir=$installDir/lib --mandir=$manDir \
90		--docdir=$docDir --disable-nls --with-gnu-ld \
91		--enable-languages=c,c++ --enable-lto --enable-frame-pointer \
92		--enable-multilib --disable-shared \
93		--without-headers --with-newlib \
94		--with-sysroot=$installDir \
95		--with-native-system-header-dir=/include \
96		--with-pkgversion=$(echo $portVersion | cut -c 7-) --target=$targetArch
97
98	echo "configure done, start build"
99	make $jobArgs all-gcc all-target-libgcc
100}
101
102INSTALL()
103{
104	cd $objectsDir
105
106	make install-gcc install-target-libgcc
107
108	### Symlinks ##############################################
109
110	echo "Creating required symlinks"
111
112	# make all tools available via default paths
113	mkdir -p $prefix/bin
114	for f in c++ cc cpp g++ gcc gcov; do
115		symlinkRelative -sfn $installDir/bin/$targetArch-$f $prefix/bin
116	done
117
118	### Cleanup ###############################################
119
120	echo "Cleanup"
121	rm -rf $installDir/info
122	rm -rf $installDir/share
123}
124