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

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

qt4-mac: Tweak qmake optimization to match the comment -- disable on OSX 10.6, 32-bit.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 20.4 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 86972 2011-11-07 17:11:42Z 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
10
11name                qt4-mac
12conflicts           qt3 qt3-mac qt4-mac-devel
13version             4.7.4
14revision            1
15categories          aqua
16platforms           macosx
17maintainers         michaelld
18license             {LGPL-2.1 GPL-3}
19
20homepage            http://qt.nokia.com/
21description         Qt Tool Kit
22long_description    Qt Tool Kit: A cross-platform framework \
23                    (headers, data, and libraries) for writing \
24                    cross-platform GUI-based applications.
25
26master_sites        trolltech
27distname            qt-everywhere-opensource-src-${version}
28
29# 4.7.4 was stealth-updated; see #31252
30dist_subdir         ${name}/${version}_1
31
32checksums           md5     9831cf1dfa8d0689a06c2c54c5c65aaf \
33                    sha1    af9016aa924a577f7b06ffd28c9773b56d74c939 \
34                    rmd160  3e47b09663a89973b1c8628506c995dfc2a5387c
35
36depends_lib-append  port:zlib port:dbus port:openssl port:sqlite3 \
37                    port:tiff port:libpng port:libmng port:jpeg
38
39# (0) Fix the testing script to properly handle both +universal as
40# well as the native arch for both CXX and CC compiling; also make
41# sure it does not create a Mac app bundle.
42patchfiles-append   patch-config.tests_unix_compile.test.diff
43
44# (1) Test for Precompiled-headers support requires a C++ compiler,
45# but configure calls it, by default, with a C compiler.
46patchfiles-append   patch-precomp.test.diff
47
48# (2) Tweak various scripts to allow easy replacement of
49# MACOSX_DEPLOYMENT_TARGET: build for just the user's current OS.
50patchfiles-append   patch-macosx-deployment-target.diff
51
52# (3) Tweak the configure script to allow easy replacement of arch
53# type(s).  The location of this patch is dependent on patch (2), but
54# 'patch' should be able to figure it out.
55patchfiles-append   patch-configure-arch.diff
56
57# (4) Tweak Qt spec files:
58# (4a) Place the -I path for local moc-created headers -before-
59# all other -I paths.
60patchfiles-append   patch-mkspecs-features-moc.prf.diff
61
62# (4b) Remove Qt's LIBDIR and INCDIR from various Qmake internal
63# variables, since they are already included in the user-supplied
64# LIBS and INCLUDEPATH.
65patchfiles-append   patch-mkspecs-features-qt.prf.diff
66
67# (4c) Change placement of Qt's LIBDIR and INCDIR, to always be after
68# those supplied by the user's QMake (.pro) files.  By the time QMake
69# gets to the patched function, it is creating the Makefile parts to
70# find Qt's headers and libraries, so moving these paths to this
71# location should always work.
72patchfiles-append   patch-mkspecs-features-qt_functions.prf.diff
73
74# (4d) Add "absolute_library_soname" to the default CONFIG variables,
75# so that when a DYLIB is created, if "target.path" is set for it then
76# that path is prepended to its "install_name".
77patchfiles-append   patch-mkspecs-macx-g++-qmake.prf.diff
78
79# (4e) allow use of 'ccache' via "qmake && make CCACHE=ccache", in mac
80# only; this patch requires that (2) already be in place.
81patchfiles-append   patch-mkspecs_common_mac.conf.diff
82
83# (5) fix the corewlan qmake file to use non-standard Developer SDK
84# location under 10.6, e.g., for some developers doing both iOS and
85# OSX.  This patch does not change behavior for 10.4 or 10.5.
86# Also include fix to use the correct SDK.
87patchfiles-append   patch-src-plugins-bearer-corewlan-corewlan.pro.diff
88
89# (6) fix use of CARBON, found on PPC64, but will work on any system
90patchfiles-append   patch-PluginView-no-carbon.diff
91
92# (7) Allow compiling under OS X 10.7
93patchfiles-append   patch-src-corelib-global-qglobal.h.diff
94
95# (8) fix #includes for OS X 10.7 in Bearer CoreWLAN
96patchfiles-append   patch-src-plugins-bearer-corewlan-qcorewlanengine.mm.diff
97
98# (9) from Qt, blocklist bad digistor certs
99# < http://labs.qt.nokia.com/2011/09/07/ >
100patchfiles-append   patch-blacklist-diginotar-certs.diff
101
102# (10) from Qt bugs (#18346), fix shader effect item code.
103patchfiles-append   patch-src-imports-shaders-shadereffectitem.cpp.diff
104
105# find a way to specify the OS MINOR version.
106global MINOR
107set MINOR ""
108
109# hopefully the macosx_deployment_target exists and is set by now.  if
110# not, last resort (which is not desirable) is to use the os.version.
111if {${macosx_deployment_target} != ""} {
112    set MINOR [lindex [split ${macosx_deployment_target} "."] 1]
113} else {
114    set MINOR [expr [lindex [split ${os.version} "."] 0] - 4]
115}
116
117post-patch {
118    # set ARCHES in configure (per the third patchfile above), for
119    # building QMake.  join any 2 or more arch entries with the GCC
120    # arch flag (join does not effect a single entry).  first "-arch"
121    # is already in place in the 'configure' script (since there has
122    # to be at least 1 arch).
123    set ARCHES ""
124    if {[variant_exists universal] && [variant_isset universal]} {
125        set ARCHES [join ${universal_archs} " -arch "]
126    } else {
127        set ARCHES ${build_arch}
128    }
129    reinplace "s|@ARCHES@|${ARCHES}|g" ${worksrcpath}/configure
130
131    global MINOR
132
133    # set MACOSX_DEPLOYMENT_TARGET version in various places.  These
134    # were all patched in (2) above, and can be easily changed or
135    # overridden by the user in a project-local qmake .pro script.
136    set TARGET "10.${MINOR}"
137    foreach fixfile {configure mkspecs/common/mac-g++.conf \
138                     mkspecs/common/mac.conf qmake/qmake.pri \
139                     src/tools/bootstrap/bootstrap.pro } {
140        reinplace "s|@MACOSX_DEPLOYMENT_TARGET@|${TARGET}|g" \
141            ${worksrcpath}/${fixfile}
142    }
143
144    # Fix OS version on Bearer CoreWLAN QMake file
145    reinplace "s|@MACOSX_VERSION_MINOR@|${MINOR}|g" \
146        ${worksrcpath}/src/plugins/bearer/corewlan/corewlan.pro
147
148    # Ensure that correct C/C++ compilers are used.
149    reinplace "s| g++\$| ${configure.cxx}|" \
150        ${worksrcpath}/mkspecs/common/g++.conf
151    reinplace "s| gcc\$| ${configure.cc}|"  \
152        ${worksrcpath}/mkspecs/common/g++.conf
153    reinplace "s| g++\$| ${configure.cxx}|" \
154        ${worksrcpath}/mkspecs/macx-g++/qmake.conf
155    reinplace "s| gcc\$| ${configure.cc}|"  \
156        ${worksrcpath}/mkspecs/macx-g++/qmake.conf
157
158    # fix up tests to work with ccache, if used
159    foreach fixfile [exec find ${worksrcpath}/config.tests \
160                         -name "*.test"] {
161        reinplace "s@\\\"\\\$COMPILER\\\"@\$COMPILER@g" ${fixfile}
162    }
163
164    # fix 'configure' script to find the correct QMAKE CXX compiler by
165    # removing possibilities that include the character "$".  Yes,
166    # that's a lot of "\"s: each "\\\\" -> a single "\" in the patched
167    # file, and need "\\\\$" (with the "s) there.
168    reinplace "/QMAKE_CONF_COMPILER/ \
169             s@tail@grep -v \"\\\\\\\\\\\\\\\\\$\" | tail@" \
170        ${worksrcpath}/configure
171
172    # fix the corewlan .pro file to use the correct developer dir
173    reinplace "s,@DEVELOPER_DIR@,${developer_dir},g" \
174        ${worksrcpath}/src/plugins/bearer/corewlan/corewlan.pro
175}
176
177# The build process uses -fconstant-cfstrings.
178# configure.compiler should therefore not be one of the MacPorts compilers.
179
180# does not work with clang, see #30271 and #31638 .
181if {${configure.compiler} == "clang"} {
182    configure.compiler llvm-gcc-4.2
183}
184
185# --prefix is not recognized.
186configure.pre_args-delete       --prefix=${prefix}
187
188# --disable-dependency-tracking is not recognized.
189configure.universal_args-delete --disable-dependency-tracking
190
191################################################################################
192# We do not want flags of any kind -- QT is smart enough to set up its own.    #
193################################################################################
194
195configure.cflags
196configure.cppflags
197configure.cxxflags
198configure.ldflags
199
200configure.universal_cflags
201configure.universal_cppflags
202configure.universal_cxxflags
203configure.universal_ldflags
204
205configure.cc_archflags
206configure.cxx_archflags
207if {[info exists configure.ld_archflags]} {
208    configure.ld_archflags
209}
210
211#  use compiler.cpath and compiler.library_path, as per
212#  http://trac.macports.org/ticket/25321 for all -I and -L entries,
213#  so-as to avoid conflicts with already-installed headers and
214#  libraries (giving preference to internal-to-this-port first)
215#
216#  CPATH is used instead of -I to avoid conflicts with other ports.
217#  See http://trac.macports.org/ticket/15219 and
218#  http://trac.macports.org/ticket/18723.
219#
220#  set the default paths to include those for SQLITE3 and DBUS-1
221
222set header_path [ list ${prefix}/include/dbus-1.0 \
223                       ${prefix}/lib/dbus-1.0/include \
224                       ${prefix}/include ]
225
226set library_path [ list ${prefix}/lib ]
227
228# -system-sqlite ensures the use SQLite provided by MacPorts instead of Qt.
229#
230# -dbus-linked prevends qt4 from trying to dynamically load libdbus-1,
231#     which it is not able to find in ${prefix}.
232#
233# -openssl-linked ensures that the MacPorts openssl is used.
234#
235# -no-framework ensures that this port is installed as separate
236#     libraries and headers, with guaranteed locations and names.
237#
238# -no-phonon ensures that Qt does not install the 3rd-parth Phonon
239#     port or its backend to QuickTime 7; Phonon is now installed via
240#     the 'phonon' port, which is more up to date than that provided
241#     by Qt.
242
243configure.args                                            \
244    -v                                                    \
245    -confirm-license                                      \
246    -opensource                                           \
247    -prefix          ${qt_dir}                            \
248    -bindir          ${qt_bins_dir}                       \
249    -libdir          ${qt_libs_dir}                       \
250    -docdir          ${qt_docs_dir}                       \
251    -headerdir       ${qt_includes_dir}                   \
252    -plugindir       ${qt_plugins_dir}                    \
253    -importdir       ${qt_imports_dir}                    \
254    -datadir         ${qt_data_dir}                       \
255    -translationdir  ${qt_translations_dir}               \
256    -sysconfdir      ${qt_sysconf_dir}                    \
257    -examplesdir     ${qt_examples_dir}                   \
258    -demosdir        ${qt_demos_dir}                      \
259    -system-sqlite                                        \
260    -openssl-linked                                       \
261    -dbus-linked                                          \
262    -fast                                                 \
263    -optimized-qmake                                      \
264    -no-framework                                         \
265    -no-phonon                                            \
266    -no-phonon-backend
267
268# Stop configure script from searching for SQL Drivers
269#    not available from MacPorts.
270foreach driver {db2 ibase oci tds} {
271    configure.args-append -no-sql-${driver}
272}
273
274# By default, disable most SQL Drivers.
275# There must be at least one enabled (http://trac.macports.org/ticket/15627).
276# SQLite is chosen to be always enabled because a copy of it is distributed
277#    with Qt, so it is reasonable for the user to expect it.
278foreach driver {mysql odbc psql sqlite2} {
279    configure.args-append -no-sql-${driver}
280}
281
282pre-configure {
283    # use the corrected CPATH and LIBRARY_PATH for build
284    compiler.cpath [join ${header_path} :]
285    compiler.library_path [join ${library_path} :]
286}
287
288platform darwin 8 {
289    # build as Carbon only, not cocoa.
290    configure.args-append -carbon
291
292    # required linking flags?
293    configure.ldflags-append -lcrypto -ldbus-1 -ljpeg -llcms -lsqlite3 -lssl -lz
294
295    # Under 10.4 only: patch QMake build files using just "-lQtHelp"
296    # to do "-lQtHelp -lQtCLucene -lQtNetwork -lQtWebKit" instead.
297    # For some reason 10.5+ "knows" that how to do this correctly.
298    patchfiles-append patch-QtHelp_10.4_only.diff
299}
300
301platform darwin {
302    pre-configure {
303        # retrieve the arch type(s) to use, in Qt-speak
304        configure.args-append -arch \"${qt_arch_types}\"
305
306        # cannot use pre-compiled headers when compiling with more than 1
307        # arch type (typically +universal) or for X11
308        #if {[llength ${qt_arch_types}] != 1 || [variant_isset x11]}
309        if {[llength ${qt_arch_types}] != 1} {
310            configure.args-append -no-pch
311        } else {
312            configure.args-append -pch
313        }
314
315        # check to see if not compiling for the native machine hardware
316        # (e.g., compiling for just i386 but CPU is x86_64); optimization
317        # of QMake does not work in this circumstance.
318        if {[lsearch -exact ${qt_arch_types} ${os.arch}] == -1} {
319            # not building for native arch: disable optimizing qmake
320            configure.args-delete -optimized-qmake
321        } elseif {${MINOR} == "6" &&
322                  [llength ${qt_arch_types}] == 1] &&
323                  [lsearch -exact ${qt_arch_types} x86] == 0} {
324            # disable qmake optimization on 10.6 32-bit
325            configure.args-delete -optimized-qmake
326        }
327
328        # find a way to specify the SDK to use; Qt will use the 10.4u
329        # by default which won't work on 10.6 since it is not
330        # supported.  Allow the user to specify the SDK if desired.
331        set SDK ${configure.sdkroot}
332        if {${SDK} == ""} {
333            # set SDK version depending on OS version
334            global MINOR
335            set sdk_version ""
336            if {${MINOR} == "4"} {
337                # OSX 10.4 requires an additional 'u'
338                set sdk_version "10.4u"
339            } else {
340                set sdk_version "10.${MINOR}"
341            }
342            set SDK ${developer_dir}/SDKs/MacOSX${sdk_version}.sdk
343        }
344        if {[file exists ${SDK}]} {
345            configure.args-append -sdk ${SDK}
346        } else {
347            ui_msg \
348"No SDK found in ${developer_dir}/SDKs for ${sdk_version} ; \
349configure will probably fail. \n \
350Please install Apple's Developer Tools again."
351        }
352    }
353}
354
355# Remove any '-I' and '-L' string from the *FLAGS for SQLITE, DBUS,
356# ODBC, and OPENSSL, so that what remains are just non-I/L flags;
357# these paths are in compiler.cpath and compiler.library_path.  The
358# header and library paths for all the other variants are not used by
359# 'configure', and are already included in the compiler.cpath and
360# compiler.library_path . during the 'build' stage, 'make' will
361# rebuild the Makefiles that depend on any of these changed files.
362# These patches are sufficient to make sure local (to this build)
363# paths are searched first, and then system paths last (via the
364# compiler.X settings).  Ideally, 'qmake' -- either via its mkspecs
365# files or the project's build files -- would distinguish between
366# "local" and "system" includes & libraries.
367post-configure {
368    # SQLITE
369    reinplace "/SQLITE/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
370        ${worksrcpath}/.qmake.cache
371    reinplace "/SQLITE/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
372        ${worksrcpath}/.qmake.cache
373    # DBUS
374    reinplace "/DBUS/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
375        ${worksrcpath}/.qmake.cache
376    reinplace "/DBUS/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
377        ${worksrcpath}/.qmake.cache
378    # OPENSSL
379    reinplace "/OPENSSL/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
380        ${worksrcpath}/.qmake.cache
381    reinplace "/OPENSSL/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
382        ${worksrcpath}/.qmake.cache
383    # ODBC
384    reinplace "/ODBC/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
385        ${worksrcpath}/.qmake.cache
386    reinplace "/ODBC/s@-L${prefix}/\[^ \]*lib\[^ \]*@@g" \
387        ${worksrcpath}/.qmake.cache
388}
389
390pre-build {
391    # use the corrected CPATH and LIBRARY_PATH for build
392    compiler.cpath [join ${header_path} :]
393    compiler.library_path [join ${library_path} :]
394}
395
396build.target all
397
398post-destroot {
399    set destroot_qt ${destroot}${qt_dir}
400
401    # Fix .pc and .prl files by changing ${worksrcpath}\${prefix} to
402    # ${qt_dir}\${prefix} ("\" means 'take away').  Cannot use
403    # "find -E" since it is not necessarily portable.
404    regsub ${prefix} ${worksrcpath} "" from_dir
405    regsub ${prefix} ${qt_dir} "" to_dir
406    foreach fixfile [exec find ${destroot_qt} -name "*.pc"] {
407        reinplace "s|${from_dir}|${to_dir}|g" ${fixfile}
408    }
409    foreach fixfile [exec find ${destroot_qt} -name "*.prl"] {
410        reinplace "s|${from_dir}|${to_dir}|g" ${fixfile}
411    }
412
413    # Install documentation.
414    xinstall -m 755 -d ${worksrcpath}/${qt_docs_dir}
415    xinstall -m 644 -W ${worksrcpath} \
416        INSTALL LGPL_EXCEPTION.txt LICENSE.FDL \
417        LICENSE.GPL3 LICENSE.LGPL README \
418        ${destroot}${qt_docs_dir}
419
420    # Move .apps into the applications_dir
421    xinstall -m 755 -d ${destroot}${qt_apps_dir}
422    foreach app [glob ${destroot}/${qt_bins_dir}/*.app] {
423        move ${app} ${destroot}${qt_apps_dir}
424    }
425
426    # install qt_menu.nib, used by any applications making use of Qt's
427    # application class.
428    xinstall -m 755 -d ${destroot_qt}/lib/Resources
429    copy ${worksrcpath}/src/gui/mac/qt_menu.nib \
430        ${destroot_qt}/lib/Resources
431}
432
433pre-activate {
434    # make sure 'none' is selected by qt4_select, so that there is no
435    # conflict between it and this port.
436    if {[file exists ${prefix}/bin/qt4_select]} {
437        if {[exec ${prefix}/bin/qt4_select -s] != "none"} {
438            ui_msg "Disabling 'qt4_select' selection."
439            system "exec ${prefix}/bin/qt4_select none"
440        }
441    }
442}
443
444variant framework description {Build as Frameworks} {
445    configure.args-delete -no-framework
446    configure.args-append -framework
447}
448
449variant mysql description {Enable MySQL SQL Driver} {
450    depends_lib-append path:lib/mysql5:mysql5
451    lunshift header_path ${prefix}/include/mysql5/mysql
452    lunshift library_path ${prefix}/lib/mysql5/mysql
453    configure.args-delete -no-sql-mysql
454    configure.args-append -plugin-sql-mysql
455}
456
457variant odbc description {Enable iODBC SQL Driver} {
458    depends_lib-append port:libiodbc
459    configure.args-delete -no-sql-odbc
460    configure.args-append -plugin-sql-odbc
461}
462
463variant psql83 conflicts psql84 psql90 psql91 \
464description {Enable Postgre SQL Driver version 8.3} {}
465
466variant psql84 conflicts psql83 psql90 psql91 \
467description {Enable Postgre SQL Driver version 8.4} {}
468
469variant psql90 conflicts psql83 psql84 psql91 \
470description {Enable Postgre SQL Driver version 9.0} {}
471
472variant psql91 conflicts psql83 psql84 psql90 \
473description {Enable Postgre SQL Driver version 9.1} {}
474
475set psql_version ""
476if {[variant_isset psql83]} {
477    set psql_version "83"
478} elseif {[variant_isset psql84]} {
479    set psql_version "84"
480} elseif {[variant_isset psql90]} {
481    set psql_version "90"
482} elseif {[variant_isset psql91]} {
483    set psql_version "91"
484}
485
486if {${psql_version} != ""} {
487    depends_lib-append port:postgresql${psql_version}
488    lunshift header_path ${prefix}/include/postgresql${psql_version}
489    lunshift library_path ${prefix}/lib/postgresql${psql_version}
490    configure.args-delete -no-sql-psql
491    configure.args-append -plugin-sql-psql
492}
493
494variant sqlite2 description {Enable SQLite version 2 SQL Driver} {
495    depends_lib-append port:sqlite2
496    configure.args-delete -no-sql-sqlite2
497    configure.args-append -plugin-sql-sqlite2
498}
499
500variant raster description {Use raster graphics system by default} {
501    configure.args-append -graphicssystem raster
502}
503
504variant demos description {Build demos} {}
505
506if {![variant_isset demos]} {
507   configure.args-append -nomake demos
508}
509
510variant examples description {Build examples} {}
511
512if {![variant_isset examples]} {
513   configure.args-append -nomake examples
514}
515
516variant debug description {Build both release and debug library} {}
517
518if {[variant_isset debug]} {
519    configure.args-append -debug-and-release
520} else {
521    configure.args-append -release
522}
523
524#variant quartz conflicts x11
525variant quartz \
526description {Build for Native OSX Quartz GUI, not X11 (default)} {}
527
528#variant x11 conflicts quartz \
529#description {Build for X11 GUI, not Native OSX Quartz} {}
530
531# if neither +x11 or +quartz were specified, default to the latter
532#if {![variant_isset quartz] && ![variant_isset x11]}
533    default_variants +quartz
534#}
535
536# check to see if user specified just "-quartz", which can't work.
537#if {![variant_isset quartz] && ![variant_isset x11]} {
538#    return -code error \
539#"\n\nThe variant -quartz will not work alone.
540#Please select one of +quartz or +x11 as a variant.\n"
541#}
542
543#if {[variant_isset x11]} {
544#    return -code error "\n\nVariant +x11 is not yet functional; \
545#please use +quartz for now.\n"
546#}
547
548livecheck.type      regex
549livecheck.url       http://get.qt.nokia.com/qt/source/
550livecheck.regex     "qt-everywhere-opensource-src-(\[0-9a-z.-\]+)${extract.suffix}"
Note: See TracBrowser for help on using the repository browser.