PKGBUILDs/qt5-base/mingw-w64/PKGBUILD

388 lines
16 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.
# All patches are managed at https://github.com/Martchus/qtbase
# Helper functions for the split builds
isDefault() {
[[ $pkgname = 'mingw-w64-qt5-base' ]] || [[ $pkgname = 'mingw-w64-qt5-base-static' ]]
}
isStatic() {
[ "${pkgname##*-}" = 'static' ]
}
isOpenGL() {
# Currently use native OpenGL by default
isDefault || \
[[ $pkgname = 'mingw-w64-qt5-base-opengl' ]] || [[ $pkgname = 'mingw-w64-qt5-base-opengl-static' ]]
}
isANGLE() {
[[ $pkgname = 'mingw-w64-qt5-base-angle' ]] || [[ $pkgname = 'mingw-w64-qt5-base-angle-static' ]] || \
[[ $pkgname = 'mingw-w64-qt5-base-dynamic' ]] || [[ $pkgname = 'mingw-w64-qt5-base-dynamic-static' ]]
# Treat dynamic version like ANGLE version, correct?
}
isDynamic() {
[[ $pkgname = 'mingw-w64-qt5-base-dynamic' ]] || [[ $pkgname = 'mingw-w64-qt5-base-dynamic-static' ]]
}
isNoOpenGL() {
[[ $pkgname = 'mingw-w64-qt5-base-noopengl' ]] || [[ $pkgname = 'mingw-w64-qt5-base-noopengl-static' ]]
}
pkgname=mingw-w64-qt5-base
pkgver=5.10.1
pkgrel=2
pkgdesc='A cross-platform application and UI framework (mingw-w64)'
# The static variant doesn't contain any executables which need to be executed on the build machine
isStatic && arch=('any') || 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')
groups=('mingw-w64-qt5')
optdepends=('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-pkg-config')
options=('!strip' '!buildflags' 'staticlibs' '!emptydirs')
_pkgfqn="qtbase-everywhere-src-${pkgver}"
source=("https://download.qt.io/official_releases/qt/${pkgver%.*}/${pkgver}/submodules/${_pkgfqn}.tar.xz"
'0001-Adjust-win32-g-profile-for-cross-compilation-with-mi.patch'
'0002-Ensure-GLdouble-is-defined-when-using-dynamic-OpenGL.patch'
'0003-Use-external-ANGLE-library.patch'
'0004-Fix-too-many-sections-assemler-error-in-OpenGL-facto.patch'
'0005-Make-sure-.pc-files-are-installed-correctly.patch'
'0006-Don-t-add-resource-files-to-LIBS-parameter.patch'
'0007-Prevent-debug-library-names-in-pkg-config-files.patch'
'0008-Fix-linking-against-shared-static-libpng.patch'
'0009-Fix-linking-against-static-D-Bus.patch'
'0010-Don-t-try-to-use-debug-version-of-D-Bus-library.patch'
'0011-Fix-linking-against-static-freetype2.patch'
'0012-Fix-linking-against-static-harfbuzz.patch'
'0013-Fix-linking-against-static-pcre.patch'
'0014-Fix-linking-against-shared-static-MariaDB.patch'
'0015-Fix-linking-against-shared-static-PostgreSQL.patch'
'0016-Rename-qtmain-to-qt5main.patch'
'0017-Build-dynamic-host-libraries.patch'
'0018-Enable-rpath-for-build-tools.patch'
'0019-Use-system-zlib-for-build-tools.patch'
'0020-Use-.dll.a-as-import-lib-extension.patch'
'0021-Merge-shared-and-static-library-trees.patch'
'0022-Pull-dependencies-of-static-libraries-in-CMake-modul.patch'
'0023-Allow-usage-of-static-version-with-CMake.patch'
'0024-Adjust-linker-flags-for-static-build-with-cmake-ming.patch'
'0025-Use-correct-pkg-config-static-flag.patch'
'0026-Fix-macro-invoking-moc-rcc-and-uic.patch'
'0027-Ignore-errors-about-missing-feature-static.patch'
'0028-Enable-and-fix-use-of-iconv.patch'
'0029-Ignore-failing-pkg-config-test.patch'
'0030-Prevent-qmake-from-messing-static-lib-dependencies.patch'
'0031-Hardcode-linker-flags-for-platform-plugins.patch'
'0032-Fix-linking-against-static-plugins-with-qmake.patch')
sha256sums=('d8660e189caa5da5142d5894d328b61a4d3ee9750b76d61ad74e4eee8765a969'
'1c482310bbfef78733a2013f42e505657059e720cf139ddcf5ad692c4dbf06b1'
'45a1020a351931b7171e55ef8165d2cc4af3bf2473b142daa51f3b5b15c447f3'
'ceb05dabed9fa2fc781e5abcfb54285960267922bac753df4179831a240da9b7'
'c4138094696342f8f976c01c9ce66919ae38802f36d3280b47883446e8d74bf9'
'2f99ae05056636b434bf7a533db6de7561c6f6e3fe8e854b4e9a182e30c684b3'
'fa69c484d557f45b1929e0b4be6328837717337155477a8fab3f9ea59731c749'
'57de459c6af72293560afcf7a872b1a4b10badd986c1fc1b43d7aaf55caf52c5'
'58e6f6a0271e82be5b7560a247cb70809169148e6413c473e2c3fed97e5d1c45'
'ea39d2b90a848a4c36a7685688283b773ff2ed5e6912be52a943f31376eefc81'
'b8f5a6a707f20cce64d9e5f04c35c555d7d14cd20344510205babc9a5698a15a'
'b1eaea87c7d7b774657feb4745450ab4e423c158ff81c144d724dcd8ac950c6f'
'8092fe23e35906b9a967ec78e1892769f06f1699c4c177ea0814876fb7c423d2'
'4b73f19e254466e5e4d13459088f773a44c9f05033ad5d29995c5116f18f999d'
'6a1411e406efab5521af71b2b8cf122c8443157114799f23d3e2cd1dc59c8e14'
'52b0fc09f05d1ca2efbf3a046cf933e72dae4bfd63026298fd60360103106c5a'
'30b5bded4f2e3ac5e4c83412c92afe0ad604e3eb18a94a3357f220b5e0456d86'
'1a18636d6089fe49ae7e0592dad6d71a1466aa0fc2d033ca926c14e468aff0c9'
'9710090523aefca66211bd8b74bcdc650125299912b735ba4845408e9e860649'
'551f05ad17737fe8b9b00c24a3a5539988455cbb706458e44c3df2df56599f63'
'd2f5aaacd2be586cfab27a23120a9f21749c1ac96664071c399f91097274ec89'
'23878d79148e4db9e1c5ba2e6e6d2ced259b64aa1ba2f1503ab9938863b2104f'
'30f5b6c738609a8ac03f806b86a632c3cf6d85b56e038f812d46358b592cc427'
'2782b7eb4f55cb5905b5bcb8387ad3a7130727b036b0fc482b1294380862f5d1'
'156e720e4ad44f257019dbe2fe1eef7b7a27989307f8a9f53072f4cbe178c655'
'53088ce6f9a22ee1735fb8b7145ce569ac1914ac05fb947ca3afae39d3cb3199'
'e61f2fd0c91c72822c1074844897641ce1c9500423b4c646aa8ae1671f9f967b'
'cccad985154167818657d0561ec349cb75931a0a64a689ab51041337d73a88b8'
'ffbc7f20785904ba64f108498aafe8b5a4c1de76c44aa5353ee3d7202f186408'
'1572c30c43e9e6d23d0f42c99c9501f092eae5d2bad2b0bc0eb694b295c0c473'
'ef96dffc0dd3bb76b237c6e886d6d5cc154e25f5ed4d5f65643e272a58306327'
'73d9df72df2f55c19ddeb9241de818d39c8da3399eee55f306889dc3c11dc934'
'892bb35a340597c77da5310685cc47102cf2522fb01cbc6d1785016babc78727')
_architectures='i686-w64-mingw32 x86_64-w64-mingw32'
isStatic && depends+=(${pkgname%-static})
if isANGLE; then
if isDynamic; then
makedepends+=('mingw-w64-angleproject')
optdepends+=('mingw-w64-angleproject: use ANGLE instead of native OpenGL')
else
depends+=('mingw-w64-angleproject')
fi
fi
if ! isDefault; then
if isStatic; then
provides+=('mingw-w64-qt5-base-static')
conflicts+=('mingw-w64-qt5-base-static' 'mingw-w64-qt5-base-angle-static' 'mingw-w64-qt5-base-noopengl-static'
'mingw-w64-qt5-base-dynamic-static' 'mingw-w64-qt5-base-openql-static')
else
provides+=('mingw-w64-qt5-base')
conflicts+=('mingw-w64-qt5-base' 'mingw-w64-qt5-base-angle' 'mingw-w64-qt5-base-noopengl'
'mingw-w64-qt5-base-dynamic' 'mingw-w64-qt5-base-openql')
fi
fi
patch() {
local input_found=
local patch_file=
for arg in $@; do
if [[ $input_found ]]; then
patch_file="$arg"
break
fi
[[ $arg == -i ]] && input_found=1
done
msg2 "Applying patch $patch_file"
/usr/bin/patch $@
}
prepare() {
cd "${srcdir}/${_pkgfqn}"
# Apply patches; further descriptions can be found in patch files itself
for patch in "$srcdir/"*.patch; do
patch -p1 -i "$patch"
done
# Make sure the Qt5 build system uses our external ANGLE library
rm -rf src/3rdparty/angle include/QtANGLE/{EGL,GLES2,GLES3,KHR}
# As well as our external PCRE library and zlib
rm -rf src/3rdparty/{pcre,zlib}
}
build() {
cd "${srcdir}/${_pkgfqn}"
# Do not set any flags here, flags are configured via mkspec
# Setting flags here is not appropriate as it does not allow to
# distinguish between flags for native compiler and cross compiler
unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
unset PKG_CONFIG_PATH
for _arch in ${_architectures}; do
# To prevent conflicts with the mingw-w64-qt4 package we have
# to put tools in a dedicated folder
# The last device option allows using ccache despite the use of
# pre-compile header
# (sloppiness must be set to pch_defines,time_macros in ccache config)
local qt_configure_args="\
-xplatform mingw-w64-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} \
-device-option CROSS_COMPILE_CFLAGS=-fpch-preprocess"
# Fix include directory of freetype2 and dbus
qt_configure_args+=" $(${_arch}-pkg-config --cflags-only-I freetype2 dbus-1)"
# Enable debug build if MINGW_W64_QT_DEBUG_BUILD is set (in /etc/makepkg.config)
[[ $MINGW_W64_QT_DEBUG_BUILD ]] \
&& qt_configure_args+=' -debug-and-release' \
|| qt_configure_args+=' -release'
# Configure usage of ANGLE/OpenGL
if isOpenGL; then
msg2 'Using native OpenGL backend'
qt_configure_args+=' -opengl desktop'
elif isNoOpenGL; then
msg2 'Building without OpenGL support'
qt_configure_args+=' -no-opengl'
elif isANGLE; then
if isDynamic; then
msg2 'Using dynamic OpenGL backend'
qt_configure_args+=' -opengl dynamic'
else
msg2 'Using ANGLE as OpenGL backend'
qt_configure_args+=' -angle'
fi
# GL_GLEXT_PROTOTYPES must be defined to enable declarations of GLES functions
qt_configure_args+=' -DGL_GLEXT_PROTOTYPES'
fi
# Fix MariaDB
qt_configure_args+=" -I/usr/${_arch}/include/mariadb"
msg2 'Configure and build qmake'
mkdir -p ../build-${_arch} && pushd ../build-${_arch}
if isStatic; then
export OPENSSL_LIBS="/usr/${_arch}/lib/libssl.a /usr/${_arch}/lib/libcrypto.a -lws2_32 -lgdi32 -lcrypt32"
../${_pkgfqn}/configure \
$qt_configure_args \
-static \
-openssl-linked
msg2 'Build static Qt libraries'
make
else
# The LD_LIBRARY_PATH override is needed because libQt5Bootstrap* are shared
# libraries which various compiled tools (like moc) use. As the libQt5Bootstrap*
# libraries aren't installed at this point yet, we have to workaround this
../${_pkgfqn}/configure \
$qt_configure_args \
-shared \
-openssl-runtime \
-device-option 'CROSS_COMPILE_CUSTOM_CONFIG=actually_a_shared_build'
msg2 'Build shared Qt libraries'
LD_LIBRARY_PATH="$PWD/lib" LDFLAGS="-L$PWD/lib" make
fi
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
if isStatic; then
# The static release contains only the static libs itself but relies on the
# shared release for Qt5Bootstrap library and tools (qmake, uic, ...)
# Drop Qt5Bootstrap and libraries which are only provided as static lib
# and are hence already present in shared build (such as Qt5OpenGLExtensions)
rm -f \
"${pkgdir}/usr/${_arch}/lib/"{lib,}qt5main* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5AccessibilitySupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5DeviceDiscoverySupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5EdidSupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5EventDispatcherSupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5FbSupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5FontDatabaseSupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5PlatformCompositorSupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5ThemeSupport* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5OpenGLExtensions* \
"${pkgdir}/usr/${_arch}/lib/"{lib,}Qt5PlatformSupport* \
"${pkgdir}/usr/${_arch}/lib/"libQt5Bootstrap* \
# Also ensure config files don't conflict with shared version
pushd "${pkgdir}/usr/${_arch}/lib/cmake"
for cmake_dir in $(find . ! -path . -type d ! -name 'Static*'); do
mkdir -p "./Static${cmake_dir:2}";
mv "${cmake_dir}/"* "./Static${cmake_dir:2}";
rm -r "${cmake_dir}"
done
rm -r "./StaticQt5OpenGLExtensions"
popd
rm "${pkgdir}/usr/${_arch}/lib/pkgconfig/StaticQt5OpenGLExtensions.pc"
# Create links to static plugins in lib directory
pushd "${pkgdir}/usr/${_arch}/lib/" && ln -s "./qt/plugins/"*/*.a . && popd
# Keep a couple pri files not found in base
mv "${pkgdir}/usr/${_arch}/lib/qt/mkspecs/modules/qt_plugin_"*.pri "${pkgdir}/usr/${_arch}"
# Delete duplicate files that are in the base package
rm -fR "${pkgdir}/usr/${_arch}/"{include,share}
rm -fR "${pkgdir}/usr/${_arch}/lib/"{qt/bin,qt/mkspecs}
# Move pri files back
mkdir -p "${pkgdir}/usr/${_arch}/lib/qt/mkspecs/modules"
mv "${pkgdir}/usr/${_arch}/"*.pri "${pkgdir}/usr/${_arch}/lib/qt/mkspecs/modules"
else # Shared release
# The .dll's are installed in both bindir and libdir, one copy of the .dll's is sufficient
find "${pkgdir}/usr/${_arch}/lib" -maxdepth 1 -name "*.dll" -exec rm {} \;
# The Qt5OpenGLExtensions module is only available as static library and hence part of the
# shared build
# 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
fi
# 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"
# Strip the binaries
if ! isStatic; then
strip --strip-all "${pkgdir}/usr/${_arch}/lib/qt/bin/"*[!.pl]
strip --strip-unneeded "${pkgdir}/usr/${_arch}/lib/libQt5Bootstrap"{,DBus}.so.${pkgver}
fi
# Applications might be useful as well; keeping them by default will not hurt anybody I suppose
if isStatic || [[ $NO_EXECUTABLES ]]; then
find "${pkgdir}/usr/${_arch}" -name "*.exe" -exec rm {} \;
else
find "${pkgdir}/usr/${_arch}" -name "*.exe" -exec ${_arch}-strip --strip-all {} \;
fi
# No use for these files though
find "${pkgdir}/usr/${_arch}" \( -name "*.bat" -o -name "*.def" -o -name "*.exp" \) -exec rm {} \;
# Strip binaries
find "${pkgdir}/usr/${_arch}" -name "*.dll" -exec ${_arch}-strip --strip-unneeded {} \;
find "${pkgdir}/usr/${_arch}" -name "*.a" -exec ${_arch}-strip -g {} \;
done
}