#!/usr/bin/make -f
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.

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

# This is the debhelper compatibility version to use.
export DH_COMPAT=1


build: build-stamp
build-stamp:
	dh_testdir
	dh_testversion 2.0.40

	# Add here commands to compile the package.
	./configure --prefix=$(shell pwd)/debian/tmp/usr --fhs
	$(MAKE)

	touch build-stamp


clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp
	
	#$(MAKE) clean
	cd makes; $(MAKE) clean-o; $(MAKE) clean-docs
	rm -f configure.cache
	rm -f Makefile
	rm -f errormsg.txt
	rm -f doc/sdh.exe
	rm -rf makes/linux/result makes/linux/setedit-*
	rm -f makes/easydiag.a makes/editor.exe makes/librhuti.a makes/settvuti.a
	dh_clean


clean-debian:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp
	dh_clean


install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_clean -k
	#dh_installdirs

	# Add here commands to install the package into debian/tmp.
	$(MAKE) install

	mv debian/tmp/usr/share/doc/setedit/change.log.gz debian/tmp/usr/share/doc/setedit/changelog.gz
	dh_link usr/share/man/man1/setedit.1.gz usr/share/man/man1/e.1.gz

	touch install-stamp


# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.


# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdocs
#	dh_installexamples
	dh_installmenu
#	dh_installemacsen
#	dh_installinit
#	dh_installcron
#	dh_installmanpages
#	dh_undocumented e.1 setedit.1
	dh_installchangelogs 
	dh_strip
	dh_compress
	dh_fixperms
	chmod 4755 debian/tmp/usr/bin/setedit
	dh_suidregister /usr/bin/setedit
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
#	dh_makeshlibs  This is for libraries.
	dh_md5sums
	dh_builddeb

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary
