# Template file for 'bitkeeper'
pkgname=bk
version=7.3ce.1
revision=2
wrksrc="bk-7.3.1ce"
hostmakedepends="gperf groff perl bison pkg-config"
makedepends="libXft-devel libtomcrypt-devel libtommath-devel pcre-devel lz4-devel"
# bundles: tcl tk
short_desc="BitKeeper Distributed Source Control System"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="Apache-2.0"
homepage="https://www.bitkeeper.org/"
distfiles="https://www.bitkeeper.org/downloads/${version}ce/${pkgname}-${version}ce.src.tar.gz"
# XXX call next version just "7.4"
distfiles="https://www.bitkeeper.org/downloads/7.3.1ce/${pkgname}-7.3.1ce.src.tar.gz"
checksum=8784fe01722ebac7d93854c25a3aa203ec2751d90d06b036003868f2d8e6d250

# Needs reworking of the build system.
nocross=yes

post_extract() {
	# For musl:
	sed -i '1i#define __DEFINED_FILE' src/libc/stdio_remap.h
	sed -i 's/__linux__/__GLIBC__/' src/libc/utils/stackdump.c
}
do_build() {
	make ${makejobs} \
		CC="$CC" CXX="$CXX" LD="$CC" RANLIB="$RANLIB" \
		CPP="$CPP" AS="$AS" OBJDUMP="$OBJDUMP" CFLAGS="$CFLAGS" \
		LDFLAGS="$CFLAGS $LDFLAGS" Q=
}
do_install() {
	# Upstream recommended site-wide location.
	make install DESTDIR=${DESTDIR} BINDIR=/usr/libexec/bitkeeper

	vmkdir usr/bin
	ln -sf /usr/libexec/bitkeeper/bk ${DESTDIR}/usr/bin/bk

	vlicense LICENSE
	vlicense LICENSE.extras.md
	vlicense NOTICE
}
