summaryrefslogtreecommitdiff
blob: 72dab2b710bc2229df6b9b89d2561e2958a7400d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit perl-module toolchain-funcs

DESCRIPTION="Serialize your C data quickly and easily"
HOMEPAGE="http://tpl.sourceforge.net"
SRC_URI="mirror://sourceforge/tpl/${P}.tar.bz2"

LICENSE="BSD-1"
SLOT="0"
KEYWORDS="~amd64 ~sparc"
IUSE="perl test"

RDEPEND="perl? ( dev-lang/perl )"
DEPEND="${RDEPEND}
	test? ( dev-lang/perl )"

# Despite of being the default src_compile, it must be redefined because the
# perl-module eclass exports src_compile.
src_compile() {
	econf
	emake || die "emake failed"
}

src_test() {
	cd tests

	sed -i -e "/CFLAGS/s/-g/${CFLAGS}/" \
		-e "/CFLAGS/s/-O3//" Makefile || die "sed cflags failed"
	sed -i "s|/tmp/||g" *.c || die "sed tpl failed"

	emake -j1 CC="$(tc-getCC)" || die "emake failed"

	if use perl ; then
		cd "${S}"/lang/perl/tests
		emake || die "emake perl failed"
	fi
}

src_install() {
	emake DESTDIR="${D}" install || die "emake install failed"
	dodoc doc/txt/{examples,future,userguide}.txt || die "dodoc failed"

	if use perl ; then
		perlinfo
		insinto ${SITE_LIB}
		doins lang/perl/Tpl.pm || die "doins failed"

		dodoc doc/txt/perl.txt || die "dodoc perl failed"
	fi
}

pkg_postinst() {
	use perl && perl-module_pkg_postinst
}