#!/usr/bin/make -f

export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed -lm
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

DEB_HOST_ARCH  ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

%:
	dh $@ --dbgsym-migration='libsdl2-gfx-dbg (<< 1.0.1+dfsg-5~)'

CONFIGURE_FLAGS ?=--disable-mmx

ifeq ($(DEB_HOST_ARCH), i386)
	CONFIGURE_FLAGS =--enable-mmx
endif
ifeq ($(DEB_HOST_ARCH), amd64)
	CONFIGURE_FLAGS =--enable-mmx
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -rf Docs/html

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS)

override_dh_auto_build-indep:
	tar -cvz --transform='s,^test,examples,' -f debian/examples.tar.gz --clamp-mtime --mtime="@$(SOURCE_DATE_EPOCH)" --sort=name --mode=go=rX,u+rw,a-s --owner=root --group=root --numeric-owner test
	(cd Docs && doxygen html.doxyfile)

override_dh_install:
	dh_install -XlibSDL2_gfx.la

override_dh_installdocs-indep:
	dh_installdocs --doc-main-package=libsdl2-gfx-doc -plibsdl2-gfx-doc

override_dh_installdocs-arch:
	dh_installdocs --doc-main-package=libsdl2-gfx-doc -plibsdl2-gfx-dev
	dh_installdocs --doc-main-package=libsdl2-gfx-doc -plibsdl2-gfx-1.0-0

override_dh_missing:
	dh_missing --fail-missing -XlibSDL2_gfx.la
