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

%:
	dh $@ 

config.status: patch-stamp
	dh_testdir
	# Add here commands to configure the package.
	touch configure-stamp

# Apply patches to the package
patch: patch-stamp
patch-stamp:
	dh_testdir
	@patches=debian/patches/*.patch; for patch in $$patches; do \
		test -f $$patch || continue; \
		echo "Applying $$patch"; \
		patch -stuN -p1 < $$patch || exit 1; \
	done
	touch $@

# Remove patches from the package
unpatch:
	dh_testdir
	@if test -f patch-stamp; then \
		patches=debian/patches/*.patch; \
		for patch in $$patches; do \
			reversepatches="$$patch $$reversepatches"; \
		done; \
		for patch in $$reversepatches; do \
			test -f $$patch || continue; \
			echo "Reversing $$patch"; \
			patch -suRf -p1 < $$patch || exit 1; \
		done; \
		rm -f patch-stamp; \
	fi

build: build-stamp
build-stamp: config.status
	dh_testdir
	#dh_auto_configure
	#dh_auto_build
	#dh_auto_test
	# Add here commands to compile the package.
	grep -v CONFIG_USE_DIET .config.auto >.config;true
	if [ -z "$(CONFIG_USE_DIET)" ];then echo '# CONFIG_USE_DIET is not set'|tee -a .config;else echo CONFIG_USE_DIET=y|tee -a .config;fi;true
	make
	touch build-stamp

binary:
	dh_testroot
	dh_prep
	dh_installdirs
	dh_auto_install
	dh_install
	dh_installdocs
	dh_installchangelogs
	#dh_installexamples
	dh_installman
	#dh_installcatalogs
	#dh_installcron
	dh_installdebconf
	#dh_installemacsen
	#dh_installifupdown
	#dh_installinfo
	dh_pysupport
	dh_installinit
	#dh_installmenu
	#dh_installmime
	#dh_installmodules
	#dh_installlogcheck
	#dh_installlogrotate
	#dh_installpam
	#dh_installppp
	#dh_installudev
	#dh_installwm
	#dh_installxfonts
	dh_bugfiles
	dh_lintian
	dh_gconf
	dh_icons
	dh_perl
	dh_usrlocal
	make debian-install DESTDIR="$(CURDIR)/debian/ngtx"
	dh_link
	dh_compress
	dh_fixperms
	-dh_strip
	dh_makeshlibs
	dh_shlibdeps
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb
