recipe 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # Build recipe for binutils.
  2. #
  3. # Copyright (c) 2015-2022 Matias Fonzo, <selk@dragora.org>.
  4. #
  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
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  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.
  16. # Exit immediately on any error
  17. set -e
  18. program=binutils
  19. version=2.38.20220801_dc2474e7d20
  20. release=1
  21. # Define a category for the output of the package name
  22. pkgcategory=devel
  23. tarname=${program}-${version}.tar.lz
  24. # Remote source(s)
  25. fetch=https://ftp.gnu.org/gnu/binutils/$tarname
  26. description="
  27. The GNU binary utilities.
  28. Binutils is a collection of programming tools for the manipulation
  29. of object code in various object file formats. These tools consist
  30. of the GNU linker (ld), the GNU assembler (as) and the profiler
  31. (gprof). There is also a collection of other binary tools like
  32. the disassembler (objdump).
  33. "
  34. homepage=https://www.gnu.org/software/binutils
  35. license="GPLv2+, GPLv3+, LGPLv2, LGPLv3"
  36. # Source documentation
  37. docs="COPYING* README"
  38. docsdir="${docdir}/${program}-${version}"
  39. build()
  40. {
  41. unpack "${tardir}/$tarname"
  42. cd "$srcdir"
  43. # Set sane permissions
  44. chmod -R u+w,go-w,a+rX-s .
  45. # Apply patches from Fedora (Nick Clifton)
  46. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-export-demangle.h.patch"
  47. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-no-config-h-check.patch"
  48. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-filename-in-error-messages.patch"
  49. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-revert-PLT-elision.patch"
  50. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-readelf-other-sym-info.patch"
  51. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-2.27-aarch64-ifunc.patch"
  52. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-link-with-static-libstdc++.patch"
  53. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-special-sections-in-groups.patch"
  54. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-mismatched-section-flags.patch"
  55. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-CVE-2019-1010204.patch"
  56. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-warn-unsupported.patch"
  57. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-use-long-long.patch"
  58. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gold-i386-gnu-property-notes.patch"
  59. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-autoconf-version.patch"
  60. patch -Np1 -i "${worktree}/patches/binutils/2.38/gcc12-libtool-no-rpath.patch"
  61. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-section-type.patch"
  62. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-gas-loc-view.patch"
  63. patch -Np1 -i "${worktree}/patches/binutils/2.38/binutils-do-not-use-debuginfod.patch"
  64. # Create a separate build directory
  65. rm -rf BUILD
  66. mkdir BUILD
  67. cd BUILD
  68. # To pass extra options to binutils according to the architecture
  69. binutils_hash_style=gnu;
  70. case $arch in
  71. i?86 | amd64 | x32 )
  72. binutils_targets="--enable-targets=i386-efi-pe,x86_64-pep"
  73. ;;
  74. mips*)
  75. binutils_hash_style=sysv;
  76. ;;
  77. esac
  78. # System-dependent
  79. MACHINE="$(gcc -dumpmachine)"
  80. ../configure CPPFLAGS="$QICPPFLAGS" \
  81. CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
  82. LDFLAGS="$(echo $QILDFLAGS | sed 's/-s//')" \
  83. $configure_args \
  84. $multilib_options \
  85. --libdir=/usr/lib${libSuffix} \
  86. --mandir=$mandir \
  87. --infodir=$infodir \
  88. --with-docdir=$docsdir \
  89. --enable-deterministic-archives \
  90. --enable-shared \
  91. --enable-gold=yes \
  92. --enable-ld=default \
  93. --enable-threads=auto \
  94. --enable-default-hash-style=$binutils_hash_style \
  95. --enable-relro \
  96. --enable-lto \
  97. --enable-plugins \
  98. --enable-64-bit-bfd \
  99. --enable-install-libiberty \
  100. --enable-separate-code \
  101. --disable-nls \
  102. --disable-werror \
  103. --disable-compressed-debug-sections \
  104. --disable-generate-build-notes \
  105. --disable-gprofng \
  106. --with-mmap \
  107. --with-system-zlib \
  108. --with-pic \
  109. --build=$MACHINE \
  110. $binutils_targets
  111. unset -v binutils_targets binutils_hash_style
  112. make -j${jobs} V=1 tooldir=/usr/${MACHINE}
  113. #make -j${jobs} V=1 check
  114. make -j${jobs} V=1 tooldir=/usr/${MACHINE} DESTDIR="$destdir" install
  115. find "$destdir" -type f -print0 | xargs -0 file | \
  116. awk '/ELF/ && /executable/ || /shared object/' | \
  117. cut -f 1 -d : | xargs -0 strip --remove-section=.comment \
  118. --remove-section=.note 2> /dev/null || true
  119. cd ../
  120. # Replace hard-links with relative soft-links for the package size
  121. (
  122. cd "${destdir}/usr/bin" && \
  123. rm -f ld ; ln -sf ld.bfd ld
  124. )
  125. (
  126. cd "${destdir}/usr/${MACHINE}/bin" && \
  127. for file in *
  128. do
  129. if test -x "../../bin/$file"
  130. then
  131. rm -f "$file" && ln -s "../../bin/$file" .
  132. fi
  133. done
  134. )
  135. unset -v MACHINE
  136. # Compress info documents deleting index file for the package
  137. if test -d "${destdir}/$infodir"
  138. then
  139. rm -f "${destdir}/${infodir}/dir"
  140. lzip -9 "${destdir}/${infodir}"/*
  141. fi
  142. # Compress man pages
  143. if test -d "${destdir}/$mandir"
  144. then
  145. lzip -9 "${destdir}/${mandir}"/man?/*
  146. fi
  147. # Copy documentation
  148. mkdir -p "${destdir}/$docsdir"
  149. cp -p $docs "${destdir}/$docsdir"
  150. }