sys-libs/libunwind: fix compilation with musl
[gentoo.git] / sys-libs / libunwind / libunwind-1.2.1-r1.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 MY_PV=${PV/_/-}
7 MY_P=${PN}-${MY_PV}
8 inherit autotools eutils libtool multilib-minimal
9
10 DESCRIPTION="Portable and efficient API to determine the call-chain of a program"
11 HOMEPAGE="https://savannah.nongnu.org/projects/libunwind"
12 SRC_URI="mirror://nongnu/libunwind/${MY_P}.tar.gz"
13
14 LICENSE="MIT"
15 SLOT="7"
16 KEYWORDS="amd64 arm arm64 hppa ia64 ~mips ppc ppc64 x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux"
17 IUSE="debug debug-frame doc libatomic lzma +static-libs"
18
19 RESTRICT="test" # half of tests are broken (toolchain version dependent)
20
21 # We just use the header from libatomic.
22 RDEPEND="lzma? ( app-arch/xz-utils )"
23 DEPEND="${RDEPEND}
24         libatomic? ( dev-libs/libatomic_ops )"
25
26 S="${WORKDIR}/${MY_P}"
27
28 MULTILIB_WRAPPED_HEADERS=(
29         /usr/include/libunwind.h
30
31         # see libunwind.h for the full list of arch-specific headers
32         /usr/include/libunwind-aarch64.h
33         /usr/include/libunwind-arm.h
34         /usr/include/libunwind-hppa.h
35         /usr/include/libunwind-ia64.h
36         /usr/include/libunwind-mips.h
37         /usr/include/libunwind-ppc32.h
38         /usr/include/libunwind-ppc64.h
39         /usr/include/libunwind-sh.h
40         /usr/include/libunwind-tilegx.h
41         /usr/include/libunwind-x86.h
42         /usr/include/libunwind-x86_64.h
43 )
44
45 PATCHES=(
46         "${FILESDIR}"/${PN}-1.2-coredump-regs.patch #586092
47         "${FILESDIR}"/${PN}-1.2-ia64-undwarf.patch
48         "${FILESDIR}"/${PN}-1.2-ia64-ptrace-coredump.patch
49         "${FILESDIR}"/${PN}-1.2-ia64-missing.patch
50         "${FILESDIR}"/${PN}-1.2.1-fix_version_macros.patch
51         "${FILESDIR}"/${PN}-1.2.1-only-include-execinfo_h-if-avaliable.patch
52 )
53
54 src_prepare() {
55         default
56         chmod +x src/ia64/mk_cursor_i || die
57         # Since we have tests disabled via RESTRICT, disable building in the subdir
58         # entirely.  This worksaround some build errors too. #484846
59         sed -i -e '/^SUBDIRS/s:tests::' Makefile.in || die
60
61         elibtoolize
62         eautoreconf
63 }
64
65 multilib_src_configure() {
66         # --enable-cxx-exceptions: always enable it, headers provide the interface
67         # and on some archs it is disabled by default causing a mismatch between the
68         # API and the ABI, bug #418253
69         # conservative-checks: validate memory addresses before use; as of 1.0.1,
70         # only x86_64 supports this, yet may be useful for debugging, couple it with
71         # debug useflag.
72         ECONF_SOURCE="${S}" \
73         ac_cv_header_atomic_ops_h=$(usex libatomic) \
74         econf \
75                 --enable-cxx-exceptions \
76                 --enable-coredump \
77                 --enable-ptrace \
78                 --enable-setjmp \
79                 $(use_enable debug-frame) \
80                 $(use_enable doc documentation) \
81                 $(use_enable lzma minidebuginfo) \
82                 $(use_enable static-libs static) \
83                 $(use_enable debug conservative_checks) \
84                 $(use_enable debug)
85 }
86
87 multilib_src_compile() {
88         # Bug 586208
89         CCACHE_NODIRECT=1 default
90 }
91
92 multilib_src_test() {
93         # Explicitly allow parallel build of tests.
94         # Sandbox causes some tests to freak out.
95         SANDBOX_ON=0 emake check
96 }
97
98 multilib_src_install() {
99         default
100         # libunwind-ptrace.a (and libunwind-ptrace.h) is separate API and without
101         # shared library, so we keep it in any case
102         use static-libs || find "${ED}"usr '(' -name 'libunwind-generic.a' -o -name 'libunwind*.la' ')' -delete
103 }