# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem                  1.0
PortGroup                   active_variants 1.1
PortGroup                   qt6_info 1.0

name                        qt6

categories                  aqua
platforms                   {macosx >= 23} ; # upon change, please update qt6 PG
maintainers                 {mcalhoun @MarcusCalhoun-Lopez} \
                            {reneeotten @reneeotten} openmaintainer

# for OpenSSLException, see source and header files in src/network/ssl of qtbase
# see also https://doc.qt.io/qt-6.9/qtnetwork-index.html#licenses-and-attributions
license                     {LGPL-3 GPL-3 OpenSSLException}

homepage                    https://www.qt.io

version                     6.9.2

# get Qt's version numbers
set branch                  [join [lrange [split ${version} .] 0 1] .]
set qt_major                [lindex [split ${version} .] 0]

# see https://www.qt.io/blog/qt-6.9-released
compiler.c_standard         2011
compiler.cxx_standard       2017

# qcompilerdetection.h emits:
#     error: "Unsupported Apple Clang version"
# which also means Q_CC_CLANG will not be set.
# That causes the check for __has_feature(cxx_unicode_literals) to be skipped, causing
#     error: "Qt6 requires Unicode string support in both the compiler and the standard library"
# to be emitted, even when the unsupported Apple Clang version does support Unicode string literals.
compiler.blacklist-append   {clang < 1100}

master_sites                https://download.qt.io/official_releases/qt/${branch}/${version}/submodules
# file sizes are significantly smaller using xz
use_xz                      yes

supported_archs             arm64 x86_64

# conflict with all other versions of qt6
foreach {qt_base qt_info} ${qt6::available_versions} {
    if { ${qt_base} ne ${name} } {
        conflicts-append    ${qt_base}-qtbase
    }
}

if {${os.platform} eq "darwin" && [vercmp ${macosx_deployment_target} >= 15.0]} {
    macosx_deployment_target 14.0
}

# cannot get qt6-qtbase to configure without setting this
use_xcode                   yes

# MacPorts LLVM/Clang version to use when required
set llvm_version            19

# MacPorts Python branch & version to use when required
set python_branch           3.13
set python_version          [join [split ${python_branch} .] ""]

############################################################################### Modules Not Considered
#
# No qtactiveqt      (Windows Only)
# No qtwayland       (Linux Only)
#
###############################################################################

############################################################################### Qt Dependencies
#
# https://code.qt.io/cgit/qt/qt5.git/tree/.gitmodules?h=6.9.2
#
###############################################################################

