#!/usr/bin/make -f
#-*- makefile -*-

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

PACKAGE = eblook

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
dpkg_buildflags = DEB_BUILD_MAINT_OPTIONS=$(DEB_BUILD_MAINT_OPTIONS) dpkg-buildflags
CFLAGS=$(shell $(dpkg_buildflags) --get CFLAGS)
CPPFLAGS=$(shell $(dpkg_buildflags) --get CPPFLAGS)
LDFLAGS=$(shell $(dpkg_buildflags) --get LDFLAGS)

build-indep:

build-arch: build-arch-stamp
build-arch-stamp:
	dh_testdir
	dh_autotools-dev_updateconfig
	CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --prefix=/usr --infodir=/usr/share/info --with-eb-conf=/etc/eb.conf --without-readline
	$(MAKE)
	touch $@

build: build-indep build-arch

clean:
	dh_testdir
	dh_testroot
	rm -f *-stamp eblook-for-h2m
	rm -f dos/Makefile
	[ ! -f Makefile ] || $(MAKE) SUBDIRS= distclean
	dh_autotools-dev_restoreconfig
	dh_clean

install-indep:

install-arch:
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs
	$(MAKE) DESTDIR=$(CURDIR)/debian/$(PACKAGE) install-exec

	cp debian/eblook-for-h2m .
	chmod 700 eblook-for-h2m
	install -d $(CURDIR)/debian/$(PACKAGE)/usr/share/man/man1
	PATH=$(CURDIR)/debian/$(PACKAGE)/usr/bin:$${PATH} help2man --include=$(CURDIR)/debian/eblook.h2m --output=$(CURDIR)/debian/$(PACKAGE)/usr/share/man/man1/eblook.1 $(CURDIR)/eblook-for-h2m; \
	rm -f eblook-for-h2m

install: install-indep install-arch

binary-indep: build-indep install-indep

binary-arch: build-arch install-arch
	dh_testdir
	dh_testroot
	dh_installchangelogs ChangeLog
	dh_installdocs
	dh_installinfo
#	dh_installexamples
#	dh_installmenu
	dh_installman
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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