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

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

CFLAGS = -Wall -g
UDEB_CFLAGS = -Wall -g

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
	UDEB_CFLAGS += -O0
else
	CFLAGS += -O2
	UDEB_CFLAGS += -Os -fomit-frame-pointer
endif

PACKAGE = fbset
UDEB_PACKAGE = $(PACKAGE)-udeb

include debian/patch.mk

debian/po/templates.pot: debian/fbset.templates
	@debconf-updatepo

build: build-stamp
build-stamp: patch debian/po/templates.pot
	dh_testdir
	
	rm -f build-stamp*
	$(MAKE) clean
	$(MAKE) CFLAGS="$(CFLAGS)"
	
	touch $@

build-udeb: build-stamp-udeb
build-stamp-udeb: patch
	dh_testdir
	
	rm -f build-stamp*
	$(MAKE) clean
	$(MAKE) CFLAGS="$(UDEB_CFLAGS)"
	
	touch $@

clean: unpatch
	dh_testdir
	dh_testroot
	rm -f build-stamp*
	
	-$(MAKE) clean
	
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k -p$(PACKAGE)
	dh_installdirs
	
	-$(MAKE) install DESTDIR=$(CURDIR)/debian/$(PACKAGE)

install-udeb: build-udeb
	dh_testdir
	dh_testroot
	dh_clean -k -p$(UDEB_PACKAGE)
	dh_installdirs
	
	-$(MAKE) install DESTDIR=$(CURDIR)/debian/$(UDEB_PACKAGE)
	rm -rf $(CURDIR)/debian/$(UDEB_PACKAGE)/usr

binary-indep:
# Nothing to do.

binary-arch: install install-udeb
	dh_testdir
	dh_testroot
	dh_installdebconf -a
	dh_installdocs -a
	dh_installexamples -a
#	dh_installinit
	dh_installman -a
#	dh_installinfo
	dh_installchangelogs -a
	dh_link -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
#	dh_makeshlibs
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch

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

