#!/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 (,$(filter 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

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

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

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp*
	
	$(MAKE) clean
	
	# FIXME: this can be removed once and if con2fbmap is merged upstream
	rm -f con2fbmap
	
	dh_clean

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

install-udeb: build-udeb
	dh_testdir
	dh_testroot
	dh_prep -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_installdocs -a
	dh_installexamples -a
	dh_installman -a
	dh_installchangelogs -a
	dh_link -a
	dh_strip -a
	dh_compress -a
	dh_fixperms -a
	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

