PKGBUILDs/qt5-base/mingw-w64/PKGBUILD

290 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.11+kde+r135
pkgrel=1
_basever=${pkgver%%+*}
_commit=b6867eef3dd3ac7e825e22b4ad4d2fc182cf20ff
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'
'bc889545b0486b17a03451b1f66e2f99d1d932632471a5b055ffdce97e2c4d0f'
'23c51a529968b0b070340a8f894c23496a28a14bf572868d144084f008848011'
'53dcb69be09c72394aee605cd041efafbc3a65fc5d8f7031093dfd5132698b4b'
'd325dea31991750ea6e723ae7a6498af282fc2d0dc498457809e25b5165da5bf'
'a0e57693ab82add358884b08a20e6a76c46ff37c0517ac35020fe686f9e26250'
'fd87249482995aca6dbf04d5b0bfd774d7144c49a6d71e7ef2dc933ead7e18c8'
'4531990f46c4d937b25fb9c2815eec1127cbf5b4c56fa504226047f56b4e9d96'
'9ecd7eaef3b3447762fe07b8021905832351c2a3ad2de6b057c08b147f4af06d'
'eb70362a0307bf96af8534de0da314c12673df6518cc94d95682e66201bfab43'
'7f7ea0ede86aa04f93fa960f84e2e450e28d39c240ff0e3bc6bc97e9ee3d8673'
'885a96fe07e42cdecf590119e22fe492f84e20f2564bc6ee8e7ff4c43949c461'
'6a2a5615f96e5f9eb51bbfca41d61b299ac2000097eb2e919705a85d258f2736'
'd7102c593422b3f172de40789b8a27427afbb1bcfbbe4b165bf2ffe139346045'
'b7c96667d2b73748ef911cfef9b714c05f1f4f0253576a9a1cd725cb62b62a1a'
'a4fdfe1f6383d0dc51b4cc898f415a37494ebd478db105daf036244b9a5f27c0'
'c32cccabeea035f91d3436fbad07f8ce63453ea3c82b69d88c7876a474ebbcb4'
'd34ac9ab2302b9c380f400eed50ca056ea9fd2412c5a97eb0746fca7a43921d6'
'5a31c5857a14f66f0e53d10f756c3ae6b46ac5ccffc790acf599a93812d68230'
'7e3de1428531b6d9225a0045c5fe4b2d3d5e4a12e211c4e44e7fc2045a8911b0'
'25a1de3adc46b4daac58cc7d83cd230522058b48aad2492251dd4d7c898a7993'
'c9a49609d6a126375da7465d203db602de3b7b9118214f97f9960001b9ad6a35'
'1021c5a078e9d59ee68be81ef1921a919a7d3f517d0ef619ed8266276fdef46b'
'b8902c748ae6f4c9b974780bf0f853ba6068a269b18ac667ac5eb8927de129fa'
'fb95bcfc8d76a774fa8d5c4f40becc381c35b7442ae882cd56b638627816d3f4'
'b1bdc2c14b99869a34f2894f88873b150cb2e9e6ef2c41f65846685489167412'
'2768a79e5d4c98111ecfdadb05ce5325a902f67d1357e1f3c655c5adca28a9be'
'30a7aa33a21fd4e620f023ee6dcecdef468c12b3c631555c12f4091f0b6e4d80'
'f2323e6aa5ff97e9517adf343fde65dbaaa7696bd368bbf6be7ae7eb6cd930f8'
'4511e3ce148f5016eb1b1ec021c942ef437b08ebbd4f3195fd263735e5940a0a'
'22ff54ddfebfa08d2721d6c0b9398376d99b84d7a63dcf72f6c91c5b8ed3cb89'
'ef3549c142c604db36737f6665e38c06b331c9eb1948c7e8860abb976ef4f025'
'6c9f598777fd6c1c35ab85bacb17e7022b66afe223b1720e240c34228cedfd22')
_architectures='i686-w64-mingw32 x86_64-w64-mingw32'
pkgver() {
cd $_pkgfqn
echo "$_basever+kde+r"`git rev-list --count v$_basever-lts-lgpl..$_commit`
}
prepare() {
cd "${srcdir}/${_pkgfqn}"
# 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
}