dev-libs/protobuf: stable 3.5.2 for sparc
[gentoo.git] / dev-libs / protobuf / protobuf-3.5.2.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 inherit autotools elisp-common flag-o-matic multilib-minimal toolchain-funcs
7
8 DESCRIPTION="Google's Protocol Buffers - Extensible mechanism for serializing structured data"
9 HOMEPAGE="https://developers.google.com/protocol-buffers/ https://github.com/google/protobuf"
10 SRC_URI="https://github.com/google/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
11
12 LICENSE="BSD"
13 SLOT="0/15"
14 KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ia64 ~mips ~ppc ~ppc64 ~sh sparc x86 ~amd64-linux ~arm-linux ~x86-linux ~x64-macos ~x86-macos"
15 IUSE="emacs examples static-libs test zlib"
16
17 RDEPEND="emacs? ( virtual/emacs )
18         zlib? ( sys-libs/zlib[${MULTILIB_USEDEP}] )"
19 DEPEND="${RDEPEND}
20         test? ( >=dev-cpp/gtest-1.8.0[${MULTILIB_USEDEP}] )"
21
22 PATCHES=(
23         "${FILESDIR}/${PN}-3.4.0-disable_no-warning-test.patch"
24         "${FILESDIR}/${PN}-3.4.0-system_libraries.patch"
25         "${FILESDIR}/${PN}-3.4.0-protoc_input_output_files.patch"
26         "${FILESDIR}/${PN}-3.5.0-atomic_operations.patch"
27 )
28
29 DOCS=(CHANGES.txt CONTRIBUTORS.txt README.md)
30
31 src_prepare() {
32         default
33         eautoreconf
34 }
35
36 src_configure() {
37         append-cppflags -DGOOGLE_PROTOBUF_NO_RTTI
38         multilib-minimal_src_configure
39 }
40
41 multilib_src_configure() {
42         local options=(
43                 $(use_enable static-libs static)
44                 $(use_with zlib)
45         )
46
47         if tc-is-cross-compiler; then
48                 # Build system uses protoc when building, so protoc copy runnable on host is needed.
49                 mkdir -p "${WORKDIR}/build" || die
50                 pushd "${WORKDIR}/build" > /dev/null || die
51                 ECONF_SOURCE="${S}" econf_build "${options[@]}"
52                 options+=(--with-protoc="$(pwd)/src/protoc")
53                 popd > /dev/null || die
54         fi
55
56         ECONF_SOURCE="${S}" econf "${options[@]}"
57 }
58
59 src_compile() {
60         multilib-minimal_src_compile
61
62         if use emacs; then
63                 elisp-compile editors/protobuf-mode.el
64         fi
65 }
66
67 multilib_src_compile() {
68         if tc-is-cross-compiler; then
69                 emake -C "${WORKDIR}/build/src" protoc
70         fi
71
72         default
73 }
74
75 multilib_src_test() {
76         emake check
77 }
78
79 multilib_src_install_all() {
80         insinto /usr/share/vim/vimfiles/syntax
81         doins editors/proto.vim
82         insinto /usr/share/vim/vimfiles/ftdetect
83         doins "${FILESDIR}/proto.vim"
84
85         if use emacs; then
86                 elisp-install ${PN} editors/protobuf-mode.el*
87                 elisp-site-file-install "${FILESDIR}/70${PN}-gentoo.el"
88         fi
89
90         if use examples; then
91                 DOCS+=(examples)
92                 docompress -x /usr/share/doc/${PF}/examples
93         fi
94
95         einstalldocs
96 }
97
98 pkg_postinst() {
99         use emacs && elisp-site-regen
100 }
101
102 pkg_postrm() {
103         use emacs && elisp-site-regen
104 }