#!/usr/bin/make -f

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

export DEB_BUILD_OPTIONS
CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
        MAKEFLAGS += -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith # -Wextra

build: build-arch-stamp
build-arch: build-arch-stamp
build-indep:

build-arch-stamp:
	$(MAKE) CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' prefix=/usr
	touch $@

clean:
	$(MAKE) clean
	rm -f build-arch-stamp
	dh_clean

binary: binary-arch binary-indep
binary-indep:

binary-arch: build-arch-stamp
	dh_testdir
	dh_testroot
	dh_prep
	$(MAKE) install prefix=/usr DESTDIR=$(CURDIR)/debian/tmp
	dh_install
	dh_installchangelogs
	dh_installexamples
	dh_installdocs
	dh_installman
	dh_link
	dh_strip
	dh_makeshlibs
	dh_shlibdeps
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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