dev-util/strace: do not copy CFLAGS to CFLAGS_FOR_{M32,MX32}
[gentoo.git] / dev-util / strace / strace-5.4.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit flag-o-matic toolchain-funcs autotools
7
8 if [[ ${PV} == "9999" ]] ; then
9         EGIT_REPO_URI="https://github.com/strace/strace.git"
10         inherit git-r3 autotools
11 else
12         SRC_URI="https://github.com/${PN}/${PN}/releases/download/v${PV}/${P}.tar.xz"
13         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux"
14 fi
15
16 DESCRIPTION="A useful diagnostic, instructional, and debugging tool"
17 HOMEPAGE="https://strace.io/"
18
19 LICENSE="BSD"
20 SLOT="0"
21 IUSE="aio perl static unwind elfutils"
22
23 REQUIRED_USE="?? ( unwind elfutils )"
24
25 LIB_DEPEND="
26         unwind? ( sys-libs/libunwind[static-libs(+)] )
27         elfutils? ( dev-libs/elfutils[static-libs(+)] )
28 "
29 # strace only uses the header from libaio to decode structs
30 DEPEND="
31         static? ( ${LIB_DEPEND} )
32         aio? ( >=dev-libs/libaio-0.3.106 )
33         sys-kernel/linux-headers
34 "
35 RDEPEND="
36         !static? ( ${LIB_DEPEND//\[static-libs(+)]} )
37         perl? ( dev-lang/perl )
38 "
39
40 PATCHES=( "${FILESDIR}"/${P}-fix-LTO-CFLAGS-handling.patch )
41
42 src_prepare() {
43         default
44
45         # Needed for applied patch (#701516). Remove with next version.
46         # Don't forget about autotools inherit.
47         eautoreconf
48
49         if [[ ! -e configure ]] ; then
50                 # git generation
51                 sed /autoreconf/d -i bootstrap || die
52                 ./bootstrap || die
53                 eautoreconf
54                 [[ ! -e CREDITS ]] && cp CREDITS{.in,}
55         fi
56
57         filter-lfs-flags # configure handles this sanely
58         # Add -pthread since strace wants -lrt for timer_create, and -lrt uses -lpthread.
59         use static && append-ldflags -static -pthread
60
61         export ac_cv_header_libaio_h=$(usex aio)
62         use elibc_musl && export ac_cv_header_stdc=no
63
64         # Stub out the -k test since it's known to be flaky. #545812
65         sed -i '1iexit 77' tests*/strace-k.test || die
66 }
67
68 src_configure() {
69         # Set up the default build settings, and then use the names strace expects.
70         tc-export_build_env BUILD_{CC,CPP}
71         local v bv
72         for v in CC CPP {C,CPP,LD}FLAGS ; do
73                 bv="BUILD_${v}"
74                 export "${v}_FOR_BUILD=${!bv}"
75         done
76
77         # Don't require mpers support on non-multilib systems. #649560
78         local myeconfargs=(
79                 --enable-mpers=check
80                 $(use_with unwind libunwind)
81                 $(use_with elfutils libdw)
82         )
83         econf "${myeconfargs[@]}"
84 }
85
86 src_test() {
87         if has usersandbox ${FEATURES} ; then
88                 ewarn "Test suite is known to fail with FEATURES=usersandbox -- skipping ..." #643044
89                 return 0
90         fi
91
92         default
93 }
94
95 src_install() {
96         default
97         if ! use perl ; then
98                 rm "${ED}"/usr/bin/strace-graph || die
99         fi
100         dodoc CREDITS
101 }