#!/usr/bin/make -f

include /usr/share/ocaml/ocamlvars.mk

DESTDIR=$(CURDIR)/debian/ocaml-obuild

%:
	dh $@ --with ocaml

override_dh_auto_build:
ifeq ($(OCAML_HAVE_OCAMLOPT),yes)
	./bootstrap
else
	./bootstrap-bytecode
	mv dist/build/obuild/obuild.byte dist/build/obuild/obuild
	mv dist/build/obuild-simple/obuild-simple.byte dist/build/obuild-simple/obuild-simple
endif

override_dh_auto_install:
# Check that installed files have not changed. If so, the Debian
# packaging must be adapted by hand. This way, we avoid a dependency
# on opam-installer.
	diff -u debian/ocaml-obuild.opam-install obuild.install

override_dh_install:
	mkdir -p "$(DESTDIR)/usr/bin"
	cp "dist/build/obuild/obuild" "dist/build/obuild-simple/obuild-simple" "$(DESTDIR)/usr/bin"
