Ticket #26646: Portfile

File Portfile, 15.7 KB (added by dsdale24@…, 14 years ago)

qt4-mac-devel portfile

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