Ticket #66114: Portfile

File Portfile, 45.7 KB (added by ShadSterling (Shad Sterling), 2 years ago)
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
3PortSystem          1.0
4
5# use the qt4 group; set 'building_qt4' so that the portgroup
6# does not include certain parts
7set building_qt4    1
8PortGroup           qt4 1.0
9PortGroup           xcodeversion 1.0
10PortGroup           compiler_blacklist_versions 1.0
11
12name                qt4-mac
13version             4.8.7
14revision            13
15set branch          [join [lrange [split ${version} .] 0 1] .]
16
17categories          aqua
18platforms           macosx
19maintainers         {michaelld @michaelld} openmaintainer
20license             {LGPL-2.1 GPL-3}
21
22homepage            http://www.qt.io/
23description         Qt Tool Kit
24long_description    Qt Tool Kit: A cross-platform framework \
25                    (headers, data, and libraries) for writing \
26                    cross-platform GUI-based applications.
27
28distname            qt-everywhere-opensource-src-${version}
29
30master_sites        http://download.qt.io/official_releases/qt/${branch}/${version}/
31
32checksums           rmd160 afb5e5a99388e6429faca59cb5000054feffd166 \
33                    sha256 e2882295097e47fe089f8ac741a95fef47e0a73a3f3cdf21b56990638f626ea0 \
34                    size   241075567
35
36if {[info exists use_xcode]} {
37    use_xcode           yes
38}
39minimum_xcodeversions   {8 2.5}
40
41depends_lib-append  port:zlib \
42                    path:bin/dbus-daemon:dbus \
43                    path:lib/libssl.dylib:openssl \
44                    port:tiff \
45                    port:libpng \
46                    port:libmng \
47                    path:include/turbojpeg.h:libjpeg-turbo
48
49platform darwin 10 {
50    # Rosetta build fails with macosx_deployment_target 10.6
51    # https://trac.macports.org/ticket/65596
52    if {${build_arch} eq "ppc"} {
53        macosx_deployment_target 10.5
54    }
55}
56
57# find a way to specify the OS MINOR version.  For OSX 10.X, this
58# value will be X.  The type is this variable is integer, so we can
59# use "==" and so forth for comparison.
60
61global MINOR, MAJOR
62set MAJOR ""
63set MINOR ""
64
65# hopefully the MACOSX_DEPLOYMENT_TARGET exists and is set by now.  if
66# not, last resort (which is not desirable) is to use the os.version.
67
68if {${macosx_deployment_target} ne ""} {
69    set MAJOR [lindex [split ${macosx_deployment_target} "."] 0]
70    set MINOR [lindex [split ${macosx_deployment_target} "."] 1]
71} else {
72    # Do we really need this branch still ??
73    if { ${os.major} < 20 } {
74        set MAJOR 10
75        set MINOR [expr [lindex [split ${os.version} "."] 0] - 4]
76    } else {
77        # Bit of a guess, and will not work once we have macOS 12
78        set MAJOR 11
79        set MINOR [expr [lindex [split ${os.version} "."] 0] - 20]
80    }
81}
82# ui_debug "Deduced OS MAJOR.MINOR = ${MAJOR}.${MINOR}"
83
84###############################################
85# Patches are used to both fix compiling on various OS versions, and
86# to enhance the functionality of QMake and its build files.  Some of
87# these patches are 2-stage: use a file here, and the replace an
88# @VARIABLE@ in post-patch.  There are LOTS of patches, because Qt is
89# a large, complicated system.
90
91# (0) Fix the testing script to properly handle both +universal as
92# well as the native arch for both CXX and CC compiling; also make
93# sure it does not create a Mac app bundle.
94
95patchfiles-append   patch-config.tests_unix_compile.test.diff
96
97# (1) Test for Precompiled-headers support (a) requires a C++
98# compiler, but configure calls it, by default, with a C compiler;
99# thus, enable testing using the C compiler. (b) to work with ccache,
100# if used.
101
102patchfiles-append   patch-config.tests_unix_precomp.test.diff
103
104# (2) fix 'configure' script: (a) to allow easy replacement of arch
105# type(s). (b) to find the correct QMAKE CXX compiler by removing
106# possibilities that include the character "$". (c) to declare, use,
107# and set QT_INSTALL_FRAMEWORKS and QMAKE_FRAMEWORKDIR_QT, both here
108# and in the resulting .qmake.cache files. (d) to allow easy
109# replacement of MACOSX_DEPLOYMENT_TARGET: build for just the user's
110# current OS. (e) add hooks for C++11 testing.
111
112patchfiles-append   patch-configure.diff
113
114# (3) (a) Tweak various scripts to allow easy replacement of
115# MACOSX_DEPLOYMENT_TARGET: build for just the user's current OS.
116# (b) Assign initial OBJECTIVE_CXXFLAGS.
117
118patchfiles-append   patch-mkspecs_common_g++-macx.conf.diff
119
120# (4) (a) Allow easy replacement of MACOSX_DEPLOYMENT_TARGET: build
121# for just the user's current OS; (b) allow QMake to use 'ccache' via,
122# e.g., "qmake && make CCACHE=ccache".
123
124patchfiles-append   patch-mkspecs_common_mac.conf.diff
125
126# (5) Place the -I path for local moc-created headers -before-
127# all other -I paths.
128
129patchfiles-append   patch-mkspecs_features_moc.prf.diff
130
131# (6) Remove Qt's LIBDIR and INCDIR from various QMake internal
132# variables, since they are already included in the user-supplied
133# LIBS and INCLUDEPATH.
134
135patchfiles-append   patch-mkspecs_features_qt.prf.diff
136
137# (7) (a) Change placement of Qt's LIBDIR and INCDIR, to always be
138# after those supplied by the user's QMake (.pro) files.  By the time
139# QMake gets to the patched function, it is creating the Makefile
140# parts to find Qt's headers and libraries, so moving these paths to
141# this location should always work. (b) If the library is QtWebKit,
142# and the build is library (no-framework), universal, and debug, then
143# the linkage is just -lQtWebKit, not -lQtWebKit_debug because the
144# debug library for 32-bit system cannot be created (too large).
145
146patchfiles-append   patch-mkspecs_features_qt_functions.prf.diff
147
148# (8) (a) Change "gcc" and "g++" to @'s for replacement in
149# post-patch; (b) add hooks for C++11.
150
151patchfiles-append   patch-mkspecs_common_g++-base.conf.diff
152
153# (9) Add default QMake variables for Objective C++.
154
155patchfiles-append   patch-mkspecs_objective_cxx.diff
156
157# (10) Add "absolute_library_soname" to the default CONFIG variables,
158# so that when a DYLIB is created, if "target.path" is set for it then
159# that path is prepended to its "install_name".
160
161patchfiles-append   patch-mkspecs_macx-g++_qmake.conf.diff
162
163# (11) Add QT_INSTALL_FRAMEWORKS and related variables to QMake, to
164# provide a default variable for the location of QMake installed
165# frameworks.
166
167patchfiles-append   \
168    patch-qmake_option.h.diff \
169    patch-qmake_property.cpp.diff \
170    patch-src_corelib_global_qlibraryinfo.cpp.diff \
171    patch-src_corelib_global_qlibraryinfo.h.diff
172
173# (12) In QMake, disable default MKSPECS and FEATURES path
174# concatinations if the shell environment variable QMAKE_NO_DEFAULTS
175# is set (to anything); we use this variable in this portfile to make
176# sure only internal paths (to the build) are searched by QMake.
177
178patchfiles-append   patch-qmake_project.cpp.diff
179
180# (13a) In QMake: (a) enable correct "-framework foo,bar" parsing as
181# specified by Apple's LD; (b) disable "/Library/Frameworks" as a
182# default search path; use "PREFIX/Library/Frameworks" and replace
183# PREFIX in post-patch.  Also set "PREFIX/lib" as a default library
184# search path.
185
186patchfiles-append   patch-qmake_generators_unix_unixmake.cpp.framework.diff
187
188# (13b) In QMake: fix issue for when LFLAGS and env LDFLAGS contain
189# multiple "-arch FOO" duplicate flags, which would result in output
190# such as "-arch x86_64 -arch -Xarch_x86_64 ...".
191
192patchfiles-append   patch-qmake_generators_unix_unixmake.cpp.fix_arch.diff
193
194# (14) Allow easy replacement of MACOSX_DEPLOYMENT_TARGET: build for
195# just the user's current OS.
196
197patchfiles-append   \
198    patch-qmake_qmake.pri.diff \
199    patch-src_tools_bootstrap_bootstrap.pro.diff
200
201# (15) fix use of CARBON, found on PPC64; does not hurt others
202
203patchfiles-append   \
204    patch-src_3rdparty_webkit_Source_WebCore_plugins_PluginView.h.diff \
205    patch-src_3rdparty_webkit_Source_WebCore_plugins_mac_PluginViewMac.mm.diff
206
207# (16) Use the "target.path" for libdir for core libraries instead of
208# the standard QT_INSTALL_LIBS; allows us to set for library or
209# framework elsewhere and have the install still work here.
210
211patchfiles-append   patch-src_qbase.pri.diff
212
213# (17) (a) Disable explicit disabling of framework or static install;
214# i.e., install as a framework if that mode is selected, and as
215# library otherwise. (b) If installing as framework, use the new
216# QT_INSTALL_FRAMEWORKS directory; otherwise, use the old
217# QT_INSTALL_LIBS; (c) Get PKGCONFIG dependencies correct, hopefully;
218# (d) create and install .pc, .la, and .prl library description files,
219# including basic path replacement into DESTDIR; we couple this with a
220# post-patch to get the correct install location.
221
222patchfiles-append   \
223    patch-src_qt_install.pri.diff \
224    patch-tools_assistant_lib_fulltextsearch_fulltextsearch.pro.diff \
225    patch-tools_assistant_lib_lib.pro.diff \
226    patch-tools_designer_src_components_lib_lib.pro.diff \
227    patch-tools_designer_src_lib_lib.pro.diff \
228    patch-tools_designer_src_uitools_uitools.pro.diff \
229    patch-mkspecs_features_uitools.prf.diff
230
231# (18) fix 'macdeployqt' to look for the correct plugins location by
232# default.  This is paired with a "reinplace" in post-patch
233
234patchfiles-append   \
235    patch-tools_macdeployqt_macdeployqt_main.cpp.diff
236
237# (19) fix the Mac timer's use of "mach_timebase_info"
238
239patchfiles-append   \
240    patch-src_corelib_tools_qelapsedtimer-mac.cpp.diff
241
242# (20) Under 10.8 and 10.9: Patch to fix corelib linking
243
244platform darwin {
245    if {${MAJOR} > 10 || ${MINOR} >= 8} {
246        patchfiles-append patch-src_corelib_corelib.pro.diff
247    }
248}
249
250# (21) fix Framework directory in MacDeployQt tool
251
252patchfiles-append   \
253    patch-tools_macdeployqt_shared_shared.cpp.diff
254
255# (22) remove ColorSync usage from qpaintengine.
256
257# This patch allows for building using the 10.11 SDK, and is also
258# backward compatible with prior OS versions since it just removes API
259# usage but does not otherwise add any. This patch does roughly the
260# same thing as that from Qt5 commit b06304e16:
261# http://code.qt.io/cgit/qt/qtbase.git/commit/?id=b06304e164ba47351fa292662c1e6383c081b5ca
262
263patchfiles-append   \
264    patch-src_gui_painting_qpaintengine_mac.diff
265
266# (23) fix qcursor_mac; already committed upstream; see also:
267# https://trac.macports.org/ticket/48516
268# http://code.qt.io/cgit/qt/qtbase.git/commit/src/plugins/platforms/cocoa/qcocoacursor.mm?id=02ea0235216beef390e9868ff770c7a54d70db83
269# https://developer.apple.com/library/prerelease/mac/documentation/Carbon/Reference/QuartzEventServicesRef/#//apple_ref/c/func/CGEventCreateMouseEvent
270
271patchfiles-append   \
272    patch-src_gui_kernel_qcursor_mac.mm.diff
273
274# (24) avoid zombie processes; see also:
275# https://trac.macports.org/ticket/46608
276# https://codereview.qt-project.org/#/c/61294/
277# approved but abandoned.
278
279patchfiles-append   \
280    patch-src_corelib_io_qprocess_unix.cpp.diff
281
282# (25) fix build on Leopard; see also:
283# https://trac.macports.org/ticket/43746
284
285patchfiles-append   \
286    patch-src_gui_dialogs_qfiledialog_mac.mm.diff
287
288# (26) QTKit no longer exists as of macOS 10.12 (Sierra)
289# https://trac.macports.org/ticket/52332
290
291platform darwin {
292    if {${MAJOR} > 10 || ${MINOR} >= 12} {
293        patchfiles-append patch-src_gui_kernel_qmime_mac.cpp.diff
294    }
295}
296
297# (27) Better invalid fonttable handling
298# Qt commit 0a2f2382 on July 10, 2015 at 7:22:32 AM EDT.
299# not included in 4.8.7 release.
300
301patchfiles-append patch-better-invalid-fonttable-handling.diff
302
303# (28) Fix pointer comparison with 0
304# These error out on clang 4.0, whereas they didn't in 3.9.
305
306patchfiles-append patch-fix_pointer_comparison_to_0.diff
307
308# (29) Backport of Qt5 patch to fix an issue with null bytes in
309# QSetting strings (QTBUG-56124).
310
311patchfiles-append patch-qsettings-null.diff
312
313# (30) Various patches to fix compilation and runtime on 10.4 Tiger.
314# These us # macros keyed on >= 10.5 or not, and so do not harm
315# compilation on non-Tiger Mac OS X.
316
317patchfiles-append   \
318    patch-src_corelib_io_qfilesystemengine_unix.cpp-tiger.diff \
319    patch-src_network_kernel_qnetworkproxy_mac.cpp-tiger.diff \
320    patch-src_gui_painting_qprintengine_mac.mm-tiger.diff \
321    patch-src_gui_dialogs_qfontdialog_mac.mm-tiger.diff \
322    patch-src_gui_text_qfontdatabase_mac.cpp-tiger.diff \
323    patch-src_gui_painting_qpaintengine_mac.cpp-tiger.diff \
324    patch-webkit-tiger.diff
325
326# (31) Patch to fix build on macOS High Sierra
327
328patchfiles-append patch-qt4-versions-without-underscores.diff
329
330# (32) Fix default thread stack size on Mac OS X (QTBUG-49607)
331# https://bugreports.qt.io/secure/attachment/52520/patch-qthread-stacksize.diff
332# Note that Qt 5.10 and later implement QThreadPool:stackSize to set the
333# stack size (QTBUG-2568).
334
335patchfiles-append patch-qthread-stacksize.diff
336
337# (33) Add possibility to set a custom global thread pool
338
339patchfiles-append patch-qt-custom-threadpool.diff
340
341# (34) Allow control over the default graphics system to be used via
342# Qt's own qtconfig utility: Native vs. Raster vs. OpenGL. Qtconfig
343# is not normally built on Mac so a patch is required to activate it.
344patchfiles-append patch-tools-build_qtconfig.diff \
345                  patch-graphicssystem-via-qtconfig.diff
346
347# (35) Various from NiXos
348# see also < https://trac.macports.org/ticket/55932 >
349# and < https://github.com/NixOS/nixpkgs/tree/master/pkgs/development/libraries/qt-4.x/4.8 >
350
351# (a) allow use of libressl as well as openssl
352
353patchfiles-append patch-allow_libressl.diff
354
355# (b) allow parallel qmake building
356# normally qmake is built using a single thread / job
357
358patchfiles-append patch-parallelize_qmake_build.diff
359
360# (c) fix unix makefile generation to augment this specific variable
361# ('ret'), not overwrite it -- this matches the other uses of the
362# specific variable in that area, especially that in the 'if' statement.
363
364patchfiles-append patch-qmake_generators_unix_unixmake.cpp.diff
365
366# (d) fix to not call qsettings before constructing a qapplication,
367# because it causes a dead-lock.
368
369patchfiles-append patch-src_corelib_io_qsettings.cpp.diff
370
371# (e) fix to properly use QFixed as a type rather than a constructor
372# (I think). Without this fix, the build errors out on Clang 5.
373
374patchfiles-append patch-src_gui_text_qfontengine_coretext.mm.diff
375
376# fix build against openssl 1.1.1
377# see https://trac.macports.org/ticket/58205
378patchfiles-append patch-qt4-openssl111.diff
379
380# newer versions of MacPorts Clang default to newer C++ standards
381# see https://trac.macports.org/ticket/57751
382if {![variant_isset cxx11]} {
383    patchfiles-append patch-compiler_standard.diff
384}
385
386# Fix slow drawing on Big Sur.
387# See:
388# - https://developer.apple.com/forums/thread/663256
389# - https://gist.github.com/lukaskubanek/9a61ac71dc0db8bb04db2028f2635779
390# - https://trac.wxwidgets.org/ticket/19111
391# The fix can only be compiled with the 10.12 SDK or later.
392patchfiles-append patch-qt4-contentsformat.diff
393
394# the configure script uses the compiler version to determine if QtXmlPatterns and QtWebKit can be built
395# the logic does not work for newer versions of GCC or Clang (masquerading as GCC)
396patchfiles-append patch-test_compiler_version.diff
397
398# on Apple Silicon / M1 / ARM64, cross-build as X86_64, which requires some minor tweaks
399if {${os.arch} == "arm"} {
400    patchfiles-append patch-fix-ARM64-cross-build-as-X86_64.diff
401}
402
403# newer Clang (e.g., on macOS Monterey 12.0+) doesn't allow "volative"
404# ASM keyword; removing it should not hurt other compilers; if it does
405# we'll add an "if" to narrow the scope of application
406patchfiles-append patch-src_3rdparty_javascriptcore_JavaScriptCore_jit_JITStubs.cpp_remove_volatile.diff
407
408# the version header file is part of C++20
409# newer versions of Clang find VERSION instead
410post-extract {
411    move \
412        ${worksrcpath}/src/3rdparty/javascriptcore/VERSION \
413        ${worksrcpath}/src/3rdparty/javascriptcore/VERSION.txt
414}
415
416# error out if trying to build on a new OSX version (> 11.0).
417
418platform darwin {
419    if { ( ${MAJOR} == 10 && ${MINOR} > 15 ) || ${MAJOR} > 13 } {
420        # This project needs to be updated to build with clang++ against libc++
421        depends_lib
422        depends_run
423        pre-fetch {
424            ui_error "$name does not currently build on macOS later than 13 'Ventura'."
425            error "unsupported platform"
426        }
427    }
428}
429
430###############################################
431
432# disable CCACHE for now (ticket #34856)
433
434configure.ccache no
435
436# find a way to specify the SDK to use; Qt will use the 10.4u by
437# default which won't work on 10.6 since it is not supported.  Allow
438# the user to specify the SDK if desired.
439
440global SDK
441set SDK ${configure.sdkroot}
442if {${SDK} eq ""} {
443    # set SDK version depending on OS version
444    set sdk_version ""
445    if { ${MAJOR} == 10 && ${MINOR} == 4 } {
446        # OSX 10.4 requires an additional 'u'
447        set sdk_version "${MAJOR}.4u"
448    } else {
449        set sdk_version "${MAJOR}.${MINOR}"
450    }
451    if {[vercmp ${xcodeversion} 4.3] < 0} {
452        set SDK ${developer_dir}/SDKs/MacOSX${sdk_version}.sdk
453    } else {
454        set SDK ${developer_dir}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${sdk_version}.sdk
455    }
456}
457
458# no support for ARM64 yet
459supported_archs ppc ppc64 i386 x86_64
460
461post-patch {
462    # set ARCHES in configure (per the third patchfile above), for
463    # building QMake.  join any 2 or more arch entries with the GCC
464    # arch flag (join does not affect a single entry).  first "-arch"
465    # is already in place in the 'configure' script (since there has
466    # to be at least 1 arch).
467
468    set ARCHES ""
469    if {[variant_exists universal] && [variant_isset universal]} {
470        set ARCHES [join ${configure.universal_archs} " -arch "]
471    } else {
472        set ARCHES ${configure.build_arch}
473    }
474    reinplace "s|@ARCHES@|${ARCHES}|g" ${worksrcpath}/configure
475
476    # set MACOSX_DEPLOYMENT_TARGET version in various places.  These
477    # were all patched in (2) above, and can be easily changed or
478    # overridden by the user in a project-local qmake .pro script.
479
480    set TARGET "${MAJOR}.${MINOR}"
481    foreach fixfile {configure mkspecs/common/g++-macx.conf \
482                     mkspecs/common/mac.conf qmake/qmake.pri \
483                     src/tools/bootstrap/bootstrap.pro } {
484        reinplace "s|@MACOSX_DEPLOYMENT_TARGET@|${TARGET}|g" \
485            ${worksrcpath}/${fixfile}
486    }
487
488    # Ensure that correct C/C++ compilers are used.
489
490    reinplace "s|@CXX@|${configure.cxx}|" \
491        ${worksrcpath}/mkspecs/common/g++-base.conf
492    reinplace "s|@CC@|${configure.cc}|"  \
493        ${worksrcpath}/mkspecs/common/g++-base.conf
494
495    # fix 'macdeployqt' to look for the correct
496    # plugins location by default.
497
498    reinplace "s,@QT_PLUGINS_DIR@,${qt_plugins_dir},g" \
499        ${worksrcpath}/tools/macdeployqt/macdeployqt/main.cpp
500
501    # fix PREFIX in QMake makefile generator
502
503    reinplace "s,@PREFIX@,${qt_dir},g" \
504        ${worksrcpath}/qmake/generators/unix/unixmake.cpp
505
506    # if no debug, then do not even build debug code
507
508    if {![variant_isset debug]} {
509        foreach fixfile { src/qbase.pri \
510                          src/3rdparty/webkit/Source/WebKit.pri \
511                          src/imports/qimportbase.pri \
512                          src/plugins/qpluginbase.pri \
513                          tools/designer/src/components/lib/lib.pro \
514                          tools/designer/src/lib/lib.pro \
515                          tools/designer/src/plugins/activeqt/activeqt.pro \
516                          tools/designer/src/plugins/plugins.pri \
517                          tools/designer/src/uitools/uitools.pro \
518                          src/3rdparty/webkit/Source/WebKit/qt/declarative/declarative.pro } {
519            reinplace "/+=/s@debug_and_release@@g" \
520                ${worksrcpath}/${fixfile}
521        }
522    }
523
524    # copy C++11 files into place, if that variant is set
525
526    if {[variant_isset cxx11]} {
527        copy ${filespath}/c++11.prf ${worksrcpath}/mkspecs/features
528        copy ${filespath}/c++11 ${worksrcpath}/config.tests/mac
529    }
530
531    # copy Objective C / CXX files into place
532
533    copy ${filespath}/objective_cxx.prf \
534        ${worksrcpath}/mkspecs/features/mac
535    copy ${filespath}/split_sources.prf \
536        ${worksrcpath}/mkspecs/features/mac
537
538    # copy extra compiler tests into place; these are patched into the
539    # configure script to the area before qmake is built.  If any
540    # fail, configure will fail quickly.
541
542    copy ${filespath}/fconstant_cfstrings.test \
543        ${worksrcpath}/config.tests/mac
544    copy ${filespath}/objc_block \
545        ${worksrcpath}/config.tests/mac
546    copy ${filespath}/cpath \
547        ${worksrcpath}/config.tests/mac
548    copy ${filespath}/library_path \
549        ${worksrcpath}/config.tests/mac
550}
551
552# Block various compilers:
553#
554# * The build process requires -Xarch, -fconstant-cfstring, and
555# Objective-C(++) blocks (^), which are not supported with vanilla GCC
556# as installed by MacPorts but are supported by all versions of CLANG
557# (both MacPorts' and Apple's).
558#
559# * Some older versions of CLANG do not honor the CPATH
560# environment variables, which is required for compiling
561# this port when using MacPorts.  The versions seem to be: MacPorts
562# CLANG 2.9 or earlier, and Apple CLANG 318.0.58 or older.
563#
564# * Some older versions of CLANG do not honor the LIBRARY_PATH
565# environment variables, which is required for compiling
566# this port when using MacPorts.  The versions seem to be: MacPorts
567# CLANG 3.0 or earlier, and Apple CLANG 318.0.61 or older.
568#
569# * qt4-creator-mac fails to build with GCC <= 4.0.
570#
571# See also:
572# < http://llvm.org/bugs/show_bug.cgi?id=8971 >,
573# < https://trac.macports.org/ticket/30271 >,
574# < https://trac.macports.org/ticket/31076 >,
575# < https://trac.macports.org/ticket/31638 >,
576# < https://trac.macports.org/ticket/37868 >, and
577# < https://trac.macports.org/ticket/40422 >.
578#
579# NOTE: qt4-mac augments the standard Qt4 configure script with
580# pre-qmake-build tests for CPATH, LIBRARY_PATH, -Xarch,
581# -fconstant-cfstring, Objective-C(++) blocks, and, if requested,
582# C++11.  The script will error out quickly if the compiler does not
583# seem to provide support for any one of these properties, no matter
584# this blacklist.
585#
586
587# does not build against libc++ with Apple clangs up to 10.8
588# does not build against macports-clang-7+
589# not certain about macports-clang-6.0 at present
590
591compiler.blacklist-append { clang <= 503 } \
592    gcc-3.3 *gcc-4.0 macports-gcc* \
593    {macports-clang-[6-8].0}
594
595# --prefix is not recognized
596
597configure.pre_args-delete       --prefix=${prefix}
598
599# --disable-dependency-tracking is not recognized
600
601configure.universal_args-delete --disable-dependency-tracking
602
603# clear all arch-oriented flags since somehow they impact how qmake is
604# created, which in turn messes up LDFLAGS in most created Makefiles.
605
606configure.ld_archflags
607configure.cc_archflags
608configure.cxx_archflags
609configure.universal_ldflags
610configure.universal_cflags
611configure.universal_cxxflags
612configure.universal_cppflags
613configure.march
614configure.mtune
615
616# Use compiler.cpath and compiler.library_path for all -I and -L
617# entries, so-as to avoid conflicts with already-installed headers and
618# libraries (giving preference to internal-to-this-port first).  CPATH
619# is used instead of -I to avoid conflicts with other ports.
620#
621# See also:
622# < https://trac.macports.org/ticket/15219 >,
623# < https://trac.macports.org/ticket/18723 >, and
624# < https://trac.macports.org/ticket/25321 >.
625
626# set the default paths to include those for SQLITE3 and DBUS-1
627
628set header_path [ list ${prefix}/include/dbus-1.0 \
629                       ${prefix}/lib/dbus-1.0/include \
630                       ${prefix}/include ]
631
632set library_path [ list ${prefix}/lib ]
633
634# -dbus-linked prevends qt4 from trying to dynamically load libdbus-1,
635#     which it is not able to find in ${prefix}.
636#
637# -openssl-linked ensures that the MacPorts openssl is used.
638#
639# -framework ensures that this port is installed as frameworks
640#     (collections of {library, headers, resources}); in
641#     post-destroot, link headers and libraries from the frameworks
642#     into non-framework locations as if "-no-framework" were
643#     specified.  Some dependent projects will not work properly if Qt
644#     is installed as libraries by default, thus make it so #1.
645#
646# -no-phonon ensures that Qt does not install the 3rd-parth Phonon
647#     port or its backend to QuickTime 7; Phonon is now installed via
648#     the 'phonon' port, which is more up to date than that provided
649#     by Qt.
650
651configure.args                                            \
652    -v                                                    \
653    -confirm-license                                      \
654    -opensource                                           \
655    -prefix          ${qt_dir}                            \
656    -bindir          ${qt_bins_dir}                       \
657    -libdir          ${qt_libs_dir}                       \
658    -docdir          ${qt_docs_dir}                       \
659    -headerdir       ${qt_includes_dir}                   \
660    -plugindir       ${qt_plugins_dir}                    \
661    -importdir       ${qt_imports_dir}                    \
662    -datadir         ${qt_data_dir}                       \
663    -translationdir  ${qt_translations_dir}               \
664    -sysconfdir      ${qt_sysconf_dir}                    \
665    -examplesdir     ${qt_examples_dir}                   \
666    -demosdir        ${qt_demos_dir}                      \
667    -openssl-linked                                       \
668    -dbus-linked                                          \
669    -fast                                                 \
670    -optimized-qmake                                      \
671    -no-pch                                               \
672    -framework                                            \
673    -no-phonon                                            \
674    -no-phonon-backend                                    \
675    --jobs=${build.jobs}
676
677# Stop configure script from searching for SQL Drivers
678#    not available from MacPorts.
679
680foreach driver {db2 ibase oci tds} {
681    configure.args-append -no-sql-${driver}
682}
683
684# Disable all remaining SQL Drivers.  These are available via the
685# ports qt4-mac-*-plugin.
686
687foreach driver {mysql odbc psql sqlite sqlite2} {
688    configure.args-append -no-sql-${driver}
689}
690
691# on older systems, /usr/include/rpcsvc/yp_prot.h redefines bool unless BOOL_DEFINED is defined
692if {${os.major} < 11} {
693    configure.args-append {-D BOOL_DEFINED}
694    patchfiles-append     patch-nis.diff
695}
696
697pre-configure {
698
699    # use the corrected CPATH and LIBRARY_PATH for build
700
701    compiler.cpath [join ${header_path} :]
702    compiler.library_path [join ${library_path} :]
703
704    # for 10.4 or 10.5 32-bit PPC, build as Carbon only, not Cocoa
705    # Same applies to 10.6 Rosetta, plus disable qmake optimization
706
707    if {${MAJOR} == 10 && ${MINOR} == 4} {
708
709        configure.args-append -carbon
710
711    } elseif {${MAJOR} == 10 && ${MINOR} == 5 &&
712              [llength ${qt_arch_types}] == 1 &&
713              [lsearch -exact ${qt_arch_types} ppc] == 0} {
714
715        configure.args-append -carbon
716
717    } elseif {${MAJOR} == 10 && ${MINOR} == 6 &&
718              [llength ${qt_arch_types}] == 1 &&
719              [lsearch -exact ${qt_arch_types} ppc] == 0} {
720
721        configure.args-append -carbon
722        configure.args-delete -optimized-qmake
723
724    }
725
726    # set the arch type(s) to use, in Qt-speak
727
728    configure.args-append -arch \"${qt_arch_types}\"
729
730    # check to see if not compiling for the native machine hardware
731    # (e.g., compiling for just i386 but CPU is x86_64); optimization
732    # of QMake does not work in this circumstance.
733
734    if {[lsearch -exact ${qt_arch_types} ${os.arch}] == -1} {
735
736        # not building for native arch: disable optimizing qmake
737        configure.args-delete -optimized-qmake
738
739    } elseif {${MAJOR} == 10 && ${MINOR} == 6 &&
740              [llength ${qt_arch_types}] == 1 &&
741              [lsearch -exact ${qt_arch_types} x86] == 0} {
742
743        # disable qmake optimization on 10.6 32-bit
744        configure.args-delete -optimized-qmake
745
746    }
747
748    # on Leopard and Snow Leopard with libc++ForOlderSystems
749    # installed, SDK must be unset as we can only use system libraries
750    # also, a missing library link must be replaced for build to
751    # succeed: <https://trac.macports.org/ticket/51844>
752    platform darwin {
753        if {${os.major} == 9 || ${os.major} == 10} {
754            if {${configure.cxx_stdlib} eq "libc++"} {
755                set SDK ""
756                configure.ldflags-append "-lobjc"
757            }
758        }
759    }
760
761    # set the SDK, if it was found and exists
762
763    if {[file exists ${SDK}]} {
764        configure.args-append -sdk ${SDK}
765    }
766
767    # set which pkg-config to use
768
769    configure.env-append PKG_CONFIG=${prefix}/bin/pkg-config
770
771    # set which stdlib to use; clang only
772    if {[string match *clang* ${configure.compiler}]} {
773        configure.env-append QMAKE_STDLIB=-stdlib=${configure.cxx_stdlib}
774        configure.ldflags-append -stdlib=${configure.cxx_stdlib}
775    }
776}
777
778post-configure {
779
780    # Remove any '-I' and '-L' string from the *FLAGS for SQLITE,
781    # DBUS, ODBC, and OPENSSL, so that what remains are just non-I/L
782    # flags; these paths are in compiler.cpath and
783    # compiler.library_path.  The header and library paths for all the
784    # other variants are not used by 'configure', and are already
785    # included in the compiler.cpath and compiler.library_path
786    # . during the 'build' stage, 'make' will rebuild the Makefiles
787    # that depend on any of these changed files.  These patches are
788    # sufficient to make sure local (to this build) paths are searched
789    # first, and then system paths last (via the compiler.X settings).
790    # Ideally, 'qmake' -- either via its mkspecs files or the
791    # project's build files -- would distinguish between "local" and
792    # "system" includes & libraries.
793
794    # SQLITE
795    reinplace -q "/SQLITE/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
796        ${worksrcpath}/.qmake.cache
797    reinplace -q "/SQLITE/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
798        ${worksrcpath}/.qmake.cache
799
800    # DBUS
801    reinplace -q "/DBUS/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
802        ${worksrcpath}/.qmake.cache
803    reinplace -q "/DBUS/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
804        ${worksrcpath}/.qmake.cache
805
806    # OPENSSL
807    reinplace -q "/OPENSSL/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
808        ${worksrcpath}/.qmake.cache
809    reinplace -q "/OPENSSL/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
810        ${worksrcpath}/.qmake.cache
811
812    # ODBC
813    reinplace -q "/ODBC/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
814        ${worksrcpath}/.qmake.cache
815    reinplace -q "/ODBC/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
816        ${worksrcpath}/.qmake.cache
817}
818
819pre-build {
820    # use the corrected CPATH and LIBRARY_PATH for build
821    compiler.cpath [join ${header_path} :]
822    compiler.library_path [join ${library_path} :]
823}
824
825# do not use DESTDIR directly in the destroot command; Qt uses DISTDIR
826# internally for other purposes, and instead uses INSTALL_ROOT for the
827# additional install root prefix.
828
829destroot.post_args
830
831post-destroot {
832
833    # shortcuts to destroot directories
834
835    set dr_qt ${destroot}${qt_dir}
836    set dr_qt_libs_dir ${destroot}${qt_libs_dir}
837    set dr_qt_includes_dir ${destroot}${qt_includes_dir}
838    set dr_qt_data_dir ${destroot}${qt_data_dir}
839    set dr_qt_docs_dir ${destroot}${qt_docs_dir}
840    set dr_qt_apps_dir ${destroot}${qt_apps_dir}
841    set dr_qt_bins_dir ${destroot}${qt_bins_dir}
842    set dr_qt_frameworks_dir ${destroot}${qt_frameworks_dir}
843
844    # create all needed destroot directories that don't already exist
845
846    xinstall -m 755 -d ${dr_qt_libs_dir}
847    xinstall -m 755 -d ${dr_qt_includes_dir}
848    xinstall -m 755 -d ${dr_qt_data_dir}
849    xinstall -m 755 -d ${dr_qt_docs_dir}
850    xinstall -m 755 -d ${dr_qt_apps_dir}
851
852    # Fix .pc and .prl files by changing ${worksrcpath}\${prefix} to
853    # ${qt_dir}\${prefix} ("\" means 'take away').  Cannot use
854    # "find -E" since it is not necessarily portable.
855
856    regsub ${prefix} ${worksrcpath} "" from_dir
857    regsub ${prefix} ${qt_dir} "" to_dir
858    foreach fixfile [exec find ${dr_qt} -name "*.pc"] {
859        reinplace -q "s|${from_dir}|${to_dir}|g" ${fixfile}
860    }
861    foreach fixfile [exec find ${dr_qt} -name "*.prl"] {
862        reinplace -q "s|${from_dir}|${to_dir}|g" ${fixfile}
863    }
864
865    # fix .pc files
866
867    foreach fixfile [exec find ${dr_qt} -name "*.pc"] {
868
869        # remove Libs.private; they can mess up linking
870
871        reinplace -q "/Libs\.private/d" ${fixfile}
872
873        # use ${qt_dir} correctly;
874        # in the .pc file, this will be ${prefix}
875
876        reinplace -q "s|${qt_dir}/|\${prefix}/|g" ${fixfile}
877
878        # fix libdir
879
880        reinplace -q "/libdir=/s|Library/Frameworks|lib|" ${fixfile}
881
882        # fix Libs: to use -L instead of -F
883
884        reinplace -q "/Libs:/s|-F|-L|" ${fixfile}
885
886        # fix Libs: to use -lQt* instead of "-framework Qt*"
887        # depends on whether for release or debug
888
889        set fn [lindex [split ${fixfile} /] end]
890
891        if {[lsearch -regexp ${fn} debug] == 0} {
892
893            # debug; need to add that string to all Qt dependency libraries
894            reinplace -q "/Libs:/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|" \
895                ${fixfile}
896
897        } else {
898
899            # no debug; just replace
900            reinplace -q "/Libs:/s|-framework Qt|-lQt|" ${fixfile}
901
902        }
903    }
904
905    # move .pc files from ${qt_frameworks_dir}/pkgconfig to
906    # ${qt_pkg_config_dir}
907
908    file delete -force ${destroot}${qt_pkg_config_dir}
909    move ${dr_qt_frameworks_dir}/pkgconfig ${dr_qt_libs_dir}
910
911    # move .la files from ${qt_frameworks_dir} to ${qt_libs_dir}
912
913    foreach laf [glob ${dr_qt_frameworks_dir}/*.la] {
914        move ${laf} ${dr_qt_libs_dir}
915    }
916
917    # remove -L entries from .prl and .la files
918
919    foreach fixfile [exec find ${dr_qt} -name "*.prl"] {
920        reinplace -q "/QMAKE_PRL_LIBS/s|-L\[^ \]*||g" ${fixfile}
921    }
922    foreach fixfile [exec find ${dr_qt} -name "*.la"] {
923        reinplace -q "/dependency_libs/s|-L\[^ \]*||g" ${fixfile}
924    }
925
926    # remove redundant -F entries from .prl and .la files
927
928    foreach fixfile [exec find ${dr_qt} -name "*.prl"] {
929        reinplace -q "/QMAKE_PRL_LIBS/s|-F\[^ \]*|FREPLACEME|1" \
930            ${fixfile}
931        reinplace -q "/QMAKE_PRL_LIBS/s|-F\[^ \]*||g" ${fixfile}
932        reinplace -q "s|FREPLACEME|-F${prefix}/Library/Frameworks|1" \
933            ${fixfile}
934    }
935    foreach fixfile [exec find ${dr_qt} -name "*.la"] {
936        reinplace -q "/dependency_libs/s|-F\[^ \]*|FREPLACEME|1" \
937            ${fixfile}
938        reinplace -q "/dependency_libs/s|-F\[^ \]*||g" ${fixfile}
939        reinplace -q "s|FREPLACEME|-F${prefix}/Library/Frameworks|1" \
940            ${fixfile}
941    }
942
943    # get Qt's version numbers
944
945    set qt_vers [split ${version} "."]
946    set qt_major [lindex ${qt_vers} 0]
947    set qt_minor [lindex ${qt_vers} 1]
948    set qt_patch [lindex ${qt_vers} 2]
949
950    # link includes and libraries for each actual installed framework
951
952    foreach fixfile [exec find ${dr_qt_frameworks_dir} \
953                         -name "*.framework" | \
954                         sed -e "s@${destroot}@@g"] {
955
956        set tf_full [strsed ${fixfile} {s@\\.framework@@}]
957        set tf [strsed ${tf_full} {g@.*\/@@}]
958
959        # special for QtWebKit entries
960
961        set t_minor ${qt_minor}
962        set is_QtWebKit 0
963        if {[string compare ${tf} QtWebKit] == 0} {
964            set t_minor 9
965            set is_QtWebKit 1
966        }
967
968        # link headers into ${qt_includes_dir}, removing directories
969        # if they are already there first
970
971        set inc_file ${dr_qt_includes_dir}/${tf}
972        if {[file exists ${inc_file}]} {
973            file delete -force ${inc_file}
974        }
975        ln -s ${tf_full}.framework/Headers ${inc_file}
976
977        # link libraries into ${qt_libs_dir}, all 4 number variants
978
979        ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.dylib
980        ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.dylib
981        ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.dylib
982        ln -s ${tf_full}.framework/${tf} ${dr_qt_libs_dir}/lib${tf}.${qt_major}.${t_minor}.${qt_patch}.dylib
983
984        # copy .prl file, then correct it for library usage
985
986        copy ${destroot}${tf_full}.framework/${tf}.prl ${dr_qt_libs_dir}/lib${tf}.prl
987
988        # fix TARGET in .prl file
989
990        reinplace -q "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}.prl
991
992        # fix PRL_LIBS -F -> -L in .prl file
993
994        reinplace -q "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}.prl
995
996        # fix "-framework Qt*" -> "-lQt*" in .prl file
997
998        reinplace -q "/QMAKE_PRL_LIBS/s|-framework Qt|-lQt|g" \
999            ${dr_qt_libs_dir}/lib${tf}.prl
1000
1001        # fix up .la files to work with ${prefix}/lib entries
1002
1003        # rename .la file
1004
1005        move ${dr_qt_libs_dir}/${tf}.la ${dr_qt_libs_dir}/lib${tf}.la
1006
1007        # fix "name that we can dlopen" in .la file
1008
1009        reinplace -q "s|dlname=''|dlname='lib${tf}.${qt_major}.${t_minor}.${qt_patch}.dylib'|" ${dr_qt_libs_dir}/lib${tf}.la
1010
1011        # fix "names of this library" in .la file
1012
1013        reinplace -q "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'|" \
1014            ${dr_qt_libs_dir}/lib${tf}.la
1015
1016        # fix "name of the static archive"; there is none in .la file
1017
1018        reinplace -q "s|old_library='\[^'\]*'|old_library=''|" \
1019            ${dr_qt_libs_dir}/lib${tf}.la
1020
1021        # fix "libraries that this one depends upon" in .la file
1022
1023        reinplace -q "/dependency_libs/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|"  ${dr_qt_libs_dir}/lib${tf}.la
1024        reinplace -q "/dependency_libs/s|-framework Qt|-lQt|g" \
1025            ${dr_qt_libs_dir}/lib${tf}.la
1026        reinplace -q "/dependency_libs/s| ${worksrcpath}\[^ \]*||g" \
1027            ${dr_qt_libs_dir}/lib${tf}.la
1028        reinplace -q "/dependency_libs/s| -lwebcore||" \
1029            ${dr_qt_libs_dir}/lib${tf}.la
1030        reinplace -q "/dependency_libs/s| -ljscore||" \
1031            ${dr_qt_libs_dir}/lib${tf}.la
1032
1033        # fix "directory that this library needs to be installed in" in .la file
1034
1035        reinplace -q "/libdir/s|${qt_frameworks_dir}|${qt_libs_dir}|" \
1036            ${dr_qt_libs_dir}/lib${tf}.la
1037
1038        # deal with debug files
1039
1040        if {[variant_isset debug]} {
1041
1042            # but not if QtWebKit and +universal, since that one does
1043            # not exist (the 32-bit version of the debug library is
1044            # larger than fits into the 32-bit filespace).
1045
1046            if {[variant_isset debug] && ${is_QtWebKit}} {
1047                continue
1048            }
1049
1050            # link libraries into ${qt_libs_dir}, all 4 number variants
1051
1052            ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.dylib
1053            ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.dylib
1054            ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.dylib
1055            ln -s ${tf_full}.framework/${tf}_debug ${dr_qt_libs_dir}/lib${tf}_debug.${qt_major}.${t_minor}.${qt_patch}.dylib
1056
1057            # copy .prl file, then correct it for library usage
1058
1059            copy ${destroot}${tf_full}.framework/${tf}_debug.prl ${dr_qt_libs_dir}/lib${tf}_debug.prl
1060
1061            # fix TARGET in .prl file
1062
1063            reinplace -q "/QMAKE_PRL_TARGET/s|Qt\\(\[^ \]*\\)|libQt\\1.${qt_major}.${t_minor}.${qt_patch}.dylib|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
1064
1065            # fix PRL_LIBS -F -> -L in .prl file
1066
1067            reinplace -q "/QMAKE_PRL_LIBS/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}_debug.prl
1068
1069            # fix "-framework Qt*" -> "-lQt*_debug" in .prl file
1070
1071            reinplace -q "/QMAKE_PRL_LIBS/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|g" ${dr_qt_libs_dir}/lib${tf}_debug.prl
1072
1073            # fix up .la files to work with ${prefix}/lib entries
1074
1075            # rename .la file
1076
1077            move ${dr_qt_libs_dir}/${tf}_debug.la \
1078                ${dr_qt_libs_dir}/lib${tf}_debug.la
1079
1080            # fix "name that we can dlopen" in .la file
1081
1082            reinplace -q "s|dlname=''|dlname='lib${tf}_debug.${qt_major}.${t_minor}.${qt_patch}.dylib'|" ${dr_qt_libs_dir}/lib${tf}_debug.la
1083
1084            # fix "names of this library" in .la file
1085
1086            reinplace -q "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'|" \
1087                ${dr_qt_libs_dir}/lib${tf}_debug.la
1088
1089            # fix "name of the static archive"; there is none in .la file
1090
1091            reinplace -q "s|old_library='\[^'\]*'|old_library=''|" \
1092                ${dr_qt_libs_dir}/lib${tf}_debug.la
1093
1094            # fix "libraries that this one depends upon" in .la file
1095
1096            reinplace -q "/dependency_libs/s|-F${qt_frameworks_dir}|-L${qt_libs_dir}|" ${dr_qt_libs_dir}/lib${tf}_debug.la
1097            reinplace -q "/dependency_libs/s|-framework Qt\\(\[^ \]*\\)|-lQt\\1_debug|g" ${dr_qt_libs_dir}/lib${tf}_debug.la
1098            reinplace -q "/dependency_libs/s| ${worksrcpath}\[^ \]*||g" \
1099                ${dr_qt_libs_dir}/lib${tf}_debug.la
1100            reinplace -q "/dependency_libs/s| -lwebcored||" \
1101                ${dr_qt_libs_dir}/lib${tf}_debug.la
1102            reinplace -q "/dependency_libs/s| -ljscored||" \
1103                ${dr_qt_libs_dir}/lib${tf}_debug.la
1104
1105            # fix "directory that this library needs to be installed in" in .la file
1106
1107            reinplace -q "/libdir/s|${qt_frameworks_dir}|${qt_libs_dir}|" \
1108                ${dr_qt_libs_dir}/lib${tf}_debug.la
1109
1110        }
1111    }
1112
1113    # Install documentation.
1114
1115    xinstall -m 644 -W ${worksrcpath} \
1116        INSTALL LGPL_EXCEPTION.txt LICENSE.FDL \
1117        LICENSE.GPL3 LICENSE.LGPL README \
1118        ${dr_qt_docs_dir}
1119
1120    # Install private headers needed by QtCreator
1121
1122    foreach {src_dir include_dir} \
1123    {corelib QtCore gui QtGui script QtScript declarative QtDeclarative} {
1124        set dest_dir ${dr_qt_frameworks_dir}/${include_dir}.framework/Headers/private
1125        xinstall -m 755 -d ${dest_dir}
1126        set files [exec find ${worksrcpath}/src/${src_dir} -type f -name "*_p.h"]
1127        xinstall -m 644 {*}[split ${files}] ${dest_dir}
1128    }
1129
1130    # Move .apps into the applications_dir, and link each .apps'
1131    # executable back into ${qt_bins_dir}
1132
1133    foreach app [glob ${dr_qt_bins_dir}/*.app] {
1134
1135        # remove the leading stuff
1136
1137        set app [lindex [split ${app} /] end]
1138
1139        # move the .app
1140
1141        move ${dr_qt_bins_dir}/${app} ${dr_qt_apps_dir}
1142
1143        # link the app's executable back
1144
1145        set texe [strsed ${app} {g@\.app@@}]
1146        ln -s ${qt_apps_dir}/${app}/Contents/MacOS/${texe} \
1147            ${dr_qt_bins_dir}
1148
1149    }
1150
1151    # move tests to ${qt_data_dir}
1152
1153    move ${dr_qt}/tests/qt4 ${dr_qt_data_dir}/tests
1154
1155    # install ${qt_includes_dir}/Qt if not already and it exists in
1156    # the build, for support of legacy projects
1157
1158    if {![file exists ${dr_qt_includes_dir}/Qt] &&
1159        [file exists ${worksrcpath}/include/Qt]} {
1160
1161        # copy the Qt headers directory
1162
1163        copy ${worksrcpath}/include/Qt ${dr_qt_includes_dir}
1164
1165    }
1166
1167    # link in Resource to ${qt_libs_dir}
1168
1169    ln -s ${qt_frameworks_dir}/QtGui.framework/Resources \
1170        ${dr_qt_libs_dir}
1171
1172    # link pkg-config files to where they will be found automatically
1173    if {${qt_libs_dir} ne "${prefix}/lib"} {
1174
1175        set qt_pc_dir ${qt_libs_dir}/pkgconfig
1176        set dr_lib_pc_dir ${destroot}${prefix}/lib/pkgconfig
1177        xinstall -d -m 0755 ${destroot}${qt_pc_dir}
1178        foreach pcfile [glob -nocomplain -tails -directory ${destroot}${qt_pc_dir} *.pc] {
1179            ln -s ${qt_pc_dir}/${pcfile} ${dr_lib_pc_dir}
1180        }
1181
1182    }
1183}
1184
1185variant odbc description {Enable iODBC SQL Driver} {
1186    depends_lib-append port:libiodbc
1187    configure.args-delete -no-sql-odbc
1188    configure.args-append -plugin-sql-odbc
1189}
1190
1191variant raster description {Use raster graphics system by default} {
1192    configure.args-append -graphicssystem raster
1193}
1194
1195variant demos description {Build demos} {}
1196
1197if {![variant_isset demos]} {
1198   configure.args-append -nomake demos
1199}
1200
1201variant examples description {Build examples} {}
1202
1203if {![variant_isset examples]} {
1204   configure.args-append -nomake examples
1205}
1206
1207variant debug description {Build both release and debug library} {}
1208
1209if {[variant_isset debug]} {
1210    configure.args-append -debug-and-release -declarative-debug
1211} else {
1212    configure.args-append -release -no-declarative-debug
1213}
1214
1215variant openvg description {Build with support for OpenVG} {
1216
1217    depends_lib-append port:mesa
1218
1219    pre-configure {
1220
1221        # set OpenVG arg, for both testing and building
1222
1223        configure.env-append QMAKE_OPENVG_ARG=-lOpenVG
1224
1225    }
1226}
1227
1228variant cxx11 description {Add library support for C++11 (EXPERIMENTAL; does not work with libc++)} {
1229
1230    compiler.cxx_standard 2011
1231
1232    pre-fetch {
1233
1234        # This variant does not work with Clang libc++
1235
1236        if {[info exists configure.cxx_stdlib] &&
1237            ${configure.cxx_stdlib} eq "libc++" &&
1238            [string match *clang* ${configure.cxx}]} {
1239
1240            ui_msg "\nERROR: C++11 support for Qt4 is not available when using Clang and libc++.\n"
1241            error "unsupported platform for C++11 support"
1242
1243        }
1244    }
1245
1246    pre-extract {
1247
1248        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"
1249
1250    }
1251
1252    # patches for C++11 only
1253
1254    patchfiles-append patch-cxx11.diff
1255
1256    # have configure test for C++11; our hooks
1257    # will error out if C++11 is not found.
1258
1259    configure.args-append -c++11
1260
1261}
1262
1263post-activate {
1264    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."
1265}
1266
1267notes-append \
1268"Users experiencing graphics glitches on newer OS versions (10.13 and up) can\
1269experiment with different graphics drawing systems that can be set in the\
1270Interface tab of the ${qt_apps_dir}/qtconfig.app utility. Raster mode is\
1271the preferred mode but is not compatible with all non-standard widget styles.\
1272Keep an eye on the Fonts setting before saving!"
1273
1274livecheck.type       none
1275
1276# livecheck.type      regex
1277# livecheck.url       http://download.qt.io/official_releases/qt/${branch}/
1278# livecheck.regex     >(\[0-9.\]+)/<