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

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

Retrieve current selection of qt4_select such that the variable
"current_select" is valid during stage "pre-deactivate".

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 12.9 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 69555 2010-07-10 01:50:58Z michaelld@macports.org $
3
4PortSystem          1.0
5PortGroup           select 1.0
6
7set select_group    qt4
8set select_branch   mac
9set select_port     ${select_group}_select
10set select_name     ${select_group}-${select_branch}
11# select.group        ${select_group}
12
13name                ${select_name}
14#conflicts           kdelibs3 kdelibs4 xmlrpcxx
15version             4.6.3
16revision            3
17categories          aqua
18platforms           macosx
19maintainers         michaelld
20
21homepage            http://qt.nokia.com/
22description         Qt Tool Kit (Native Aqua Version)
23long_description    \
24    Qt is a cross-platform application and UI framework for writing \
25    cross-platform GUI applications. This version uses the native Aqua UI. \
26    For a X11 version, see qt4-x11\[-devel\].
27
28master_sites        trolltech
29distname            qt-everywhere-opensource-src-${version}
30checksums           md5     5c69f16d452b0bb3d44bc3c10556c072 \
31                    sha1    1c18a564df9296c7cb0e0dedde40b9843e1b30e8 \
32                    rmd160  ceb3ca78263d0d9cdf92fef903e30c0026db6bff
33
34depends_build       port:pkgconfig port:${select_port}
35
36depends_lib         port:zlib port:dbus port:openssl port:sqlite3 \
37                    port:tiff port:libpng port:libmng port:jpeg
38
39# Test for Precompiled-headers support requires a C++ compiler,
40# but configure calls it, by default, with a C compiler.
41patchfiles          patch-precomp.test.diff
42
43# The build process uses -fconstant-cfstrings.
44# configure.compiler should therefore not be one of the MacPorts compilers.
45
46# --prefix is not recognized.
47configure.pre_args-delete  --prefix=${prefix}
48
49################################################################################
50# We do not want flags of any kind -- QT is smart enough to set up its own.    #
51################################################################################
52
53configure.cflags
54configure.cppflags
55configure.cxxflags
56configure.ldflags
57
58configure.universal_cflags
59configure.universal_cppflags
60configure.universal_cxxflags
61configure.universal_ldflags
62
63configure.cc_archflags
64configure.cxx_archflags
65if {[info exists configure.ld_archflags]} {
66    configure.ld_archflags
67}
68
69set dirname ${name}
70set qt_dir ${prefix}/libexec/${dirname}
71
72#  use compiler.cpath and compiler.library_path, as per
73#  http://trac.macports.org/ticket/25321 for all -I and -L entries,
74#  so-as to avoid conflicts with already-installed headers and
75#  libraries (giving preference to internal-to-this-port first)
76#
77#  CPATH is used instead of -I to avoid conflicts with other ports.
78#  See http://trac.macports.org/ticket/15219 and
79#  http://trac.macports.org/ticket/18723.
80#
81#  set the default paths to include those for SQLITE3 and DBUS-1
82
83set header_path [ list ${prefix}/include/dbus-1.0 \
84                       ${prefix}/lib/dbus-1.0/include \
85                       ${prefix}/include ]
86
87set library_path [ list ${prefix}/lib ]
88
89# -system-sqlite ensures the use SQLite provided by MacPorts instead of Qt.
90#
91# -dbus-linked prevends qt4 from trying to dynamically load libdbus-1,
92#     which it is not able to find in ${prefix}.
93#
94# -openssl-linked ensures that the MacPorts openssl is used.
95
96configure.args                                            \
97    -v                                                    \
98    -debug-and-release                                    \
99    -confirm-license                                      \
100    -opensource                                           \
101    -prefix          ${qt_dir}                            \
102    -docdir          ${qt_dir}/share/doc/${dirname}       \
103    -examplesdir     ${qt_dir}/share/${dirname}/examples  \
104    -demosdir        ${qt_dir}/share/${dirname}/demos     \
105    -cocoa                                                \
106    -system-sqlite                                        \
107    -openssl-linked                                       \
108    -dbus-linked                                          \
109    -arch            \"${build_arch}\"
110
111# Stop configure script from searching for SQL Drivers
112#    not available from MacPorts.
113foreach driver {db2 ibase oci sqlite_symbian tds} {
114    configure.args-append -no-sql-${driver}
115}
116
117# By default, disable most SQL Drivers.
118# There must be at least one enabled (http://trac.macports.org/ticket/15627).
119# SQLite is chosen to be always enabled because a copy of it is distributed
120#    with Qt, so it is reasonable for the user to expect it.
121foreach driver {mysql odbc psql sqlite2} {
122    configure.args-append -no-sql-${driver}
123}
124
125# use the corrected CPATH and LIBRARY_PATH for configure
126pre-configure {
127    compiler.cpath [join ${header_path} :]
128    compiler.library_path [join ${library_path} :]
129}
130
131# Remove any '-I' string from the C*FLAGS for SQLITE and DBUS, so that
132# what remains are just non-I flags; these paths are in compiler.cpath .
133# The includes for all the other variants are not used by
134# 'configure', and are already included in the compiler.cpath .
135post-configure {
136    # SQLITE first
137    reinplace "/CFLAGS_SQLITE/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
138        ${worksrcpath}/.qmake.cache
139    # DBUS last
140    reinplace "/CFLAGS_DBUS/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \
141        ${worksrcpath}/.qmake.cache
142    # during the 'build' stage, 'make' will rebuild the Makefiles that
143    # depend on any of these changed files.
144}
145
146# use the corrected CPATH and LIBRARY_PATH for build
147pre-build {
148    compiler.cpath [join ${header_path} :]
149    compiler.library_path [join ${library_path} :]
150}
151
152variant mysql description {Enable MySQL SQL Driver} {
153    depends_lib-append path:lib/mysql5:mysql5
154    lunshift header_path ${prefix}/include/mysql5/mysql
155    lunshift library_path ${prefix}/lib/mysql5/mysql
156    configure.args-delete -no-sql-mysql
157}
158
159variant odbc description {Enable iODBC SQL Driver} {
160    depends_lib-append port:libiodbc
161    configure.args-delete -no-sql-odbc
162}
163
164variant psql description {Enable PostgreSQL SQL Driver} {
165    depends_lib-append port:postgresql83
166    lunshift header_path ${prefix}/include/postgresql83
167    lunshift library_path ${prefix}/lib/postgresql83
168    configure.args-delete -no-sql-psql
169}
170
171variant sqlite2 description {Enable SQLite version 2 SQL Driver} {
172    depends_lib-append port:sqlite2
173    configure.args-delete -no-sql-sqlite2
174}
175
176variant raster description {Use raster graphics system by default} {
177    configure.args-append -graphicssystem raster
178}
179
180variant no_demos description {Do not build demo programs} {
181   configure.args-append -nomake demos
182}
183
184variant no_examples description {Do not build example programs} {
185   configure.args-append -nomake examples
186}
187
188variant no_debug description {Do not include debugging libraries and pkgconfig files} {
189    configure.args-delete -debug-and-release
190    configure.args-append -release
191}
192
193variant universal {
194    configure.universal_args-delete --disable-dependency-tracking
195    configure.args-delete -arch \"${build_arch}\"
196    configure.args-append -arch \"${universal_archs}\"
197    if {[info exists universal_sysroot]} {
198        configure.args-append -sdk ${universal_sysroot}
199    }
200}
201
202# use the 10.4 SDK (the default) for 10.4 only.
203# and, build as Carbon by disabling Cocoa.
204platform darwin 8 {
205    configure.args-delete -cocoa
206    post-configure {
207        fs-traverse item ${worksrcpath} {
208            if {"Makefile" == [file tail ${item}]} {
209                reinplace "s|-framework QtHelp|-framework QtHelp -lQtCLucene|" ${item}
210            }
211        }
212    }
213}
214
215# use the 10.5 SDK for 10.5,
216# but only if not (doing universal and the universal sysroot is set)
217platform darwin 9 {
218    if {![variant_isset universal] || ![info exists universal_sysroot]} {
219        if {[file exists /Developer/SDKs/MacOSX10.5.sdk]} {
220            configure.args-append -sdk /Developer/SDKs/MacOSX10.5.sdk/
221        } else {
222            ui_msg "No SDK found in Developer/SDKs ; \
223configure will probably fail. \n \
224Please install Apple's Developer Tools again."
225        }
226    }
227}
228
229# use the 10.6 SDK for 10.6
230# but only if not (doing universal and the universal sysroot is set)
231platform darwin 10 {
232    if {![variant_isset universal] || ![info exists universal_sysroot]} {
233        if {[file exists /Developer/SDKs/MacOSX10.6.sdk]} {
234            configure.args-append -sdk /Developer/SDKs/MacOSX10.6.sdk/
235        } else {
236            ui_msg "No SDK found in /Developer/SDKs ; \
237configure will probably fail. \n \
238Please install Apple's Developer Tools again."
239        }
240    }
241}
242
243build.target        first
244use_parallel_build  yes
245
246destroot.destdir    INSTALL_ROOT="${destroot}"
247
248post-patch {
249    # Ensure that correct compilers are used.
250    reinplace "s| g++\$| ${configure.cxx}|" ${worksrcpath}/mkspecs/common/g++.conf
251    reinplace "s| gcc\$| ${configure.cc}|"  ${worksrcpath}/mkspecs/common/g++.conf
252    reinplace "s| g++\$| ${configure.cxx}|" ${worksrcpath}/mkspecs/macx-g++/qmake.conf
253    reinplace "s| gcc\$| ${configure.cc}|"  ${worksrcpath}/mkspecs/macx-g++/qmake.conf
254}
255
256post-destroot {
257    # Fix .pc and .prl files by changing ${destroot}/lib to ${qt_dir}/lib
258    foreach fixfile [glob -nocomplain -directory ${destroot} ${qt_dir}/lib/pkgconfig/* ${qt_dir}/lib/*.prl ${qt_dir}/lib/*/*.prl ${qt_dir}/share/${dirname}/demos/shared/*.prl] {
259        reinplace  \
260            "s|${worksrcpath}/lib|${qt_dir}/lib|g" \
261            ${fixfile}
262    }
263
264    # Install documentation.
265    foreach doc { INSTALL LGPL_EXCEPTION.txt LICENSE.GPL3 LICENSE.LGPL README } {
266        xinstall -c -m 644 ${worksrcpath}/${doc} \
267            ${destroot}${qt_dir}/share/doc/${name}
268    }
269
270    # Fix includes
271    # (1) Remove include/Qt ; it should never be used
272    if {[file exists ${destroot}${qt_dir}/include/Qt]} {
273        delete ${destroot}${qt_dir}/include/Qt
274    }
275
276    # (2) remove from ${qt_dir}/include/FOO, for each FOO in the
277    # frameworks, and link into the headers provided by the FOO framework
278    foreach fms [glob -nocomplain -directory ${destroot} \
279                     ${qt_dir}/lib/*.framework] {
280        # 0: split the framework abs path using '/'
281        set tmp [split ${fms} /]
282        # 1: retrieve the framework name
283        set tfm [lindex [split [lindex ${tmp} [expr [llength ${tmp}] - 1]] .] 0]
284        # 2: remove the include directory, if it exists
285        if {[file exists ${destroot}${qt_dir}/include/${tfm}] } {
286            # if it exists
287            delete ${destroot}${qt_dir}/include/${tfm}
288        }
289        # 3: link into the framework's Headers
290        ln -s ${qt_dir}/lib/${tfm}.framework/Headers \
291            ${destroot}${qt_dir}/include/${tfm}
292    }
293
294    # install the select file
295    xinstall -m 755 -d ${destroot}${prefix}/etc/select/${select_group}
296    xinstall -c -m 644 ${filespath}/${select_name} \
297        ${destroot}${prefix}/etc/select/${select_group}/${select_name}
298
299    # then, reinplace the select file as necessary for variants; put
300    # these here instead of in the variants because I don't know which
301    # are executed first (this post-destroot or a variant's) & the
302    # select file needs to be in place first.
303    if {[variant_isset no_debug]} {
304        # remove select entries for debug
305        reinplace "/debug/ c\\\n-\n" \
306            ${destroot}${prefix}/etc/select/${select_group}/${select_name}
307    }
308    if {[variant_isset no_demo]} {
309        # remove select entries for demo
310        reinplace "/demo/ c\\\n-\n" \
311            ${destroot}${prefix}/etc/select/${select_group}/${select_name}
312
313        # special case: if no examples and no debug,
314        if {[variant_isset no_examples]} {
315            # remove select entry for share/qt4-mac
316            reinplace "/share\\/qt4-mac/ c\\\n-\n" \
317                ${destroot}${prefix}/etc/select/${select_group}/${select_name}
318        }
319    }
320}
321
322post-activate {
323    # If this is the first qt4-* installed, select it.
324    set current_select [exec ${prefix}/bin/${select_port} -s]
325    if {${current_select} == "none"} {
326        system "${prefix}/bin/${select_port} ${select_name}"
327    } else {
328        if {${current_select} != ${select_name}} {
329            # Print out the 'select' info.
330            ui_msg "\
331Port ${current_select} is already selected.\n \
332To fully complete this installation and make ${name} the default,\n \
333please run:\n \
334\tsudo ${select_port} ${select_name}"
335        }
336    }
337}
338
339pre-deactivate {
340    # If this is qt4-* is selected, select 'none' & tell the user
341    set current_select [exec ${prefix}/bin/${select_port} -s]
342    if { [exec ${prefix}/bin/${select_port} -s] == ${select_name} } {
343        system "${prefix}/bin/${select_port} none"
344        ui_msg "\
345Port '${current_select}' was selected; none is now selected.\n \
346To select another port for group '${select_group}', \
347please run '${select_port}'."
348    }
349
350    # remove case-sensitive ${prefix}/${qt_dir}/include/phonon/[Pp]honon
351    foreach tf [glob -directory ${prefix}/${qt_dir}/include/phonon \
352                     ?honon] {
353        delete ${tf}
354    }
355}
356
357livecheck.type      regex
358livecheck.url       http://get.qt.nokia.com/qt/source/
359livecheck.regex     "qt-everywhere-opensource-src-(\[0-9a-z.-\]+)${extract.suffix}"
Note: See TracBrowser for help on using the repository browser.