### this file is sourced not run
PKGNAME=qt5webengine
PKGVER=5.11.1
PKGBUILD=1
PKGARCH=x86_64

# source: BLFS SVN 05112018 and Arch linux
TARBALL=qtwebengine-everywhere-src-${PKGVER}.tar.xz
MD5SUM=75d2ff31addba4ec41981b0f459cc587
SRC_URL=https://download.qt.io/archive/qt/5.11/5.11.1/submodules/$TARBALL
BUNDLE=

SLACKREQ='qt5-common'
SLACKDESC="qt5webengine: qt5webengine $PKGVER (Qt5 Webkit Engine)  
${PKGNAME}:  
${PKGNAME}: QtWebEngine integrates chromiums web capabilities into Qt. 
${PKGNAME}: It ships with its own copy of ninja which it uses for the 
${PKGNAME}: build if it cannot find a system copy, and various copies  
${PKGNAME}: of libraries from ffmpeg, icu, libvpx, and zlib including 
${PKGNAME}: libminizip which have been forked by the chromium 
${PKGNAME}: developers.
${PKGNAME}: 
${PKGNAME}: 
${PKGNAME}: 
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/qtwebengine*
	patch -Np1 -i $CHROOT_DIR/tmp/pkg/qtbug-68699.patch &&
	cd src/3rdparty/chromium
	patch -Np2 -i $CHROOT_DIR/tmp/pkg/qtwebengine-ffmpeg4.patch
}
### default pkg_package
### build
pkg_build() {
	export PATH="$PATH:/opt/qt5/bin"
	export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/qt5/lib64"
	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/opt/qt5/lib64/pkgconfig"
	export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:/opt/qt5/include"
	export QT5_PATH="/opt/qt5/bin"
	export QT5_LD_LIBRARY_PATH="/opt/qt5/lib64"
	export QT5_PKG_CONFIG_PATH="/opt/qt5/lib64/pkgconfig"
	export QT5_CPLUS_INCLUDE_PATH="/opt/qt5/include"
	export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb"
	export QT5DIR=/opt/qt5

	cd /tmp/qtwebengine* &&
	
	# Hack to force using python2
	mkdir -p bin
	ln -s /usr/bin/python2 bin/python
	export PATH="/tmp/qtwebengine*/bin:$PATH"
	
	mkdir build &&
	cd build &&
	qmake .. -- -proprietary-codecs -system-ffmpeg -webp -spellchecker &&
    
	make ${MAKEFLAGS} &&
    make install
	#Remove references to the build directory from installed library dependency (prl) files
	find $QT5DIR/ -name \*.prl \
	-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
		
	pkg_build_slackdesc
}
