recipes: Rename 'pkghashtag' variable to 'pkgcategory'
[dragora.git] / recipes / devel / binutils / recipe
blobe704878c61b1fdcc8425be4bdc540de6382bcf8b
1 # Build recipe for binutils.
3 # Copyright (c) 2015-2020 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 program=binutils
18 version=2.34
19 release=2
21 # Define a category for the output of the package name
22 pkgcategory=devel
24 tarname=${program}-${version}.tar.lz
26 # Remote source(s)
27 fetch=http://ftp.gnu.org/gnu/binutils/$tarname
29 description="
30 The GNU binary utilities.
32 Binutils is a collection of programming tools for the manipulation
33 of object code in various object file formats.  These tools consist
34 of the GNU linker (ld), the GNU assembler (as) and the profiler
35 (gprof).  There is also a collection of other binary tools like
36 the disassembler (objdump).
39 homepage=http://www.gnu.org/software/binutils
40 license="GPLv2+, GPLv3+, LGPLv2, LGPLv3"
42 # Source documentation
43 docs="COPYING* README"
44 docsdir="${docdir}/${program}-${version}"
46 # System-dependent
47 MACHTYPE="$(cc -dumpmachine)"
49 build()
51     set -e
53     unpack "${tardir}/$tarname"
55     cd "$srcdir"
57     # Set sane permissions
58     chmod -R u+w,go-w,a+rX-s .
60     patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff"
62     # Create a separate build directory
63     rm -rf ../binutils-build
64     mkdir ../binutils-build
65     cd ../binutils-build
67     # Set sane permissions
68     chmod -R u+w,go-w,a+rX-s .
70     # To pass extra options to binutils according to the architecture
71     case $arch in
72     i?86 | x86_64*)
73         binutils_targets="--enable-targets=i386-efi-pe,x86_64-pep"
74         ;;
75     esac
77     ../${program}-${version}/configure \
78     CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
79      $configure_args \
80      $multilib_options \
81      --libdir=/usr/lib${libSuffix} \
82      --mandir=$mandir \
83      --infodir=$infodir \
84      --with-docdir=$docsdir \
85      --enable-deterministic-archives \
86      --enable-shared \
87      --enable-gold=yes \
88      --enable-ld=default \
89      --enable-threads=auto \
90      --enable-relro \
91      --enable-lto \
92      --enable-nls \
93      --enable-plugins \
94      --enable-64-bit-bfd \
95      --enable-install-libiberty \
96      --enable-initfini-array \
97      --disable-werror \
98      --disable-separate-code \
99      --disable-compressed-debug-sections \
100      --with-system-zlib \
101      --build=$MACHTYPE \
102      $binutils_targets
104     unset binutils_targets
105     make -j${jobs} tooldir=/usr/${MACHTYPE}
106     #make -k check
107     make -j${jobs} tooldir=/usr/${MACHTYPE} DESTDIR="$destdir" install-strip
109     # Back to srcdir
110     cd .. && cd "$srcdir"
112     # Replace hard-links with relative soft-links for the package size
113     (
114         cd "${destdir}/usr/bin" && \
115         rm -f ld ; ln -sf ld.bfd ld
116     )
117     (
118         cd "${destdir}/usr/${MACHTYPE}/bin" && \
119         for file in *
120         do
121             if test -x "../../bin/$file"
122             then
123                 rm -f "$file" && ln -s "../../bin/$file" .
124             fi
125         done
126     )
128     # Compress info documents deleting index file for the package
129     if test -d "${destdir}/$infodir"
130     then
131         rm -f "${destdir}/${infodir}/dir"
132         lzip -9 "${destdir}/${infodir}"/*
133     fi
135     # Compress man pages
136     if test -d "${destdir}/$mandir"
137     then
138         lzip -9 "${destdir}/${mandir}"/man?/*
139     fi
141     # Copy documentation
142     mkdir -p "${destdir}${docsdir}"
143     cp -p $docs "${destdir}${docsdir}/"
145     # Delete temporary build directory
146     cd -- "$TMPDIR"
147     if test -d ./binutils-build
148     then
149         rm -rf ./binutils-build
150     fi