#!/usr/bin/make -f

export DH_VERBOSE=1
export QT_SELECT=qt5

VERSION = $(shell dpkg-parsechangelog -ldebian/changelog -SVersion | sed 's/.*.is.//g')
_PACK_VER = $(shell echo $(VERSION) | awk -F'[+_~-]' '{print $$1}')
CONFIG_VERSION = $(_PACK_VER)

%:
	dh $@  --parallel

ifeq ($(DEB_BUILD_ARCH), amd64)
override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_RESOURCES=ON -DCONFIG_VERSION=$(CONFIG_VERSION)
else
override_dh_auto_configure:
	dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_RESOURCES=ON -DBUILD_WEB_RESOURCES=OFF -DDISABLE_DXCB=ON -DDISABLE_MULTI_THREAD=ON -DCONFIG_VERSION=$(CONFIG_VERSION)
endif

override_dh_auto_build:
ifneq (,$(wildcard .git/config))
	git submodule update --init --recursive
	git submodule update --remote
else
	rm -rf src/web/node_modules src/web/vendor-deps
	git clone -b deepin-appstore https://gitlab.deepin.io/github-linuxdeepin-mirror/vendor-deps src/web/vendor-deps --depth 1
	cd src/web; ln -s vendor-deps/node_modules node_modules
endif
