#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2011-2021 IOhannes m zmölnig <zmoelnig@iem.at>
# Description: Main Debian packaging script for gmerlin-avdecoder

DPKG_EXPORT_BUILDFLAGS = 1
DEB_BUILD_MAINT_OPTIONS=hardening=+all
export DEB_BUILD_MAINT_OPTIONS

include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/pkg-info.mk

export DEB_CPPFLAGS_MAINT_APPEND =
export DEB_LDFLAGS_MAINT_APPEND =

export FLAC_VERSION=$(shell dpkg-query --show --showformat='$${source:Upstream-Version}' libflac-dev)

## only link what is needed
DEB_LDFLAGS_MAINT_APPEND += -Wl,--as-needed

%:
	dh $@

execute_before_dh_autoreconf:
	./autogen.sh

override_dh_auto_configure:
	dh_auto_configure -- \
		--docdir=\$${prefix}/share/doc/libgmerlin-avdec2/ \
		--libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
		--disable-vdpau \
		--with-cpuflags=none \
		$(DEB_CONFIGURE_EXTRA_FLAGS)

# Suppress scanning documentation images causing false alarms.
DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^(icons/.*|doc/img/.*|skins/.*/.*|po/.*\.gmo|debian/(changelog|copyright(|_hints|_newhints)))$
licensecheck:
	licensecheck -i "$(DEB_COPYRIGHT_CHECK_IGNORE_REGEX)" --deb-machine -r * \
		> debian/copyright_newhints
	cmp debian/copyright_hints debian/copyright_newhints \
		&& rm debian/copyright_newhints
