# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ccache
pkgver=3.4.1
pkgrel=0
pkgdesc="A fast C/C++ compiler cache"
url="http://ccache.samba.org/"
arch="all"
license="GPL-3.0-or-later"
makedepends="zlib-dev"
checkdepends="bash perl"
subpackages="$pkgname-doc"
source="http://samba.org/ftp/$pkgname/$pkgname-$pkgver.tar.xz"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare

	cd "$builddir"
	update_config_sub
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	cd "$builddir"
	make test
}

package() {
	cd "$builddir"
	install -Dm 755 ccache "$pkgdir"/usr/bin/ccache
	install -Dm 644 ccache.1 "$pkgdir"/usr/share/man/man1/ccache.1

	local link=
	mkdir -p "$pkgdir"/usr/lib/ccache/bin

	for link in cc gcc g++ cpp c++ ${CHOST}-cc ${CHOST}-gcc \
			${CHOST}-g++ ${CHOST}-cpp ${CHOST}-c++; do
		ln -sf /usr/bin/ccache "$pkgdir"/usr/lib/ccache/bin/$link
	done
}

sha512sums="ebfa65888c2d8ef87c2e86889723afcc88103af0e73e386ba39f474a7f542712b705a553611a5f51a057c5f056925f10492bb1f3d9b837c9d578d7a913a845de  ccache-3.4.1.tar.xz"
