#!/usr/bin/make -f
# -*- makefile -*-

include /usr/share/ocaml/ocamlvars.mk
DESTDIR := $(CURDIR)/debian/tmp

%:
	dh $@ --with ocaml

override_dh_auto_clean:
	dune clean

override_dh_auto_build:
	rm -rf _tmp
	OCAMLPATH=$(CURDIR)/_tmp$(OCAML_STDLIB_DIR) dune build -p bitstring
	dune install --destdir=$(CURDIR)/_tmp --prefix=/usr --libdir=..$(OCAML_STDLIB_DIR) bitstring
	OCAMLPATH=$(CURDIR)/_tmp$(OCAML_STDLIB_DIR) dune build -p ppx_bitstring
	dune install --destdir=$(CURDIR)/_tmp --prefix=/usr --libdir=..$(OCAML_STDLIB_DIR) ppx_bitstring

override_dh_auto_test:
	OCAMLPATH=$(CURDIR)/_tmp$(OCAML_STDLIB_DIR) dune runtest -p bitstring
	OCAMLPATH=$(CURDIR)/_tmp$(OCAML_STDLIB_DIR) dune runtest -p ppx_bitstring

override_dh_auto_install:
	rm -rf debian/tmp
	cp -a $(CURDIR)/_tmp debian/tmp
	for u in ppx_bitstring; do rm -rf $(DESTDIR)/usr/doc/$$u; done
	rm -f $(DESTDIR)/usr/doc/*/LICENSE*
