recipe 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # Build recipe for valgrind.
  2. #
  3. # Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
  4. # Copyright (c) 2017-2022 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.20.0
  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=https://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. # Copy definition in order to build Valgrind (Thanks to "Alpine Linux")
  59. cp -p "${worktree}/archive/valgrind/musl.supp" .
  60. ./configure CPPFLAGS="-D_FORTIFY_SOURCE=0" \
  61. CFLAGS="-no-pie -fno-PIE -fPIC" \
  62. CXXFLAGS="-no-pie -fno-PIE -fPIC" \
  63. LDFLAGS="" \
  64. $configure_args \
  65. --libdir=/usr/lib${libSuffix} \
  66. --infodir=$infodir \
  67. --mandir=$mandir \
  68. --docdir=$docsdir \
  69. --enable-tls \
  70. --enable-inner \
  71. --disable-ubsan \
  72. $arch_options
  73. unset -v arch_options
  74. make -j${jobs} V=1
  75. make -j${jobs} DESTDIR="$destdir" install
  76. # Remove installed Valgrind's documentation for reduce the package size
  77. rm -rf "${destdir}/$docsdir"
  78. # Strip ELF executables excluding shared objects (as suggested)
  79. find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
  80. cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  81. # Compress info documents deleting index file for the package
  82. if test -d "${destdir}/$infodir"
  83. then
  84. rm -f "${destdir}/${infodir}/dir"
  85. lzip -9 "${destdir}/${infodir}"/*
  86. fi
  87. # Compress and link man pages (if needed)
  88. if test -d "${destdir}/$mandir"
  89. then
  90. (
  91. cd "${destdir}/$mandir"
  92. find . -type f -exec lzip -9 {} +
  93. find . -type l | while read -r file
  94. do
  95. ln -sf "$(readlink -- "$file").lz" "${file}.lz"
  96. rm -- "$file"
  97. done
  98. )
  99. fi
  100. # Copy documentation
  101. mkdir -p "${destdir}/$docsdir"
  102. cp -p $docs "${destdir}/$docsdir"
  103. }