#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@

override_dh_auto_clean:
	-dh_auto_clean

execute_after_dh_clean:
	for spec in image-spec runtime-spec; do \
		if [ -d libocispec/$$spec.saved ]; then \
			rm -r libocispec/$$spec; \
			mv libocispec/$$spec.saved libocispec/$$spec; \
		fi; \
	done

execute_after_dh_auto_configure:
	for spec in image-spec runtime-spec; do \
		if [ ! -d libocispec/$$spec.saved ]; then \
			mv libocispec/$$spec libocispec/$$spec.saved ; \
			cp -rv /usr/share/gocode/src/github.com/opencontainers/$$spec/ libocispec/; \
		fi; \
	done

override_dh_auto_test:
	-dh_auto_test

execute_before_dh_auto_build:
	make generate-signals.c
	make generate-mount_flags.c

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp
	-$(RM) debian/tmp/usr/lib/*/*.la

override_dh_gencontrol:
	dh_gencontrol -- -Vmy:Built-Using="$(shell dpkg-query --show -f '$${source:Package} (=$${source:Version}),' golang-github-opencontainers-image-spec-dev golang-github-opencontainers-specs-dev)"
