# Template file for 'coq'
pkgname=coq
version=8.19.2
revision=2
hostmakedepends="dune ocaml ocaml-findlib ocaml-num ocaml-zarith"
depends="ocaml-findlib"
checkdepends="python3 rsync time"
short_desc="Proof assistant written in OCaml"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="LGPL-2.1-only"
homepage="https://coq.inria.fr"
distfiles="https://github.com/coq/coq/archive/V${version}.tar.gz"
checksum=18035624bcda4f8cffe5f348e02f0ae2503af1c40de165788d7d45578e6c5725
nopie=yes
nocross=yes
make_check=ci-skip  # takes long and has some faults

case "$XBPS_TARGET_MACHINE" in
	ppc64*) ;;
	ppc*) broken="R_PPC_REL24 relocation out of range";;
esac

do_patch() {
	if ! command -v ocamlc.opt >/dev/null; then
		# see coq/coq#18609
		vsed -i -e 's/dep ^ ".cmxs"/dep ^ ".cma"/' tools/dune_rule_gen/coq_rules.ml
	fi
}

do_build() {
	make dunestrap
	dune build --display=short -p coq-core,coq-stdlib,coqide-server
}

do_install() {
	dune install coq-core coq-stdlib coqide-server --prefix=/usr --destdir="$DESTDIR" \
		--mandir=/usr/share/man --docdir=/usr/share/doc
}

do_check() {
	make -C test-suite UNIT_TESTS= || make -C test-suite report PRINT_LOGS=1
}
