#!/usr/bin/make -f

# Local Lintian after dpkg-buildpackage (uses debian/lintianrc). For sbuild, see debian/README.sbuild
# and debian/sbuild.suryaos.conf (set SBUILD_CONFIG to that file).
.PHONY: run-lintian
run-lintian:
	@if ! ls ../*.changes >/dev/null 2>&1; then \
		echo "run-lintian: no ../*.changes — run dpkg-buildpackage from this directory first." >&2; \
		exit 1; \
	fi; \
	export LINTIAN_CFG="$(CURDIR)/debian/lintianrc"; \
	for c in ../*.changes; do lintian "$$c"; done; \
	if ls ../*.dsc >/dev/null 2>&1; then for d in ../*.dsc; do lintian "$$d"; done; fi

%:
	dh $@

override_dh_auto_build:
	:

override_dh_auto_test:
	:

override_dh_auto_install:
	set -e; \
	pkg="$(shell dh_listpackages)"; \
	install -d "debian/$$pkg"; \
	for d in *; do \
	  case "$$d" in debian|DEBIAN) continue;; esac; \
	  cp -a "$$d" "debian/$$pkg/"; \
	done

override_dh_installdocs:
	dh_installdocs

override_dh_installchangelogs:
	dh_installchangelogs

override_dh_fixperms:
	dh_fixperms
	pkg="$(shell dh_listpackages)"; \
	if [ -d "debian/$$pkg/usr/share" ]; then \
	  find "debian/$$pkg/usr/share" -type f -perm /111 ! -name '*.sh' \
	    -exec chmod a-x {} + 2>/dev/null || true; \
	fi

override_dh_strip_nondeterminism:
	dh_strip_nondeterminism -X.png -X.svgz
