PKGBUILDs/qt5-base/mingw-w64/PKGBUILD

291 lines
13 KiB
Bash

# Maintainer: Martchus <martchus@gmx.net>
# Contributor: ant32 <antreimer@gmail.com>
# Contributor: Filip Brcic <brcha@gna.org>
# Contributor: jellysheep <max.mail@dameweb.de>
# BEFORE COMMENTING OR REPORING ISSUES, PLEASE READ THE FILE `README.md` IN THIS REPOSITORY.
# ALSO HAVE A LOOK AT THE COMMENTS IN THE AUR.
# All my PKGBUILDs are managed at https://github.com/Martchus/PKGBUILDs where
# you also find the URL of a binary repository.
# This file is created from PKGBUILD.sh.ep contained by the mentioned repository.
# Do not edit it manually! See README.md in the repository's root directory
# for more information.
# All patches are managed at https://github.com/Martchus/qtbase
_qt_module=qtbase
pkgname=mingw-w64-qt5-base
pkgver=5.15.2+kde+r274
pkgrel=1
_commit=98aa64af7e1e677bd107bfb0c432cabf7c3a5e32
pkgdesc='A cross-platform application and UI framework, native OpenGL backend (mingw-w64)'
arch=('i686' 'x86_64')
url='https://www.qt.io/'
license=('GPL3' 'LGPL3' 'FDL' 'custom')
depends=('mingw-w64-crt' 'mingw-w64-zlib' 'mingw-w64-libjpeg-turbo' 'mingw-w64-sqlite'
'mingw-w64-libpng' 'mingw-w64-openssl' 'mingw-w64-dbus' 'mingw-w64-harfbuzz'
'mingw-w64-pcre2')
optdepends=('mingw-w64-mesa: use LLVMpipe software rasterizer for Qt Quick'
'mingw-w64-postgresql: PostgreSQL support'
'mingw-w64-mariadb-connector-c: MySQL support')
makedepends=('mingw-w64-gcc' 'mingw-w64-postgresql' 'mingw-w64-mariadb-connector-c'
'mingw-w64-vulkan-headers' 'mingw-w64-pkg-config' 'mingw-w64-environment' 'git')
groups=('mingw-w64-qt5')
options=('!strip' '!buildflags' 'staticlibs' '!emptydirs')
_pkgfqn=${_qt_module}
source=(git+https://invent.kde.org/qt/qt/$_pkgfqn#commit=$_commit
'0001-Adjust-win32-g-profile-for-cross-compilation-with-mi.patch'
'0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch'
'0003-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch'
'0004-Make-sure-.pc-files-are-installed-correctly.patch'
'0005-Don-t-add-resource-files-to-LIBS-parameter.patch'
'0006-Prevent-debug-library-names-in-pkg-config-files.patch'
'0007-Fix-linking-against-shared-static-libpng.patch'
'0008-Fix-linking-against-static-D-Bus.patch'
'0009-Don-t-try-to-use-debug-version-of-D-Bus-library.patch'
'0010-Fix-linking-against-static-freetype2.patch'
'0011-Fix-linking-against-static-harfbuzz.patch'
'0012-Fix-linking-against-static-pcre.patch'
'0013-Fix-linking-against-shared-static-MariaDB.patch'
'0014-Fix-linking-against-shared-static-PostgreSQL.patch'
'0015-Rename-qtmain-to-qt5main.patch'
'0016-Enable-rpath-for-build-tools.patch'
'0017-Use-system-zlib-for-build-tools.patch'
'0018-Merge-shared-and-static-library-trees.patch'
'0019-Use-.dll.a-as-import-lib-extension.patch'
'0020-Pull-dependencies-of-static-libraries-in-CMake-modul.patch'
'0021-Allow-usage-of-static-version-with-CMake.patch'
'0022-Adjust-linker-flags-for-static-build-with-cmake-ming.patch'
'0023-Use-correct-pkg-config-static-flag.patch'
'0024-Fix-macro-invoking-moc-rcc-and-uic.patch'
'0025-Ignore-errors-about-missing-feature-static.patch'
'0026-Enable-and-fix-use-of-iconv.patch'
'0027-Ignore-failing-pkg-config-test.patch'
'0028-Prevent-qmake-from-messing-static-lib-dependencies.patch'
'0029-Hardcode-linker-flags-for-platform-plugins.patch'
'0030-Fix-linking-against-static-plugins-with-qmake.patch'
'0031-Prevent-Cannot-find-feature-windows_vulkan_sdk.patch'
'0032-Fix-crashes-in-rasterization-code-using-setjmp.patch')
sha256sums=('SKIP'
'8ec72a1bb610e30a06c5bd301e0f502a4b1098e4f7709950d42f8d4f6b4529b1'
'3e2150bf9fd9b7bf4e02a7355b3316f1129159de4523dd56e2e002c17461a06b'
'e18708d7a35920fff7b366cd98fabf87dda254b940581df2a3768dd22be86989'
'8be908199db7ed2d11dfa5b1a8b037a183e1a331b818e511a62ed366e56e322b'
'ea9abbd04d03beb28682824750449ec734d0cd5980d18e43ee8c43a081522a39'
'ede654c3021e9b2b5672fe67e6f3c8841dc3e9f59a16e1119adc5581021b6584'
'238a37d318d46d02e6a0632e58824ec64e323bf1a80f04fd2ca673eeb7eac167'
'1afa605f868eb859192c9e4a36474e2c9d3fd9808b8bbe83bf28fe44a0c5354a'
'3c9c7d80b88d7da333c13b366e0807d3d1bea7641a6e8540142c2197e00fb177'
'ca065a912f79b3b8bd511d076e8d15e18802a7dc4baeb4f9af2a9ad1b2d65b25'
'519cf065067d7d1a15d02735457576f85d3d32ed2548650e93866e0e903e88bc'
'0811548a8f4c533f3b0df2b6114de673754aa269264a7bc99cc69db4228e24a8'
'e8e754415d38b286c94f4227a372ef9d875d5f7d5493a88815903d0d9425f198'
'ddddd2c328870aa66feed1415a34437cdbb6e086e6309fe5ac640cd551fdbc8d'
'9cf7eac11820012cedd0f5da75e7690e83a80e7002af0dec283d4b424142c22d'
'24e7863c621ab360c392b29244fcb2ffc4d116b8a5ef1f4e2a40841218c9bee1'
'790fb8562e2eee0b80bf23d6123e2f2c537021d8bbbec45053b12b8330244f93'
'6ff67b6c2c17478096409a90ee3e00b2a34b3e64dc8ecf24af8c4f33fbe9b083'
'3ce30f710591ba5dddb7c3a5cf0f9743da203ecc84d2e727e6d0f6a2a9502db6'
'80e5af98f00d73ad4210aa4fd4aed5f3259d7b965b2933568c30e539bb8a3fe3'
'9409620a23301e6410310ef9c865f19b185b35fa52593fc75f3674c1c95be81d'
'd5fe2bcaa51e96ae1254d4596aabd4635d31959d15c2e5e6eefd238f824f1cf2'
'2bfd85eb2dad9ffbd3ca0920208091e85792c3b3673beff3467929ef3f7c399d'
'11d8dc525166ccbbc431fb3ed3a56540bfe26ad69b180c99ab6d3d9322d85ccc'
'a633e33bf22e33ba549bd7bec1dbb3c1896922ed9041239f70fe13b32162c836'
'0057e150aed1f2119dd7dff27d21ed7f160ba398e9a4630c4f8ff979203dc8c2'
'30395cee07666b2cab06051033e3532140e8c4258ab6d576ef6514b90731bc8d'
'a7ee924a26424c15f4a639f7e11ef154e70325c67e78d7d9231e7cff51fc01b2'
'431bd1f62600f985a4160fcdb2e44a6d8fec807eadb2f68738f941a649335150'
'ba978e69e897e5ada1dce268517a5aeb356250052738c61730718f5014a39490'
'f6c3027f58205167f6a18e51463ee0702c1f4a57106ff6a75dff6c3a9e654ebc'
'0f6796e6c7e0436b61bbc3947197f821732a07db900d440772054cf25a9ca9de')
_architectures='i686-w64-mingw32 x86_64-w64-mingw32'
pkgver() {
cd $_pkgfqn
echo "5.15.2+kde+r"`git rev-list --count origin/5.15.2..$_commit`
}
prepare() {
cd "${srcdir}/${_pkgfqn}"
git revert -n 6344955d17e17e2398720fe60c34cfc2a4a95208 # Revert version bump
# apply patches; further descriptions can be found in patch files itself
for patch in "$srcdir/"*.patch; do
msg2 "Applying patch $patch"
patch -p1 -i "$patch"
done
# clear buildflags ('!buildflags' only effects build() but not prepare())
unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS PKG_CONFIG_PATH
# build qmake using mingw-w64 {C,CXX,LD}FLAGS
# * This also sets default {C,CXX,LD}FLAGS for projects built using qmake.
source mingw-env
sed -i -e "s|^\(QMAKE_CFLAGS_RELEASE.*=\).*$|\1 ${CFLAGS}|" \
-e "s|^\(QMAKE_CXXFLAGS_RELEASE.*=\).*$|\1 ${CXXFLAGS}|" \
-e "s|^\(QMAKE_LFLAGS_RELEASE.*=\).*$|\1 ${LDFLAGS}|" \
mkspecs/common/gcc-base.conf \
mkspecs/common/g++-win32.conf
sed -i -e "s|^\(QMAKE_LFLAGS_RELEASE.*=\).*$|\1|" \
mkspecs/common/g++-unix.conf
}
build() {
cd "${srcdir}/${_pkgfqn}"
for _arch in ${_architectures}; do
# define general configure arguments
local qt_configure_args="\
-xplatform win32-g++ \
-optimized-qmake \
-verbose \
-opensource \
-confirm-license \
-force-pkg-config \
-force-debug-info \
-system-zlib \
-system-libpng \
-system-libjpeg \
-system-sqlite \
-system-freetype \
-system-harfbuzz \
-system-pcre \
-no-fontconfig \
-sql-mysql \
-sql-psql \
-sql-sqlite \
-dbus-linked \
-no-glib \
-no-icu \
-iconv \
-nomake examples \
-make tools \
-hostprefix /usr/${_arch} \
-hostdatadir /usr/${_arch}/lib/qt \
-hostbindir /usr/${_arch}/lib/qt/bin \
-prefix /usr/${_arch} \
-bindir /usr/${_arch}/bin \
-archdatadir /usr/${_arch}/lib/qt \
-datadir /usr/${_arch}/share/qt \
-docdir /usr/${_arch}/share/doc/qt \
-examplesdir /usr/${_arch}/share/qt/examples \
-headerdir /usr/${_arch}/include/qt \
-libdir /usr/${_arch}/lib \
-plugindir /usr/${_arch}/lib/qt/plugins \
-sysconfdir /usr/${_arch}/etc \
-translationdir /usr/${_arch}/share/qt/translations \
-device-option CROSS_COMPILE=${_arch}- \
-device-option CROSS_COMPILE_PREFIX=/usr/${_arch}"
# allows using ccache despite the use of pre-compile header (sloppiness must be set to pch_defines,time_macros in ccache config for this)
qt_configure_args+=' -device-option CROSS_COMPILE_CFLAGS=-fpch-preprocess'
qt_configure_args+=' -device-option CROSS_COMPILE_CXXFLAGS=-fpch-preprocess'
# add include directory of freetype2 and dbus manually (pkg-config detection in qmake doesn't work which is currently ignored via a patch)
qt_configure_args+=" $(${_arch}-pkg-config --cflags-only-I freetype2 dbus-1 | sed -e "s/-I\/usr\/${_arch}\/include //g")"
# note: The sed is required to prevent -isystem /usr/${_arch}/include (qmake will turn -I into -isystem) which would lead to
# the same issue as here: https://github.com/Martchus/tageditor/issues/22#issuecomment-330899141
# enable debug build if MINGW_W64_QT_DEBUG_BUILD is set (could be set in eg. /etc/makepkg.config if debug build is wanted)
[[ $MINGW_W64_QT_DEBUG_BUILD ]] \
&& qt_configure_args+=' -debug-and-release' \
|| qt_configure_args+=' -release'
# configure usage of ANGLE/OpenGL
msg2 'Using native OpenGL backend'
qt_configure_args+=' -opengl desktop'
# add include directory of MariaDB
qt_configure_args+=" -I/usr/${_arch}/include/mariadb"
# add include directory for Vulkan
export VULKAN_SDK=/usr/${_arch}
msg2 'Configure and build qmake'
mkdir -p ../build-${_arch} && pushd ../build-${_arch}
qt_configure_args+=' -shared'
# configure shared version to load OpenSSL dynamically
qt_configure_args+=' -openssl-runtime'
qt_configure_args+=' -device-option CROSS_COMPILE_CUSTOM_CONFIG=actually_a_shared_build'
# override LD_LIBRARY_PATH so libraries for native build tools like libQt5Bootstrap.so are found
#export LD_LIBRARY_PATH="$PWD/lib"
#export LDFLAGS="-L$PWD/lib"
msg2 'Build qmake and configure' && ../${_pkgfqn}/configure $qt_configure_args
msg2 'Build Qt libraries' && make
popd
done
}
package() {
for _arch in ${_architectures}; do
cd "$srcdir/${_pkgfqn}"
make install -C ../build-${_arch} INSTALL_ROOT="${pkgdir}"
# use prl files from build directory since installed prl files seem to have incorrect QMAKE_PRL_LIBS_FOR_CMAKE
pushd "$srcdir/build-${_arch}/lib"
find -iname '*.prl' -exec cp --target-directory "${pkgdir}/usr/${_arch}/lib" --parents {} +
popd
pushd "$srcdir/build-${_arch}/plugins"
find -iname '*.prl' -exec cp --target-directory "${pkgdir}/usr/${_arch}/lib/qt/plugins" --parents {} +
popd
# remove DLLs from libdir (DLLs are installed in both bindir and libdir, one copy is sufficient)
find "${pkgdir}/usr/${_arch}/lib" -maxdepth 1 -name "*.dll" -exec rm {} \;
# install missing libQt5BootstrapDBus.a manually
cp --target-directory "${pkgdir}/usr/${_arch}/lib" "$srcdir/build-${_arch}/lib/libQt5BootstrapDBus.a"
# create symlinks for tools
mkdir -p "${pkgdir}/usr/bin"
for tool in qmake moc rcc uic qdbuscpp2xml qdbusxml2cpp qdoc syncqt.pl; do
ln -s "../${_arch}/lib/qt/bin/${tool}" "${pkgdir}/usr/bin/${_arch}-${tool}-qt5"
done
# create qt.conf containing plugin path, see https://github.com/Martchus/PKGBUILDs/issues/109
echo "[Paths]
Plugins = /usr/${_arch}/lib/qt/plugins" > "${pkgdir}/usr/${_arch}/bin/qt.conf"
# drop QMAKE_PRL_BUILD_DIR because reference the build dir
find "${pkgdir}/usr/${_arch}/lib" -type f -name '*.prl' -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;
# remove doc
rm -rf "${pkgdir}/usr/${_arch}/share/doc"
# remove prl files for debug version
if ! [[ $MINGW_W64_QT_DEBUG_BUILD ]]; then
for file in $(find "${pkgdir}/usr/${_arch}" -name '*d.prl' -o -name '*d.static.prl'); do
[ -f "${file%d*}${file##*d}" ] && rm "${file}";
done
fi
# remove '.static.prl' files
find "${pkgdir}/usr/${_arch}" -name '.static.prl' -delete
# replace library path in *.prl files so it points to the installed location and not the build directory
find "${pkgdir}/usr/${_arch}/lib" \( -type f -name '*.prl' -o -name '*.pc' \) -exec sed -i -e "s:${PWD%/*}/build-${_arch}/lib:/usr/${_arch}/lib:g" {} \;
# strip binaries, remove unuseful files
strip --strip-all "${pkgdir}/usr/${_arch}/lib/qt/bin/"*[!.pl]
strip --strip-debug "${pkgdir}/usr/${_arch}/lib/libQt5Bootstrap"*.a
if [[ $NO_EXECUTABLES ]]; then
find "${pkgdir}/usr/${_arch}" -name '*.exe' -delete
else
find "${pkgdir}/usr/${_arch}" -name '*.exe' -exec ${_arch}-strip --strip-all {} \;
fi
find "${pkgdir}/usr/${_arch}" \( -name '*.bat' -o -name '*.def' -o -name '*.exp' \) -delete
find "${pkgdir}/usr/${_arch}" -name '*.dll' -exec ${_arch}-strip --strip-unneeded {} \;
find "${pkgdir}/usr/${_arch}" \( -name '*.a' -not -name 'libQt5QmlDevTools.a' -not -name 'libQt5Bootstrap.a' \) -exec ${_arch}-strip -g {} \;
done
}