#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# This file is public domain software, originally written by Joey Hess. 

#export DH_VERBOSE=1

export DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

build: build-stamp
build-stamp:
	dh_testdir
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS="-O0 -g -Wall" \
	./configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
		--prefix=/ --exec-prefix=/usr
else
	CFLAGS="-O2 -g -Wall" \
	./configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
		--prefix=/ --exec-prefix=/usr
endif
	$(MAKE) 
	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp
	[ ! -f Makefile ] || $(MAKE) distclean
	dh_clean

install:
	dh_testdir
	dh_testroot
	dh_prep
	$(MAKE) DESTDIR="$(CURDIR)"/debian/noflushd install-exec

# 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_installdirs
	dh_installdocs -XCVS
	dh_installinit --update-rcd-params="defaults 80 10"
	dh_installman
	dh_installchangelogs ChangeLog
	dh_installdebconf
	dh_strip
	dh_compress
	dh_fixperms 
	chmod 700 "$(CURDIR)"/debian/noflushd/var/lib/noflushd/
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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