############################################################################### Module Format
#
# "Qt Module Name" {
#     {
#         checksum, rmd160
#         checksum, sha256
#         checksum, size
#     }
#     dependencies, build
#     dependencies, lib
#     dependencies, Qt module name
#     Qt components provided
#     included in "standard" installation of Qt (empty string is no, explanation string is yes)
#     variant overrides
#     revision number
#     license replacement
# }
#
# module info found at https://doc.qt.io/qt-6.9/qtmodules.html
#
###############################################################################
array set modules {
    qtbase {
        {
            6b278a57658ae35e8104be58df338abe8f3dabc3 \
            44be9c9ecfe04129c4dea0a7e1b36ad476c9cc07c292016ac98e7b41514f2440 \
            49812824
        }
        ""
        "port:brotli path:bin/dbus-daemon:dbus port:double-conversion port:freetype
            path:lib/pkgconfig/glib-2.0.pc:glib2 path:lib/pkgconfig/harfbuzz.pc:harfbuzz
            path:lib/pkgconfig/icu-uc.pc:icu path:include/turbojpeg.h:libjpeg-turbo port:libb2
            port:libpng port:md4c path:lib/pkgconfig/libpcre2-posix.pc:pcre2
            port:zlib path:lib/pkgconfig/libzstd.pc:zstd"
        ""
        {"Qt Core" "Qt GUI" "Qt Network" "Qt SQL" "Qt Test" "Qt Widgets" "Qt Concurrent" "Qt D-Bus" \
         "Qt OpenGL" "Qt Platform Headers" "Qt Print Support" "Qt XML"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtsvg {
        {
            d7d36ce4ae2202b154a113f36f4dbf50e5f71b35 \
            d984cab8f26334aa1c15e5b8f0cd9f1b7c0c1289fe0b68c1c84ab469b75605a5 \
            2004052
        }
        ""
        "port:zlib"
        "qtbase"
        {"Qt SVG"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtdeclarative {
        {
            e9db403f1d7dcfffa8b5c730b45ff7cb408fea1e \
            477f2d2c0bd98916107818725e6d498206e033dfb2859c52121e01a06ac42664 \
            37207872
        }
        ""
        ""
        "qtbase qtimageformats qtshadertools qtsvg qtlanguageserver"
        {"Qt QML" "Qt Quick" "Qt Quick Layouts" "Qt Quick Widgets"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtmultimedia {
        {
            596406c5e1774ccc0296faa4eabc410a55fa2173 \
            7bf8a19a57a7432181b05d0e264acfd8ca4b75a3901d01a27a32935703e5ab12 \
            9768828
        }
        ""
        "port:ffmpeg7 port:pulseaudio"
        "qtbase qtshadertools qtdeclarative qtquick3d"
        {"Qt Multimedia"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qttools {
        {
            98f3f47e4238003d276a68ca41e8835d8d22ea0a \
            d8b7f7e8e970cc0b975205fd6d5832ea917ef3e751df69b97439c1cddd67a489 \
            10330412
        }
        ""
        "port:clang-${llvm_version} path:lib/pkgconfig/libzstd.pc:zstd"
        "qtbase qtdeclarative"
        {"Qt Designer" "Qt Help" "Qt UI Tools"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qttranslations {
        {
            4ce22a4e01298e9deba665f303f7d5c499108b55 \
            c73bb6281ed365c0f954f4b1b6e1b13e1b3fefd94854f46fcd9a412f641f7ed6 \
            1628840
        }
        ""
        ""
        "qttools"
        {"translation files"}
        ""
        "variant overrides: ~examples ~tests ~debug noarch ~docs"
        "revision 0"
        "License: "
    }
    qtdoc {
        {
            5cbfd0a6502df5e0a8d9288f8d53d4954841144e \
            3fdabbb6556564fc8cdbdb7a98d41e827d6a09dd086255904532e78a3515cf62 \
            46187424
        }
        ""
        ""
        "qtdeclarative qttools qtmultimedia"
        {"documentation and examples"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtlocation {
        {
            4e92fa3aa0e8869cbb675afb6009405ba7578d00 \
            5a45ed1967958982899b79891afc0b4530cf2e59d3b1a57af6dfdc645e1c73f9 \
            3149364
        }
        ""
        ""
        "qtbase qtpositioning qtdeclarative"
        {"Qt Location"}
        "status = preview"
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtpositioning {
        {
            80558eec8371d187397a7d19715bc8bff9e151c0 \
            489a9801ffbda04b16c62f64a687efae4c1a07807f6b67f40ce1f37c3dfdbc1a \
            649488
        }
        ""
        "port:gconf port:gettext-runtime path:lib/pkgconfig/glib-2.0.pc:glib2"
        "qtbase qtdeclarative qtserialport"
        {"Qt Positioning"}
        ""
        "variant overrides: ~examples ~tests"
        "revision 0"
        "License: "
    }
    qtsensors {
        {
            346fe75b22c1797c3548dc32e3f17bdf51531617 \
            964ca82f39e2e25f952dc2f072f4c602392faf4ee9ce812b1957d4b8c9314462 \
            1485268
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt Sensors"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtconnectivity {
        {
            7b2e69a20df832eb2e5bfe1ee9244d1e8161e434 \
            8affc67146dd6a2eb4b007623b47584b4783ff338bbe27725a0b6963216a0463 \
            1057556
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt Bluetooth" "Qt NFC"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qt3d {
        {
            8135d613a5906bb3112d1bbc8dd3ea6f2b4b77b3 \
            aa6e023b8b5605f212cc52c46c1a8b74bd2ca67d01473d305b5b48a7972bb659 \
            141825804
        }
        ""
        "port:assimp port:zlib port:minizip port:pugixml"
        "qtbase qtdeclarative qtshadertools"
        {"Qt 3D"}
        "status = deprecated"
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtimageformats {
        {
            ae23d51c851744c789cb9ab4ea2c7c9564bb89da \
            8a023f7e2f57dedc02e2ab10c975f7cb3cccac9b8f0823c12fd6824834549139 \
            2021564
        }
        ""
        "path:lib/pkgconfig/jasper.pc:jasper port:libmng port:tiff port:webp
            path:include/turbojpeg.h:libjpeg-turbo"
        "qtbase"
        {"Qt Image Formats"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtserialbus {
        {
            31a1a929e3bcf0c10124d9ef5eb3e0039a5e1a27 \
            951e07c2faf4476c75a59af96b40eeedbdf1a1c5c354c2825b59eaf3594f2a76 \
            535216
        }
        ""
        ""
        "qtbase qtserialport"
        {"Qt Serial Bus"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtserialport {
        {
            f1723b8724e4d81ef9e26e324908a09f27bc9ce1 \
            8b90b2f0c2c07ab13085acf584a34201931477422f2d37a9694d62a2d56ce26b \
            263012
        }
        ""
        ""
        "qtbase"
        {"Qt Serial Port"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtwebsockets {
        {
            a2c7e094555b24f66e7bc5dd772faeca5987d3eb \
            be833f667ed8d6c2f41c0b9d1f8addf20b8d2b11c3a9466ec6d70c62121708ee \
            447432
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt WebSockets"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtwebchannel {
        {
            230e525b0d8963b5d73f1265d2795a3555e10cc9 \
            878a6337ad4d2c2a1de5bedb28c36b05b2733242d10f6c3d0eae55c5433c8e65 \
            193888
        }
        ""
        ""
        "qtbase qtdeclarative qtwebsockets"
        {"Qt WebChannel"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtwebengine {
        {
            0324a663fd25f46466bc8b3d4f5a535d4648ca40 \
            99cb0792abc2e39b299d73d8e2aa076b9ebcd55c3f4a4b5fd514eef5a62d03ab \
            672191852
        }
        "path:bin/node:nodejs20 port:python${python_version} port:py${python_version}-html5lib port:py${python_version}-ply"
        "port:libpng port:zlib"
        "qtdeclarative qtwebchannel qttools qtpositioning"
        {"Qt WebEngine Qt" "Qt PDF"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtwebview {
        {
            511f7c9d6cc435eefc17c780a2081a8749b597df \
            4ccfd14ae68222d5709e54c970da51d7f0b4cf58af045a96935dfcc34f1b1ff1 \
            125560
        }
        ""
        ""
        "qtdeclarative qtwebengine"
        {"Qt WebView"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtcharts {
        {
            96d582b3342ff6c2fda7766df5619b72ba03f2fb \
            9f01f15f64e73f18ee8b17b490c1b0ca02e969bc58919cf46bd1152c01a4ff4b \
            4649540
        }
        ""
        ""
        "qtbase qtdeclarative qtmultimedia"
        {"Qt Charts"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtdatavis3d {
        {
            e116a533311b419e962567b8c724e852890c9333 \
            5dff1ca1a8754111977135a8904f42315544b06006281a961c1d160454dccb5c \
            3939532
        }
        ""
        ""
        "qtbase qtdeclarative qtmultimedia"
        {"Qt Data Visualization"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtvirtualkeyboard {
        {
            e298d12a7352c6d050fab25155a896cd48d7df52 \
            7b4100da01bafa72e20ab4e1459dcda1e6048e70b4d650b3c578613f0ffc11e3 \
            3275760
        }
        ""
        "port:hunspell"
        "qtbase qtdeclarative qtsvg qtmultimedia"
        {"Qt Virtual Keyboard"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtscxml {
        {
            819ab73f2c24fc332de13e022750ffdeae7c3b84 \
            e06af183012996a64f07745064318303d3765959ebba29489f8af0f50f32ebb6 \
            545560
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt SCXML"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtspeech {
        {
            98a26beaa6007a3e65ad67f032a5bb3145ac3750 \
            b2b667375111637e45517a6e63475987691b922a19900abc52996617a0a088b1 \
            247748
        }
        ""
        "port:flite"
        "qtbase qtdeclarative qtmultimedia"
        {"Qt TextToSpeech"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtnetworkauth {
        {
            ddc9ba1cd296225f6128d6542630971515679012 \
            2165d9568eb8ab9f3cb91abdb0e72c17fe7a70707150ef1738db94e75f318c84 \
            432076
        }
        ""
        ""
        "qtbase"
        {"Qt Network Authorization"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtremoteobjects {
        {
            54bdc2b0e652746179c2ba67529fac63779eacf6 \
            df624ef14befbc92a293f2c193c5a7fd5d3f9d795fb33cc38b4e0b869bf18b26 \
            528608
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt Remote Objects"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtlottie {
        {
            e39d04c4f3297685708f635a08078e7a2d66f1af \
            a4df93d2dd5c5942f1dc23e29667199fbf5cfaba84a51e6a9ffc874b967e31c6 \
            83560
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt Lottie Animation"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtquicktimeline {
        {
            a88ab7a04db19f6a531d6d450c66792f064281fb \
            bc65688d8cb588ff67d32a63a821163211452ae7cb07dd07c261230f380ec526 \
            97140
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt Quick Timeline"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtquick3d {
        {
            7e28cb2a8bdd1f1c1bf45391458f828dd2b6aa2b \
            2f0e97b0d29ecabb976d7f3dc23873a2d6415ba4d48d4090ddb54feb3a424800 \
            74198672
        }
        ""
        "port:assimp"
        "qtbase qtdeclarative qtshadertools"
        {"Qt Quick 3D"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtshadertools {
        {
            60e371821583884f61f84bc8a1306930fc899948 \
            17678af9d9543224bbb932bf18d4fc05e180b2b3a3216241e557631bd6bf1495 \
            1151576
        }
        ""
        ""
        "qtbase"
        {"Qt Shader Tools"}
        ""
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qt5compat {
        {
            3fd4e2a294183db01201ac247322127dcae4370b \
            cb289905c689fc271ce783f8b67844040aa73d78f4f0cf8421fa713390a75b60 \
            14618016
        }
        ""
        "path:lib/pkgconfig/icu-uc.pc:icu port:libiconv"
        "qtbase qtdeclarative"
        {"Qt 5 Core Compatibility APIs"}
        "status = deprecated"
        "variant overrides: "
        "revision 0"
        "License: "
    }
    qtlanguageserver {
        {
            83cbe974a625c125caf25081f87eb306f77f1f73 \
            781b6eafe1fe1ab7e942fb15dc220b79c602db6efdce7fdc272bf8512c068bee \
            137008
        }
        ""
        ""
        "qtbase"
        {"Qt Language Server"}
        "status = preview"
        "variant overrides: ~docs"
        "revision 0"
        "License: "
    }
    qthttpserver {
        {
            1b4fe0c1309dd4a36cdc7f2e9d5c40baceff494e \
            1343fa1d1d6dfda9b9de4a1ff36471b6ff4bd16f9ee7c19deb098c15e4714019 \
            175292
        }
        ""
        ""
        "qtbase"
        {"Qt HTTP Server"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtquick3dphysics {
        {
            4b9536f340a3e8cfa65d14d8251ba608116c7bdb \
            87fc6485638f52cd33dc1a755a11c78fd992e438fe77ef53e0ca57c63505cc8b \
            4668516
        }
        ""
        ""
        "qtbase qtdeclarative qtquick3d qtshadertools"
        {"Qt Quick 3D Physics"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtgrpc {
        {
            04105f679945abd65544852c7f257beb5c1af917 \
            a43d3c8823fe11b71d0c362527150914134239fa285feaff86fd692617353f64 \
            602148
        }
        ""
        ""
        "qtbase qtdeclarative"
        {"Qt GRPC"}
        "GPLv3 license only"
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
    qtquickeffectmaker {
        {
            7e0eef777134eb638b732658691c3e2f6e5ffdb3 \
            7985f1496ed411e3a3ae06ca55c8e37825e1c7f1c25ed4d120a68909ee0dd8f9 \
            4342904
        }
        ""
        ""
        "qtbase qtdeclarative qtquick3d qtshadertools"
        {"Qt Quick Effects"}
        ""
        "variant overrides: "
        "revision 0"
        ""
    }
    qtgraphs {
        {
            32a5d499071e66a16afcb0b163f739b5eec307e1 \
            a780fb639011a8b2a8cff28275886d7d705de991a300ea698cb0899255244a73 \
            5214768
        }
        ""
        ""
        "qtbase qtdeclarative qtquick3d"
        {"Qt Graphs"}
        ""
        "variant overrides: "
        "revision 0"
        "License: {GPL-3 OpenSSLException}"
    }
}

############################################################################### SQL Plugin Format
#
# {
#     module name
#     {
#         SQL name
#         revision string
#         {list of feature names}
#         {
#             variant name
#             {
#                 variant name
#                 library dependencies
#                 {list of CMake options to find library}
#             }
#         }
#     }
# }
#
###############################################################################
array set sql_plugins {
    sqlite {
        SQLite
        "revision 0"
        {sql-sqlite system-sqlite}
        {
            sqlite3 {
                "port:sqlite3"
                {
                    -DSQLite3_INCLUDE_DIR=${prefix}/include
                    -DSQLite3_LIBRARY=${prefix}/lib/libsqlite3.dylib
                }
            }
        }
    }
    psql {
        PostgreSQL
        "revision 0"
        {sql-psql}
        {
            postgresql17 {
                "port:postgresql17"
                {
                    -DPostgreSQL_INCLUDE_DIR=${prefix}/include/postgresql17
                    -DPostgreSQL_TYPE_INCLUDE_DIR=${prefix}/include/postgresql17
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib/postgresql17
                }
            }
            postgresql16 {
                "port:postgresql16"
                {
                    -DPostgreSQL_INCLUDE_DIR=${prefix}/include/postgresql16
                    -DPostgreSQL_TYPE_INCLUDE_DIR=${prefix}/include/postgresql16
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib/postgresql16
                }
            }
            postgresql15 {
                "port:postgresql15"
                {
                    -DPostgreSQL_INCLUDE_DIR=${prefix}/include/postgresql15
                    -DPostgreSQL_TYPE_INCLUDE_DIR=${prefix}/include/postgresql15
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib/postgresql15
                }
            }
            postgresql14 {
                "port:postgresql14"
                {
                    -DPostgreSQL_INCLUDE_DIR=${prefix}/include/postgresql14
                    -DPostgreSQL_TYPE_INCLUDE_DIR=${prefix}/include/postgresql14
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib/postgresql14
                }
            }
            postgresql13 {
                "port:postgresql13"
                {
                    -DPostgreSQL_INCLUDE_DIR=${prefix}/include/postgresql13
                    -DPostgreSQL_TYPE_INCLUDE_DIR=${prefix}/include/postgresql13
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib/postgresql13
                }
            }
            postgresql12 {
                "port:postgresql12"
                {
                    -DPostgreSQL_INCLUDE_DIR=${prefix}/include/postgresql12
                    -DPostgreSQL_TYPE_INCLUDE_DIR=${prefix}/include/postgresql12
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib/postgresql12
                }
            }
            postgresql11 {
                "port:postgresql11"
                {
                    -DPostgreSQL_INCLUDE_DIR=${prefix}/include/postgresql11
                    -DPostgreSQL_TYPE_INCLUDE_DIR=${prefix}/include/postgresql11
                    -DCMAKE_LIBRARY_PATH=${prefix}/lib/postgresql11
                }
            }
        }
    }
    mysql {
        MySQL
        "revision 0"
        {sql-mysql}
        {
            mariadb10_11 {
                "port:mariadb-10.11"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.11/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.11/mysql/libmariadb.dylib
                }
            }
            mariadb10_10 {
                "port:mariadb-10.10"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.10/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.10/mysql/libmariadb.dylib
                }
            }
            mariadb10_9 {
                "port:mariadb-10.9"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.9/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.9/mysql/libmariadb.dylib
                }
            }
            mariadb10_8 {
                "port:mariadb-10.8"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.8/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.8/mysql/libmariadb.dylib
                }
            }
            mariadb10_7 {
                "port:mariadb-10.7"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.7/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.7/mysql/libmariadb.dylib
                }
            }
            mariadb10_6 {
                "port:mariadb-10.6"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.6/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.6/mysql/libmariadb.dylib
                }
            }
            mariadb10_5 {
                "port:mariadb-10.5"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.5/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.5/mysql/libmariadb.dylib
                }
            }
            mariadb10_4 {
                "port:mariadb-10.6"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mariadb-10.4/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mariadb-10.4/mysql/libmariadb.dylib
                }
            }
            mysql8 {
                "port:mysql8"
                {
                    -DMySQL_INCLUDE_DIR=${prefix}/include/mysql8/mysql
                    -DMySQL_LIBRARY=${prefix}/lib/mysql8/mysql/libmysqlclient.dylib
                }
            }
        }
    }
}

foreach {module module_info} [array get modules] {
    subport ${name}-${module} {

        distname                            ${module}-everywhere-src-${version}

        revision                            [regexp -inline {[0-9]+} [lindex ${module_info} 7]]

        checksums                           rmd160  [lindex [lindex ${module_info} 0] 0] \
                                            sha256  [lindex [lindex ${module_info} 0] 1] \
                                            size    [lindex [lindex ${module_info} 0] 2]

        set license_string                  [lindex ${module_info} 8]
        set license_string                  [string range ${license_string} 1+[string first ":" ${license_string}] end]
        set license_string                  [string trim ${license_string}]
        if { ${license_string} ne "" } {
            license                         {*}${license_string}
        }

        foreach deps [lindex ${module_info} 1] {
            depends_build-append            [subst ${deps}]
        }

        foreach deps [lindex ${module_info} 2] {
            depends_lib-append              [subst ${deps}]
        }

        foreach qtdeps [lindex ${module_info} 3] {
            depends_lib-append              port:${name}-${qtdeps}
        }

        description                         Tools and Module(s) for Qt Tool Kit ${qt_major}

        set modules_provided_list           [lindex ${module_info} 4]
        if { [llength ${modules_provided_list}] == 1 } {
            set modules_provided_join       [lindex ${modules_provided_list} 0]
        } elseif { [llength ${modules_provided_list}] == 2 } {
            set modules_provided_join       [join ${modules_provided_list} " and "]
        } else {
            set modules_provided_join       [join [list [join [lrange ${modules_provided_list} 0 end-1] ", "] [lindex ${modules_provided_list} end]] ", and "]
        }

        long_description                    Tools and Module(s) for Qt Tool Kit ${qt_major}: ${modules_provided_join}

        if { [lsearch -exact [lindex ${module_info} 6] "~universal"] != -1 } {
            universal_variant               no
        }

        if { [lsearch -exact [lindex ${module_info} 6] "noarch"] != -1 } {
            supported_archs                 noarch
            platforms                       any
        }

        if { [lsearch -exact [lindex ${module_info} 6] "~debug"] == -1 } {
            # debugging seems to be turned on if and only if it is turned on in the base
            # CMAKE_CONFIGURATION_TYPES is set with the FORCE option
            # see https://code.qt.io/cgit/qt/qtbase.git/tree/cmake/QtPostProcessHelpers.cmake
            variant debug description {Build both release and debug libraries} {
                require_active_variants     qt6-qtbase debug ""
            }
            if {![variant_isset debug]} {
                require_active_variants     qt6-qtbase "" debug
            }
        }

        if { [lsearch -exact [lindex ${module_info} 6] "~examples"] == -1 } {
            variant examples description {Build examples} {}
        }

        if { [lsearch -exact [lindex ${module_info} 6] "~tests"] == -1 } {
            variant tests description {Enable tests} {}
        }
    }
}

foreach {module module_info} [array get modules] {
    if { [lsearch -exact [lindex ${module_info} 6] "~docs"] != -1 } { continue }

    subport ${name}-${module}-docs {

        # minimum supported versions have changed over time and new qtXY ports were added
        # this attempts to provide a clean "upgrade" path for user who had  "qt6-XY" (sub)ports installed
        # on a system that is no longer supported
        # REMOVE after 2026-02-19
        if {${os.platform} eq "darwin" && ${os.major} < 23 && ${os.major} >= 21} {
            PortGroup               obsolete 1.0
            replaced_by             qt67-${module}
        } elseif {${os.platform} eq "darwin" && ${os.major} < 21 && ${os.major} >= 18} {
            PortGroup               obsolete 1.0
            replaced_by             qt64-${module}
        }

        distname                            ${module}-everywhere-src-${version}

        revision                            [regexp -inline {[0-9]+} [lindex ${module_info} 7]]

        checksums                           rmd160  [lindex [lindex ${module_info} 0] 0] \
                                            sha256  [lindex [lindex ${module_info} 0] 1] \
                                            size    [lindex [lindex ${module_info} 0] 2]

        set license_string                  [lindex ${module_info} 8]
        set license_string                  [string range ${license_string} 1+[string first ":" ${license_string}] end]
        set license_string                  [string trim ${license_string}]
        if { ${license_string} ne "" } {
            license                         {*}${license_string}
        }

        depends_build-append                port:${name}-qttools \
                                            port:${name}-sqlite-plugin

        # have the same build dependencies
        foreach deps [lindex ${module_info} 1] {
            depends_build-append [subst ${deps}]
        }

        depends_lib-append                  port:${name}-${module}

        description                         Documentation for Qt Tool Kit ${qt_major}

        set modules_provided_list           [lindex ${module_info} 4]
        if { [llength ${modules_provided_list}] == 1 } {
            set modules_provided_join       [lindex ${modules_provided_list} 0]
        } elseif { [llength ${modules_provided_list}] == 2 } {
            set modules_provided_join       [join ${modules_provided_list} " and "]
        } else {
            set modules_provided_join       [join [list [join [lrange ${modules_provided_list} 0 end-1] ", "] [lindex ${modules_provided_list} end]] ", and "]
        }

        long_description                    Documentation for Qt Tool Kit ${qt_major}: ${modules_provided_join}

        supported_archs                     noarch
        platforms                           any
    }
}

# see https://doc.qt.io/qt-6/sql-driver.html for info on building SQL Database Drivers
foreach {driver driver_info} [array get sql_plugins] {
    set dbms                                [lindex ${driver_info} 0]

    set revision_string                     [string trim [lindex ${driver_info} 1]]
    set revision_string                     [string range ${revision_string} 1+[string last " " ${revision_string}] end]

    set sql_variants                        [lindex ${driver_info} 3]

    subport ${name}-${driver}-plugin {

        # minimum supported versions have changed over time and new qtXY ports were added
        # this attempts to provide a clean "upgrade" path for user who had  "qt6-XY" (sub)ports installed
        # on a system that is no longer supported
        # REMOVE after 2026-02-19
        if {${os.platform} eq "darwin" && ${os.major} < 23 && ${os.major} >= 21} {
            PortGroup               obsolete 1.0
            replaced_by             qt67-${driver}-plugin
        } elseif {${os.platform} eq "darwin" && ${os.major} < 21 && ${os.major} >= 18} {
            PortGroup               obsolete 1.0
            replaced_by             qt64-${driver}-plugin
        }

        distname                            qtbase-everywhere-src-${version}

        revision                            ${revision_string}

        checksums                           rmd160  [lindex [lindex $modules(qtbase) 0] 0] \
                                            sha256  [lindex [lindex $modules(qtbase) 0] 1] \
                                            size    [lindex [lindex $modules(qtbase) 0] 2]

        depends_lib-append                  port:${name}-qtbase

        description                         ${dbms} Database Driver for Qt Tool Kit ${qt_major}
        long_description                    ${dbms} Database Driver for Qt Tool Kit ${qt_major}

        foreach feature {sql-db2 sql-ibase sql-mysql sql-oci sql-odbc sql-psql sql-sqlite system-sqlite} {
            if { ${feature} in [lindex ${driver_info} 2] } {
                configure.args-append       -feature-${feature}
            } else {
                configure.args-append       -no-feature-${feature}
            }
        }

        set worksrcpath                     ${worksrcpath}/src/plugins/sqldrivers

        set any_sql                         no
        foreach {variant_name variant_info} ${sql_variants} {
            set conflict_list ""

            foreach {variant_name_other variant_info_other} ${sql_variants} {
                if { ${variant_name_other} ne ${variant_name} } {
                    lappend conflict_list   ${variant_name_other}
                }
            }

            if { [llength ${conflict_list}] > 0 } {
                variant ${variant_name} conflicts {*}${conflict_list} description "use version [regexp -inline {[0-9].} ${variant_name}] of ${dbms}" {}
            }
            if { ([variant_exists ${variant_name}] && [variant_isset ${variant_name}]) || [llength ${conflict_list}]==0 } {
                set any_sql                 yes
            }
        }

        if { !${any_sql} } {
            default_variants-append         +[lindex ${sql_variants} 0]
            if { ![variant_isset [lindex ${sql_variants} 0]] } {
                known_fail                  yes
                pre-extract {
                    ui_error                "At least one SQL variant must be selected."
                    return -code error      "No SQL variant selected."
                }
            }
        }

        foreach {variant_name variant_info} ${sql_variants} {
            if { ([variant_exists ${variant_name}] && [variant_isset ${variant_name}]) || [llength ${conflict_list}]==0 } {
                depends_lib-append          {*}[lindex ${variant_info} 0]
                configure.post_args-append  {*}[subst [lindex ${variant_info} 1]]
            }
        }

        post-destroot {
            if {[file exists ${qt6.dir}/sbom/qsqlitedriverplugins-${version}.spdx]} {
                file delete ${destroot}${qt6.dir}/sbom/qsqlitedriverplugins-${version}.spdx
            }
        }
    notes "${destroot}${qt6.dir}/sbom/qsqlitedriverplugins-${version}.spdx"
    }
}

###############################################################################
# Special Cases
###############################################################################
subport ${name}-qttools {
    configure.env-append            LLVM_INSTALL_DIR=${prefix}/libexec/llvm-${llvm_version}

    post-destroot {
        # avoid having to add `-Wl,-rpath ${prefix}/libexec/llvm-${llvm_version}/lib` or something like it
        foreach bin {lupdate qdoc} {
            foreach lib {libclang.dylib libclang-cpp.dylib libLLVM.dylib} {
                system              "install_name_tool -change @rpath/${lib} ${prefix}/libexec/llvm-${llvm_version}/lib/${lib} ${destroot}${qt6.dir}/bin/${bin}"
            }
        }
    }
}

if { ${subport} in [list "${name}-qtwebengine" "${name}-qtwebengine-docs"] } {
    compiler.cxx_standard           2020
    configure.env-append            PYTHON3_PATH=${prefix}/Library/Frameworks/Python.framework/Versions/${python_branch}/bin
    # in ${worksrcpath}, `${qt6.dir}/bin/qt-configure-module . -help` and `${qt6.dir}/bin/qt-configure-module . -list-features`
    # it is not clear why, but icu and ffmpeg support must be added manually
    # native-spellchecker support is off by default
    # support for proprietary codecs could by added via `-webengine-proprietary-codecs`
    configure.args-append           -webengine-icu \
                                    -webengine-ffmpeg \
                                    -webengine-native-spellchecker

    # avoid
    #     xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer
    #     directory '/Library/Developer/CommandLineTools' is a command line tools
    #     instance
    use_xcode                       yes
}

subport ${name}-qtwebengine {
    # manually install icudtl.dat
    post-destroot {
        xinstall -m 0644 ${worksrcpath}/src/3rdparty/chromium/third_party/icu/common/icudtl.dat \
                         ${destroot}${qt6.dir}/lib/QtWebEngineCore.framework/Resources/
    }
}

subport ${name}-qtmultimedia {
    # GStreamer will be found if gstreamer1 and gstreamer1-gst-plugins-base are installed
    # however, an error will ensue since the GStreamer support requires "Linux DMA buffer support"
    # see
    #     https://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/multimedia/gstreamer/CMakeLists.txt
    #     https://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/multimedia/configure.cmake
    configure.args-append           -no-gstreamer

    configure.post_args-append      -DFFMPEG_DIR=${prefix}/libexec/ffmpeg7 \
                                    -DAVCODEC_INCLUDE_DIR=${prefix}/libexec/ffmpeg7/include \
                                    -DAVCODEC_LIBRARY=${prefix}/libexec/ffmpeg7/lib/libavcodec.dylib \
                                    -DAVFORMAT_INCLUDE_DIR=${prefix}/libexec/ffmpeg7/include \
                                    -DAVFORMAT_LIBRARY=${prefix}/libexec/ffmpeg7/lib/libavformat.dylib \
                                    -DAVUTIL_INCLUDE_DIR=${prefix}/libexec/ffmpeg7/include\
                                    -DAVUTIL_LIBRARY=${prefix}/libexec/ffmpeg7/lib/libavutil.dylib
}

subport ${name}-qt5compat {
    patchfiles-append               patch-qt5compat-find_libs.diff
}

subport ${name}-qtspeech {
    # ALSA is Linux only (https://www.alsa-project.org/wiki/Main_Page)
    # Speech Dispatcher *might* be made to work on macOS (https://freebsoft.org/speechd)
    configure.args-append           -no-flite \
                                    -no-speechd
}

if { ${subport} eq "${name}-qtbase" || ${subport} eq "${name}-qtbase-docs" } {

    configure.pre_args-replace      --prefix=${prefix} \
                                    "-prefix ${qt6.dir}"

    # configure options:
    configure.args-append           -shared \
                                    -accessibility

    # SQL Options
    foreach driver {db2 ibase mysql oci odbc psql sqlite} {
        configure.args-append       -no-sql-${driver}
    }

    # use -Oz instead of -O2
    configure.args-append           -optimize-size

    configure.args-append           -pkg-config

    # Third Party Libraries:
    configure.args-append           -system-zlib \
                                    -no-mtdev \
                                    -no-journald \
                                    -no-syslog \
                                    -system-libpng \
                                    -system-libjpeg \
                                    -system-freetype \
                                    -system-harfbuzz \
                                    -system-pcre \
                                    -no-openssl \
                                    -no-libproxy \
                                    -glib \
                                    -no-gtk

    # additional options:
    configure.args-append           {-make tools} \
                                    {-nomake examples} \
                                    {-nomake tests} \
                                    -gui \
                                    -widgets \
                                    -cups \
                                    -no-evdev \
                                    -no-tslib \
                                    -icu \
                                    -no-fontconfig \
                                    -no-pch \
                                    -no-ltcg \
                                    -dbus-linked \
                                    -no-use-gold-linker \
                                    -no-separate-debug-info \
                                    -no-xcb \
                                    -no-eglfs \
                                    -no-gbm \
                                    -no-directfb \
                                    -no-linuxfb \
                                    -no-kms \
                                    -no-libinput \
                                    -no-system-proxies \
                                    -no-libudev \
                                    -no-egl

    # macOS/iOS options:
    configure.args-append           -framework \
                                    -securetransport

    # do not opportunistically enable Vulkan support
    # (TODO: is Vulkan support desirable?)
    # see https://trac.macports.org/ticket/62104
    configure.args-append           -no-feature-vulkan

    # attempt to avoid @rpath
    configure.args-append           -no-rpath \
                                    -no-feature-relocatable
}

subport ${name}-qtbase {
    # this subport uses configure script
    PortGroup                       openssl 1.0

    build.cmd                       ninja
    build.post_args-append          -v
    destroot.target                 install

    variant tests description {Enable tests} {
        configure.args-replace      {-nomake tests} \
                                    {-make tests}
    }

    variant examples description {Build examples} {
        configure.args-replace      {-nomake examples} \
                                    {-make examples}
    }

    variant debug description {Build both release and debug libraries} {
        configure.args-replace      -release \
                                    -debug-and-release
    }

    variant openssl description {Use OpenSSL instead of Secure Transport} {
        configure.args-delete       -securetransport \
                                    -no-openssl
        configure.args-append       -openssl-linked

        # configure has issues locating openssl files
        configure.pre_args-append   -DOPENSSL_ROOT_DIR=[openssl::install_area] \
                                    -DOPENSSL_INCLUDE_DIR=[openssl::include_dir] \
                                    -DOPENSSL_LIBRARIES=[openssl::install_area]/lib \
                                    -DOPENSSL_LIBS='-L[openssl::install_area]/lib -lssl -lcrypto'
    }
    default_variants-append         +openssl

    post-destroot {
        # do not record  __qt_initial_c_compiler and __qt_initial_cxx_compiler
        reinplace                   "s|${configure.cc}|/usr/bin/clang|g" \
                                    ${destroot}${qt6.dir}/lib/cmake/Qt6/qt.toolchain.cmake
        reinplace                   "s|${configure.cxx}|/usr/bin/clang++|g" \
                                    ${destroot}${qt6.dir}/lib/cmake/Qt6/qt.toolchain.cmake

        # return to default value of CMAKE_OSX_DEPLOYMENT_TARGET
        #reinplace                   "s|CMAKE_OSX_DEPLOYMENT_TARGET \"${macosx_deployment_target}\"|CMAKE_OSX_DEPLOYMENT_TARGET \"10.14\"|g" \
        #                            ${destroot}${qt6.dir}/lib/cmake/Qt6/qt.toolchain.cmake

        # do not record QT_SOURCE_TREE
        reinplace                   "s|${worksrcpath}|${qt6.dir}/src|g" \
                                    ${destroot}${qt6.dir}/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake

        # do not record original_cmake_path
        reinplace                   "s|${prefix}/bin/cmake|/Applications/CMake.app/Contents/bin/cmake|g" \
                                    ${destroot}${qt6.dir}/bin/qt-cmake
        reinplace                   "s|${prefix}/bin/cmake|/Applications/CMake.app/Contents/bin/cmake|g" \
                                    ${destroot}${qt6.dir}/bin/qt-cmake-create

        if { "${qt6.dir}" ne "${prefix}" } {
            # Add dummy cmake find modules that forward to the real ones
            file mkdir "${destroot}${prefix}/lib/cmake/Qt6"
            foreach configfile [list "Qt6Config.cmake" "Qt6ConfigVersion.cmake"] {
                set fd [open "${destroot}${prefix}/lib/cmake/Qt6/${configfile}" "w"]
                puts $fd "set(_PREFIX_PATH_BAK \${CMAKE_PREFIX_PATH})"
                puts $fd "list(APPEND CMAKE_PREFIX_PATH \"${qt6.dir}\")"
                puts $fd "include(\"${qt6.dir}/lib/cmake/Qt6/${configfile}\")"
                puts $fd "set(CMAKE_PREFIX_PATH \${_PREFIX_PATH_BAK})"
                close $fd
            }
        }
    }

    # Qt builds part of the system using environment provided by MacPorts.
    # It builds the rest using its own internal environment.
    # For consistency, clear MacPorts environment.
    configure.cxx_stdlib
    proc portconfigure::should_add_stdlib {} { return false }
    configure.sdkroot
    configure.cc_archflags
    configure.cxx_archflags
    configure.objc_archflags
    configure.objcxx_archflags
    configure.ld_archflags
    configure.cppflags
    configure.cflags
    configure.cxxflags
    configure.objcflags
    configure.objcxxflags
    configure.ldflags
    configure.pipe                  no
    configure.march
    configure.mtune
    configure.universal_ldflags
    configure.universal_cflags
    configure.universal_cxxflags
    configure.universal_cppflags
}

subport ${name}-qtbase-docs {
    # see https://wiki.qt.io/Building_Qt_Documentation
    build.cmd                      cmake --build ${build.dir}
    destroot.target
    build.target                   --target docs
    destroot.cmd                   cmake --build ${build.dir} --target install_docs
}

###############################################################################
# Applies to allmost all modules
###############################################################################
if { ${subport} ne "${name}" && ${subport} ne "${name}-qtbase" && ${subport} ne "${name}-qtbase-docs" } {
    # attempting to match module configure instructions from here: https://www.qt.io/blog/qt-6-build-system
    configure.cmd                   ${qt6.dir}/bin/qt-configure-module
    configure.dir                   ${workpath}/build
    configure.pre_args              ${worksrcpath}
    configure.args-append           -verbose

    build.dir                       ${workpath}/build
    build.cmd                       cmake --build ${build.dir}

    destroot.target

    if { [lindex [split ${subport} -] end] ne "docs" } {
        build.target
        destroot.cmd               cmake --install ${build.dir}
    } else {
        build.target               --target docs
        destroot.cmd               cmake --build ${build.dir} --target install_docs
    }

    if { [variant_exists examples] } {
        configure.post_args-append  -DQT_BUILD_EXAMPLES=[expr {[variant_isset examples] ? ON : OFF}]
    }
    if { [variant_exists tests] } {
        configure.post_args-append  -DQT_BUILD_TESTS=[expr {[variant_isset tests] ? ON : OFF}]
    }
}

###############################################################################
# Applies to all subports except ${name}
#     this code may depend on the subport specific code (e.g., configure.cc)
###############################################################################
depends_build-append                path:bin/cmake:cmake \
                                    port:ninja \
                                    port:pkgconfig

# because CPATH is set, pkgconfig does not include ${prefix}/lib and ${prefix}/include even when requested
# this means that files in ${prefix}/lib and ${prefix}/include are the *last* to be found
# this causes problems when there are files in ${worksrpath} that are unintentionally found instead
configure.env-append                PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
                                    PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
build.env-append                    PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
                                    PKG_CONFIG_ALLOW_SYSTEM_LIBS=1

configure.universal_args

test.cmd                            ctest
test.args                           -V
test.target

# ninja needs the DESTDIR argument in the environment
destroot.destdir
destroot.env-append                 DESTDIR=${destroot}

# set CMake variables (similar to what cmake PortGroup does)
# to allow using ccache and controlling compiler selection
configure.post_args-prepend         --
configure.post_args-append          -DCMAKE_C_COMPILER=[option configure.cc] \
                                    -DCMAKE_CXX_COMPILER=[option configure.cxx] \
                                    -DCMAKE_OBJC_COMPILER=[option configure.objc] \
                                    -DCMAKE_OBJCXX_COMPILER=[option configure.objcxx] \
                                    -DCMAKE_OSX_DEPLOYMENT_TARGET=${macosx_deployment_target}
if { ${configure.ccache} } {
    if { ${subport} ne "${name}-qtbase" } {
        configure.post_args-append  -DQT_USE_CCACHE=ON
    } else {
        # do not use `configure.args-append -ccache`
        # or `configure.post_args-append -DQT_USE_CCACHE=1`
        # since that affects installed files.
        configure.post_args-append  -DCMAKE_C_COMPILER_LAUNCHER=${prefix}/bin/ccache \
                                    -DCMAKE_CXX_COMPILER_LAUNCHER=${prefix}/bin/ccache \
                                    -DCMAKE_OBJC_COMPILER_LAUNCHER=${prefix}/bin/ccache \
                                    -DCMAKE_OBJCXX_COMPILER_LAUNCHER=${prefix}/bin/ccache
    }
}

test.run                            [expr {[variant_exists tests] && [variant_isset tests] ? yes : no}]

if { ${universal_possible} && [variant_isset universal] } {
    configure.post_args-append      -DCMAKE_OSX_ARCHITECTURES="[join ${configure.universal_archs} \;]"
} elseif { ${configure.build_arch} ne ""  } {
    configure.post_args-append      -DCMAKE_OSX_ARCHITECTURES="${configure.build_arch}"
}

# attempt to avoid @rpath
configure.post_args-append          -DCMAKE_INSTALL_NAME_DIR=${qt6.dir}/lib

post-destroot {
    fs-traverse f ${destroot} {
        if { [file isfile ${f}] && [file extension ${f}] eq ".prl" } {
            # do not record build directory
            reinplace -q            "/^QMAKE_PRL_BUILD_DIR = /d" \
                                    ${f}
        }
    }

    # .app and non-.app programs are both put in ${qt6.dir}/bin
    # put a link of any .app programs in the ${applications_dir}/Qt6
    xinstall -d -m 0755             ${destroot}${applications_dir}/Qt6
    foreach app [glob -nocomplain -tails -directory ${destroot}${qt6.dir}/bin *.app] {
        ln -s                       ${qt6.dir}/bin/${app} \
                                    ${destroot}${applications_dir}/Qt6
    }
}

livecheck.type                      none

###############################################################################
# Special Case: must be near the end since it undoes other code
###############################################################################
subport ${name} {
    # the main port is Meta-port to install various modules
    revision                        0

    description                     Qt Tool Kit ${qt_major}
    long_description                Qt Tool Kit: A cross-platform framework \
                                    (headers, data, and libraries) for writing \
                                    cross-platform GUI-based applications.

    master_sites
    distfiles
    use_configure                   no
    supported_archs                 noarch
    platforms                       any
    installs_libs                   no
    test.run                        no
    depends_extract
    depends_build
    depends_lib
    depends_test

    build                           {}

    # create a dummy file so the port can be successfully activated
    destroot {
        xinstall -d -m 0755         ${destroot}${prefix}/share/doc/${subport}
        set docfile                 [open ${destroot}${prefix}/share/doc/${subport}/README.txt "w"]
        puts ${docfile}             "Meta-port for ${name}"
        puts ${docfile}             "${long_description}"
        close ${docfile}
    }

    foreach {module module_info} [array get modules] {
        if { [lindex ${module_info} 5] eq "" } {
            depends_run-append      port:${name}-${module}
        }
    }
    depends_run-append              port:${name}-sqlite-plugin

    livecheck.type                  regex
    livecheck.url                   https://download.qt.io/archive/qt/${branch}/
    livecheck.regex                 (\\d+(\\.\\d+)\\.\\d+)
}
