#!/usr/bin/make -f
# debhelper rules file for donkey, the One-Time-Password calculator

# Aim for the top, adapt if anything should break on the buildds.
DEB_BUILD_MAINT_OPTIONS=	hardening=+all
export DEB_BUILD_MAINT_OPTIONS

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

CPPFLAGS+=	-D_FILE_OFFSET_BITS=64

CFLAGS_ADD=	-Wall -W -Wextra
ifeq (,$(filter nowerror,$(DEB_BUILD_OPTIONS)))
	CFLAGS_ADD+=	-Werror
endif

export CFLAGS CPPFLAGS LDFLAGS

pkgname=donkey
sysname=$(shell uname -s| sed -e 's/\///')
revname=$(shell uname -r)
objdir=obj/$(sysname).$(revname)
instdir=$(CURDIR)/debian/$(pkgname)

override_dh_auto_configure:
	mkdir obj
	./setup
	cd $(objdir) && sh ./configure

override_dh_auto_build:
	$(MAKE) -C $(objdir) CFLAGS="$(CFLAGS) $(CFLAGS_ADD)"

override_dh_auto_clean:
	rm -rf obj

override_dh_auto_install:
	$(MAKE) -C $(objdir) install BINDIR=$(instdir)/usr/bin

override_dh_installchangelogs:
	dh_installchangelogs 00changes

%:
	dh $@
