# relaxed TEXTREL check for all 32-bit architectures for system with installed rpm-build-ocaml
# https://github.com/ocaml/ocaml/issues/9800
%_verify_elf_method %{?_is_ilp32:textrel=relaxed}%{!?_is_ilp32:default}

%_ocamldir %_libdir/ocaml
%_ocaml_req_skip	""
%add_ocaml_req_skip()	%global _ocaml_req_skip %_ocaml_req_skip [[:space:]]%*$
%__dune %_bindir/dune
%dune_build %__dune build --verbose

%dune_install \
	__dune_install() \
	{ \
		%__dune install --destdir=%buildroot "$@"; \
		\
find %buildroot%_ocamldir/ -type f -regextype posix-extended \\\( \\\
                -regex '.*\\\.(cma|cmi|cmxs|so|js)$' \\\
                -o -name 'META' \\\
                \\\) -printf '%_ocamldir/%%P\\\n' >ocaml-files.runtime; \
find %buildroot%_ocamldir/ -type d -printf '%%%%dir %_ocamldir/%%P\\\n' >>ocaml-files.runtime; \
find %buildroot%_ocamldir/ -type f -regextype posix-extended \\\( \\\
                -regex '.*\\\.(a|cmt|cmti|cmx|cmxa|ml|mli|exe)$' \\\
                -o -name 'opam' \\\
                -o -name 'dune-package' \\\
                \\\) -printf '%_ocamldir/%%P\\\n' >ocaml-files.devel; \
	} \
	__dune_install

%dune_check %__dune runtest

