#!/usr/bin/make -f
# 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


# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -O2
endif
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	INSTALL_PROGRAM += -s
endif

config.status: configure
	dh_testdir
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
	[ -e config.sub ] && mv config.sub config.sub.save
	cp -f /usr/share/misc/config.sub config.sub
endif
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
	[ -e config.guess ] && mv config.guess config.guess.save
	cp -f /usr/share/misc/config.guess config.guess
endif
	[ ! -f Makefile ] || mv Makefile Makefile.save
	./configure --host=$(DEB_HOST_GNU_TYPE) \
		--build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr \
		--mandir=\$${prefix}/share/man \
		--infodir=\$${prefix}/share/info --enable-a4 --disable-pango


build: build-arch build-indep
build-arch: build-stamp
build-indep: build-stamp
build-stamp:  config.status
	dh_testdir

	$(MAKE)
	/usr/bin/docbook-to-man debian/abcm2ps.sgml > abcm2ps.1

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp 

	if [ -e config.sub.save ]; then mv config.sub.save config.sub; fi
	if [ -e config.guess.save ]; then mv config.guess.save config.guess; fi
	if [ -e Makefile.save ]; then mv Makefile.save Makefile; fi
	[ ! -f Makefile ] || $(MAKE) clean
	rm -f abcm2ps abcm2ps.1

	dh_clean config.log config.cache config.status

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# We take care of the documentation files later ourselves.
	$(MAKE) install prefix=$(CURDIR)/debian/abcm2ps/usr \
		docdir=$(CURDIR)/debian/abcm2ps/doc
	rm -rf $(CURDIR)/debian/abcm2ps/doc


# 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_installchangelogs Changes
	dh_installdocs
	dh_installexamples *.abc *.eps
#	dh_install
#	dh_installmenu
#	dh_installdebconf	
#	dh_installlogrotate
#	dh_installemacsen
#	dh_installpam
#	dh_installmime
#	dh_installinit
#	dh_installcron
#	dh_installinfo
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_perl
#	dh_python
#	dh_makeshlibs
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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