recipe 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # Build recipe for valgrind.
  2. #
  3. # Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
  4. # Copyright (c) 2017-2021 Matias Fonzo, <selk@dragora.org>.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Exit immediately on any error
  18. set -e
  19. program=valgrind
  20. version=3.16.1
  21. release=1
  22. # Define a category for the output of the package name
  23. pkgcategory=devel
  24. tarname=${program}-${version}.tar.bz2
  25. # Remote source(s)
  26. fetch=ftp://sourceware.org/pub/valgrind/$tarname
  27. description="
  28. Generic framework for creating dynamic analysis tools.
  29. Valgrind is an instrumentation framework for building dynamic analysis tools.
  30. There are Valgrind tools that can automatically detect many memory management
  31. and threading bugs, and profile your programs in detail. You can also use
  32. Valgrind to build new tools.
  33. "
  34. homepage=https://valgrind.org/
  35. license="GPLv2"
  36. # Source documentation
  37. docs="AUTHORS COPYING* FAQ.txt NEWS* 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. # Set installation for documentation directory
  46. patch -p0 < "${worktree}/patches/valgrind/valgrind-docdir.patch"
  47. # Set specific options for the architecture
  48. case $arch in
  49. i?86)
  50. arch_options="--enable-only32bit --build=$(gcc -dumpmachine)"
  51. ;;
  52. amd64 | x32 )
  53. arch_options="--enable-only64bit --build=$(gcc -dumpmachine)"
  54. ;;
  55. esac
  56. # We do not try to strip any debugging symbol as
  57. # suggested in README_PACKAGERS
  58. ./configure CPPFLAGS="-D_FORTIFY_SOURCE=0" \
  59. CFLAGS="-no-pie -fno-PIE -fPIC" \
  60. CXXFLAGS="-no-pie -fno-PIE -fPIC" \
  61. LDFLAGS="" \
  62. $configure_args \
  63. --libdir=/usr/lib${libSuffix} \
  64. --infodir=$infodir \
  65. --mandir=$mandir \
  66. --docdir=$docsdir \
  67. --enable-tls \
  68. --enable-inner \
  69. --disable-ubsan \
  70. $arch_options
  71. unset -v arch_options
  72. make -j${jobs} V=1
  73. make -j${jobs} DESTDIR="$destdir" install
  74. # Remove installed Valgrind's documentation for reduce the package size
  75. rm -rf "${destdir}${docsdir}"
  76. # Strip ELF executables excluding shared objects (as suggested)
  77. find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
  78. cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  79. # Compress info documents deleting index file for the package
  80. if test -d "${destdir}/$infodir"
  81. then
  82. rm -f "${destdir}/${infodir}/dir"
  83. lzip -9 "${destdir}/${infodir}"/*
  84. fi
  85. # Compress and link man pages (if needed)
  86. if test -d "${destdir}/$mandir"
  87. then
  88. (
  89. cd "${destdir}/$mandir"
  90. find . -type f -exec lzip -9 {} +
  91. find . -type l | while read -r file
  92. do
  93. ln -sf "$(readlink -- "$file").lz" "${file}.lz"
  94. rm -- "$file"
  95. done
  96. )
  97. fi
  98. # Copy documentation
  99. mkdir -p "${destdir}${docsdir}"
  100. cp -p $docs "${destdir}${docsdir}"
  101. }