#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

DEB_HOST_MULTIARCH 	:= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_HOST_ARCH		:= $(shell dpkg-architecture -qDEB_HOST_ARCH)
COMMON_OPTIONS := -DENABLE_TESTS=1 -DBOOTSTRAP_GN=1

ifeq (arm64,$(DEB_HOST_ARCH))
COMMON_OPTIONS += -DENABLE_HYBRIS=0
else
COMMON_OPTIONS += -DENABLE_HYBRIS_CAMERA=1
endif

%:
	dh $@ --parallel

override_dh_auto_configure:
	dh_auto_configure -- $(COMMON_OPTIONS) -DENABLE_PROPRIETARY_CODECS=1

override_dh_auto_build:
	dh_auto_build
	dh_auto_build -- doc

override_dh_auto_test:
	#xvfb-run -a -s "-screen 0 1024x768x24" dh_auto_test --max-parallel=1

override_dh_auto_install:
	dh_auto_install
	dh_auto_configure -- $(COMMON_OPTIONS) -DENABLE_PROPRIETARY_CODECS=0
	dh_auto_build
	dh_auto_install --destdir debian/tmp.free

override_dh_install:
	dh_install
	dh_install -poxideqt-codecs --sourcedir=debian/tmp.free usr/lib/$(DEB_HOST_MULTIARCH)/oxide-qt/libffmpeg.so

override_dh_fixperms:
	dh_fixperms
	chmod 4755 debian/liboxideqtcore0/usr/lib/*/oxide-qt/chrome-sandbox
