Ticket #40852: Portfile

File Portfile, 40.8 KB (added by BSeppke (Benjamin Seppke), 11 years ago)

proposed new Portfile for qt4-mac and Mac OS X 10.9 Maverics

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