#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/buildflags.mk

%:
	dh $@

# The upstream Makefile assigns CXXFLAGS and LDLIBS outright, which discards
# the flags dh exports; command-line variables win over a Makefile assignment.
override_dh_auto_build:
	dh_auto_build -- CXXFLAGS="$(CXXFLAGS) -fPIC -std=c++11 -Wall" LDLIBS="$(LDFLAGS) -lpam -lcurl -lldap -llber"

# The upstream install target puts the module in /lib/security, which Debian's
# libpam does not search, and a mode-600 config template under /etc.
override_dh_auto_install:
	install -D -m 0644 pam_oauth2_device.so $(CURDIR)/debian/libpam-oauth2-device/usr/lib/$(DEB_HOST_MULTIARCH)/security/pam_oauth2_device.so
