#!/usr/bin/make -f

export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=+lto
export PREFIX = /usr

## DPF specific vars to streamline the package for Debian
# we do the stripping ourselves
export SKIP_STRIPPING = true
# we have a base architecture to support
export NOOPT = true
# build loud
export VERBOSE = true
# support cross-compilation
ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
	export CROSS_COMPILING = true
endif

%:
	dh $@

execute_before_dh_auto_build:
	@echo "blhc: ignore-line-regexp: ^Compiling .*"

override_dh_auto_build:
	dh_auto_build -- \
		CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
		CXXFLAGS="$(CPPFLAGS) $(CXXFLAGS)" \
		$(empty)

# Clean the dpf-source package
execute_after_dh_auto_install:
	rm -fr $(CURDIR)/dpf/build \
		$(CURDIR)/dpf/dgl/src/pugl-upstream/.gitignore \
		$(CURDIR)/dpf/utils/lv2_ttl_generator*

DEB_COPYRIGHT_CHECK_IGNORE_REGEX = \
        debian/.*|.*\.png|.*\.jpg|.*\.psd|.*\.icns|.*\.ico|.*/VeraMono\.ttf|.*/DejaVuSans\.ttf|.*/DEVROYE_\.otf|dpf/lac/2014-small-talk\.odp
        #debian/.*|.*\.png|.*\.jpg|.*\.psd|.*\.icns|.*\.ico|.*/VeraMono\.ttf|.*/DejaVuSans\.ttf|.*/DEVROYE_\.otf|dpf/lac/2014-small-talk\.odp|.*\.lib|.*\.pch|.*\.aps
# licensecheck v1
.PHONY: licensecheck
licensecheck:
	LANG=C.UTF-8 licensecheck \
		-i "^($(DEB_COPYRIGHT_CHECK_IGNORE_REGEX))$$" \
		--check '.*' --recursive --deb-machine --lines 0 * \
		> debian/copyright_newhints
	cmp debian/copyright_hints debian/copyright_newhints \
		&& rm debian/copyright_newhints
