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
  20. release=2
  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. patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff"
  65. # Create a separate build directory
  66. rm -rf BUILD
  67. mkdir BUILD
  68. cd BUILD
  69. # To pass extra options to binutils according to the architecture
  70. binutils_hash_style=gnu;
  71. case $arch in
  72. i?86 | amd64 | x32 )
  73. binutils_targets="--enable-targets=i386-efi-pe,x86_64-pep"
  74. ;;
  75. mips*)
  76. binutils_hash_style=sysv;
  77. ;;
  78. esac
  79. # System-dependent
  80. MACHINE="$(gcc -dumpmachine)"
  81. ../configure CPPFLAGS="$QICPPFLAGS" \
  82. CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
  83. LDFLAGS="$(echo $QILDFLAGS | sed 's/-s//')" \
  84. $configure_args \
  85. $multilib_options \
  86. --libdir=/usr/lib${libSuffix} \
  87. --mandir=$mandir \
  88. --infodir=$infodir \
  89. --with-docdir=$docsdir \
  90. --enable-deterministic-archives \
  91. --enable-shared \
  92. --enable-gold=yes \
  93. --enable-ld=default \
  94. --enable-threads=auto \
  95. --enable-default-hash-style=$binutils_hash_style \
  96. --enable-relro \
  97. --enable-lto \
  98. --enable-plugins \
  99. --enable-64-bit-bfd \
  100. --enable-install-libiberty \
  101. --enable-separate-code \
  102. --disable-nls \
  103. --disable-werror \
  104. --disable-compressed-debug-sections \
  105. --disable-generate-build-notes \
  106. --with-system-zlib \
  107. --with-pic \
  108. --build=$MACHINE \
  109. $binutils_targets
  110. unset -v binutils_targets binutils_hash_style
  111. make -j${jobs} V=1 tooldir=/usr/${MACHINE}
  112. #make -j${jobs} V=1 check
  113. make -j${jobs} V=1 tooldir=/usr/${MACHINE} DESTDIR="$destdir" install
  114. find "$destdir" -type f -print0 | xargs -0 file | \
  115. awk '/ELF/ && /executable/ || /shared object/' | \
  116. cut -f 1 -d : | xargs -0 strip --remove-section=.comment \
  117. --remove-section=.note 2> /dev/null || true
  118. cd ../
  119. # Replace hard-links with relative soft-links for the package size
  120. (
  121. cd "${destdir}/usr/bin" && \
  122. rm -f ld ; ln -sf ld.bfd ld
  123. )
  124. (
  125. cd "${destdir}/usr/${MACHINE}/bin" && \
  126. for file in *
  127. do
  128. if test -x "../../bin/$file"
  129. then
  130. rm -f "$file" && ln -s "../../bin/$file" .
  131. fi
  132. done
  133. )
  134. unset -v MACHINE
  135. # Compress info documents deleting index file for the package
  136. if test -d "${destdir}/$infodir"
  137. then
  138. rm -f "${destdir}/${infodir}/dir"
  139. lzip -9 "${destdir}/${infodir}"/*
  140. fi
  141. # Compress man pages
  142. if test -d "${destdir}/$mandir"
  143. then
  144. lzip -9 "${destdir}/${mandir}"/man?/*
  145. fi
  146. # Copy documentation
  147. mkdir -p "${destdir}/$docsdir"
  148. cp -p $docs "${destdir}/$docsdir"
  149. }