#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DEB_BUILD_ARCH_OS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)

%:
	dh $@ -with autotools_dev,autoreconf

override_dh_auto_configure:
	./autogen.sh
	dh_auto_configure

override_dh_auto_install:
	dh_auto_install
	# Debian Policy rightfully suggest to not ship LICENSE files as the information is also part of debian/copyright
	rm debian/tlsdate/usr/share/doc/tlsdate/LICENSE
	# Remove .la file
	rm -f debian/tlsdate/usr/lib/libtlsdate_compat.la

ifeq ($(DEB_BUILD_ARCH_OS),linux)
override_dh_systemd_enable:
	dh_systemd_enable tlsdated.service
endif
		
ifeq ($(DEB_BUILD_ARCH_OS),linux)
override_dh_install:
	cp apparmor-profile debian/tlsdate/etc/apparmor.d/usr.bin.tlsdate
	# use copy from debian/tlsdated.service as long as upstream file is broken:
	cp debian/tlsdated.service debian/tlsdate/lib/systemd/system/
	dh_apparmor --profile-name=usr.bin.tlsdate -ptlsdate
endif
	

override_dh_installchangelogs:
	dh_installchangelogs
	# Debian Policy requires that the upstream changelog is called changelog...
	mv debian/tlsdate/usr/share/doc/tlsdate/CHANGELOG debian/tlsdate/usr/share/doc/tlsdate/changelog

override_dh_auto_clean:
	dh_auto_clean
	rm -f src/configmake.h
