#!/usr/bin/make -f
# -*- makefile -*-

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
export CCFLAGS:=$(shell dpkg-buildflags --get CFLAGS) -DSTRATAGUS_LIB_PATH=\"/usr/share/games/boswars\"
export LINKFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

%:
	dh $@

override_dh_auto_build-arch:
	scons CPPFLAGS='$(CPPFLAGS)' CCFLAGS='$(CCFLAGS)' LINKFLAGS='$(LINKFLAGS)'
	# rename binary
	mv build/boswars-release build/boswars

override_dh_auto_install:

override_dh_install:
	# Copy (and rename) an icon to be used as desktop file
	cp units/tank/ico_tank.png debian/boswars.png
	# Default action
	dh_install
	# Remove unneeded files.
	for i in genpot.sh makesame.py updatepo.sh ; do \
		rm -f debian/boswars-data/usr/share/games/boswars/languages/$$i ; \
	done
	rm -f debian/boswars/usr/share/doc/boswars/html/README-SDL.txt
	rm -f debian/boswars/usr/share/doc/boswars/html/*copyright*
	rm -f debian/boswars/usr/share/doc/boswars/html/gpl3.txt

override_dh_fixperms-indep:
	dh_fixperms
	chmod a-x debian/boswars-data/usr/share/games/boswars/campaigns/swindler/*
	chmod a-x debian/boswars-data/usr/share/games/boswars/maps/tokelau.map/presentation.smp

override_dh_clean:
	dh_clean
	scons -c
	# Additional icon (see build-indep-stamp)
	$(RM) debian/boswars.png
	# Scons is stupid and leaves them behind no matter what.
	$(RM) .sconsign.dblite
	$(RM) .sconf_temp
	$(RM) build_conf_cache.py build_options.py config.log
	$(RM) build/boswars

