PKGBUILDs/qt5-base/mingw-w64-static/PKGBUILD

404 lines
18 KiB
Bash
Raw Normal View History

2016-02-03 20:42:14 +01:00
# Maintainer: Martchus <martchus@gmx.net>
# Contributor: ant32 <antreimer@gmail.com>
# Contributor: Filip Brcic <brcha@gna.org>
# Contributor: jellysheep <max.mail@dameweb.de>
# 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
# There are different variants of the package which can be selected by simply adjusting pkgname:
# - mingw-w64-qt5-base or mingw-w64-qt5-base-opengl: using native OpenGL
# - mingw-w64-qt5-base-angle: using ANGLE rather than native OpenGL
# - mingw-w64-qt5-base-dynamic: allows choosing between ANGLE and native OpenGL dynamically at runtime
# - mingw-w64-qt5-base-noopenql: no OpenGL support
# The variants are conflicting (and hence can not be installed at the same time).
# See also: http://doc.qt.io/qt-5/windows-requirements.html#dynamically-loading-graphics-drivers
# The variants listed above only contain dynamic libraries. For building static libraries
# just append '-static' to the package name, eg. mingw-w64-qt5-base-static or mingw-w64-qt5-base-angle-static.
# The static variants rely on the corresponding dynamic variant for headers and tools.
# I only tested the static version using native OpenGL so far (mingw-w64-qt5-base-static).
# Note that ANGLE will still be loaded as dynamic library in mingw-w64-qt5-base-dynamic-static.
# By default CMake and qmake will link against the dynamic Qt libraries.
# To use the static Qt libraries with CMake prefix the Qt module with Static:
# eg. find_package(Qt5Core) becomes find_package(StaticQt5Core)
# To use a static module, add the corresponding imported target, eg.
# target_link_libraries(target ... Qt5::static::Core)
# This approach allows installing dynamic and static Qt in the same prefix and using
# both variants in the same CMake project.
# To use a static plugin, add the corresponding imported target, eg.
# target_link_libraries(target ... Qt5::static::QWindowsIntegrationPlugin)
# Automatically importing static plugins is currently not possible, though. Hence it is required to use Q_IMPORT_PLUGIN, eg.
# #include<QtPlugin>
# Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
# To use the static Qt libraries with qmake set the following variables (either inside the *.pro file or as qmake argument):
# CONFIG+=static
# Further Qt modules (those not found in the base repository and hence not included in this package) include by default
# static and dynamic libraries; if only one version is requried, just set $NO_STATIC_LIBS or $NO_SHARED_LIBS when building
# the package.
# By default, executables will not be removed because I find them useful when testing. To remove executables
# set $NO_EXECUTABLES (or $NO_STATIC_EXECUTABLES to remove statically linked executables only) when building the package.
# If Qt modules containing tools are built as static and as dynamic library only the dynamically linked tools will be present
# in the package.
# Qt packages can be built in the following order (for example):
# qt5-base qt5-base-static qt5-declarative qt5-tools qt5-xmlpatterns qt5-script qt5-location qt5-multimedia qt5-sensors qt5-webchannel qt5-3d qt5-imageformats qt5-quickcontrols qt5-quickcontrols2 qt5-translations qt5-svg qt5-websockets qt5-winextras qt5-serialport qt5-canvas3d qt5-connectivity qt5-charts qt5-gamepad qt5-scxml qt5-datavis3s qt5-virtualkeyboard qt5-activeqt qt5-webkit
# 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-static
2017-06-02 18:20:04 +02:00
pkgver=5.9.0
pkgrel=1
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'
2017-06-02 18:20:04 +02:00
'mingw-w64-libpng' 'mingw-w64-openssl-1.0' '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')
2016-02-03 20:42:14 +01:00
_pkgfqn="qtbase-opensource-src-${pkgver}"
source=("https://download.qt.io/official_releases/qt/${pkgver:0:3}/${pkgver}/submodules/${_pkgfqn}.tar.xz"
'0001-Add-profile-for-cross-compilation-with-mingw-w64.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'
2017-06-02 18:20:04 +02:00
'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-Disable-determing-default-include-and-lib-dirs-at-qm.patch'
'0021-Use-.dll.a-as-import-lib-extension.patch'
'0022-Merge-shared-and-static-library-trees.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')
sha256sums=('267eb2af1a203c087f2113f43b08014d0e2d2cb269295b8602d869a2fad5296c'
'b4406bba39ee7c8cf74c3b8a98b936b46772ca1798ef6884b7b1574ece80fbdc'
'86cf470f1694abf6973f7b0f8e6cb75dd8a58e9335bab075b25229d26064adab'
'670b6cd7a6ee49f12ccf4121e997055daec887d080baf0269793b1d0243d1d89'
'878c08a1e9d0c8d639ddbdbc944ac8647ff204e9f078ddd9337737b2b929c2ed'
'38533dba16df99074e8c3f5d52bc15fabdbaffe0a56dbed79683c47f08342587'
'5ef3a569f4c53e848750ff655342e92a103abe78495905a5ef47afea9da8d1fb'
'd21ebc9465a19e01912ebccb365b4f7ecfd3a95787c1de2640f29bdbc161983c'
'0622a2e606d9edbea23d3a5724ea9d4ed3958e60296b85134176c3980d590a41'
'90f1347e5c41b9e447c0339715d19e0434a0b58c36fd8405e850190fe17369dc'
'6b6ebfdf598658172680e4e83d2c3de24dcbc93233b0f48d5ccbf760d8f59a5c'
'11ce05f79174440406d84b38023d81c1fa87034119360fa2f0bd3887429fa694'
'c30c558ea413c986aec2ffe86e34dd8e99f96cbc615e3963f711ec1628888114'
'b9fbfc213089e3b44ed888f4e628030e78dd84c8030ba7a2a9f79fbf31312934'
'94ebedf699ebc0a5c6fed307eecd3dfabf9f864c696f3cf17bd8462789c1fae2'
'df05b0f65dcafede1f83ce190895e6c6f4a22feecb1c5b1a0ba03f4948e56220'
'0acae3adb542d6ea0b405a947adf087826b4971df133b984d9166a9872e5cc98'
'bb825226ca1e97cb49c3ac3a0c03a7db9f3e1eca632628d344201fcf9816376d'
'e74fb8219bf599fbe5fbd1b08ff89d717089f1fa4d9e488a60e6097b212b7391'
'cf3f90b69feb98e42ede770828db4538a3dd31dd02b2b15f55ea1743db5868ad'
'813cd1c22e3211133337231e1df754b5560159eecf1cf3eef0408d335e186190'
'a0feb7b5a9747d6a88058360fc34f8ac8fb3cdeb2b343a5a2b28a88fdabb45b3'
'82f8f1eba6ac63c9a8749e20eb57fad80e92ddd5a58912a60a8c2fad9e83d6eb'
'34652aec17d7511815db59b438b0597e52b7f43c19d068e7e417325897a72254'
'dcfe2103ace81898960316dd691fae38d05b2b6a79dc0ae0f245ae402f1101a8'
'0682dcc62b44717fa850700cec183cd856ce7335f26884ab15d4d0e7d3543bfe'
'cecf5ff2916d95ffdbcf60ba3e18297a6107e17e9766a5e4d8b9ae748d99ba52'
'79bc920bb539fc68001b5def07eea3e45eb3d2c6aa3f2a949823236adf8e4633'
'80757f614fe02bfb85d00292d4f84c9f2ab2c39a512c21e956df135f3fbfdd81'
'cc46ffc3a2183539aba923fb256045464eaae37a666034172138f4689a5c9bd3'
'f0e63e022d1e52b82a7622828b568c57d1422f9726e116902cd2be81fec45da4'
'28b11e63f570891212073b3739a20489304d3c7205ae38471cbd6b15c651fabc')
_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 $@
}
2016-02-03 20:42:14 +01:00
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
2016-02-03 20:42:14 +01:00
# Make sure the Qt5 build system uses our external ANGLE library
rm -rf src/3rdparty/angle include/QtANGLE/{EGL,GLES2,GLES3,KHR}
2016-02-03 20:42:14 +01:00
# 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
2016-02-03 20:42:14 +01:00
unset LDFLAGS
unset PKG_CONFIG_PATH
2016-02-03 20:42:14 +01:00
for _arch in ${_architectures}; do
2017-06-02 18:20:04 +02:00
echo "INCLUDEPATH += /usr/${_arch}/include/openssl-1.0" >> src/network/network.pro
2016-02-03 20:42:14 +01:00
# Phonon is disabled for now because we lack the directx headers
2016-09-17 16:23:20 +02:00
# FIXME: check whether this is still the case
# To prevent conflicts with the mingw-w64-qt4 package we have
# to put tools in a dedicated folder
2016-09-17 16:23:20 +02:00
# The last device option allows using ccache though 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++ \
2016-02-03 20:42:14 +01:00
-optimized-qmake \
-verbose \
-opensource \
-confirm-license \
-force-pkg-config \
-force-debug-info \
-system-zlib \
-system-libpng \
-system-libjpeg \
-system-sqlite \
-system-freetype \
2016-02-03 20:42:14 +01:00
-system-harfbuzz \
-system-pcre \
2016-02-03 20:42:14 +01:00
-no-fontconfig \
-sql-mysql \
-sql-psql \
-sql-sqlite \
2016-02-03 20:42:14 +01:00
-openssl \
-dbus-linked \
-no-glib \
-no-icu \
-iconv \
2016-02-03 20:42:14 +01:00
-release \
-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 \
2016-09-17 16:23:20 +02:00
-device-option CROSS_COMPILE=${_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)"
2016-02-03 20:42:14 +01:00
# Configure usage of ANGLE/OpenGL
if isOpenGL; then
msg2 'Using native OpenGL backend'
2016-03-07 21:16:08 +01:00
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
2016-03-07 21:16:08 +01:00
qt_configure_args+=' -DGL_GLEXT_PROTOTYPES'
fi
2016-02-03 20:42:14 +01:00
# Fix MariaDB
qt_configure_args+=" -I/usr/${_arch}/include/mariadb"
2016-02-03 20:42:14 +01:00
2016-06-17 23:55:59 +02:00
mkdir -p ../build-${_arch} && pushd ../build-${_arch}
2016-02-03 20:42:14 +01:00
if isStatic; then
../${_pkgfqn}/configure -static $qt_configure_args
2016-02-03 20:42:14 +01:00
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 -shared $qt_configure_args
2016-06-17 23:55:59 +02:00
LD_LIBRARY_PATH="$PWD/lib" LDFLAGS="-L$PWD/lib" make
2016-02-03 20:42:14 +01:00
fi
popd
done
}
package() {
for _arch in ${_architectures}; do
cd "$srcdir/${_pkgfqn}"
make install -C ../build-${_arch} INSTALL_ROOT="${pkgdir}"
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, ...)
2016-02-03 20:42:14 +01:00
# 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,}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* \
2016-12-20 23:05:26 +01:00
"${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"
# Keep various Qt 5 plugins to be used in static builds
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}"
2016-02-03 20:42:14 +01:00
# 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 {} \;
2016-02-03 20:42:14 +01:00
# The Qt5OpenGLExtensions module is only available as static library and hence part of the
# shared build
# Create symlinks for tools
2016-02-03 20:42:14 +01:00
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"
2016-02-03 20:42:14 +01:00
done
fi
# Remove doc
2016-02-03 20:42:14 +01:00
rm -rf "${pkgdir}/usr/${_arch}/share/doc"
# Strip the binaries
2016-02-03 20:42:14 +01:00
if ! isStatic; then
strip --strip-all "${pkgdir}/usr/${_arch}/lib/qt/bin/"*[!.pl]
2016-02-03 20:42:14 +01:00
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
2016-02-03 20:42:14 +01:00
find "${pkgdir}/usr/${_arch}" -name "*.dll" -exec ${_arch}-strip --strip-unneeded {} \;
find "${pkgdir}/usr/${_arch}" -name "*.a" -exec ${_arch}-strip -g {} \;
2016-02-03 20:42:14 +01:00
done
}