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

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

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# The tests needs libpthread
export CHECK_LIBS=-lpthread $(shell $(DEB_HOST_GNU_TYPE)-pkg-config --libs check)

# doxygen version
doxygen_version := $(shell dpkg-query -W -f="\$${source:Version}\n" doxygen)

DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CUFLAGS += -O0
else

ifeq ($(DEB_HOST_ARCH),amd64)
CUFLAGS += -O2 -fomit-frame-pointer -mno-sse4 -mno-sse3 -msse2 
endif
ifeq ($(DEB_HOST_ARCH),i386)
CUFLAGS += -O2 -fomit-frame-pointer -march=i686 -mmmx -mno-sse4 -mno-sse3
endif
ifeq ($(DEB_HOST_ARCH),i486)
CUFLAGS += -O2 -fomit-frame-pointer -march=i686 -mtune=pentiumpro -mmmx -mno-sse4 -mno-sse3 
endif

endif
export DEB_CFLAGS_MAINT_APPEND  = $(CUFLAGS)


%:
	dh $@

override_dh_auto_test:
# Tests must be run as root

override_dh_auto_configure:
	dh_auto_configure -- --disable-silent-rules

override_dh_gencontrol:
	dh_gencontrol -- -Vdoxygen:Version=$(doxygen_version)

override_dh_makeshlibs:
	dh_makeshlibs --add-udeb=libevdev2-udeb

override_dh_auto_install:
	rm -f doc/html/*.md5
	dh_auto_install
