#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpkg/architecture.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

DEBVERSION := 1.0.3+dfsg1
TARBALL = OpenCTM-1.0.3-src.tar.bz2
TDIR = OpenCTM-1.0.3
get-orig-source:
	[ -e $(TARBALL) ] || wget http://qa.debian.org/watch/sf.php/openctm/$(TARBALL)
	tar -jxf $(TARBALL)
	# Remove PDFs without source
	rm -f $(TDIR)/doc/DevelopersManual.pdf
	rm -f $(TDIR)/doc/FormatSpecification.pdf
	# Remove external libraries which are in Debian or not used
	rm -rf $(TDIR)/tools/glew
	rm -rf $(TDIR)/tools/jpeg
	rm -rf $(TDIR)/tools/pnglite
	rm -rf $(TDIR)/tools/tinyxml
	rm -rf $(TDIR)/tools/zlib
	tar -jcf openctm_$(DEBVERSION).orig.tar.bz2 $(TDIR)

override_dh_auto_build:
	dpkg-architecture -a$(DEB_BUILD_ARCH) -f -c dh_auto_build --buildsystem=makefile --sourcedirectory=tools -- -f Makefile.linux bin2c
	dh_auto_build

override_dh_compress:
	dh_compress -X.pdf

override_dh_clean:
	rm -f Makefile
	dh_clean

%:
	ln -s -f Makefile.linux Makefile
	dh $@
