#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

VERSION := $(DEB_VERSION_UPSTREAM)
REVISION := $(shell echo $(DEB_VERSION) | cut -d- -f2)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with autoreconf --parallel

override_dh_auto_configure:
	@# Embed the downstream version in the module.
	@sed \
	  -e 's/^Version:.*/Version:      $(VERSION)/' \
	  -e 's/^Release:.*/Release:      $(REVISION)/' \
	  -i.orig META

	@# Build the userland, but don't build the kernel modules.
	dh_auto_configure -- --with-config=user --disable-debug-kmem

override_dh_auto_test:
	# scripts/check.sh tries insmod and rmmod, so it cannot
	# run in an unprivileged build environment.

override_dh_auto_install:
	@# Install the utilities.
	$(MAKE) install DESTDIR='$(CURDIR)/debian/tmp'

override_dh_auto_clean:
	dh_auto_clean
	@if test -e META.orig; then mv META.orig META; fi
