stages: 2/04-iso: Do not include kernel build/source tree in the LiveCD
[dragora.git] / recipes / devel / binutils / recipe
bloba03a03211859277c80c07581021d889b73304c23
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
18 set -e
20 program=binutils
21 version=2.38.20220801_dc2474e7d20
22 release=1
24 # Define a category for the output of the package name
25 pkgcategory=devel
27 tarname=${program}-${version}.tar.lz
29 # Remote source(s)
30 fetch=https://ftp.gnu.org/gnu/binutils/$tarname
32 description="
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}"
49 build()
51     unpack "${tardir}/$tarname"
53     cd "$srcdir"
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
80     rm -rf BUILD
81     mkdir BUILD
82     cd BUILD
84     # To pass extra options to binutils according to the architecture
85     binutils_hash_style=gnu;
86     case $arch in
87     i?86 | amd64 | x32 )
88         binutils_targets="--enable-targets=i386-efi-pe,x86_64-pep"
89         ;;
90     mips*)
91         binutils_hash_style=sysv;
92         ;;
93     esac
95     # System-dependent
96     MACHINE="$(gcc -dumpmachine)"
98     ../configure CPPFLAGS="$QICPPFLAGS" \
99     CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
100     LDFLAGS="$(echo $QILDFLAGS | sed 's/-s//')" \
101      $configure_args \
102      $multilib_options \
103      --libdir=/usr/lib${libSuffix} \
104      --mandir=$mandir \
105      --infodir=$infodir \
106      --with-docdir=$docsdir \
107      --enable-deterministic-archives \
108      --enable-shared \
109      --enable-gold=yes \
110      --enable-ld=default \
111      --enable-threads=auto \
112      --enable-default-hash-style=$binutils_hash_style \
113      --enable-relro \
114      --enable-lto \
115      --enable-plugins \
116      --enable-64-bit-bfd \
117      --enable-install-libiberty \
118      --enable-separate-code \
119      --disable-nls \
120      --disable-werror \
121      --disable-compressed-debug-sections \
122      --disable-generate-build-notes \
123      --disable-gprofng \
124      --with-mmap \
125      --with-system-zlib \
126      --with-pic \
127      --build=$MACHINE \
128      $binutils_targets
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
141     cd ../
143     # Replace hard-links with relative soft-links for the package size
144     (
145         cd "${destdir}/usr/bin" && \
146         rm -f ld ; ln -sf ld.bfd ld
147     )
148     (
149         cd "${destdir}/usr/${MACHINE}/bin" && \
150         for file in *
151         do
152             if test -x "../../bin/$file"
153             then
154                 rm -f "$file" && ln -s "../../bin/$file" .
155             fi
156         done
157     )
159     unset -v MACHINE
161     # Compress info documents deleting index file for the package
162     if test -d "${destdir}/$infodir"
163     then
164         rm -f "${destdir}/${infodir}/dir"
165         lzip -9 "${destdir}/${infodir}"/*
166     fi
168     # Compress man pages
169     if test -d "${destdir}/$mandir"
170     then
171         lzip -9 "${destdir}/${mandir}"/man?/*
172     fi
174     # Copy documentation
175     mkdir -p "${destdir}/$docsdir"
176     cp -p $docs "${destdir}/$docsdir"