# Template file for 'cgit'
_git_version=2.25.1
pkgname=cgit
version=1.2.3
revision=2
make_build_args="
 prefix=/usr
 NO_REGEX=NeedsStartEnd
 NO_OPENSSL=yes
 CGIT_DATA_PATH=/usr/share/webapps/cgit
 CGIT_SCRIPT_PATH=/usr/libexec/cgit"
hostmakedepends="asciidoc"
makedepends="zlib-devel"
checkdepends="perl"
short_desc="Hyperfast web frontend for git repositories written in C"
maintainer="Duncaen <duncaen@voidlinux.org>"
license="GPL-2.0-only"
homepage="https://git.zx2c4.com/cgit/"
distfiles="https://git.zx2c4.com/cgit/snapshot/cgit-${version}.tar.xz
 https://www.kernel.org/pub/software/scm/git/git-${_git_version}.tar.xz"
checksum="5a5f12d2f66bd3629c8bc103ec8ec2301b292e97155d30a9a61884ea414a6da4
 222796cc6e3bf2f9fd765f8f097daa3c3999bb7865ac88a8c974d98182e29f26"

post_extract() {
	rm -r git
	mv ../git-$_git_version git
}

pre_build() {
	if ! grep -q "^GIT_VER = $_git_version\$" Makefile; then
		msg_error "$pkgver: update _git_version to match upstream Makefile.\n"
	fi
}

do_build() {
	make CC=$CC CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
		 ${makejobs} ${make_build_args} all doc-man
}

do_check() {
	make test
}

do_install() {
	make CC=$CC CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
		DESTDIR=${DESTDIR} ${make_build_args} install install-man

	ln -s /usr/libexec/cgit/cgit.cgi ${DESTDIR}/usr/share/webapps/cgit/cgit.cgi
}
