#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export PYBUILD_NAME = openshot-qt
export PYBUILD_DESTDIR = debian/openshot-qt
export TMPDIR = $(CURDIR)/debian/openshot-qt
export PYBUILD_TEST_CUSTOM = 1
export PYBUILD_TEST_COMMAND = PYTHONPATH={build_dir}/openshot_qt:{build_dir}:$$PYTHONPATH {interpreter} -m unittest discover -v -s openshot_qt/tests -p "*_tests.py" && PYTHONPATH={build_dir}/openshot_qt:{build_dir}:$$PYTHONPATH {interpreter} -m unittest discover -v -s openshot_qt/language -p "test_*.py"

# 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


%:
	dh $@ --buildsystem=pybuild


# dh_make generated override targets.
# This is an example for Cmake (see <https://bugs.debian.org/641051>).
#override_dh_auto_configure:
#	dh_auto_configure -- \
#	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)

execute_after_dh_auto_build:
	PYTHONPATH=. http_proxy='127.0.0.1:9' python3 -m sphinx -N -b html -d build/doctrees doc build/html
	PYTHONPATH=. http_proxy='127.0.0.1:9' python3 -m sphinx -N -b man  -d build/doctrees doc build/man

execute_after_dh_auto_install:
	# Extra license file must not be removed, otherwise crash will happen
	# Removal line patched out. See https://bugs.debian.org/908320
	#rm $(TMPDIR)/usr/lib/python3*/dist-packages/openshot_qt/resources/license.txt
	chmod -x \
		$(TMPDIR)/usr/lib/python3*/dist-packages/openshot_qt/presets/format_mp4_librav1e.xml \
		$(TMPDIR)/usr/lib/python3*/dist-packages/openshot_qt/presets/format_mp4_libsvtav1.xml

execute_after_dh_auto_clean:
	rm -rf build