#!/usr/bin/make -f

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DOPACKAGES = $(shell dh_listpackages)

%:
	dh $@

ifneq (,$(filter pkg.oaklisp.disable-readline,$(DEB_BUILD_PROFILES)))
CONFIGURE_ARGS += --with-readline=no
else
CONFIGURE_ARGS += --with-readline=yes
endif

ifeq (,$(filter oaklisp-doc,$(DOPACKAGES)))
CONFIGURE_ARGS += --disable-docs
endif

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_ARGS)

# Build from source alone with Guile (the tarball has no prebuilt
# material, and make never looks for an installed Oaklisp), then
# bootstrap to self-hosting: rebuild the world with itself twice and
# check that it reaches a fixpoint.
override_dh_auto_build:
	dh_auto_build -- bootstrap

override_dh_auto_install:
	dh_auto_install
	-rm --verbose debian/tmp/usr/share/doc/oaklisp/ChangeLog
	-rm --verbose debian/tmp/usr/share/doc/oaklisp/COPYING

override_dh_compress:
	dh_compress --exclude=.pdf
