summaryrefslogtreecommitdiff
blob: 90d501b2fac07e490945b42ac7addd18ad36f967 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

inherit multilib toolchain-funcs

MY_P="${PN}${PV/./}"
DESCRIPTION="Unified compressor for PAQ algorithms"
HOMEPAGE="http://mattmahoney.net/dc/#zpaq"
SRC_URI="http://mattmahoney.net/dc/${MY_P}.zip"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="optimization"

DEPEND="app-arch/unzip"
RDEPEND=""

src_prepare() {
	# make it FHS-friendly
	sed -e 's:^pcomp :&/usr/libexec/zpaq/:' -i *.cfg || die

	if use optimization; then
		sed \
			-e "s:%CXX%:$(tc-getCXX):" \
			-e "s:%CXXFLAGS%:${CXXFLAGS}:" \
			-e "s:%LIBDIR%:$(get_libdir):" \
			"${FILESDIR}"/zpaqmake.in > zpaqmake || die
	fi
}

src_configure() {
	tc-export CXX

	if use optimization; then
		# NOTE: zpaqmake is used in runtime by zpaq to compile profiles
		# please do not complain about stripping, it's not for build time

		local stripflag=' -Wl,--strip-all'
		# check whether the default compiler supports -Wl,--strip-all
		echo 'int main(void) {return 0;}' > striptest.c
		"${CXX}" ${CXXFLAGS} striptest.c -o striptest \
			${LDFLAGS} ${stripflag} || stripflag=

		sed -i -e "s:%LDFLAGS%:${LDFLAGS}${stripflag}:" zpaqmake || die
	fi
}

src_compile() {
	"${CXX}" ${CXXFLAGS} -DNDEBUG zpaq.cpp -o zpaq ${LDFLAGS} || die
	"${CXX}" ${CXXFLAGS} lzppre.cpp -o lzppre ${LDFLAGS} || die

	if use optimization; then
		# provide precompiled stub
		"${CXX}" -c ${CXXFLAGS} -DNDEBUG -DOPT zpaq.cpp -o zpaq.o || die
	fi
}

src_install() {
	dobin zpaq || die
	dodoc readme.txt || die

	if use optimization; then
		dobin zpaqmake || die
		insinto /usr/include/zpaq
		doins zpaq.h || die
		insinto /usr/$(get_libdir)/zpaq
		doins zpaq.o || die
	fi

	# Preprocessors
	exeinto /usr/libexec/zpaq
	doexe lzppre || die

	# These are more like compression profiles, so install them in /usr/share
	insinto /usr/share/zpaq
	doins *.cfg || die
}

pkg_postinst() {
	elog "Unlike conventional archivers, zpaq doesn't have any algorithm chain"
	elog "compiled in by default. Instead, it provides many PAQ components to allow"
	elog "user to create his own chain and supply it as configuration file."
	elog
	elog "We install few default configs in /usr/share/zpaq to start with. They can"
	elog "be used like that:"
	if use optimization; then
		elog "	zpaq oc/usr/share/zpaq/max.cfg out.zpaq files"
	else
		elog "	zpaq c/usr/share/zpaq/max.cfg out.zpaq files"
	fi
	elog
	elog "You may also want to install app-arch/zpaq-extras package which provides"
	elog "few additional configs and preprocessors for use with zpaq."
}