#!/usr/bin/make -f

DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)

ifeq ($(DEB_HOST_GNU_SYSTEM), linux-gnu)
	target = linux
else
	target = generic
endif

CFLAGS = -Wall -g -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -O0
else
	CFLAGS += -pipe -fomit-frame-pointer
	ifeq ($(target), generic)
		CFLAGS += -O6
	else
		CFLAGS += -O9 -finline-functions -funroll-loops -fstrength-reduce
	endif
endif

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- $(target) CFLAGS="$(CFLAGS)"
