Ticket #51135: Portfile

File Portfile, 38.7 KB (added by kylesch@…, 8 years ago)

Portfile that applies patchfile patch-src_network_ssl_qsslsocket_openssl.diff as patch 27 -- the last patch applied

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