#!/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

DB2MAN=/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl
XP=xsltproc --nonet

%:
	dh $@

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

override_dh_auto_build:
	CC=gcc CPPFLAGS='-DDATADIR=\"/usr/share/games/meritous\" -DSAVES_IN_HOME' \
		dh_auto_build
	$(XP) $(DB2MAN) debian/meritous.xml

override_dh_auto_clean:
	# The $(MAKE) clean target doesn't clean properly when the
	# *.o files don't exist. Until they are fixed upstream, we
	# do it manually.
	#$(MAKE) clean
	rm -f src/*.o
	rm -f meritous
	rm -f meritous.6


# DFSG Building
ORIG_HOST=http://www.asceai.net/files
ORIG_FILE=meritous_v12_src.tar.bz2
DFSG_FILE=meritous_1.2+dfsg.orig.tar.gz

get-orig-source:
	# Get the file
	wget $(ORIG_HOST)/$(ORIG_FILE)
	tar -xjf $(ORIG_FILE)

	# Music file licenses cannot be validated
	rm -rf meritous_v12_src/dat/m

	# Repackage it
	tar -czf $(DFSG_FILE) meritous_v12_src
	rm -rf meritous_v12_src $(ORIG_FILE)
