recipes: Honor CPPFLAGS (through QICPPFLAGS) whenever is possible
[dragora.git] / recipes / devel / valgrind / recipe
blob2cf780ce4ba1f4869ef672185d8540b31c8375ca
1 # Build recipe for valgrind.
3 # Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
4 # Copyright (c) 2017-2021 Matias Fonzo, <selk@dragora.org>.
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
10 #    http://www.apache.org/licenses/LICENSE-2.0
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.
18 # Exit immediately on any error
19 set -e
21 program=valgrind
22 version=3.16.1
23 release=1
25 # Define a category for the output of the package name
26 pkgcategory=devel
28 tarname=${program}-${version}.tar.bz2
30 # Remote source(s)
31 fetch=ftp://sourceware.org/pub/valgrind/$tarname
33 description="
34 Generic framework for creating dynamic analysis tools.
36 Valgrind is an instrumentation framework for building dynamic analysis tools.
37 There are Valgrind tools that can automatically detect many memory management
38 and threading bugs, and profile your programs in detail. You can also use
39 Valgrind to build new tools.
42 homepage=http://valgrind.org/
43 license="GPLv2"
45 # Source documentation
46 docs="AUTHORS COPYING* FAQ.txt NEWS* README*"
47 docsdir="${docdir}/${program}-${version}"
49 build()
51     unpack "${tardir}/$tarname"
53     cd "$srcdir"
55     # Set sane permissions
56     chmod -R u+w,go-w,a+rX-s .
58     # Set installation for documentation directory
59     patch -p0 < "${worktree}/patches/valgrind/valgrind-docdir.patch"
61     # Set specific options for the architecture
62     case $arch in
63     i?86)
64         arch_options="--enable-only32bit --build=$(gcc -dumpmachine)"
65         ;;
66     amd64 | x32 )
67         arch_options="--enable-only64bit --build=$(gcc -dumpmachine)"
68         ;;
69     esac
71     # We do not try to strip any debugging symbol as
72     # suggested in README_PACKAGERS
74     ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="-no-pie -fno-PIE -fPIC" \
75      CXXFLAGS="-no-pie -fno-PIE -fPIC" \
76      $configure_args \
77      --libdir=/usr/lib${libSuffix} \
78      --infodir=$infodir \
79      --mandir=$mandir \
80      --docdir=$docsdir \
81      --enable-tls \
82      --enable-inner \
83      --disable-ubsan \
84      $arch_options
86     unset -v arch_options
88     make -j${jobs} V=1
89     make -j${jobs} DESTDIR="$destdir" install
91     # Remove installed Valgrind's documentation for reduce the package size
92     rm -rf "${destdir}${docsdir}"
94     # Strip ELF executables excluding shared objects (as suggested)
95     find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
96      cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
98     # Compress info documents deleting index file for the package
99     if test -d "${destdir}/$infodir"
100     then
101         rm -f "${destdir}/${infodir}/dir"
102         lzip -9 "${destdir}/${infodir}"/*
103     fi
105     # Compress and link man pages (if needed)
106     if test -d "${destdir}/$mandir"
107     then
108         (
109             cd "${destdir}/$mandir"
110             find . -type f -exec lzip -9 {} +
111             find . -type l | while read -r file
112             do
113                 ln -sf "$(readlink -- "$file").lz" "${file}.lz"
114                 rm -- "$file"
115             done
116         )
117     fi
119     # Copy documentation
120     mkdir -p "${destdir}${docsdir}"
121     cp -p $docs "${destdir}${docsdir}"