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

# export DH_VERBOSE=1

CFLAGS = -Wall -g -Werror

DESTDIR = $(CURDIR)/debian/tmp

# Use thumb mode if it enabled.
ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -mthumb
endif

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

build:
	CFLAGS="$(CFLAGS)" $(MAKE)

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(MAKE) DESTDIR=$(DESTDIR) install

clean:
	$(MAKE) clean
	dh_testdir
	dh_clean

binary: build install
	dh_testdir
	dh_testroot
	dh_install
	dh_installdocs
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_makeshlibs
	dh_shlibdeps
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

.PHONY: build clean binary install
