% layout 'mingw-w64-qt5-module';
\
#_fix_deps_of_static_3rdparty_libs='s:\(-L\/.*\/lib.*\.a\) \(\/.*\/libqt\)\(openwnn\|pinyin\|tcime\)\(d*\.a\)\(.*\):\2\3\4 \1 \5:g'        # -L is used (pre Qt 5.13)
_fix_deps_of_static_3rdparty_libs='s:\(LIBS *= *\)\(.*\)\(\/build\/.*\/libqt\)\(openwnn\|pinyin\|tcime\)\(d*\.a\)\(.*\):\1 \3\4\5 \2 \6:g' # absolute paths are used (Qt 5.13 and above)
pkgver=5.15.10
pkgrel=1
arch=('any')
pkgdesc="Virtual keyboard framework (translations, mingw-w64)"
depends=('mingw-w64-pkg-config' <%== qt5deps qw(declarative svg) %>)
makedepends=('mingw-w64-gcc')
license=('GPL3')
\
% content_for build_config_before_make => begin

      # fix dependency order for libqtopenwnn and other static 3rdparty libraries which depend Qt5Core and hence need
      # it subsequent on the linker line
      # (Not sure why qmake isn't smart enough to put it in the right order itself. It also appears that in Qt 5.12
      #  the order is messed in a different way than in Qt 5.11. Now it also seems to update the Makefile again unless
      #  touched to a date in the future.)
      make qmake_all
      find . \( -type f -name 'Makefile*' -o -name '*.prl' \) -exec sed -i "$_fix_deps_of_static_3rdparty_libs" {} \; -exec touch -d 300101 {} \;

% end
\
% content_for package_config_after_install => begin

      # apply the fix for the dependency order like in build
      find "${pkgdir}/usr/${_arch}/lib" \( -type f -name '*.prl' -o -name '*.pc' \) -exec sed -i -e "$_fix_deps_of_static_3rdparty_libs" {} \;
% end
