Ticket #46238: Portfile.qt4

File Portfile.qt4, 46.0 KB (added by RJVB (René Bertin), 10 years ago)

minor corrections

Line 
1# -*- 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
2# $Id: Portfile 126922 2014-10-17 18:50:56Z ryandesign@macports.org $
3
4# use the qt4 group; set 'building_qt4' so that the portgroup
5# does not include certain parts
6set building_qt4    1
7
8PortGroup           qt4 1.0
9if {[variant_isset exclusive] && ![variant_isset libsymlinks]} {
10        # qt4-mac-devel is "replaced_by" this port,
11        # so this port cannot conflict with it.
12        #conflicts           qt3 qt3-mac qt4-mac-devel
13        conflicts           qt3 qt3-mac qt5-mac
14}
15
16PortGroup           xcodeversion 1.0
17PortGroup           compiler_blacklist_versions 1.0
18
19set branch          [join [lrange [split ${version} .] 0 1] .]
20
21categories          aqua
22platforms           macosx
23maintainers         michaelld openmaintainer
24license             {LGPL-2.1 GPL-3}
25
26homepage            http://qt-project.org
27description         Qt Tool Kit
28long_description    Qt Tool Kit: A cross-platform framework \
29                    (headers, data, and libraries) for writing \
30                    cross-platform GUI-based applications. \
31                    Installs to ${qt_dir}
32
33
34distname            qt-everywhere-opensource-src-${version}
35
36master_sites        http://download.qt-project.org/official_releases/qt/${branch}/${version}/
37
38checksums           rmd160  0220d4e76ac761c9ecfb8ddab6f2c1dc6ad70c33 \
39                    sha256  8b14dd91b52862e09b8e6a963507b74bc2580787d171feda197badfa7034032c
40
41minimum_xcodeversions   {8 2.5}
42
43depends_lib-append  port:zlib path:bin/dbus-daemon:dbus \
44                    port:openssl port:tiff \
45                    port:libpng port:libmng port:jpeg
46
47# find a way to specify the OS MINOR version.  For OSX 10.X, this
48# value will be X.  The type is this variable is integer, so we can
49# use "==" and so forth for comparison.
50
51global MINOR
52set MINOR ""
53
54# hopefully the MACOSX_DEPLOYMENT_TARGET exists and is set by now.  if
55# not, last resort (which is not desirable) is to use the os.version.
56
57if {${macosx_deployment_target} ne ""} {
58    set MINOR [lindex [split ${macosx_deployment_target} "."] 1]
59} else {
60    set MINOR [expr [lindex [split ${os.version} "."] 0] - 4]
61}
62
63###############################################
64# Patches are used to both fix compiling on various OS versions, and
65# to enhance the functionality of QMake and its build files.  Some of
66# these patches are 2-stage: use a file here, and the replace an
67# @VARIABLE@ in post-patch.  There are LOTS of patches, because Qt is
68# a large, complicated system.
69
70# (0) Fix the testing script to properly handle both +universal as
71# well as the native arch for both CXX and CC compiling; also make
72# sure it does not create a Mac app bundle.
73
74patchfiles-append   patch-config.tests_unix_compile.test.diff
75
76# (1) Test for Precompiled-headers support (a) requires a C++
77# compiler, but configure calls it, by default, with a C compiler;
78# thus, enable testing using the C compiler. (b) to work with ccache,
79# if used.
80
81patchfiles-append   patch-config.tests_unix_precomp.test.diff
82
83# (2) fix 'configure' script: (a) to allow easy replacement of arch
84# type(s). (b) to find the correct QMAKE CXX compiler by removing
85# possibilities that include the character "$". (c) to declare, use,
86# and set QT_INSTALL_FRAMEWORKS and QMAKE_FRAMEWORKDIR_QT, both here
87# and in the resulting .qmake.cache files. (d) to allow easy
88# replacement of MACOSX_DEPLOYMENT_TARGET: build for just the user's
89# current OS. (e) add hooks for C++11 testing.
90
91patchfiles-append   patch-configure.diff
92
93# (3) (a) Tweak various scripts to allow easy replacement of
94# MACOSX_DEPLOYMENT_TARGET: build for just the user's current OS.
95# (b) Assign initial OBJECTIVE_CXXFLAGS.
96
97patchfiles-append   patch-mkspecs_common_g++-macx.conf.diff
98
99# (4) (a) Allow easy replacement of MACOSX_DEPLOYMENT_TARGET: build
100# for just the user's current OS; (b) allow QMake to use 'ccache' via,
101# e.g., "qmake && make CCACHE=ccache".
102
103patchfiles-append   patch-mkspecs_common_mac.conf.diff
104
105# (5) Place the -I path for local moc-created headers -before-
106# all other -I paths.
107
108patchfiles-append   patch-mkspecs_features_moc.prf.diff
109
110# (6) Remove Qt's LIBDIR and INCDIR from various QMake internal
111# variables, since they are already included in the user-supplied
112# LIBS and INCLUDEPATH.
113
114patchfiles-append   patch-mkspecs_features_qt.prf.diff
115
116# (7) (a) Change placement of Qt's LIBDIR and INCDIR, to always be
117# after those supplied by the user's QMake (.pro) files.  By the time
118# QMake gets to the patched function, it is creating the Makefile
119# parts to find Qt's headers and libraries, so moving these paths to
120# this location should always work. (b) If the library is QtWebKit,
121# and the build is library (no-framework), universal, and debug, then
122# the linkage is just -lQtWebKit, not -lQtWebKit_debug because the
123# debug library for 32-bit system cannot be created (too large).
124
125patchfiles-append   patch-mkspecs_features_qt_functions.prf.diff
126
127# (8) (a) Change "gcc" and "g++" to @'s for replacement in
128# post-patch; (b) add hooks for C++11.
129
130patchfiles-append   patch-mkspecs_common_g++-base.conf.diff
131
132# (9) Add default QMake variables for Objective C++.
133
134patchfiles-append   patch-mkspecs_objective_cxx.diff
135
136# (10) Add "absolute_library_soname" to the default CONFIG variables,
137# so that when a DYLIB is created, if "target.path" is set for it then
138# that path is prepended to its "install_name".
139
140patchfiles-append   patch-mkspecs_macx-g++_qmake.conf.diff
141
142# (11) Add QT_INSTALL_FRAMEWORKS and related variables to QMake, to
143# provide a default variable for the location of QMake installed
144# frameworks.
145
146patchfiles-append   \
147    patch-qmake_option.h.diff \
148    patch-qmake_property.cpp.diff \
149    patch-src_corelib_global_qlibraryinfo.cpp.diff \
150    patch-src_corelib_global_qlibraryinfo.h.diff
151
152# (12) In QMake, disable default MKSPECS and FEATURES path
153# concatinations if the shell environment variable QMAKE_NO_DEFAULTS
154# is set (to anything); we use this variable in this portfile to make
155# sure only internal paths (to the build) are searched by QMake.
156
157patchfiles-append   patch-qmake_project.cpp.diff
158
159# (13) In QMake: (a) enable correct "-framework foo,bar" parsing as
160# specified by Apple's LD; (b) disable "/Library/Frameworks" as a
161# default search path; use "PREFIX/Library/Frameworks" and replace
162# PREFIX in post-patch.  Also set "PREFIX/lib" as a default library
163# search path.
164
165patchfiles-append   patch-qmake_generators_unix_unixmakke.cpp.diff
166
167# (14) Allow easy replacement of MACOSX_DEPLOYMENT_TARGET: build for
168# just the user's current OS.
169
170patchfiles-append   \
171    patch-qmake_qmake.pri.diff \
172    patch-src_tools_bootstrap_bootstrap.pro.diff
173
174# (15) fix use of CARBON, found on PPC64; does not hurt others
175
176patchfiles-append   \
177    patch-src_3rdparty_webkit_Source_WebCore_plugins_PluginView.h.diff \
178    patch-src_3rdparty_webkit_Source_WebCore_plugins_mac_PluginViewMac.mm.diff
179
180# (16) fix the corewlan qmake file to use non-standard Developer SDK
181# location under 10.6 and newer, e.g., for some developers doing both
182# iOS and OSX.  This patch does not change behavior for 10.4 or 10.5.
183# Also include fix to use the correct SDK.
184
185patchfiles-append   patch-src_plugins_bearer_corewlan_corewlan.pro.diff
186
187# (17) Use the "target.path" for libdir for core libraries instead of
188# the standard QT_INSTALL_LIBS; allows us to set for library or
189# framework elsewhere and have the install still work here.
190
191patchfiles-append   patch-src_qbase.pri.diff
192
193# (18) (a) Disable explicit disabling of framework or static install;
194# i.e., install as a framework if that mode is selected, and as
195# library otherwise. (b) If installing as framework, use the new
196# QT_INSTALL_FRAMEWORKS directory; otherwise, use the old
197# QT_INSTALL_LIBS; (c) Get PKGCONFIG dependencies correct, hopefully;
198# (d) create and install .pc, .la, and .prl library description files,
199# including basic path replacement into DESTDIR; we couple this with a
200# post-patch to get the correct install location.
201
202patchfiles-append   \
203    patch-src_qt_install.pri.diff \
204    patch-tools_assistant_lib_fulltextsearch_fulltextsearch.pro.diff \
205    patch-tools_assistant_lib_lib.pro.diff \
206    patch-tools_designer_src_components_lib_lib.pro.diff \
207    patch-tools_designer_src_lib_lib.pro.diff \
208    patch-tools_designer_src_uitools_uitools.pro.diff \
209    patch-mkspecs_features_uitools.prf.diff
210
211# (19) fix 'macdeployqt' to look for the correct plugins location by
212# default.  This is paired with a "reinplace" in post-patch
213
214patchfiles-append   \
215    patch-tools_macdeployqt_macdeployqt_main.cpp.diff
216
217# (20) Under 10.4 only: patch QMake build files using just "-lQtHelp"
218# to do "-lQtHelp -lQtCLucene -lQtNetwork -lQtWebKit" instead.  For
219# some reason 10.5+ "knows" that how to do this correctly.
220
221platform darwin {
222    if {${MINOR} == 4} {
223        patchfiles-append patch-QtHelp_10.4_only.diff
224    }
225}
226
227# (21) fix the Mac timer's use of "mach_timebase_info"
228
229patchfiles-append   \
230    patch-src_corelib_tools_qelapsedtimer-mac.cpp.diff
231
232# (22) Under 10.8 and 10.9: Patch to fix corelib linking
233
234platform darwin {
235    if {${MINOR} >= 8} {
236        patchfiles-append patch-src_corelib_corelib.pro.diff
237    }
238}
239
240# (23) fix Framework directory in MacDeployQt tool
241
242patchfiles-append   \
243    patch-tools_macdeployqt_shared_shared.cpp.diff
244
245# (24) minimum patches required for 10.10; squashed; temporary until 4.8.7.
246
247patchfiles-append   \
248    patch-10.10.diff
249
250# (25) avoid leaving zombies when starting an inexisting executable through QProcess
251patchfiles-append \
252    qprocess-nozombies.patch
253
254# error out if trying to build on a new OSX version (> 10.10).
255
256platform darwin {
257    if {${MINOR} > 10} {
258        # This project needs to be updated to build with clang++ against libc++
259        depends_lib
260        depends_run
261        pre-fetch {
262            ui_error "$name does not currently build on OSX later than 10.10 'Yosemite'."
263            error "unsupported platform"
264        }
265    }
266}
267
268###############################################
269
270# disable CCACHE for now (ticket #34856)
271
272configure.ccache no
273
274## The main port that installs Qt4:
275if {${subport} ne "${name}-transitional"} {
276
277    # find a way to specify the SDK to use; Qt will use the 10.4u by
278    # default which won't work on 10.6 since it is not supported.  Allow
279    # the user to specify the SDK if desired.
280
281    global SDK
282    set SDK ${configure.sdkroot}
283    if {${SDK} eq ""} {
284        # set SDK version depending on OS version
285        set sdk_version ""
286        if {${MINOR} == 4} {
287            # OSX 10.4 requires an additional 'u'
288            set sdk_version "10.4u"
289        } else {
290            set sdk_version "10.${MINOR}"
291        }
292        if {[vercmp ${xcodeversion} 4.3] < 0} {
293            set SDK ${developer_dir}/SDKs/MacOSX${sdk_version}.sdk
294        } else {
295            set SDK ${developer_dir}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${sdk_version}.sdk
296        }
297    }
298
299    post-patch {
300        # set ARCHES in configure (per the third patchfile above), for
301        # building QMake.  join any 2 or more arch entries with the GCC
302        # arch flag (join does not effect a single entry).  first "-arch"
303        # is already in place in the 'configure' script (since there has
304        # to be at least 1 arch).
305
306        set ARCHES ""
307        if {[variant_exists universal] && [variant_isset universal]} {
308            set ARCHES [join ${universal_archs} " -arch "]
309        } else {
310            set ARCHES ${build_arch}
311        }
312        reinplace "s|@ARCHES@|${ARCHES}|g" ${worksrcpath}/configure
313
314        # set MACOSX_DEPLOYMENT_TARGET version in various places.  These
315        # were all patched in (2) above, and can be easily changed or
316        # overridden by the user in a project-local qmake .pro script.
317
318        set TARGET "10.${MINOR}"
319        foreach fixfile {configure mkspecs/common/g++-macx.conf \
320                         mkspecs/common/mac.conf qmake/qmake.pri \
321                         src/tools/bootstrap/bootstrap.pro } {
322            reinplace "s|@MACOSX_DEPLOYMENT_TARGET@|${TARGET}|g" \
323                ${worksrcpath}/${fixfile}
324        }
325
326        # Fix OS version on Bearer CoreWLAN QMake file
327
328        reinplace "s|@MACOSX_VERSION_MINOR@|${MINOR}|g" \
329            ${worksrcpath}/src/plugins/bearer/corewlan/corewlan.pro
330
331        # Ensure that correct C/C++ compilers are used.
332
333        reinplace "s|@CXX@|${configure.cxx}|" \
334            ${worksrcpath}/mkspecs/common/g++-base.conf
335        reinplace "s|@CC@|${configure.cc}|"  \
336            ${worksrcpath}/mkspecs/common/g++-base.conf
337
338        # fix the corewlan .pro file to use the correct developer SDK
339
340        reinplace "s,@DEVELOPER_SDK@,${SDK},g" \
341            ${worksrcpath}/src/plugins/bearer/corewlan/corewlan.pro
342
343        # fix 'macdeployqt' to look for the correct
344        # plugins location by default.
345
346        reinplace "s,@QT_PLUGINS_DIR@,${qt_plugins_dir},g" \
347            ${worksrcpath}/tools/macdeployqt/macdeployqt/main.cpp
348
349        # fix PREFIX in QMake makefile generator
350
351        reinplace "s,@PREFIX@,${qt_dir},g" \
352            ${worksrcpath}/qmake/generators/unix/unixmake.cpp
353
354        # if no debug, then do not even build debug code
355
356        if {![variant_isset debug]} {
357            foreach fixfile { src/qbase.pri \
358                              src/3rdparty/webkit/Source/WebKit.pri \
359                              src/imports/qimportbase.pri \
360                              src/plugins/qpluginbase.pri \
361                              tools/designer/src/components/lib/lib.pro \
362                              tools/designer/src/lib/lib.pro \
363                              tools/designer/src/plugins/activeqt/activeqt.pro \
364                              tools/designer/src/plugins/plugins.pri \
365                              tools/designer/src/uitools/uitools.pro \
366                              src/3rdparty/webkit/Source/WebKit/qt/declarative/declarative.pro } {
367                reinplace "/+=/s@debug_and_release@@g" \
368                    ${worksrcpath}/${fixfile}
369            }
370        }
371
372        # copy C++11 files into place, if that variant is set
373
374        if {[variant_isset cxx11]} {
375            copy ${filespath}/c++11.prf ${worksrcpath}/mkspecs/features
376            copy ${filespath}/c++11 ${worksrcpath}/config.tests/mac
377        }
378
379        # copy Objective C / CXX files into place
380
381        copy ${filespath}/objective_cxx.prf \
382            ${worksrcpath}/mkspecs/features/mac
383        copy ${filespath}/split_sources.prf \
384            ${worksrcpath}/mkspecs/features/mac
385
386        # copy extra compiler tests into place; these are patched into the
387        # configure script to the area before qmake is built.  If any
388        # fail, configure will fail quickly.
389
390        copy ${filespath}/fconstant_cfstrings.test \
391            ${worksrcpath}/config.tests/mac
392        copy ${filespath}/objc_block \
393            ${worksrcpath}/config.tests/mac
394        copy ${filespath}/cpath \
395            ${worksrcpath}/config.tests/mac
396        copy ${filespath}/library_path \
397            ${worksrcpath}/config.tests/mac
398    }
399
400    # Block various compilers:
401    #
402    # * The build process requires -Xarch, -fconstant-cfstring, and
403    # Objective-C(++) blocks (^), which are not supported with vanilla GCC
404    # as installed by MacPorts but are supported by all versions of CLANG
405    # (both MacPorts' and Apple's).
406    #
407    # * Some older versions of CLANG do not honor the CPATH
408    # environment variables, which is required for compiling
409    # this port when using MacPorts.  The versions seem to be: MacPorts
410    # CLANG 2.9 or earlier, and Apple CLANG 318.0.58 or older.
411    #
412    # * Some older versions of CLANG do not honor the LIBRARY_PATH
413    # environment variables, which is required for compiling
414    # this port when using MacPorts.  The versions seem to be: MacPorts
415    # CLANG 3.0 or earlier, and Apple CLANG 318.0.61 or older.
416    #
417    # * qt4-creator-mac fails to build with GCC <= 4.0.
418    #
419    # See also:
420    # < http://llvm.org/bugs/show_bug.cgi?id=8971 >,
421    # < https://trac.macports.org/ticket/30271 >,
422    # < https://trac.macports.org/ticket/31076 >,
423    # < https://trac.macports.org/ticket/31638 >,
424    # < https://trac.macports.org/ticket/37868 >, and
425    # < https://trac.macports.org/ticket/40422 >.
426    #
427    # NOTE: qt4-mac augments the standard Qt4 configure script with
428    # pre-qmake-build tests for CPATH, LIBRARY_PATH, -Xarch,
429    # -fconstant-cfstring, Objective-C(++) blocks, and, if requested,
430    # C++11.  The script will error out quickly if the compiler does not
431    # seem to provide support for any one of these properties, no matter
432    # this blacklist.
433    #
434
435    compiler.blacklist-append { clang <= 318.0.61 } \
436        gcc-3.3 *gcc-4.0 macports-gcc* \
437        macports-clang-2.9 macports-clang-3.0
438
439    # --prefix is not recognized.
440    configure.pre_args-delete       --prefix=${prefix}
441
442    # --disable-dependency-tracking is not recognized.
443    configure.universal_args-delete --disable-dependency-tracking
444
445    # clear all arch-oriented flags since somehow they impact how qmake is
446    # created, which in turn messes up LDFLAGS in most created Makefiles.
447
448    configure.ld_archflags
449    configure.cc_archflags
450    configure.cxx_archflags
451    configure.universal_ldflags
452    configure.universal_cflags
453    configure.universal_cxxflags
454    configure.universal_cppflags
455    configure.march
456    configure.mtune
457
458    # Use compiler.cpath and compiler.library_path for all -I and -L
459    # entries, so-as to avoid conflicts with already-installed headers and
460    # libraries (giving preference to internal-to-this-port first).  CPATH
461    # is used instead of -I to avoid conflicts with other ports.
462    #
463    # See also:
464    # < https://trac.macports.org/ticket/15219 >,
465    # < https://trac.macports.org/ticket/18723 >, and
466    # < https://trac.macports.org/ticket/25321 >.
467
468    # set the default paths to include those for SQLITE3 and DBUS-1
469
470    set header_path [ list ${prefix}/include/dbus-1.0 \
471                           ${prefix}/lib/dbus-1.0/include \
472                           ${prefix}/include ]
473
474    set library_path [ list ${prefix}/lib ]
475
476    # -dbus-linked prevends qt4 from trying to dynamically load libdbus-1,
477    #     which it is not able to find in ${prefix}.
478    #
479    # -openssl-linked ensures that the MacPorts openssl is used.
480    #
481    # -framework ensures that this port is installed as frameworks
482    #     (collections of {library, headers, resources}); in
483    #     post-destroot, link headers and libraries from the frameworks
484    #     into non-framework locations as if "-no-framework" were
485    #     specified.  Some dependent projects will not work properly if Qt
486    #     is installed as libraries by default, thus make it so #1.
487    #
488    # -no-phonon ensures that Qt does not install the 3rd-parth Phonon
489    #     port or its backend to QuickTime 7; Phonon is now installed via
490    #     the 'phonon' port, which is more up to date than that provided
491    #     by Qt.
492
493    configure.args                                            \
494        -v                                                    \
495        -confirm-license                                      \
496        -opensource                                           \
497        -prefix          ${qt_dir}                            \
498        -bindir          ${qt_bins_dir}                       \
499        -libdir          ${qt_libs_dir}                       \
500        -docdir          ${qt_docs_dir}                       \
501        -headerdir       ${qt_includes_dir}                   \
502        -plugindir       ${qt_plugins_dir}                    \
503        -importdir       ${qt_imports_dir}                    \
504        -datadir         ${qt_data_dir}                       \
505        -translationdir  ${qt_translations_dir}               \
506        -sysconfdir      ${qt_sysconf_dir}                    \
507        -examplesdir     ${qt_examples_dir}                   \
508        -demosdir        ${qt_demos_dir}                      \
509        -openssl-linked                                       \
510        -dbus-linked                                          \
511        -fast                                                 \
512        -optimized-qmake                                      \
513        -no-pch                                               \
514        -framework                                            \
515        -no-phonon                                            \
516        -no-phonon-backend                                    \
517        -fontconfig -system-freetype
518
519    # Stop configure script from searching for SQL Drivers
520    #    not available from MacPorts.
521
522    foreach driver {db2 ibase oci tds} {
523        configure.args-append -no-sql-${driver}
524    }
525
526    # Disable all remaining SQL Drivers.  These are available via the
527    # ports qt4-mac-*-plugin.
528
529    foreach driver {mysql odbc psql sqlite sqlite2} {
530        configure.args-append -no-sql-${driver}
531    }
532
533    pre-configure {
534
535        # use the corrected CPATH and LIBRARY_PATH for build
536
537        compiler.cpath [join ${header_path} :]
538        compiler.library_path [join ${library_path} :]
539
540        # for 10.4 or 10.5 32-bit PPC, build as Carbon only, not Cocoa
541
542        if {${MINOR} == 4} {
543
544            configure.args-append -carbon
545
546            # required linking flags?
547
548            configure.ldflags-append -lcrypto -ldbus-1 -ljpeg -llcms \
549                -lssl -lz
550
551        } elseif {${MINOR} == 5 &&
552                  [llength ${qt_arch_types}] == 1 &&
553                  [lsearch -exact ${qt_arch_types} ppc] == 0} {
554
555            configure.args-append -carbon
556
557        }
558
559        # set the arch type(s) to use, in Qt-speak
560
561        configure.args-append -arch \"${qt_arch_types}\"
562
563        # cannot use pre-compiled headers when compiling with more than 1
564        # arch type (typically +universal) or for X11
565
566        #if {[llength ${qt_arch_types}] != 1 || [variant_isset x11]}
567
568        # check to see if not compiling for the native machine hardware
569        # (e.g., compiling for just i386 but CPU is x86_64); optimization
570        # of QMake does not work in this circumstance.
571
572        if {[lsearch -exact ${qt_arch_types} ${os.arch}] == -1} {
573
574            # not building for native arch: disable optimizing qmake
575            configure.args-delete -optimized-qmake
576
577        } elseif {${MINOR} == 6 &&
578                  [llength ${qt_arch_types}] == 1 &&
579                  [lsearch -exact ${qt_arch_types} x86] == 0} {
580
581            # disable qmake optimization on 10.6 32-bit
582            configure.args-delete -optimized-qmake
583
584        }
585
586        # set the SDK, if it was found and exists
587
588        if {[file exists ${SDK}]} {
589            configure.args-append -sdk ${SDK}
590        }
591
592        # set which pkg-config to use
593
594        configure.env-append PKG_CONFIG=${prefix}/bin/pkg-config
595
596        # set which stdlib to use; clang only
597        if {[string match *clang* ${configure.compiler}]} {
598            configure.env-append QMAKE_STDLIB="-stdlib=${configure.cxx_stdlib}"
599            configure.ldflags-append -stdlib=${configure.cxx_stdlib}
600        }
601    }
602
603    post-configure {
604
605        # Remove any '-I' and '-L' string from the *FLAGS for SQLITE,
606        # DBUS, ODBC, and OPENSSL, so that what remains are just non-I/L
607        # flags; these paths are in compiler.cpath and
608        # compiler.library_path.  The header and library paths for all the
609        # other variants are not used by 'configure', and are already
610        # included in the compiler.cpath and compiler.library_path
611        # . during the 'build' stage, 'make' will rebuild the Makefiles
612        # that depend on any of these changed files.  These patches are
613        # sufficient to make sure local (to this build) paths are searched
614        # first, and then system paths last (via the compiler.X settings).
615        # Ideally, 'qmake' -- either via its mkspecs files or the
616        # project's build files -- would distinguish between "local" and
617        # "system" includes & libraries.
618
619        # SQLITE
620        reinplace "/SQLITE/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
621            ${worksrcpath}/.qmake.cache
622        reinplace "/SQLITE/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
623            ${worksrcpath}/.qmake.cache
624        # DBUS
625        reinplace "/DBUS/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
626            ${worksrcpath}/.qmake.cache
627        reinplace "/DBUS/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
628            ${worksrcpath}/.qmake.cache
629        # OPENSSL
630        reinplace "/OPENSSL/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
631            ${worksrcpath}/.qmake.cache
632        reinplace "/OPENSSL/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
633            ${worksrcpath}/.qmake.cache
634        # ODBC
635        reinplace "/ODBC/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
636            ${worksrcpath}/.qmake.cache
637        reinplace "/ODBC/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
638            ${worksrcpath}/.qmake.cache
639    }
640
641    pre-build {
642        # use the corrected CPATH and LIBRARY_PATH for build
643        compiler.cpath [join ${header_path} :]
644        compiler.library_path [join ${library_path} :]
645    }
646
647    # do not use DESTDIR directly in the destroot command; Qt uses DISTDIR
648    # internally for other purposes, and instead uses INSTALL_ROOT for the
649    # additional install root prefix.
650
651    destroot.post_args
652
653    pre-destroot {
654        # this isn't really nice if the user has 2nd thoughts and wants to install those html files after all
655        # (and knows how to get port to redo an install without cleaning and rebuilding everything).
656        # Let's hope that happens rarely enough to prefer speeding up the destroot step for the others
657        if {![variant_isset htmldocs]} {
658            if {[file exists ${worksrcpath}/doc/html/images]} {
659                ui_msg "cleaning out ${worksrcpath}/doc/html per your request"
660                delete file ${worksrcpath}/doc/html/images ${worksrcpath}/doc/html/scripts ${worksrcpath}/doc/html/style
661                eval file delete [glob ${worksrcpath}/doc/html/*.html]
662                eval file delete [glob ${worksrcpath}/doc/html/qt.*]
663            }
664        }
665    }
666
667    post-destroot {
668
669        set destroot_qt ${destroot}${qt_dir}
670
671        # Fix .pc and .prl files by changing ${worksrcpath}\${prefix} to
672        # ${qt_dir}\${prefix} ("\" means 'take away').  Cannot use
673        # "find -E" since it is not necessarily portable.
674
675        regsub ${prefix} ${worksrcpath} "" from_dir
676        regsub ${prefix} ${qt_dir} "" to_dir
677        foreach fixfile [exec find ${destroot_qt} -name "*.pc"] {
678            reinplace "s|${from_dir}|${to_dir}|g" ${fixfile}
679        }
680        foreach fixfile [exec find ${destroot_qt} -name "*.prl"] {
681            reinplace "s|${from_dir}|${to_dir}|g" ${fixfile}
682        }
683
684        # fix .pc files
685
686        foreach fixfile [exec find ${destroot_qt} -name "*.pc"] {
687
688            # remove Libs.private; they can mess up linking
689
690            reinplace "/Libs\.private/d" ${fixfile}
691
692            # use ${prefix} correctly
693
694            # RJVB:
695            # don't replace ${prefix} (e.g. /opt/local) with \${prefix}
696            # unless ${qt_dir} == ${prefix} (but I don't see the point at all...)
697            if {${prefix} eq ${qt_dir}} {
698                reinplace "s|${prefix}/|\${prefix}/|g" ${fixfile}
699            }
700
701            # fix libdir
702
703            reinplace "/libdir=/s|Library/Frameworks|lib|" ${fixfile}
704
705            # fix Libs: to use -L instead of -F
706
707            reinplace "/Libs:/s|-F|-L|" ${fixfile}
708
709            # fix Libs: to use -lQt* instead of "-framework Qt*"
710            # depends on whether for release or debug
711
712            set fn [lindex [split ${fixfile} /] end]
713
714            if {[lsearch -regexp ${fn} debug] == 0} {
715
716                # debug; need to add that string to all Qt dependency libraries
717                reinplace "/Libs:/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|" \
718                    ${fixfile}
719
720            } else {
721
722                # no debug; just replace
723                reinplace "/Libs:/s|-framework Qt|-lQt|" ${fixfile}
724
725            }
726        }
727
728        # move .pc files from ${qt_frameworks_dir}/pkgconfig to
729        # ${qt_pkg_config_dir}
730
731        file delete -force ${destroot}${qt_pkg_config_dir}
732        xinstall -m 755 -d ${destroot}${qt_libs_dir}
733    #    move ${destroot}${qt_frameworks_dir}/pkgconfig \
734    #        ${destroot}${qt_libs_dir}
735    # RJVB: ${destroot}${qt_libs_dir} is NOT always equal to ${qt_pkg_config_dir} !!
736        move ${destroot}${qt_frameworks_dir}/pkgconfig \
737            ${destroot}${qt_pkg_config_dir}
738        if {![variant_isset exclusive]} {
739            # qt_pkg_config_dir==${prefix}/lib/pkgconfig; make a symlink to that place in
740            # ${qt_libs_dir} so that 3rd party .pc files end up where pkg-config can find them ...
741            ln -s ${qt_pkg_config_dir} ${destroot}${qt_libs_dir}/pkgconfig
742        }
743
744        # move .la files from ${qt_frameworks_dir} to ${qt_libs_dir}
745
746        foreach laf [glob ${destroot}/${qt_frameworks_dir}/*.la] {
747            move ${laf} ${destroot}${qt_libs_dir}
748        }
749
750        # remove -L entries from .prl and .la files
751
752        foreach fixfile [exec find ${destroot_qt} -name "*.prl"] {
753            reinplace "/QMAKE_PRL_LIBS/s|-L\[^ \]*||g" ${fixfile}
754        }
755        foreach fixfile [exec find ${destroot_qt} -name "*.la"] {
756            reinplace "/dependency_libs/s|-L\[^ \]*||g" ${fixfile}
757        }
758
759        # remove redundant -F entries from .prl and .la files
760
761        foreach fixfile [exec find ${destroot_qt} -name "*.prl"] {
762            reinplace "/QMAKE_PRL_LIBS/s|-F\[^ \]*|FREPLACEME|1" \
763                ${fixfile}
764            reinplace "/QMAKE_PRL_LIBS/s|-F\[^ \]*||g" ${fixfile}
765            reinplace "s|FREPLACEME|-F${prefix}/${qt_frameworks_dir_rel}|1" \
766                ${fixfile}
767            # also remove the QMAKE_PRL_BUILD_DIR lines
768            reinplace "/QMAKE_PRL_BUILD_DIR/d" ${fixfile}
769        }
770        foreach fixfile [exec find ${destroot_qt} -name "*.la"] {
771            reinplace "/dependency_libs/s|-F\[^ \]*|FREPLACEME|1" \
772                ${fixfile}
773            reinplace "/dependency_libs/s|-F\[^ \]*||g" ${fixfile}
774            reinplace "s|FREPLACEME|-F${prefix}/${qt_frameworks_dir_rel}|1" \
775                ${fixfile}
776        }
777
778        # get Qt's version numbers
779
780        set qt_vers [split ${version} "."]
781        set qt_major [lindex ${qt_vers} 0]
782        set qt_minor [lindex ${qt_vers} 1]
783        set qt_patch [lindex ${qt_vers} 2]
784
785        # link includes and libraries for each actual installed framework
786
787        # make sure that qt_includes_dir exist; apparently it will not have been created at this point,
788        # despite the -headerdir ${qt_includes_dir} argument to configure. Because of doing a framework build?
789        exec mkdir -p ${destroot}${qt_includes_dir}
790        foreach fixfile [exec find ${destroot}${qt_frameworks_dir} \
791                             -name "*.framework" | \
792                             sed -e "s@${destroot}@@g"] {
793
794            set tf_full [strsed ${fixfile} {s@\\.framework@@}]
795            set tf [strsed ${tf_full} {g@.*\/@@}]
796
797            # special for QtWebKit entries
798
799            set t_minor ${qt_minor}
800            set is_QtWebKit 0
801            if {[string compare ${tf} QtWebKit] == 0} {
802                set t_minor 9
803                set is_QtWebKit 1
804            }
805
806            # link headers into ${qt_includes_dir}, removing directories
807            # if they are already there first
808
809            set inc_file ${destroot}${qt_includes_dir}/${tf}
810            if {[file exists ${inc_file}]} {
811                file delete -force ${inc_file}
812            }
813            ln -s ${tf_full}.framework/Headers ${inc_file}
814
815            # link libraries into ${qt_libs_dir}, all 4 number variants
816
817            set dr_qt_libs_dir ${destroot}${qt_libs_dir}
818
819            ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.dylib
820            ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.dylib
821            ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.dylib
822            ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.${qt_patch}.dylib
823
824            # copy .prl file, then correct it for library usage
825
826            copy ${destroot}${tf_full}.framework/${tf}.prl ${dr_qt_libs_dir}/lib${tf}.prl
827
828            # fix TARGET in .prl file
829
830            reinplace "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}.prl
831
832            # fix PRL_LIBS -F -> -L in .prl file
833
834            reinplace "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}.prl
835
836            # fix "-framework Qt*" -> "-lQt*" in .prl file
837
838            reinplace "/QMAKE_PRL_LIBS/s|-framework Qt|-lQt|g" \
839                ${dr_qt_libs_dir}/lib${tf}.prl
840
841            # fix up .la files to work with ${prefix}/lib entries
842
843            # rename .la file
844
845            move ${dr_qt_libs_dir}/${tf}.la ${dr_qt_libs_dir}/lib${tf}.la
846
847            # fix "name that we can dlopen" in .la file
848
849            reinplace "s|dlname=''|dlname='lib${tf}.${qt_major}.${t_minor}.${qt_patch}.dylib'|" ${dr_qt_libs_dir}/lib${tf}.la
850
851            # fix "names of this library" in .la file
852
853            reinplace "s|library_names='\[^'\]*'|library_names='lib${tf}.${qt_major}.${t_minor}.${qt_patch}.dylib lib${tf}.${qt_major}.${t_minor}.dylib lib${tf}.${qt_major}.dylib lib${tf}.dylib'|" \
854                ${dr_qt_libs_dir}/lib${tf}.la
855
856            # fix "name of the static archive"; there is none in .la file
857
858            reinplace "s|old_library='\[^'\]*'|old_library=''|" \
859                ${dr_qt_libs_dir}/lib${tf}.la
860
861            # fix "libraries that this one depends upon" in .la file
862
863            reinplace "/dependency_libs/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|"  ${dr_qt_libs_dir}/lib${tf}.la
864            reinplace "/dependency_libs/s|-framework Qt|-lQt|g" \
865                ${dr_qt_libs_dir}/lib${tf}.la
866            reinplace "/dependency_libs/s| ${worksrcpath}\[^ \]*||g" \
867                ${dr_qt_libs_dir}/lib${tf}.la
868            reinplace "/dependency_libs/s| -lwebcore||" \
869                ${dr_qt_libs_dir}/lib${tf}.la
870            reinplace "/dependency_libs/s| -ljscore||" \
871                ${dr_qt_libs_dir}/lib${tf}.la
872
873            # fix "directory that this library needs to be installed in" in .la file
874
875            reinplace "/libdir/s|${qt_frameworks_dir}|${qt_libs_dir}|" \
876                ${dr_qt_libs_dir}/lib${tf}.la
877
878            # deal with debug files
879
880            if {[variant_isset debug]} {
881
882                # but not if QtWebKit and +universal, since that one does
883                # not exist (the 32-bit version of the debug library is
884                # larger than fits into the 32-bit filespace).
885
886                if {[variant_isset debug] && ${is_QtWebKit}} {
887                    continue
888                }
889
890                # link libraries into ${qt_libs_dir}, all 4 number variants
891
892                ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.dylib
893                ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.dylib
894                ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.dylib
895                ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.${qt_patch}.dylib
896
897                # copy .prl file, then correct it for library usage
898
899                copy ${destroot}${tf_full}.framework/${tf}_debug.prl ${dr_qt_libs_dir}/lib${tf}_debug.prl
900
901                # fix TARGET in .prl file
902
903                reinplace "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
904
905                # fix PRL_LIBS -F -> -L in .prl file
906
907                reinplace "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
908
909                # fix "-framework Qt*" -> "-lQt*_debug" in .prl file
910
911                reinplace "/QMAKE_PRL_LIBS/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|g" ${dr_qt_libs_dir}/lib${tf}_debug.prl
912
913                # fix up .la files to work with ${prefix}/lib entries
914
915                # rename .la file
916
917                move ${dr_qt_libs_dir}/${tf}_debug.la \
918                    ${dr_qt_libs_dir}/lib${tf}_debug.la
919
920                # fix "name that we can dlopen" in .la file
921
922                reinplace "s|dlname=''|dlname='lib${tf}_debug.${qt_major}.${t_minor}.${qt_patch}.dylib'|" ${dr_qt_libs_dir}/lib${tf}_debug.la
923
924                # fix "names of this library" in .la file
925
926                reinplace "s|library_names='\[^'\]*'|library_names='lib${tf}_debug.${qt_major}.${t_minor}.${qt_patch}.dylib lib${tf}_debug.${qt_major}.${t_minor}.dylib lib${tf}_debug.${qt_major}.dylib lib${tf}_debug.dylib'|" \
927                    ${dr_qt_libs_dir}/lib${tf}_debug.la
928
929                # fix "name of the static archive"; there is none in .la file
930
931                reinplace "s|old_library='\[^'\]*'|old_library=''|" \
932                    ${dr_qt_libs_dir}/lib${tf}_debug.la
933
934                # fix "libraries that this one depends upon" in .la file
935
936                reinplace "/dependency_libs/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}_debug.la
937                reinplace "/dependency_libs/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|g" ${dr_qt_libs_dir}/lib${tf}_debug.la
938                reinplace "/dependency_libs/s| ${worksrcpath}\[^ \]*||g" \
939                    ${dr_qt_libs_dir}/lib${tf}_debug.la
940                reinplace "/dependency_libs/s| -lwebcored||" \
941                    ${dr_qt_libs_dir}/lib${tf}_debug.la
942                reinplace "/dependency_libs/s| -ljscored||" \
943                    ${dr_qt_libs_dir}/lib${tf}_debug.la
944
945                # fix "directory that this library needs to be installed in" in .la file
946
947                reinplace "/libdir/s|${qt_frameworks_dir}|${qt_libs_dir}|" \
948                    ${dr_qt_libs_dir}/lib${tf}_debug.la
949
950            }
951        }
952
953        # Install documentation.
954
955        xinstall -m 755 -d ${worksrcpath}/${qt_docs_dir}
956        xinstall -m 644 -W ${worksrcpath} \
957            INSTALL LGPL_EXCEPTION.txt LICENSE.FDL \
958            LICENSE.GPL3 LICENSE.LGPL README \
959            ${destroot}${qt_docs_dir}
960
961        # Install private headers needed by QtCreator
962
963        foreach {src_dir include_dir} \
964        {corelib QtCore gui QtGui script QtScript declarative QtDeclarative} {
965            set dest_dir ${destroot}${qt_frameworks_dir}/${include_dir}.framework/Headers/private
966            xinstall -m 755 -d ${dest_dir}
967            set files [exec find ${worksrcpath}/src/${src_dir} -type f -name "*_p.h"]
968            eval xinstall -m 644 [split ${files}] ${dest_dir}
969        }
970
971        # Move .apps into the applications_dir, and link each .apps'
972        # executable back into ${qt_bins_dir}
973
974        set dr_qt_apps_dir ${destroot}${qt_apps_dir}
975        set dr_qt_bins_dir ${destroot}${qt_bins_dir}
976
977        xinstall -m 755 -d ${dr_qt_apps_dir}
978        foreach app [glob ${dr_qt_bins_dir}/*.app] {
979
980            # remove the leading stuff
981
982            set app [lindex [split ${app} /] end]
983
984            # move the .app
985
986            move ${dr_qt_bins_dir}/${app} ${dr_qt_apps_dir}
987
988            # link the app's executable back
989
990            set texe [strsed ${app} {g@\.app@@}]
991            ln -s ${qt_apps_dir}/${app}/Contents/MacOS/${texe} \
992                ${dr_qt_bins_dir}
993
994        }
995
996        # move tests to ${qt_data_dir}
997
998        xinstall -m 755 -d ${destroot}${qt_data_dir}
999        move ${destroot_qt}/tests/qt4 ${destroot}${qt_data_dir}/tests
1000
1001        # install ${qt_includes_dir}/Qt if not already and it exists in
1002        # the build, for support of legacy projects
1003
1004        if {![file exists ${destroot}${qt_includes_dir}/Qt] &&
1005            [file exists ${worksrcpath}/include/Qt]} {
1006
1007            # copy the Qt headers directory
1008
1009            copy ${worksrcpath}/include/Qt ${destroot}${qt_includes_dir}
1010
1011        }
1012
1013        # link in Resource to ${qt_libs_dir}
1014
1015        ln -s ${qt_frameworks_dir}/QtGui.framework/Resources \
1016            ${destroot}${qt_libs_dir}
1017
1018        if {![variant_isset exclusive]} {
1019            ln -s ${qt_qmake_cmd} ${destroot}/${prefix}/bin/qmake${qt_major}.${qt_minor}
1020            ln -s ${qt_moc_cmd} ${destroot}/${prefix}/bin/moc${qt_major}.${qt_minor}
1021            ln -s ${qt_uic_cmd} ${destroot}/${prefix}/bin/uic${qt_major}.${qt_minor}
1022            ln -s ${qt_lrelease_cmd} ${destroot}/${prefix}/bin/lrelease${qt_major}.${qt_minor}
1023        }
1024        if {[variant_isset KDE]} {
1025            # expose KDE4 styles to Qt4:
1026            ln -s ${prefix}/lib/kde4/plugins/styles ${destroot}${qt_plugins_dir}/
1027        }
1028        if {[variant_isset noexceptions ]} {
1029            # building with -no-exceptions will add a section to QtCore/qconfig.h that has to be removed
1030            # given that we did NOT build QtCore WITHOUT exceptions...
1031            exec patch -d ${destroot}${qt_frameworks_dir} -Np0 -i ${filespath}/qconfig-remove-EXCEPTIONS.diff
1032        }
1033    }
1034
1035    variant odbc description {Enable iODBC SQL Driver} {
1036        depends_lib-append port:libiodbc
1037        configure.args-delete -no-sql-odbc
1038        configure.args-append -plugin-sql-odbc
1039    }
1040
1041    variant raster description {Use raster graphics system by default} {
1042        configure.args-append -graphicssystem raster
1043    }
1044
1045    variant demos description {Build demos} {}
1046
1047    if {![variant_isset demos]} {
1048       configure.args-append -nomake demos
1049    }
1050
1051    variant examples description {Build examples} {}
1052
1053    if {![variant_isset examples]} {
1054       configure.args-append -nomake examples
1055    }
1056
1057    variant debug description {Build both release and debug library} {}
1058
1059    if {[variant_isset debug]} {
1060        configure.args-append -debug-and-release -declarative-debug
1061    } else {
1062        configure.args-append -release -no-declarative-debug
1063    }
1064
1065    variant openvg description {Build with *experimental* support for OpenVG} {
1066
1067        depends_lib-append port:mesa
1068
1069        pre-configure {
1070
1071            # set OpenVG arg, for both testing and building
1072
1073            configure.env-append QMAKE_OPENVG_ARG=-lOpenVG
1074
1075        }
1076    }
1077
1078    variant cxx11 description {Add library support for C++11 (EXPERIMENTAL; does not work with libc++)} {
1079
1080        # Block compilers that do not support C++11. This variant seems to
1081        # work with MacPorts' clang 3.0 or newer and Apple clang newer
1082        # than 318.0.58 (but, not that version, which is already blocked).
1083
1084        compiler.blacklist-append \
1085            apple-gcc-4.2 gcc-4.2 llvm-gcc-4.2
1086
1087        pre-fetch {
1088
1089            # This variant does not work with Clang libc++
1090
1091            if {[info exists configure.cxx_stdlib] &&
1092                ${configure.cxx_stdlib} eq "libc++" &&
1093                [string match *clang* ${configure.cxx}]} {
1094
1095                ui_msg "\nERROR: C++11 support for Qt4 is not available when using Clang and libc++.\n"
1096                error "unsupported platform for C++11 support"
1097
1098            }
1099        }
1100
1101        pre-extract {
1102
1103            ui_msg "\nWARNING: You have enabled C++11 support for Qt4, which is EXPERIMENTAL.  Qt's libraries and applications (not including QMake) will be compiled using C++11.  That said, C++11 will NOT be enabled by default when using QMake.  You can enable C++11 by specifying, e.g. \'CONFIG += c++11\', in any QMake build file.\n"
1104
1105        }
1106
1107        # patches for C++11 only
1108
1109        patchfiles-append patch-cxx11.diff
1110
1111        # have configure test for C++11; our hooks
1112        # will error out if C++11 is not found.
1113
1114        configure.args-append -c++11
1115
1116    }
1117
1118    variant htmldocs description {Install HTML documentation (>200Mb)} {}
1119
1120    post-activate {
1121        ui_msg "NOTE: Qt database plugins for mysql55, postgresql91, and sqlite2 are NOT installed by this port\; they are installed by qt4-mac-*-plugin instead."
1122    }
1123
1124    variant KDE description {Include RJVB's patches for use with KDE} {
1125        patchfiles-append  qt4-correct-systraymenu-iconhandling.patch \
1126                           qt4-deactivate-menurole-heuristics.patch \
1127                           prevent_addTitleRelated_crash.patch \
1128                           debug-negative-qtimerint.patch \
1129                           silence-qfilesystemwatcher.patch \
1130                           patch-QAction_isEnabled.diff
1131    }
1132
1133    variant noexceptions description {build without using exceptions internally} {
1134        # (26) don't build with exceptions, which gives a completely ABI-compatible build
1135        patchfiles-append       disable-exceptions.patch
1136        configure.args-append   -no-exceptions
1137    }
1138
1139}
1140
1141## The convenience subport that installs the symlinks which allow ports built against qt4-mac +exclusive
1142## to keep functioning after installing qt4-mac in the new concurrent mode, without rebuilding them.
1143## It can be uninstalled after all Qt4 "client" ports have been rebuilt.
1144if { ${subport} eq "${name}-transitional" } {
1145    if {[variant_isset exclusive]} {
1146            return -code error "\n\nERROR:\n\
1147    ${name}-transitional is available only when qt4-mac has been installed without +exclusive\n"
1148    }
1149    fetch {
1150        if {![info exists qt4_is_concurrent]} {
1151            return -code error "\n\nERROR:\n\
1152    ${name}-transitional is available only when qt4-mac has been installed without +exclusive\n"
1153        }
1154    }
1155    if {[file exists ${prefix}/Library/Frameworks/QtCore.framework/Versions/5/Headers/QtCore]} {
1156        conflicts-append    qt5-mac
1157    }
1158    checksum {}
1159    extract {}
1160    patch {}
1161    post-patch {}
1162    configure {}
1163    build {}
1164    destroot {
1165        set qt_vers [split ${version} "."]
1166        set qt_major [lindex ${qt_vers} 0]
1167        set qt_minor [lindex ${qt_vers} 1]
1168        set qt_patch [lindex ${qt_vers} 2]
1169        exec mkdir -p ${destroot}/${prefix}/lib ${destroot}/${prefix}/Library/Frameworks
1170        foreach fixfile [exec find ${qt_frameworks_dir} \
1171                             -name "*.framework"] {
1172
1173            set tf_full [strsed ${fixfile} {s@\\.framework@@}]
1174            set tf [strsed ${tf_full} {g@.*\/@@}]
1175            ln -s ${tf_full}.framework/${tf} ${destroot}/${prefix}/lib/lib${tf}.${qt_major}.dylib
1176            ln -s ${tf_full}.framework/${tf} ${destroot}/${prefix}/lib/lib${tf}.${qt_major}.${qt_minor}.dylib
1177            ln -s ${tf_full}.framework/${tf} ${destroot}/${prefix}/lib/lib${tf}.${qt_major}.${qt_minor}.${qt_patch}.dylib
1178            ln -s ${tf_full}.framework       ${destroot}/${prefix}/Library/Frameworks/${tf}.framework
1179        }
1180    }
1181}
1182
1183livecheck.type      regex
1184livecheck.url       http://download.qt-project.org/official_releases/qt/${branch}/
1185livecheck.regex     >(\[0-9.\]+)/<