#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1


# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

include /usr/share/dpkg/architecture.mk
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@


override_dh_auto_configure:
	dh_auto_configure -- --libdir=/usr/lib/$(DEB_TARGET_MULTIARCH)/vlc/plugins --with-tests

override_dh_auto_install:
	dh_auto_install
	find debian/vlc-plugin-bittorrent/ -name '*.la' -delete
	find debian/vlc-plugin-bittorrent/ -name '*.a' -delete
override_dh_auto_test:
	# The VLC test need to write to $HOME, make sure $HOME exist
	# and is writable.  Tried useing debhelper compat level 13 to
	# get the same effect, but it did not work.
	-HOME=$(CURDIR)/debian/tmp dh_auto_test

# Provide substvar with VLC plugin ABI reference (BTS #1060138)
override_dh_gencontrol-arch:
	sed -n 's/^# define MODULE_SYMBOL \([0-9][_0-9a-z]*\)/-Vvlc:PluginABI=vlc-plugin-abi-\1/p' \
	  /usr/include/vlc/plugins/vlc_plugin.h | \
	  tr _ - | xargs dh_gencontrol -a --

override_dh_auto_clean:
	dh_auto_clean
	$(RM) debian/files test/data/vlcdummy-vlc.log
