#!/usr/bin/make -f
# Based on sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

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

CFLAGS = -Wall -g
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
  CFLAGS += -O0
else
  CFLAGS += -O2
endif
export CFLAGS

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

# FOR AUTOCONF 2.52 AND NEWER ONLY
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
  confflags += --build $(DEB_HOST_GNU_TYPE)
else
  confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
endif


configure: configure-stamp
configure-stamp:
	dh_testdir
	autoconf
	./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man
	touch configure-stamp

build-arch: build-arch-stamp

build-arch-stamp: configure-stamp
	dh_testdir
	$(MAKE)
	touch build-arch-stamp

build-indep:
# Nothing to do

build: build-arch build-indep

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp build-arch-stamp configure-stamp
	[ ! -f GNUmakefile ] || $(MAKE) clean
	rm -f GNUmakefile configure
	dh_clean

install-arch: build-arch
	dh_testdir
	dh_testroot
	dh_prep
#	This is not needed by this package, but save in case it is one day
#	dh_installdirs
	$(MAKE) install DESTDIR=debian/mftrace

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

# Build architecture-dependent files here.
binary-arch: build-arch install-arch
	dh_testdir
	dh_testroot
#	dh_installdebconf	
	dh_installchangelogs ChangeLog
	dh_installdocs
#	dh_installexamples
#	dh_installmenu
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installman
#	dh_installinfo
#	dh_undocumented
#	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_makeshlibs
	dh_pycentral
#	dh_perl
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

# Build architecture-independent files here.
# It's only a dummy package we're building
binary-indep: build-indep
# We have nothing to do

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