#!/usr/bin/make -f

export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed -lm

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

%:
	dh $@ --with autoreconf --parallel

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_autoreconf:
	AUTOMAKE="automake --foreign" dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIGURE_FLAGS)

override_dh_install:
	dh_install --fail-missing -XlibSDL2_gfx.la

override_dh_auto_build:
	dh_auto_build
	tar -cvz --transform='s,^test,examples,' -f debian/examples.tar.gz --mode=go=rX,u+rw,a-s --owner=root --group=root --numeric-owner test

override_dh_auto_build-indep:
	doxygen Docs/html.doxyfile

override_dh_strip:
	dh_strip --dbg-package=libsdl2-gfx-dbg
