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

.PHONY: \
 configure-stamp configure \
 build-stamp build-indep build-arch build \
 clean \
 install \
 binary-indep binary-arch binary \
 fizmo fizmo-common fizmo-console fizmo-ncursesw


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

configure-stamp:
	dh_testdir
	cp config.default.mk config.mk
	touch configure-stamp

configure: configure-stamp

build-stamp: configure-stamp
	dh_testdir
	touch build-stamp

build-stamp-fizmo-console: configure-stamp
	dh_testdir
	$(MAKE) prefix=/usr DISABLE_BABEL=1 DISABLE_FILELIST=1 \
 DISABLE_BLOCKBUFFER=1 DISABLE_COMMAND_HISTORY=1 DISABLE_OUTPUT_HISTORY=1 \
 fizmo-console
	touch build-stamp

build-stamp-fizmo-ncursesw: configure-stamp
	dh_testdir
	$(MAKE) prefix=/usr fizmo-ncursesw
	touch build-stamp

# All build target will do nothing by default, since different types of
# builds are required to build each package. Building is instead invoked
# from the "binary" targets later on.

build-indep:
build-arch:
build:

clean:

install:

binary: binary-indep binary-arch

binary-indep: fizmo-common fizmo

binary-arch: fizmo-console fizmo-ncursesw


fizmo:
	dh_testdir
	dh_testroot
	dh_auto_clean -p$@
	dh_prep -p$@
	dh_installdirs
	dh_installchangelogs -p$@ CHANGELOG.txt
	dh_installdocs -p$@
	dh_link -p$@
	dh_strip -p$@
	dh_compress -p$@
	dh_fixperms -p$@
	dh_installdeb -p$@
	dh_shlibdeps -p$@
	dh_gencontrol -p$@
	dh_md5sums -p$@
	dh_builddeb -p$@

fizmo-common: configure-stamp
	dh_testdir
	dh_testroot
	dh_auto_clean -p$@
	dh_prep -p$@
	dh_installdirs
	dh_installchangelogs -p$@ CHANGELOG.txt
	dh_installdocs -p$@
	$(MAKE) prefix=$(CURDIR)/debian/fizmo-common/usr install-locales
	dh_installexamples -p$@
	dh_installman -p$@
	dh_link -p$@
	dh_strip -p$@
	dh_compress -p$@
	dh_fixperms -p$@
	dh_installdeb -p$@
	dh_shlibdeps -p$@
	dh_gencontrol -p$@
	dh_md5sums -p$@
	dh_builddeb -p$@

fizmo-console: configure-stamp build-stamp-fizmo-console
	dh_testdir
	dh_testroot
	dh_auto_clean -p$@
	dh_prep -p$@
	dh_installdirs
	dh_installchangelogs -p$@ CHANGELOG.txt
	dh_installdocs -p$@
	$(MAKE) prefix=/usr DESTDIR=$(CURDIR)/debian/fizmo-console install-fizmo-console
	dh_installexamples -p$@
	dh_installman -p$@
	dh_link -p$@
	dh_strip -p$@
	dh_compress -p$@
	dh_fixperms -p$@
	dh_installdeb -p$@
	dh_shlibdeps -p$@
	dh_gencontrol -p$@
	dh_md5sums -p$@
	dh_builddeb -p$@

fizmo-ncursesw: configure-stamp build-stamp-fizmo-ncursesw
	dh_testdir
	dh_testroot
	dh_prep -p$@
	dh_auto_clean -p$@
	dh_installdirs
	dh_installchangelogs -p$@ CHANGELOG.txt
	dh_installdocs -p$@
	$(MAKE) prefix=/usr DESTDIR=$(CURDIR)/debian/fizmo-ncursesw install-fizmo-ncursesw
	dh_installexamples -p$@
	dh_installman -p$@
	dh_link -p$@
	dh_strip -p$@
	dh_compress -p$@
	dh_fixperms -p$@
	dh_installdeb -p$@
	dh_shlibdeps -p$@
	dh_gencontrol -p$@
	dh_md5sums -p$@
	dh_builddeb -p$@
