Ticket #30346: Portfile

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