#!/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

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -Wall -O0
endif

%:
	dh $@  --with autoreconf

override_dh_installchangelogs:
	dh_installchangelogs change.log

override_dh_auto_test:

deb_source := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
svn_rev := $(shell dpkg-parsechangelog | sed -rne 's,^Version: .*[+~]svn([0-9]+).*,\1,p')
upstream_version := $(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')

.PHONY: get-orig-source
get-orig-source:
	rm -rf $(deb_source)-$(upstream_version).orig
	rm -f $(deb_source)-$(upstream_version).orig.tar.gz
	svn -q export -r $(svn_rev) https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo/trunk \
		$(deb_source)-$(upstream_version).orig
	GZIP=--best tar -cz --owner root --group root --mode a+rX \
	     -f $(deb_source)_$(upstream_version).orig.tar.gz \
	     $(deb_source)-$(upstream_version).orig
	rm -r $(deb_source)-$(upstream_version).orig

