#!/usr/bin/make -f

export SHELL=/bin/bash

# Build with gcc-4.9 on Stretch, Buster,Xenial, Yakkety, Zesty, and Horizon.
distrelease := $(shell lsb_release -cs)
ifeq ($(distrelease),$(filter $(distrelease),stretch buster xenial yakkety \
zesty Horizon))
export CC=gcc-4.9
export CXX=g++-4.9
export CPP=cpp-4.9
export LD=gcc-4.9
endif

%:
	dh $@

override_dh_auto_clean:
	find . -iname "*.o" -type f -delete
	rm -f .sconsign.dblite build/vdrift
	rm -rf .sconf_temp
	rm -rf data/locale/*/LC_MESSAGES/vdrift.mo

override_dh_auto_configure:

override_dh_auto_build:
	scons release=1

override_dh_auto_install:
	scons install prefix=/usr destdir=$(CURDIR)/debian/tmp bindir=games
	find $(CURDIR)/debian/tmp/usr/share/games/vdrift -type f -exec chmod -x {} \;

override_dh_install:
	dh_install --sourcedir=$(CURDIR)/debian/tmp --list-missing
