# Maintainer: Martchus <martchus@gmx.net>
<%== content_for 'additional_contributors' %>\

# All my PKGBUILDs are managed at https://github.com/Martchus/PKGBUILDs where
# you also find the URL of a binary repository.

<%== content_for 'comment_header' %>\
pkgname=qt6-<%== $qt_module %>
<%== content %>\
groups=(qt6)
_pkgfqn="${pkgname/6-/}-everywhere-src-${_qtver}"
<%== include 'fragments/qt6-source' %>\
<%== include 'fragments/source_file_list', relevant_files => $patch_files %>)
sha256sums=('<%== stash('git_commit') ? 'SKIP' : $qt_module_sha256 %>'\
<%== include 'fragments/sha256_list', relevant_files => $patch_files %>)

build() {
  cmake -G Ninja -B build -S $_pkgfqn
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build

% if (stash('has_binaries')) {
  mkdir "$pkgdir"/usr/bin
  for b in "${pkgdir}"/usr/lib/qt6/bin/*; do
    ln -rs "$pkgdir"/usr/lib/qt6/bin/$(basename $b) "$pkgdir"/usr/bin/$(basename $b)-qt6
  done

% }
% unless (stash('no_libs')) {
  # Drop QMAKE_PRL_BUILD_DIR because reference the build dir
  find "$pkgdir/usr/lib" -type f -name '*.prl' \\
    -exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

% }
  install -d "$pkgdir"/usr/share/licenses
  ln -s /usr/share/licenses/qt6-base "$pkgdir"/usr/share/licenses/qt6-<%== $qt_module %>
}
