#!/usr/bin/make -f
#export DH_VERBOSE = 1

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export QT_SELECT = qt5

# Exclude "obs-" from NAME and set a DEST
export PLUGIN_NAME=$(shell echo ${DEB_SOURCE} | cut -d"-" -f2-)
export PLUGIN_DEST=debian/${DEB_SOURCE}/usr/lib/${DEB_TARGET_MULTIARCH}/obs-plugins

%:
	dh $@

# Using DEB_INSTALL, BUILD_OUT_OF_TREE will automatically be detected.
override_dh_auto_configure:
	dh_auto_configure -- -DDEB_INSTALL=ON \
                             -DLINUX_PORTABLE=OFF \
                             -DCMAKE_INSTALL_PREFIX=/usr \
                             -DLIBOBS_INCLUDE_DIR=/usr/include/obs \
                             -DLIBOBS_LIB=/usr/lib/${DEB_TARGET_MULTIARCH}/libobs.so \
                             -DLIBOBS_FRONTEND_INCLUDE_DIR=/usr/include/obs \
                             -DLIBOBS_FRONTEND_API_LIB=/usr/lib/${DEB_TARGET_MULTIARCH}/libobs-frontend-api.so \
                             -DLIB_OUT_DIR=lib/${DEB_TARGET_MULTIARCH}/obs-plugins \
                             -DDATA_OUT_DIR=share/obs/obs-plugins/$(PLUGIN_NAME)

execute_after_dh_install-arch:
	# Check if the plugin is in right place
	ls $(PLUGIN_DEST)/lib$(PLUGIN_NAME).so
