1 # Build recipe for binutils.
3 # Copyright (c) 2015-2022 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Exit immediately on any error
21 version=2.38.20220801_dc2474e7d20
24 # Define a category for the output of the package name
27 tarname=${program}-${version}.tar.lz
30 fetch=https://ftp.gnu.org/gnu/binutils/$tarname
33 The GNU binary utilities.
35 Binutils is a collection of programming tools for the manipulation
36 of object code in various object file formats. These tools consist
37 of the GNU linker (ld), the GNU assembler (as) and the profiler
38 (gprof). There is also a collection of other binary tools like
39 the disassembler (objdump).
42 homepage=https://www.gnu.org/software/binutils
43 license="GPLv2+, GPLv3+, LGPLv2, LGPLv3"
45 # Source documentation
46 docs="COPYING* README"
47 docsdir="${docdir}/${program}-${version}"
51 unpack "${tardir}/$tarname"
55 # Set sane permissions
56 chmod -R u+w,go-w,a+rX-s .
58 # Apply patches from Fedora (Nick Clifton)
60 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-export-demangle.h.patch"
61 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-no-config-h-check.patch"
62 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-filename-in-error-messages.patch"
63 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-revert-PLT-elision.patch"
64 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-readelf-other-sym-info.patch"
65 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-2.27-aarch64-ifunc.patch"
66 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-link-with-static-libstdc++.patch"
67 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-special-sections-in-groups.patch"
68 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-mismatched-section-flags.patch"
69 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-CVE-2019-1010204.patch"
70 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-warn-unsupported.patch"
71 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-use-long-long.patch"
72 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-i386-gnu-property-notes.patch"
73 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-autoconf-version.patch"
74 patch -Np1 -i "${worktree}/patches/binutils/2.38/gcc12-libtool-no-rpath.patch"
75 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-section-type.patch"
76 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gas-loc-view.patch"
77 patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-use-debuginfod.patch"
79 # Create a separate build directory
84 # To pass extra options to binutils according to the architecture
85 binutils_hash_style=gnu;
88 binutils_targets="--enable-targets=i386-efi-pe,x86_64-pep"
91 binutils_hash_style=sysv;
96 MACHINE="$(gcc -dumpmachine)"
98 ../configure CPPFLAGS="$QICPPFLAGS" \
99 CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
100 LDFLAGS="$(echo $QILDFLAGS | sed 's/-s//')" \
103 --libdir=/usr/lib${libSuffix} \
106 --with-docdir=$docsdir \
107 --enable-deterministic-archives \
110 --enable-ld=default \
111 --enable-threads=auto \
112 --enable-default-hash-style=$binutils_hash_style \
116 --enable-64-bit-bfd \
117 --enable-install-libiberty \
118 --enable-separate-code \
121 --disable-compressed-debug-sections \
122 --disable-generate-build-notes \
130 unset -v binutils_targets binutils_hash_style
132 make -j${jobs} V=1 tooldir=/usr/${MACHINE}
133 #make -j${jobs} V=1 check
134 make -j${jobs} V=1 tooldir=/usr/${MACHINE} DESTDIR="$destdir" install
136 find "$destdir" -type f -print0 | xargs -0 file | \
137 awk '/ELF/ && /executable/ || /shared object/' | \
138 cut -f 1 -d : | xargs -0 strip --remove-section=.comment \
139 --remove-section=.note 2> /dev/null || true
143 # Replace hard-links with relative soft-links for the package size
145 cd "${destdir}/usr/bin" && \
146 rm -f ld ; ln -sf ld.bfd ld
149 cd "${destdir}/usr/${MACHINE}/bin" && \
152 if test -x "../../bin/$file"
154 rm -f "$file" && ln -s "../../bin/$file" .
161 # Compress info documents deleting index file for the package
162 if test -d "${destdir}/$infodir"
164 rm -f "${destdir}/${infodir}/dir"
165 lzip -9 "${destdir}/${infodir}"/*
169 if test -d "${destdir}/$mandir"
171 lzip -9 "${destdir}/${mandir}"/man?/*
175 mkdir -p "${destdir}/$docsdir"
176 cp -p $docs "${destdir}/$docsdir"