#!/usr/bin/make -f

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

%:
	dh $@

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

override_dh_auto_install-arch:
	dh_installyorick

override_dh_auto_configure:
# configuration is done in a patch resulting from:
#	./configure --no-avcodec
# also make sure yorz.doc is not built (or installed)

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ifeq (,$(filter $(DEB_HOST_ARCH), ia64))
	$(MAKE) check
else
	echo 'check suite deactivated on this architecture'
endif
else
	echo 'DEB_BUILD_OPTIONS contains "nocheck": skipping check step.'
endif

override_dh_auto_clean:
	touch Makeyorz
	$(MAKE) Y_MAKEDIR=/usr/lib/yorick Y_EXE=/usr/bin/yorick clean
ifeq (,$(shell head -1 Makeyorz))
	rm -f Makeyorz *.o
endif
