# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=ocaml5-ctypes
pkgver=0.23.0
pkgrel=1
pkgdesc="Combinators for binding to C libraries without writing any C"
url="https://github.com/ocamllabs/ocaml-ctypes"
arch="all"
license="MIT"
depends="libffi-dev ocaml5-integers"
makedepends="dune ocaml5"
subpackages="$pkgname-doc"
_dune=3.18.2 # community/dune-configurator is built for OCaml 4 so cannot be used here
source="https://github.com/ocamllabs/ocaml-ctypes/archive/$pkgver/ocaml-ctypes-$pkgver.tar.gz
	https://github.com/ocaml/dune/archive/$_dune/dune-$_dune.tar.gz
	allow-dune-configurator-to-use-csexp.patch
	use-stdlib-bigarray.patch
	"
builddir="$srcdir/ocaml-ctypes-$pkgver"
options="!check" # requires more deps

prepare() {
	# Name the dir "dune-configurator" to avoid conflict with "dune" file
	mv -v "$srcdir"/dune-$_dune "$builddir"/dune-configurator

	default_prepare
}

build() {
	dune build \
		-p ctypes,ctypes-foreign,dune-configurator \
		--verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		ctypes \
		ctypes-foreign

	mv -v "$pkgdir"/usr/share/doc/ctypes "$pkgdir"/usr/share/doc/$pkgname
	# remove duplicate files
	rm -r "$pkgdir"/usr/share/doc/ctypes-foreign
}

sha512sums="
0c287cd3162d092b37bd6d4b24c196d41c93b792c4aa77938fde60f5dbc7eedde588097493a645af9bffc0ed722eadd0fa90e04b04d5e36e78e6467ae9e4baf8  ocaml-ctypes-0.23.0.tar.gz
fffaee517e236f34b2d3d47be94c4a6eacb457e080757affadd4bc27dad1e5d0140f6d5a118c3342d2df13b2dd0ded3071df97af212b0217719a5c64e07c3e75  dune-3.18.2.tar.gz
2a99d1e3a66c637172e3da499cb7a2aaa742cc786e8366a15bf2d50328e30a7c3d4465d5a458e3ad96cff96504b351a63bb31e010974d5c3b277fd3d51c777b9  allow-dune-configurator-to-use-csexp.patch
aa52ec874efb5c851be6295043b178ebaf830b499c2352f8599f251dfb0d6afadd4249bf0a777f62805ff0a62af18c30465f73228a75daf63be6bd2e3fbe78f7  use-stdlib-bigarray.patch
"
