#!/usr/bin/make -f

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

LIBPKG = libsdl-gfx1.2-4

ifeq ($(DEB_BUILD_ARCH),i386)
	confflags = --enable-mmx
else
	confflags = --disable-mmx
endif

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

override_dh_auto_configure:
	dh_auto_configure -- $(confflags)

override_dh_auto_build:
	dh_auto_build
	tar -cvz --transform='s,^Test,examples,' -f debian/examples.tar.gz Test

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/examples.tar.gz

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

override_dh_link:
	dh_link -p$(LIBPKG) usr/lib/$(DEB_HOST_MULTIARCH)/libSDL_gfx.so.13.9.1 \
		usr/lib/$(DEB_HOST_MULTIARCH)/libSDL_gfx.so.4
	dh_link --remaining-packages

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog
