#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
export CONFIG_SHELL:=/bin/sh

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

include /usr/share/dpkg/architecture.mk


%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --with-conf=/etc/default --disable-zypp --enable-xattrs --disable-silent-rules

override_dh_auto_install:
	dh_auto_install

	# Add pam-configs for snapper
	cp -a $(CURDIR)/debian/pam-configs $(CURDIR)/debian/tmp/usr/share

	# Remove zypp-related files
	find $(CURDIR)/debian/tmp -name *zypp* -delete

	# Install the configuration file in /etc/default
	mkdir -p $(CURDIR)/debian/tmp/etc/default
	install -m 0644 $(CURDIR)/data/sysconfig.snapper $(CURDIR)/debian/tmp/etc/default/snapper

	# temporary workaround: remove cronjob
	rm -rf $(CURDIR)/debian/tmp/etc/cron*

	# Move the pam library to /lib
	mkdir -p $(CURDIR)/debian/tmp/lib
	mv $(CURDIR)/debian/tmp/$(DEB_BUILD_MULTIARCH) $(CURDIR)/debian/tmp/lib

	# Purge the la files
	find $(CURDIR)/debian/tmp -name *.la -delete

	# Purge a redundant COPYING file
	rm -f $(CURDIR)/debian/tmp/usr/share/doc/snapper/COPYING

	# Cleanup examples
	make -C examples clean

override_dh_compress:
	dh_compress -X.c -X.cc -X.h -X.hpp -X.am

override_dh_makeshlibs:
	dh_makeshlibs -V

override_dh_install:
	dh_install --fail-missing
