#!/usr/bin/make -f

VERSION = $(shell dpkg-parsechangelog -S Version | cut -d- -f1)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND = -DVERSION=\"$(VERSION)\" -DGLOBAL_CONF=\"/etc/onddirrc\"

CC ?= cc
CFLAGS_FOR_MAKEFILE=$(shell dpkg-buildflags --get CPPFLAGS) $(shell dpkg-buildflags --get CFLAGS)
LDFLAGS_FOR_MAKEFILE=$(shell dpkg-buildflags --get LDFLAGS)

%:
	dh $@

override_dh_auto_build:
	dh_auto_build -- CC='$(CC)' LD='$(CC)' CFLAGS='$(CFLAGS_FOR_MAKEFILE)' LDFLAGS='$(LDFLAGS_FOR_MAKEFILE)'

override_dh_auto_install:
	dh_auto_install -- CC='$(CC)' LD='$(CC)' CFLAGS='$(CFLAGS_FOR_MAKEFILE)' LDFLAGS='$(LDFLAGS_FOR_MAKEFILE)'

override_dh_fixperms:
	dh_fixperms
	@# Remove the executable flag from files installed there, since
	@# they are supposed to be sourced.
	chmod a-x debian/ondir/usr/share/ondir/integration/*
