1SUMMARY="Assembler, linker and binary tools for ARM microcontrollers and processors"
2DESCRIPTION="The GNU Binutils are a collection of binary tools.
3
4The main ones are:
5- ld - the GNU linker.
6- as - the GNU assembler.
7
8But they also include:
9- addr2line - converts addresses into filenames and line numbers.
10- ar - a utility for creating, modifying and extracting of archives.
11- c++filt - filter to demangle encoded C++ symbols.
12- nm - lists symbols from object files.
13- objcopy - copys and translates object files.
14- objdump - displays information from object files.
15- ranlib - generates an index to the contents of an archive.
16- readelf - displays information from any ELF format object file.
17- size - lists the section sizes of an object or archive file.
18- strings - lists printable strings from files.
19- strip - discards symbols.
20
21The tools of this package can be used for cross-builds to $effectiveTargetMachineTriple."
22HOMEPAGE="https://www.gnu.org/software/binutils"
23COPYRIGHT="1988-2023 Free Software Foundation, Inc."
24LICENSE="GNU GPL v3
25	GNU LGPL v3"
26REVISION="2"
27SOURCE_URI="https://ftp.gnu.org/gnu/binutils/binutils-$portVersion.tar.xz"
28SOURCE_DIR="binutils-$portVersion"
29CHECKSUM_SHA256="0f8a4c272d7f17f369ded10a4aca28b8e304828e95526da482b0ccc4dfc9d8e1"
30
31ARCHITECTURES="all !x86_gcc2"
32SECONDARY_ARCHITECTURES="x86"
33
34targetArch="arm-none-eabi"
35targetU="arm_none_eabi"
36
37PROVIDES="
38	${targetU}_binutils$secondaryArchSuffix = $portVersion compat >= 2.36
39	cmd:${targetU}_addr2line = $portVersion compat >= 2.36
40	cmd:${targetU}_ar = $portVersion compat >= 2.36
41	cmd:${targetU}_as = $portVersion compat >= 2.36
42	cmd:${targetU}_c++filt = $portVersion compat >= 2.36
43	cmd:${targetU}_elfedit = $portVersion compat >= 2.36
44	cmd:${targetU}_gprof = $portVersion compat >= 2.36
45	cmd:${targetU}_ld = $portVersion compat >= 2.36
46	cmd:${targetU}_ld.bfd = $portVersion compat >= 2.36
47	cmd:${targetU}_nm = $portVersion compat >= 2.36
48	cmd:${targetU}_objcopy = $portVersion compat >= 2.36
49	cmd:${targetU}_objdump = $portVersion compat >= 2.36
50	cmd:${targetU}_ranlib = $portVersion compat >= 2.36
51	cmd:${targetU}_readelf = $portVersion compat >= 2.36
52	cmd:${targetU}_size = $portVersion compat >= 2.36
53	cmd:${targetU}_strings = $portVersion compat >= 2.36
54	cmd:${targetU}_strip = $portVersion compat >= 2.36
55	lib:${targetU}_libbfd_$binutilsVersion$secondaryArchSuffix = $portVersion compat >= 2.36
56	lib:${targetU}_libopcodes_$binutilsVersion$secondaryArchSuffix = $portVersion compat >= 2.36
57	lib:libctf_nobfd$secondaryArchSuffix = 0.0.0 compat >= 0
58	lib:libctf$secondaryArchSuffix = 0.0.0 compat >= 0
59	lib:libsframe$secondaryArchSuffix = 0.0.0 compat >= 0
60	devel:libctf_nobfd$secondaryArchSuffix = 0.0.0 compat >= 0
61	devel:libctf$secondaryArchSuffix = 0.0.0 compat >= 0
62	devel:libsframe$secondaryArchSuffix = 0.0.0 compat >= 0
63	"
64
65REQUIRES="
66	binutils$secondaryArchSuffix
67	haiku$secondaryArchSuffix
68	"
69BUILD_REQUIRES="
70	haiku${secondaryArchSuffix}_devel
71	cmd:find
72	cmd:xargs
73	"
74BUILD_PREREQUIRES="
75	cmd:autoconf
76	cmd:awk
77	cmd:bison
78	cmd:find
79	cmd:flex
80	cmd:gcc$secondaryArchSuffix
81	cmd:ld$secondaryArchSuffix
82	cmd:make
83	cmd:makeinfo
84	cmd:sed
85	cmd:strip
86	cmd:tar
87	cmd:xargs
88	"
89
90BUILD_PACKAGE_ACTIVATION_PHASE=INSTALL
91
92sourceDir=$(pwd)
93relativeInstallDir="develop/tools/${targetArch}"
94installDir="$prefix/$relativeInstallDir"
95objectsDir=$(pwd)/../${portVersionedName}-obj
96
97BUILD()
98{
99	rm -rf $objectsDir
100
101	mkdir -p $objectsDir
102	cd $objectsDir
103
104	CFLAGS=-O2 CXXFLAGS=-O2 runConfigure --omit-dirs binDir \
105		"$sourceDir/configure" \
106		--exec-prefix=$installDir \
107		--includedir=$includeDir/binutils \
108		--docdir=$docDir --with-sysroot=$installDir \
109		--enable-deterministic-archives --enable-shared=yes \
110		--disable-nls --bindir=$prefix/bin --target=${targetArch}
111
112	make $jobArgs LEXLIB=
113}
114
115INSTALL()
116{
117	cd $objectsDir
118
119	make install
120
121	# no info documentation
122	rm -r $infoDir
123
124	### Strip #################################################
125
126	echo "Strip debug info"
127
128	strip --strip-debug $prefix/bin/*
129
130	### Symlinks ##############################################
131
132	echo "Creating required symlinks"
133
134	# There are copies of a subset of the commands below installDir. We
135	# overwrite those with symlinks to the ones in binDir.
136	for file in $installDir/${targetArch}/bin/*; do
137		symlinkRelative -sfn $prefix/bin/${targetArch}-$(basename $file) $file
138	done
139
140	### Cleanup #################################################
141
142	echo "Cleanup"
143
144	# delete man pages for commands that we aren't including
145	cd $manDir
146	for cmd in dlltool nlmconv windmc windres; do
147		rm -f man1/$cmd.1
148	done
149
150	rm $libDir/*.la $libDir/*.a
151	prepareInstalledDevelLibs libctf libsframe
152}
153