Ticket #48088: qt5mac-mindiff+review.diff

File qt5mac-mindiff+review.diff, 19.5 KB (added by RJVB (René Bertin), 9 years ago)
  • Portfile

    old new  
    33
    44PortSystem          1.0
    55
     6# RJVB: at the time of the initial request for a Qt5 port, the opinion was voiced and supported by michaelld
     7# that it should be called simply qt5 . I adhere to that opinion because there will be no "non-mac" Qt5 port.
     8# Instead, it is possible to create (and I have implemented) a qt5-x11 subport that installs the xcb platform
     9# plugin in the Qt5 plugin directory. Semantics, but it would be weird to call it qt5-mac-x11 ...
    610name                qt5-mac
    711version             5.4.2
    812set branch          [join [lrange [split ${version} .] 0 1] .]
     
    1216maintainers         mcalhoun openmaintainer
    1317license             {LGPL-2.1 GPL-3}
    1418
    15 homepage            http://qt-project.org
    16 description         Qt Tool Kit
     19homepage            http://qt.io
     20description         Qt Tool Kit ${branch}
    1721long_description    Qt Tool Kit: A cross-platform framework \
    1822    (headers, data, and libraries) for writing \
    1923    cross-platform GUI-based applications.
    2024
    2125distname            qt-everywhere-opensource-src-${version}
    2226
    23 master_sites        http://download.qt-project.org/official_releases/qt/${branch}/${version}/single/
     27master_sites        http://download.qt.io/official_releases/qt/${branch}/${version}/single/
    2428
    2529checksums           rmd160  3382c482a99e114560f56a9fe9501b8cabf334a9 \
    2630                    sha256  cfc768c55f0a0cd232bed914a9022528f8f2e50cb010bf0e4f3f62db3dfa17bd
     
    7377    # See https://bugreports.qt.io/browse/QTBUG-34902
    7478    conflicts_build-append  qt4-mac
    7579
    76     # Kuba states in https://trac.macports.org/ticket/44207#comment:7
    77     #  "There's no reason to have parallel building disabled. Really."
    78     #use_parallel_build no
    79 
    8080    # qtwebengine/src/core/gyp_run.pro buils an executable using g++
    8181    # This causes an error if UsingTheRightCompiler (https://trac.macports.org/wiki/UsingTheRightCompiler)
    8282    # Quick fix is to use full path to g++ (should use ${configure.cxx} instead?)
     
    135135        set libreplace [string repeat ../ [llength ${qt_list}]][join ${framework_list} /]
    136136        if { ${libreplace} ne "lib" } {
    137137            patchfiles-append patch-shared.diff
    138             reinplace "s|__MACPORTS_FRAMWORK_DIR__|${libreplace}|g" ${worksrcpath}/qttools/src/macdeployqt/shared/shared.cpp
     138            # RJVB: reinplace should be done in the post-patch
     139            post-patch {
     140                reinplace "s|__MACPORTS_FRAMWORK_DIR__|${libreplace}|g" ${worksrcpath}/qttools/src/macdeployqt/shared/shared.cpp
     141            }
    139142        }
    140143    }
    141144
     
    152155    #-hostbindir    HOSTPREFIX/bin
    153156    #-hostlibdir    HOSTPREFIX/lib
    154157    configure.args-append                      \
    155         -prefix         ${qt_dir}              \
     158        -prefix         ${prefix}              \
    156159        -bindir         ${qt_bins_dir}         \
    157160        -headerdir      ${qt_includes_dir}     \
    158         -libdir         ${qt_libs_dir}         \
     161        -libdir         ${qt_frameworks_dir}   \
    159162        -archdatadir    ${qt_archdata_dir}     \
    160163        -plugindir      ${qt_plugins_dir}      \
    161164        -importdir      ${qt_imports_dir}      \
     
    166169        -sysconfdir     ${qt_sysconf_dir}      \
    167170        -examplesdir    ${qt_examples_dir}     \
    168171        -testsdir       ${qt_tests_dir}        \
    169         -hostdatadir    ${qt_host_data_dir}
     172        -hostdatadir    ${qt_host_data_dir}    \
     173        -hostbindir     ${qt_bins_dir}         \
     174        -hostlibdir     ${qt_frameworks_dir}
     175
    170176
    171177    # Configure options:
     178    # RJVB : -c++11 is the default (when auto-detection detects it's supported) and it
     179    # is probably best left implicit (e.g. for building on earlier OS X versions) => remove -c++11
    172180    configure.args-append \
    173181        -release          \
    174182        -opensource       \
     
    177185        -shared           \
    178186        -largefile        \
    179187        -accessibility
    180    
    181     foreach driver { db2 ibase mysql oci odbc psql sqlite sqlite2 tds } {
     188
     189    # RJVB/pixilla: the sqlite3 plugin ("sqlite") should  be re-absorbed into the main port
     190    configure.args-append -system-sqlite
     191    depends_lib-append port:sqlite3
     192    foreach driver { db2 ibase mysql oci odbc psql sqlite2 tds } {
    182193        configure.args-append -no-sql-${driver}
    183194    }
    184195
     196    # RJVB: -qml-debug is the default
    185197    configure.args-append \
    186198        -qml-debug
    187199
     
    196208        -force-pkg-config
    197209
    198210    # Third Party Libraries:
     211    # RJVB : Qt has no business depending on PulseAudio on OS X; it only pulls in undesirable dependencies (like gnome...)
    199212    configure.args-append   \
    200213        -system-zlib        \
    201214        -no-mtdev           \
     
    216229        -no-gtkstyle
    217230
    218231    # Additional options:
     232    # RJVB: what's the point in not optimising qmake? Any increase in configure time (which I don't believe in)
     233    # can be compensated by patching the configure script so it builds qmake with -j${build.jobs} .
    219234    configure.args-append       \
    220235        {-make libs}            \
    221236        {-make tools}           \
     
    243258        -no-linuxfb             \
    244259        -no-kms                 \
    245260        -no-system-proxies
    246    
     261
    247262    # MacOS/iOS options:
    248263    configure.args-append    \
    249264        -framework
     
    252267        configure.args-append \
    253268            -sdk [string tolower [join [lrange [split [lindex [split ${configure.sdkroot} "/"] end] "."] 0 end-1] "."]]
    254269    }
    255    
     270
    256271    # configure options that don't show up in configure --help
    257272    configure.args-append \
    258273        -no-libudev       \
     
    288303}
    289304
    290305if { ${subport} eq ${name} } {
     306    # RJVB: port:pulseaudio should disappear from this list when Qt is configured *without* PA support
    291307    depends_lib                              \
    292308        port:zlib                            \
    293309        port:libpng                          \
     
    325341
    326342                reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${dir}${qt_mkspecs_dir}/modules/qt_lib_bootstrap_private.pri
    327343                reinplace "s|macx-clang-32|macx-clang|g"              ${dir}${qt_libs_dir}/cmake/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake
    328                
    329                
     344
     345
    330346                if { [variant_isset examples] } {
    331347                    reinplace "s|${worksrcpath}-${arch}|${worksrcpath}|g" ${dir}${qt_examples_dir}/declarative/tutorials/gettingStarted/parts/part5/filedialog/Makefile
    332348                    reinplace -E "/\\w*-arch \\\\/d"                      ${dir}${qt_examples_dir}/declarative/tutorials/gettingStarted/parts/part5/filedialog/Makefile
     
    358374
    359375    post-destroot {
    360376        # see #44204
    361         foreach f [glob -nocomplain -tails -directory ${destroot}${qt_libs_dir} *.framework] {
    362             set framework [file rootname ${f}]
     377        # RJVB: use the code below ">>>..." instead of this block, which fails to populate qt_includes_dir completely.
     378#         foreach f [glob -nocomplain -tails -directory ${destroot}${qt_libs_dir} *.framework] {
     379#             set framework [file rootname ${f}]
     380#
     381#             set include_list   [split ${qt_includes_dir}   '/']
     382#             set framework_list [split ${qt_libs_dir} '/']
     383#
     384#             while {[llength ${include_list}] && [llength ${framework_list}]} {
     385#                 set var_include   [lindex $include_list   0]
     386#                 set var_framework [lindex $framework_list 0]
     387#
     388#                 if { ${var_include} ne ${var_framework} } {
     389#                     break
     390#                 }
     391#
     392#                 # remove first element from list
     393#                 set include_list   [lreplace ${include_list} 0 0]
     394#                 set framework_list [lreplace ${framework_list} 0 0]
     395#             }
     396#
     397#             ln -s [string repeat ../ [llength ${include_list}]][join ${framework_list} /]/${f}/Headers ${destroot}${qt_includes_dir}/${framework}
     398#         }
     399
     400        # RJVB: tried and true logic copied from the qt4-mac port
     401        # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
     402        # move items out of the Frameworks directory that are more appropriate to lib directory
     403        xinstall -m 775 -d ${destroot}${qt_cmake_module_dir}
     404        foreach d [glob -tails -nocomplain -directory ${destroot}${qt_frameworks_dir}/cmake *] {
     405            xinstall -m 775 -d ${destroot}${qt_cmake_module_dir}/${d}
     406            foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/cmake/${d} *.cmake] {
     407                # ${qt_frameworks_dir} is  ${qt_dir}/Library/Frameworks while
     408                # ${qt_libs_dir}       is  ${qt_dir}/lib
     409                # unless modified, cmake files will point to a directory that is too high in the directory hierarchy
     410                reinplace "s|/../../../../|/../../../${qt_dir_rel}/|g" ${f}
     411                file rename ${f} ${destroot}${qt_cmake_module_dir}/${d}/
     412            }
     413        }
     414        set qt_vers [split ${version} "."]
     415        set qt_major [lindex ${qt_vers} 0]
     416        set qt_minor [lindex ${qt_vers} 1]
     417        set qt_patch [lindex ${qt_vers} 2]
     418
     419        # link includes and libraries for each actual installed framework
     420        # make sure that the target directories exist
     421        exec mkdir -p ${destroot}${qt_includes_dir} ${destroot}${qt_libs_dir}
     422        foreach fixfile [exec find ${destroot}${qt_frameworks_dir} \
     423                             -name "*.framework" | \
     424                             sed -e "s@${destroot}@@g"] {
     425
     426                set tf_full [strsed ${fixfile} {s@\\.framework@@}]
     427                set tf [strsed ${tf_full} {g@.*\/@@}]
     428
     429                # special for QtWebKit entries
     430                set t_minor ${qt_minor}
     431                set is_QtWebKit 0
     432                if {[string compare ${tf} QtWebKit] == 0} {
     433                    set t_minor 9
     434                    set is_QtWebKit 1
     435                }
     436
     437                # link headers into ${qt_includes_dir}, removing directories
     438                # if they are already there first
     439                set inc_file ${destroot}${qt_includes_dir}/${tf}
     440                if {[file exists ${inc_file}]} {
     441                    ui_msg "*Warning* replacing directory ${inc_file} with a symlink to ${tf_full}.framework/Headers!"
     442                    file delete -force ${inc_file}
     443                }
     444                ln -s ${tf_full}.framework/Headers ${inc_file}
     445
     446                # link libraries into ${qt_libs_dir}, all 4 number variants
     447                set dr_qt_libs_dir ${destroot}${qt_libs_dir}
     448                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.dylib
     449                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.dylib
     450                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.dylib
     451                ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.${qt_patch}.dylib
     452
     453                # copy .prl file, then correct it for library usage
     454                copy ${destroot}${tf_full}.framework/${tf}.prl ${dr_qt_libs_dir}/lib${tf}.prl
     455
     456                # fix TARGET in .prl file
     457                reinplace "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}.prl
     458
     459                # fix PRL_LIBS -F -> -L in .prl file
     460                reinplace "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}.prl
     461
     462                # fix "-framework Qt*" -> "-lQt*" in .prl file
     463                reinplace "/QMAKE_PRL_LIBS/s|-framework Qt|-lQt|g" \
     464                    ${dr_qt_libs_dir}/lib${tf}.prl
    363465
    364             set include_list   [split ${qt_includes_dir}   '/']
    365             set framework_list [split ${qt_libs_dir} '/']
     466                # remove the QMAKE_PRL_BUILD_DIR line from the .prl file
     467                reinplace "/QMAKE_PRL_BUILD_DIR/d" ${dr_qt_libs_dir}/lib${tf}.prl
    366468
    367             while {[llength ${include_list}] && [llength ${framework_list}]} {
    368                 set var_include   [lindex $include_list   0]
    369                 set var_framework [lindex $framework_list 0]
     469                # deal with debug files
     470                # RJVB: this is the only block I never tested
     471                if {[variant_isset debug]} {
    370472
    371                 if { ${var_include} ne ${var_framework} } {
    372                     break
     473                    # but not if QtWebKit and +universal, since that one does
     474                    # not exist (the 32-bit version of the debug library is
     475                    # larger than fits into the 32-bit filespace).
     476
     477                    if {[variant_isset debug] && ${is_QtWebKit}} {
     478                        continue
     479                    }
     480
     481                    # link libraries into ${qt_libs_dir}, all 4 number variants
     482                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.dylib
     483                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.dylib
     484                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.dylib
     485                    ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.${qt_patch}.dylib
     486
     487                    # copy .prl file, then correct it for library usage
     488                    copy ${destroot}${tf_full}.framework/${tf}_debug.prl ${dr_qt_libs_dir}/lib${tf}_debug.prl
     489
     490                    # fix TARGET in .prl file
     491                    reinplace "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
     492
     493                    # fix PRL_LIBS -F -> -L in .prl file
     494                    reinplace "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
     495
     496                    # fix "-framework Qt*" -> "-lQt*_debug" in .prl file
     497                    reinplace "/QMAKE_PRL_LIBS/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|g" ${dr_qt_libs_dir}/lib${tf}_debug.prl
     498                }
     499            }
     500            # RJVB: spoiler: reference to the qt5*-kde subport
     501            if {${subport} eq ${name} || ${subport} eq "${name}-kde"} {
     502                ln -s ${qt_qmake_cmd} ${destroot}/${prefix}/bin/qmake-qt${qt_major}
     503                ln -s ${qt_moc_cmd} ${destroot}/${prefix}/bin/moc-qt${qt_major}
     504                ln -s ${qt_uic_cmd} ${destroot}/${prefix}/bin/uic-qt${qt_major}
     505                ln -s ${qt_lrelease_cmd} ${destroot}/${prefix}/bin/lrelease-qt${qt_major}
     506            }
     507            if {${qt_pkg_config_dir} ne "${qt_frameworks_dir}/pkgconfig"} {
     508                # move the pkgconfig files to their assigned location
     509                foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir}/pkgconfig *.pc] {
     510                    file rename ${f} ${destroot}${qt_pkg_config_dir}
     511                }
     512            }
     513            if {${qt_libs_dir} ne ${qt_frameworks_dir}} {
     514                xinstall -m 775 -d ${destroot}${qt_libs_dir}/
     515                foreach f [glob -nocomplain -directory ${destroot}${qt_frameworks_dir} *.{a,prl,la}] {
     516                    file rename ${f} ${destroot}${qt_libs_dir}/
    373517                }
    374518
    375                 # remove first element from list
    376                 set include_list   [lreplace ${include_list} 0 0]
    377                 set framework_list [lreplace ${framework_list} 0 0]
     519                # link back the static libraries to where some Qt components expect them:
     520                foreach f [exec find ${destroot}${qt_libs_dir} \
     521                                     -name "*.a" | \
     522                                     sed -e "s@${destroot}@@g"] {
     523                    ln -s ${f} ${destroot}${qt_frameworks_dir}/
     524                }
     525                # certain applications might expect to find the following .prl files in ${qt_frameworks_dir}
     526                foreach fixfile { libQt5OpenGLExtensions_debug.prl libQt5PlatformSupport_debug.prl \
     527                                    libQt5QmlDevTools.prl libQt5UiTools.prl libQt5UiTools_debug.prl } {
     528                    if {[file exists ${destroot}${qt_libs_dir}/${fixfile}]} {
     529                        ln -s ${qt_libs_dir}/${fixfile} ${destroot}${qt_frameworks_dir}/${fixfile}
     530                    }
     531                }
    378532            }
    379533
    380             ln -s [string repeat ../ [llength ${include_list}]][join ${framework_list} /]/${f}/Headers ${destroot}${qt_includes_dir}/${framework}
    381         }
     534            # Move .apps into the applications_dir, and link each .apps'
     535            # executable back into ${qt_bins_dir}
     536            set dr_qt_apps_dir ${destroot}${qt_apps_dir}
     537            set dr_qt_bins_dir ${destroot}${qt_bins_dir}
     538            xinstall -m 755 -d ${dr_qt_apps_dir}
     539            foreach app [glob -nocomplain ${dr_qt_bins_dir}/*.app] {
     540                # remove the leading stuff
     541                set app [lindex [split ${app} /] end]
     542                # move the .app
     543                move ${dr_qt_bins_dir}/${app} ${dr_qt_apps_dir}
     544                # link it back
     545                ln -s ${qt_apps_dir}/${app} ${dr_qt_bins_dir}
     546                # provide a proxy to the app's executable; symlinks won't
     547                # be accepted by qtchooser if the user has that port installed.
     548                # RJVB: requires ${filespath}/appProxy.sh
     549#                 set texe [strsed ${app} {g@\.app@@}]
     550#                 set appProxy ${dr_qt_bins_dir}/[string tolower ${texe}]
     551#                 copy ${filespath}/appProxy.sh ${appProxy}
     552#                 reinplace "s|@BUNDLEEXEC@|${qt_apps_dir}/${app}/Contents/MacOS/${texe}|g" ${appProxy}
     553
     554            }
     555            if {[file exists ${destroot}${qt_mkspecs_dir}/qmodule.pri]} {
     556                # clean up the generated mkspecs/qmodule.pri:
     557                # undo any symlink normalisation that introduced the clang version number into QMAKE_CC/CXX (e.g. clang++-mp-3.5)
     558                reinplace "s|bin/clang-mp-.*|bin/clang|g"  ${destroot}${qt_mkspecs_dir}/qmodule.pri
     559                reinplace "s|bin/clang\+\+-mp-.*|bin/clang\+\+|g"  ${destroot}${qt_mkspecs_dir}/qmodule.pri
     560            }
     561            if {[file exists ${destroot}${qt_mkspecs_dir}/qmodule.pri]} {
     562                # if the user used configure.optflags="-something" make sure that gets added to compiler options qmake
     563                # determines, rather than replacing all of those
     564                reinplace "s|QMAKE_CFLAGS = |QMAKE_CFLAGS \+= |g"  ${destroot}${qt_mkspecs_dir}/qmodule.pri
     565                reinplace "s|QMAKE_CXXFLAGS = |QMAKE_CXXFLAGS \+= |g"  ${destroot}${qt_mkspecs_dir}/qmodule.pri
     566            }
     567            #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    382568    }
    383569
    384570    variant tests description {Enable tests} {
     
    394580    }
    395581}
    396582
     583# RJVB: the docs subport should be renamed such that it comes last during an `upgrade outdated`
    397584subport ${name}-docs {
    398585    depends_lib-append \
    399586        path:${qt_bins_dir}/qdoc:${name} \
     
    422609
    423610# See http://doc.qt.io/qt-5/sql-driver.html for info on building SQL Database Drivers
    424611
     612# RJVB/pixilla: applications built by the main port depend on the sqlite3 plugin. It should be built
     613# with the main port and not be a separate subport.
    425614subport ${name}-sqlite3-plugin {
     615    replaced_by         ${name}
     616    PortGroup           obsolete 1.0
    426617    PortGroup           qmake5 1.0
    427618
    428619    depends_lib-append port:sqlite3
     
    468659}
    469660
    470661livecheck.type      regex
    471 livecheck.url       http://qt-project.org/downloads
    472 livecheck.regex     "Qt (5(?:\\.\\d+)*) for Mac"
     662livecheck.url       http://download.qt.io/archive/qt/5.4/
     663livecheck.regex     (\\d+(\\.\\d+)+)