# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5
inherit toolchain-funcs

COMMIT="c54dc204ef4278f949a965dc90e693799b6aae41"
LIBZOPFLI_VERSION="1.0.1"

DESCRIPTION="Compression library programmed in C to perform very good,
	but slow, deflate or zlib compression."
HOMEPAGE="https://code.google.com/p/${PN}/"
SRC_URI="https://${PN}.googlecode.com/archive/${COMMIT}.zip"

LICENSE="Apache-2.0"
SLOT="0/${LIBZOPFLI_VERSION}"
KEYWORDS="~amd64 ~x86"
IUSE=""

DEPEND="app-arch/unzip"
S="${WORKDIR}/${PN}-${COMMIT:0:12}"

src_compile() {
	local target
	for target in lib${PN} ${PN} ${PN}png; do
		emake \
			CC="$(tc-getCC)" \
			LD="$(tc-getCC)" \
			CFLAGS="${CFLAGS} -W -Wall -Wextra -ansi -pedantic -lm" \
			CXXFLAGS="${CXXFLAGS} -W -Wall -Wextra -ansi -pedantic" \
			LDFLAGS="${LDFLAGS}" \
			${target}
	done
}

src_install() {
	dobin ${PN} ${PN}png
	dodoc CONTRIBUTORS README README.${PN}png
	dolib lib${PN}.so.${LIBZOPFLI_VERSION}
	dosym lib${PN}.so.${LIBZOPFLI_VERSION} /usr/$(get_libdir)/lib${PN}.so
	dosym lib${PN}.so.${LIBZOPFLI_VERSION} /usr/$(get_libdir)/lib${PN}.so.${LIBZOPFLI_VERSION%%.*}
	doheader src/${PN}/*.h
}