#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND = -DSSHD_SERVICE=\"ssh.service\"
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,-z,defs

%:
	dh $@

override_dh_auto_configure:
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo ubuntu),ubuntu)
	patch -p1 < debian/ubuntu/Adapts-the-region-capplet-and-the-language-chooser-in-the.patch
	touch ./debian/ubuntu/applied
endif
	dh_auto_configure -- \
		-Dprivileged_group=sudo \
		-Ddocumentation=true

override_dh_clean:
	dh_clean
ifeq ($(shell dpkg-vendor --derives-from Ubuntu && echo ubuntu),ubuntu)

	@if [ -e ./debian/ubuntu/applied ]; then \
		patch -R -p1 < debian/ubuntu/Adapts-the-region-capplet-and-the-language-chooser-in-the.patch ; \
		rm ./debian/ubuntu/applied ; \
	fi
endif
