#!/usr/bin/make -f

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

# Filter -g from environment on troublesome arches. Replace it with -gstabs
# See also: stabs_format_debug_info.diff
DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
ifneq (,$(filter $(DEB_HOST_ARCH),s390 armel mips mipsel))
    export CFLAGS := $(filter-out -g,$(CFLAGS)) -gstabs
    export CXXFLAGS := $(filter-out -g,$(CXXFLAGS)) -gstabs
endif

ifeq ($(DEB_HOST_ARCH_OS),linux)
	extra_configure_opts = DEFINES+=ENABLE_VIDEO=1 DEFINES+=WTF_USE_GSTREAMER=1
endif

%:
	dh $@ --buildsystem=qmake --parallel --list-missing --dbg-package=libqtwebkit4-dbg --with pkgkde_symbolshelper,lzma

override_dh_auto_configure:
	dh_auto_configure --buildsystem=qmake --sourcedirectory=Source -- $(extra_configure_opts)
	dh_auto_configure --sourcedirectory=debian/qtdesigner-qwebview

override_dh_auto_build:
	dh_auto_build --buildsystem=qmake --sourcedirectory=Source
	dh_auto_build --sourcedirectory=debian/qtdesigner-qwebview

override_dh_auto_install:
	dh_auto_install --buildsystem=qmake --sourcedirectory=Source
	dh_auto_install --sourcedirectory=debian/qtdesigner-qwebview

override_dh_auto_clean:
	grep -q "MODULES = JavaScriptGlue ThirdParty/ANGLE" Source/Makefile && rm Source/Makefile || :
	dh_auto_clean --buildsystem=qmake --sourcedirectory=Source
	dh_auto_clean --sourcedirectory=debian/qtdesigner-qwebview

override_dh_makeshlibs:
	dh_makeshlibs -V
