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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
#export DH_OPTIONS=-v

DESTDIR=$(CURDIR)/debian/jbuilder

%:
	dh $@ --with ocaml

.PHONY: override_dh_auto_build
override_dh_auto_build:
	ocaml bootstrap.ml
	./boot.exe

.PHONY: override_dh_auto_install
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/jbuilder.opam-install jbuilder.install

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	rm -rf _build */.merlin vendor/*/*/.merlin boot.exe jbuilder.install

.PHONY: override_dh_install
override_dh_install:
# We don't use dh_install nor dh_installdocs because they don't handle
# symbolic links nor renaming files
	mkdir -p $(DESTDIR)/usr/bin
	cp _build/install/default/bin/jbuilder $(DESTDIR)/usr/bin
	mkdir -p $(DESTDIR)/usr/share/doc/jbuilder
	cp _build/install/default/doc/jbuilder/README.md $(DESTDIR)/usr/share/doc/jbuilder
