#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
export DH_VERBOSE = 1

# see FEATURE AREAS in dpkg-buildflags(1):
# - https://wiki.debian.org/Hardening#dpkg-buildflags

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

CONFIG_OPT += --dynlibdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)
CONFIG_OPT += --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)
CONFIG_OPT += --includedir=\$${prefix}/include
CONFIG_OPT += --libexecdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)/s6
CONFIG_OPT += --with-sysdeps=/usr/lib/$(DEB_HOST_MULTIARCH)/skalibs/sysdeps
CONFIG_OPT += --enable-absolute-paths
CONFIG_OPT += --enable-shared
CONFIG_OPT += --disable-allstatic

%:
	dh $@

override_dh_auto_configure-arch:
	./tools/gen-deps.sh > package/deps.mak
	dh_auto_configure -- $(CONFIG_OPT)

override_dh_auto_configure-indep:
override_dh_auto_build-indep:
override_dh_auto_install-indep:
	mkdir -p debian/tmp/usr/share/doc/s6
	cp -aT doc debian/tmp/usr/share/doc/s6

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp
