# Template file for 'python3-pybind11'
pkgname=python3-pybind11
version=3.0.4
revision=1
build_style=python3-pep517
hostmakedepends="python3-scikit-build-core ninja
 python3-sphinx_rtd_theme python3-breathe"
depends="python3-devel"
checkdepends="python3-pytest python3-numpy $depends"
short_desc="C++ header-only library to produce Python bindings"
maintainer="Andrew J. Hesford <ajh@sideband.org>"
license="BSD-3-Clause"
homepage="https://github.com/pybind/pybind11"
distfiles="https://github.com/pybind/pybind11/archive/v${version}.tar.gz"
checksum=74b6a2c2b4573a400cafb6ecbf60c98df300cd3d0041296b913d02b2cbbb2676

post_build() {
	# Build the man page
	make $makejobs -C docs man
}

pre_check() {
	mkdir -p build.tests

	cd build.tests

	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" \
		CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" cmake ..

	make $makejobs
}

do_check() {
	make $makejobs -C build.tests check
}

post_install() {
	vlicense LICENSE

	# Copy the man page, but make it section 7
	local _manpage=docs/.build/man/pybind11.1
	vsed -i ${_manpage} -e '/^\.TH/ s/"1"/"7"/'
	vman ${_manpage} pybind11.7

	# Include links for a "system" installation
	local _pybind11="${DESTDIR}/${py3_sitelib}/pybind11"
	local _tgt

	for _tgt in include share/{cmake,pkgconfig}; do
		vmkdir "usr/${_tgt}"
	done

	for _tgt in {include,share/cmake}/pybind11 share/pkgconfig/pybind11.pc; do
		ln -Trs "${_pybind11}/${_tgt}" "${DESTDIR}/usr/${_tgt}"
	done
}
