dev-libs/roct-thunk-interface: 3.5.0 version bump
[gentoo.git] / dev-libs / ustr / ustr-1.0.4-r8.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit toolchain-funcs multilib-minimal
7
8 DESCRIPTION="Low-overhead managed string library for C"
9 HOMEPAGE="http://www.and.org/ustr/"
10 SRC_URI="ftp://ftp.and.org/pub/james/ustr/${PV}/${P}.tar.bz2"
11
12 LICENSE="|| ( BSD-2 MIT LGPL-2 )"
13 SLOT="0"
14 KEYWORDS="amd64 ~arm ~arm64 ~mips x86"
15 IUSE="static-libs ustr-import"
16
17 DOCS=(ChangeLog README README-DEVELOPERS AUTHORS NEWS TODO)
18
19 MULTILIB_WRAPPED_HEADERS=(
20         /usr/include/ustr-conf.h
21         /usr/include/ustr-conf-debug.h
22 )
23
24 src_prepare() {
25         epatch "${FILESDIR}/${P}-gcc_5-check.patch"
26         epatch "${FILESDIR}/${PN}-1.0.4-build-libs.patch"
27         multilib_copy_sources
28 }
29
30 _emake() {
31         emake \
32                 USE_STATIC=$(usex static-libs) \
33                 AR="$(tc-getAR)" \
34                 CC="$(tc-getCC)" \
35                 CFLAGS="${CFLAGS} ${CPPFLAGS}" \
36                 LDFLAGS="${LDFLAGS}" \
37                 prefix="${EPREFIX}/usr" \
38                 libdir="${EPREFIX}/usr/$(get_libdir)" \
39                 mandir="${EPREFIX}/usr/share/man" \
40                 SHRDIR="${EPREFIX}/usr/share/${P}" \
41                 DOCSHRDIR="${EPREFIX}/usr/share/doc/${PF}" \
42                 HIDE= \
43                 "$@"
44 }
45
46 multilib_src_configure() {
47         # The included configure tests require execution.
48
49         # We require vsnprintf everywhere as it's in POSIX.
50         printf '#!/bin/sh\necho 0\n' > autoconf_vsnprintf
51         chmod a+rx autoconf_vsnprintf
52
53         # Always use stdint.h as it's in POSIX.
54         sed -i '/have_stdint_h=0/s:=0:=1:' Makefile || die
55
56         # Figure out the size of size_t.
57         printf '#include <sys/types.h>\nint main() { char buf[sizeof(size_t) - 8]; }\n' > sizet_test.c
58          $(tc-getCC) ${CPPFLAGS} ${CFLAGS} -c sizet_test.c 2>/dev/null
59         printf '#!/bin/sh\necho %s\n' $(( $? == 0 )) > autoconf_64b
60         chmod a+rx autoconf_64b
61
62         # Generate the config file now to avoid bad makefile deps.
63         _emake ustr-import
64 }
65
66 multilib_src_compile() {
67         _emake all-shared
68 }
69
70 multilib_src_install() {
71         _emake DESTDIR="${D}" install
72
73         if ! use ustr-import ; then
74                 rm -r \
75                         "${ED}/usr/bin/ustr-import" \
76                         "${ED}/usr/share/man/man1/ustr-import.1" \
77                         "${ED}/usr/share/${P}" || die
78         fi
79 }
80
81 multilib_src_test() {
82         _emake check
83 }