virtual/perl-Parse-CPAN-Meta: keyword ~riscv
[gentoo.git] / dev-util / astyle / astyle-3.1-r2.ebuild
1 # Copyright 1999-2018 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit flag-o-matic toolchain-funcs versionator java-pkg-opt-2
7
8 DESCRIPTION="Artistic Style is a re-indenter and reformatter for C++, C and Java source code"
9 HOMEPAGE="http://astyle.sourceforge.net/"
10 SRC_URI="mirror://sourceforge/astyle/astyle_${PV}_linux.tar.gz"
11
12 LICENSE="MIT"
13 SLOT="0/3.1"
14 KEYWORDS="amd64 ~ppc ~ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos"
15 IUSE="examples java static-libs"
16
17 DEPEND="app-arch/xz-utils
18         java? ( >=virtual/jdk-1.6:= )"
19 RDEPEND="${DEPEND}"
20
21 S="${WORKDIR}/${PN}"
22
23 src_prepare() {
24         if use java ; then
25                 java-pkg-opt-2_src_prepare
26                 sed     -e "s:^\(JAVAINCS\s*\)=.*$:\1= $(java-pkg_get-jni-cflags):" \
27                         -e "s:ar crs:$(tc-getAR) crs:" \
28                         -i build/gcc/Makefile || die
29         else
30                 default
31         fi
32 }
33
34 src_configure() {
35         append-cxxflags -std=c++11
36         tc-export CXX
37         default
38 }
39
40 src_compile() {
41         # ../build/clang/Makefile is identical except for CXX line.
42         emake CXX="$(tc-getCXX)" -f ../build/gcc/Makefile -C src \
43                 ${PN} \
44                 shared \
45                 $(usev java) \
46                 $(usex static-libs static '')
47 }
48
49 src_install() {
50         doheader src/${PN}.h
51
52         pushd src/bin >/dev/null || die
53         dobin ${PN}
54
55         local libastylename="lib${PN}.so.${PV}.0"
56         local libastylejname="lib${PN}j.so.${PV}.0"
57         local libdestdir="/usr/$(get_libdir)"
58
59         dolib.so "${libastylename}"
60         dosym "${libastylename}" "${libdestdir}/lib${PN}.so.$(get_major_version)"
61         dosym "${libastylename}" "${libdestdir}/lib${PN}.so"
62         if use java ; then
63                 dolib.so "${libastylejname}"
64                 dosym "${libastylejname}" "${libdestdir}/lib${PN}j.so.$(get_major_version)"
65                 dosym "${libastylejname}" "${libdestdir}/lib${PN}j.so"
66         fi
67         if use static-libs ; then
68                 dolib.a lib${PN}.a
69         fi
70         popd >/dev/null || die
71         if use examples ; then
72                 docinto examples
73                 dodoc -r file/.
74                 docompress -x /usr/share/doc/${PF}/examples
75         fi
76         local HTML_DOCS=( doc/. )
77         einstalldocs
78 }
79
80 pkg_postinst() {
81         if [[ -n "$REPLACING_VERSIONS" && "$(get_major_version $REPLACING_VERSIONS)" -lt 3 ]]; then
82                 elog "Artistic Style 3.0 introduces new configuration verbiage more fitting"
83                 elog "for modern use. Some options that were valid in 2.06 or older are now"
84                 elog "deprecated. For more information, consult astyle's release notes at"
85                 elog "http://astyle.sourceforge.net/news.html. To view offline, see:"
86                 elog
87                 elog "${EROOT%/}/usr/share/doc/${P}/html"
88         fi
89 }