#!/usr/bin/make -f

MIRROR=http://media.steampowered.com/client
#MIRROR=http://localhost

DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)

%:
	dh $@

ifneq ($(DEB_BUILD_ARCH), i386)
	@echo "error: $(DEB_BUILD_ARCH) is not a supported architecture"
	@exit 1
endif

override_dh_auto_configure:
	python3 debian/scripts/templates-helper

override_dh_clean:
	dh_clean -- debian/templates
	python3 debian/scripts/copyright-helper \
	    debian/copyright.in debian/copyright

override_dh_strip:
	dh_strip --no-automatic-dbgsym

get-orig-source:
	rm -rf dest/
	# this can't use uscan as package isn't versioned at all
	mkdir -p dest/tmp
	cd dest/tmp ; wget $(MIRROR)/steamcmd_linux.tar.gz
	tar xf dest/tmp/steamcmd_linux.tar.gz -C dest/tmp
	mv dest/tmp/steamcmd.sh dest/
	mv dest/tmp/linux32/steamcmd dest/
	# ignore libstdc++.so.6 and maybe futurer other stuff
	rm -rf dest/tmp
	find dest -ls
	# version number = main binary timestamp
	version=0~$$(date -r dest/steamcmd +%Y%m%d) ; \
	dest=../steamcmd-$$version.orig ; \
	orig=../steamcmd_$$version.orig.tar.xz ; \
	mv dest $$dest ; \
	tar cJf $$orig $$dest ; \
	rm -rf $$dest ; \
	echo "Successfully created new upstream source file: $$orig"
