#!/usr/bin/make -f

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
DPKG_EXPORT_BUILDFLAGS = 1
-include /usr/share/dpkg/buildflags.mk
DEB_YORICK=/usr/bin/yorick

%:
	dh $@

override_dh_auto_configure:
	./configure --yorick=$(DEB_YORICK)

override_dh_auto_build:
	$(MAKE) COPT_DEFAULT="" \
	        Y_CFLAGS="$(CFLAGS) $(CPPFLAGS)" \
	        Y_LDFLAGS="$(LDFLAGS)"

override_dh_auto_install-arch:
	dh_installyorick

override_dh_auto_test:
# tests take too long on the mips buildd
ifeq (,$(filter $(DEB_HOST_ARCH), mips))
	$(MAKE) tests
endif

override_dh_auto_clean:
	./configure --deplibs="" --cflags="" --ldflags="" --yorick=$(DEB_YORICK)
	$(MAKE) Y_MAKEDIR=/usr/lib/yorick Y_EXE=$(DEB_YORICK) distclean
