source: trunk/dports/aqua/qt4-mac/Portfile

Last change on this file was 153936, checked in by mcalhoun@…, 11 months ago

qt4-mac: Remove code which requires QTKit; fixes #52332
QTKit no longer exists as of macOS 10.12
The code comments indicate it is only needed prior to 10.6

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