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

Last change on this file since 138275 was 138275, checked in by michaelld@…, 4 years ago

qt4-mac:
+ fix homepage;
+ fix correcting of .pc files to handle all install location cases, e.g., for when Qt4 is installed into ${prefix} or ${prefix}/libexec/qt4.

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