# Template build file for "cgit".
_git_version=2.10.2

pkgname=cgit
version=1.1
revision=2
hostmakedepends="asciidoc"
makedepends="libressl-devel zlib-devel"
short_desc="A fast webinterface for git"
maintainer="Eivind Uggedal <eivind@uggedal.com>"
homepage="http://git.zx2c4.com/cgit/"
license="GPL-2"
distfiles="http://git.zx2c4.com/cgit/snapshot/cgit-${version}.tar.xz
 https://www.kernel.org/pub/software/scm/git/git-${_git_version}.tar.xz"
checksum="0889af29be15fc981481caa09579f982b9740fe9fd2860ab87dff286f4635890
 94802903dd707d85ca3b9a2be35e936a54ce86375f52c6a789efe7ce7e238671"

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

	case "$XBPS_TARGET_MACHINE" in
		*-musl) sed -i 's/NO_CURL=1/NO_CURL=1 NO_REGEX=NeedsStartEnd/' Makefile ;;
	esac
}

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" prefix=/usr ${makejobs} all doc-man
}

do_install() {
	make CC=$CC CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" prefix=/usr DESTDIR=${DESTDIR} \
		CGIT_SCRIPT_PATH=/usr/share/webapps/cgit install install-man
}
