# Template file for 'postgrest'
pkgname=postgrest
version=10.2.0
revision=1
hostmakedepends="cabal-install postgresql-libs-devel"
makedepends="zlib-devel postgresql-libs-devel"
short_desc="REST API for any Postgres database"
maintainer="Piotr Wójcik <chocimier@tlen.pl>"
license="MIT"
homepage="https://postgrest.org/"
distfiles="https://github.com/PostgREST/postgrest/archive/v${version}.tar.gz"
checksum=23d63292d50d303bf61154061704f642dd3d699367e2ccb159ec7604f2848487
nocross="cabal does not support cross compilation"
nopie=yes # ghc is currently built without PIE support

_cabal_opts="-g"

if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
	_cabal_opts+=" --ghc-option -latomic"
fi

if [ "$XBPS_MAKEJOBS" ]; then
	_cabal_opts+=" --jobs=$XBPS_MAKEJOBS"
fi

do_build() {
	cabal update $_cabal_opts
	cabal build  $_cabal_opts
	mv dist-newstyle/build/*/*/postgrest-${version}/x/postgrest/build/postgrest/postgrest postgrest
}

do_install() {
	vbin postgrest
	vlicense LICENSE
}
