#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# 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.

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

# DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_CONFIGURE_SCRIPT_ENV += LDFLAGS=” -Wl,–as-needed”

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

%:
	dh $@ --sourcedirectory=src  

override_dh_auto_configure:
	sed s/x86_64-linux-gnu/$(DEB_HOST_MULTIARCH)/ configure > configure.sed
	chmod 755 configure.sed
	./configure.sed BINDIR="$(CURDIR)/debian/tmp/scid/usr/games" \
                SHAREDIR="$(CURDIR)/debian/tmp/scid/usr/share/scid" TB=""

override_dh_auto_install:
	$(MAKE) install_scid
	cp -R $(CURDIR)/sounds/ $(CURDIR)/debian/tmp/scid/usr/share/scid/
	dh_install
#	mv -f $(CURDIR)/debian/scid/usr/share/scid/data/ \
#		$(CURDIR)/debian/scid-data/usr/share/scid/


override_dh_auto_clean:
	[ ! -f Makefile ] || $(MAKE) clean
	rm -f config.sub config.guess Makefile a.out
	dh_clean
	rm -f configure.sed

override_dh_auto_build:
	dh_auto_build --sourcedirectory=src  -- all_scid

