#!/usr/bin/make -f
# -*- makefile -*-
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

# As of 2014-05, there are issues on Raspbian with -O2 or -Os
# Cf. https://bugs.launchpad.net/raspbian/+bug/1322849
ifeq ($(DEB_HOST_ARCH), armhf)
	export DEB_CFLAGS_MAINT_SET=$(patsubst -O%,-O1,$(shell dpkg-buildflags --get CFLAGS))
endif

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

override_dh_auto_configure:
	# Using '--bindir=/usr/games' by Debian policy
	#   (e.g. not the case for Fedora)
	# Using '--disable-embedded-resources' because 'dh_strip' will remove
	#   them anyway, and we need it for the -dbg package -- too bad :/
	dh_auto_configure -- --bindir=/usr/games --datadir=/usr/share/games --disable-embedded-resources 

override_dh_strip:
	# Create -dbg package with debug symbols for gdb
	dh_strip --dbg-package=freedink-engine-dbg

override_dh_auto_install:
	# There's only one real package, let's not bother with
	# debian/tmp + move files in dh_install - install straight in
	# the appropriate directory
	dh_auto_install --destdir=debian/freedink-engine
	# Lintian complains with 'duplicate-font-file', let's have
	# FreeDink rely on libfontconfig + depend on ttf-liberation
	rm debian/freedink-engine/usr/share/games/freedink/LiberationSans-Regular.ttf
	# Install XPM icon
	cp -a src/freedink_xpm.c debian/freedink-engine/usr/share/pixmaps/freedink.xpm

override_dh_installdocs:
	# --link-doc requires debhelper 7.4.2
	dh_installdocs --link-doc=freedink-engine

override_dh_installchangelogs:
	dh_installchangelogs ChangeLog
