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

Last change on this file since 78364 was 78359, checked in by michaelld@…, 9 years ago

qt4-mac: upgrade to version 4.7.3

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