#!/usr/bin/make -f
# -*- makefile -*-
# Rules file for filepp based on the rules template by Joey Hess.

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

PACKAGE = filepp
TMP = ${CURDIR}/debian/$(PACKAGE)

build-arch: build
build-indep: build

build: build-stamp

build-stamp:
	dh_testdir

	# Substitute variables in the filepp.in file.
	# The "configure" script does not actually do much more than
	# that so I'll do those simple steps right here.
	# (Upstream is informed about the bloatetness of his approach.)
	sed -e 's/@VERSION@/1.8.0/' \
	    -e 's/@moduledir@/\/usr\/share\/filepp/' \
			-e 's/@PERL@/\/usr\/bin\/perl/' \
			< filepp.in > filepp
	chmod u+x filepp

	# Generate the man page
	./filepp -DHIDDEN -I. ./filepp.1.in -o filepp.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 

	# clean up after the build process
	# (I do not use the configure / make distclean here
	# because it is too bloated and I hope the upstream will
	# provide a plain Makefile with the next release.)
	rm -f filepp.1 filepp

	dh_clean 

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Add here commands to install the package into debian/filepp.
	#
	# The Makefile has problems with the modules directory. Either
	# the files are copied correctly for the package and can't be
	# found later or they are correctly packaged but later point
	# to the wrong directory.
	# So let's to the installation without "make install"
	#$(MAKE) install prefix=$(CURDIR)/debian/filepp/usr

# Build architecture-independent files here.
binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installexamples
	dh_install
	dh_installman
	dh_link
	dh_compress -X examples/filepp.1.in
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# nothing to do for binary-arch
binary-arch:

binary: binary-indep

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

