#!/usr/bin/make -f

#export DH_VERBOSE=1

include /usr/share/dpkg/buildflags.mk
LDFLAGS += -Wl,--as-needed
CFLAGS += $(LDFLAGS)
DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@

override_dh_auto_configure:
	./configure

override_dh_auto_build:
	$(MAKE) all

override_dh_auto_install:
	mkdir -p $(CURDIR)/debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}
	mkdir -p $(CURDIR)/debian/tmp/usr/include
	install $(CURDIR)/src/libdevXlib.a $(CURDIR)/debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}
	install $(CURDIR)/src/*.mod $(CURDIR)/debian/tmp/usr/include

override_dh_auto_test:
	dh_auto_test
	(cd bin; for TEST in test*; do ./$$TEST; if [ "$$?" != 0 ]; then exit 1; fi; done)
