#!/usr/bin/make -f

# include for OCAMLBUILD_BEST
include /usr/share/ocaml/ocamlvars.mk

%:
	dh $@ --with python3,ocaml

# only build the wiki in the indep target if no nodoc
override_dh_auto_build-indep:
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS))$(filter nodoc,$(DEB_BUILD_PROFILES)),)
	$(MAKE) wiki
endif

# build everything else in the arch target
override_dh_auto_build-arch:
	$(MAKE) $(OCAMLBUILD_BEST) man

# don't run tests in the indep target
override_dh_auto_test-indep:

# only run tests in the arch target if no nocheck
override_dh_auto_test-arch:
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS))$(filter nocheck,$(DEB_BUILD_PROFILES)),)
	$(MAKE) test
endif

# only install the wiki in the indep target if no nodoc
override_dh_auto_install-indep:
ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS))$(filter nodoc,$(DEB_BUILD_PROFILES)),)
	$(MAKE) DESTDIR="$(CURDIR)/debian/tmp" install-wiki
else
	# at least create the target directory so that dh_install doesn't barf later
	mkdir -p "$(CURDIR)/debian/tmp/usr/share/doc/botch"
endif

# install everything else in the arch target
override_dh_auto_install-arch:
	$(MAKE) DESTDIR="$(CURDIR)/debian/tmp" install-bin install-man
