# FIXME: create directory in prior because of the error below
# qt.qdoc: Cannot find index directory:  "/var/cache/acbs/build/acbs._ulyv6k4/qt-everywhere-src-6.11.1/abbuild/share/doc/qt-6"
# LIBCLANG FATAL ERROR: IO failure on output stream: Bad address
if ab_match_arch loongson3; then
    abinfo "Creating directory ..."
    mkdir -pv "$SRCDIR"/abbuild/share/doc/qt-6
fi

abinfo "Building Qt 6 documentation ..."
cmake --build "$BLDDIR" --target docs

abinfo "Installing Qt 6 documentation ..."
DESTDIR="$PKGDIR" cmake --build "$BLDDIR" --target install_docs


# As PKGBUILD of qt6-doc of Arch Linux says, The various
# example dirs have conflicting project files, but QtCreator 
# requires them to be in the same top-level directory.
# Matching the Qt installer, only the qtbase project is kept.
abinfo "Installing Qt 6 examples..."
EXAMPLESDIR="$PKGDIR"/usr/share/doc/qt-6/examples
[ -d "$EXAMPLESDIR" ] || mkdir -pv "$EXAMPLESDIR"

cp -v "$SRCDIR"/qtbase/examples/{examples.pro,CMakeLists.txt,README} "$EXAMPLESDIR"
for dir in `find "$SRCDIR" -maxdepth 2 -type d -name examples`
do
    rm -fv "$dir"/{examples.pro,CMakeLists.txt,README}
    cp -rv "$dir"/* "$EXAMPLESDIR"
done
