recipe 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # Build recipe for binutils.
  2. #
  3. # Copyright (c) 2015-2021 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.35.2
  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/binutils-export-demangle.h.patch"
  47. patch -Np1 -i "${worktree}/patches/binutils/binutils-no-config-h-check.patch"
  48. patch -Np1 -i "${worktree}/patches/binutils/binutils-gold-warn-unsupported.patch"
  49. patch -Np1 -i "${worktree}/patches/binutils/binutils-use-long-long.patch"
  50. #patch -Np1 -i "${worktree}/patches/binutils/branch-updates.diff"
  51. # Create a separate build directory
  52. mkdir BUILD
  53. cd BUILD
  54. # Set sane permissions
  55. chmod -R u+w,go-w,a+rX-s .
  56. # To pass extra options to binutils according to the architecture
  57. case $arch in
  58. i?86 | amd64 | x32 )
  59. binutils_targets="--enable-targets=i386-efi-pe,x86_64-pep"
  60. ;;
  61. esac
  62. # System-dependent
  63. MACHINE="$(gcc -dumpmachine)"
  64. ../configure CPPFLAGS="$QICPPFLAGS" \
  65. CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
  66. LDFLAGS="$(echo $QILDFLAGS | sed 's/-s//')" \
  67. $configure_args \
  68. $multilib_options \
  69. --libdir=/usr/lib${libSuffix} \
  70. --mandir=$mandir \
  71. --infodir=$infodir \
  72. --with-docdir=$docsdir \
  73. --enable-deterministic-archives \
  74. --enable-shared \
  75. --enable-gold=yes \
  76. --enable-ld=default \
  77. --enable-threads=auto \
  78. --enable-default-hash-style=gnu \
  79. --enable-relro \
  80. --enable-lto \
  81. --enable-nls \
  82. --enable-plugins \
  83. --enable-64-bit-bfd \
  84. --enable-install-libiberty \
  85. --disable-werror \
  86. --disable-compressed-debug-sections \
  87. --with-system-zlib \
  88. --build=$MACHINE \
  89. $binutils_targets
  90. unset -v binutils_targets
  91. make -j${jobs} tooldir=/usr/${MACHINE}
  92. #make -j${jobs} check
  93. make -j${jobs} tooldir=/usr/${MACHINE} DESTDIR="$destdir" install
  94. find "$destdir" -type f -print0 | xargs -0 file | \
  95. awk '/ELF/ && /executable/ || /shared object/' | \
  96. cut -f 1 -d : | xargs -0 strip --remove-section=.comment \
  97. --remove-section=.note 2> /dev/null || true
  98. cd ../
  99. # Replace hard-links with relative soft-links for the package size
  100. (
  101. cd "${destdir}/usr/bin" && \
  102. rm -f ld ; ln -sf ld.bfd ld
  103. )
  104. (
  105. cd "${destdir}/usr/${MACHINE}/bin" && \
  106. for file in *
  107. do
  108. if test -x "../../bin/$file"
  109. then
  110. rm -f "$file" && ln -s "../../bin/$file" .
  111. fi
  112. done
  113. )
  114. unset -v MACHINE
  115. # Compress info documents deleting index file for the package
  116. if test -d "${destdir}/$infodir"
  117. then
  118. rm -f "${destdir}/${infodir}/dir"
  119. lzip -9 "${destdir}/${infodir}"/*
  120. fi
  121. # Compress man pages
  122. if test -d "${destdir}/$mandir"
  123. then
  124. lzip -9 "${destdir}/${mandir}"/man?/*
  125. fi
  126. # Copy documentation
  127. mkdir -p "${destdir}${docsdir}"
  128. cp -p $docs "${destdir}${docsdir}"
  129. }