4392d25b3dfd0e72724cd52dee57776bc342a525
[gentoo.git] / dev-util / astyle / astyle-3.0.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit eutils 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"
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         emake -f ../build/gcc/Makefile -C src \
42                 ${PN} \
43                 shared \
44                 $(usev java) \
45                 $(usex static-libs static '')
46 }
47
48 src_install() {
49         doheader src/${PN}.h
50
51         pushd src/bin >/dev/null || die
52         dobin ${PN}
53
54         # ex: libastyle.so.3.0.0
55         dolib.so lib${PN}.so.${PV}.0
56         # ex: libastyle.so.3
57         dosym lib${PN}.so.${PV}.0 /usr/$(get_libdir)/lib${PN}.so.$(get_major_version)
58         if use java ; then
59                 dolib.so lib${PN}j.so.${PV}.0
60                 dosym lib${PN}j.so.${PV}.0 /usr/$(get_libdir)/lib${PN}j.so.$(get_major_version)
61         fi
62         if use static-libs ; then
63                 dolib lib${PN}.a
64         fi
65         popd >/dev/null || die
66         if use examples ; then
67                 docinto examples
68                 dodoc -r file/.
69                 docompress -x /usr/share/doc/${PF}/examples
70         fi
71         local HTML_DOCS=( doc/. )
72         einstalldocs
73 }
74
75 pkg_postinst() {
76         if [[ -n "$REPLACING_VERSIONS" && "$(get_major_version $REPLACING_VERSIONS)" -lt 3 ]]; then
77                 elog "Artistic Style 3.0 introduces new configuration verbiage more fitting"
78                 elog "for modern use. Some options that were valid in 2.06 or older are now"
79                 elog "deprecated. For more information, consult astyle's release notes at"
80                 elog "http://astyle.sourceforge.net/news.html. To view offline, see:"
81                 elog
82                 elog "${ROOT}usr/share/doc/${P}/html"
83         fi
84 }