#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

make_options += release=1
molinillo_lib = molinillo

%:
	dh $@

override_dh_auto_build:
	mkdir lib
	cd lib && ln -s ../crystal-molinillo $(molinillo_lib)
	dh_auto_build -- $(make_options)

override_dh_auto_install: DESTDIR=$(CURDIR)/debian/tmp
override_dh_auto_install:
	dh_auto_install -- PREFIX=/usr

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir $(CURDIR)/tmp
	# don't run in parallel, the temporal created dirs clashes between them
	HOME=$(CURDIR)/tmp make $(make_options) test_unit
	HOME=$(CURDIR)/tmp make $(make_options) test_integration
endif

override_dh_clean:
	dh_clean
	rm -f man/*.gz
	rm -Rf spec/.repositories/
	rm -Rf tmp/*
	rm -Rf lib
