Ticket #50966: qt5-kde-1.0.tcl

File qt5-kde-1.0.tcl, 18.6 KB (added by RJVB (René Bertin), 8 years ago)
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# kate: backspace-indents true; indent-pasted-text true; indent-width 4; keep-extra-spaces true; remove-trailing-spaces modified; replace-tabs true; replace-tabs-save true; syntax Tcl/Tk; tab-indents true; tab-width 4;
3# $Id: qt5-1.0.tcl 113952 2015-06-11 16:30:53Z gmail.com:rjvbertin $
4# $Id: qt5-1.0.tcl 113952 2013-11-26 18:01:53Z michaelld@macports.org $
5
6# Copyright (c) 2014 The MacPorts Project
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions are
11# met:
12#
13# 1. Redistributions of source code must retain the above copyright
14#    notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright
16#    notice, this list of conditions and the following disclaimer in the
17#    documentation and/or other materials provided with the distribution.
18# 3. Neither the name of Apple Computer, Inc. nor the names of its
19#    contributors may be used to endorse or promote products derived from
20#    this software without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33#
34#
35# This portgroup defines standard settings when using Qt5.
36#
37# Usage:
38# set qt5.prefer_kde 1
39# PortGroup     qt5 1.0
40# or
41# PortGroup     qt5-kde 1.0
42#
43# Define qt5.depends_qtwebengine before including the portgroup to add
44# a dependency on qt5-kde-qtwebengine .
45
46if { ![exists universal_variant] || [option universal_variant] } {
47    PortGroup muniversal 1.0
48    #universal_archs_supported i386 x86_64
49}
50
51# check for +debug variant of this port, and make sure Qt was
52# installed with +debug as well; if not, error out.
53platform darwin {
54    pre-extract {
55        if {[variant_exists debug] && \
56            [variant_isset debug] && \
57           ![info exists building_qt5]} {
58            if {![file exists ${qt_frameworks_dir}/QtCore.framework/QtCore_debug]} {
59                return -code error "\n\nERROR:\n\
60In order to install this port as +debug,
61Qt5 must also be installed with +debug.\n"
62            }
63        }
64    }
65}
66
67if {![variant_exists qt5kde]} {
68    # define a variant that will be set default when port:qt5-kde or port:qt5-kde-devel is
69    # installed. This means that a user doing a new install (or upgrade) of a port depending
70    # on Qt5 and with port:qt5-kde installed will request a variant the build bots should not
71    # consider a default variant. This meant to protect against pulling in a binary build against
72    # the wrong Qt5 port, which was relevant in the time of port:qt5-mac, and hopefully no
73    # longer now that port:qt5 installs to the same place as we do (but as an all-inclusive prefix).
74    variant qt5kde description {default variant set for port:qt5-kde* and ports that depend on them} {}
75}
76# it should no longer be necessary to set qt5kde but we will continue to do so for now.
77default_variants        +qt5kde
78
79# standard Qt5 name. This should be just "qt5" (or qt53 for instance when more
80# specific version info must be included). There is nothing but a historical reason
81# to call the Qt5 port itself qt5-mac, so that name should not appear on disk where
82# files could be installed that would be the distant descendants of files from qt4-x11
83global qt_name
84set qt_name             qt5
85
86# global definitions with explanation; set the actual values below for cleanness.
87# standard install directory
88    global qt_dir
89# idem, relative to ${prefix}
90    global qt_dir_rel
91# archdata: equal to qt_dir
92    global qt_archdata_dir
93# standard Qt documents directory
94    global qt_docs_dir
95# standard Qt plugins directory
96    global qt_plugins_dir
97# standard Qt mkspecs directory
98    global qt_mkspecs_dir
99# standard Qt imports directory
100    global qt_imports_dir
101# standard Qt qml directory
102    global qt_qml_dir
103# standard Qt includes directory, under ${prefix}/includes where they would be expected
104    global qt_includes_dir
105# standard Qt libraries directory
106    global qt_libs_dir
107# standard Qt libraries directory: OS X frameworks
108    global qt_frameworks_dir
109# idem, relative to ${prefix}
110    global qt_frameworks_dir_rel
111# standard Qt non-.app executables directory
112    global qt_bins_dir
113# standard Qt data directory
114    global qt_data_dir
115# standard Qt translations directory
116    global qt_translations_dir
117# standard Qt sysconf directory
118    global qt_sysconf_dir
119# standard Qt .app executables directory, if created
120    global qt_apps_dir
121# standard Qt examples directory
122    global qt_examples_dir
123# standard Qt demos directory
124    global qt_demos_dir
125# standard Qt tests directory
126    global qt_tests_dir
127# standard CMake module directory for Qt-related files
128    global qt_cmake_module_dir
129# standard qmake command location
130    global qt_qmake_cmd
131# standard moc command location
132    global qt_moc_cmd
133# standard uic command location
134    global qt_uic_cmd
135# standard lrelease command location
136    global qt_lrelease_cmd
137    global qt_lupdate_cmd
138
139global qt5_is_concurrent
140# check if we're building qt5 itself. We're aiming to phase out exclusive installs, but we
141# keep the this block for now that handles detection of the nature of the installed port.
142# if {![info exists building_qt5] || ![info exists name] \
143#     || (${name} ne "qt5-mac" && ${name} ne "qt5-mac-devel" && ${name} ne "qt5-kde" && ${name} ne "qt5-kde-devel")} {
144#     # no, this must be a dependent port: check the qt5 install:
145#     if {[file exists ${prefix}/libexec/${qt_name}/bin/qmake]} {
146#         # we have a "concurrent" install, which means we must look for the various components
147#         # in different locations (esp. qmake)
148#         set qt5_is_concurrent   1
149#     }
150# } else {
151#     # we're building qt5, qt5-mac or one of its subports/variants
152#     # we're asking for the standard concurrent install. No need to guess anything, give the user what s/he wants
153#     set qt5_is_concurrent   1
154# }
155set qt5_is_concurrent       1
156
157set qt_dir                  ${prefix}/libexec/${qt_name}
158set qt_dir_rel              libexec/${qt_name}
159set qt_includes_dir         ${prefix}/include/${qt_name}
160set qt_libs_dir             ${qt_dir}/lib
161set qt_frameworks_dir       ${qt_dir}/Library/Frameworks
162set qt_frameworks_dir_rel   ${qt_dir_rel}/Library/Frameworks
163set qt_bins_dir             ${qt_dir}/bin
164set qt_cmake_module_dir     ${prefix}/lib/cmake
165set qt_archdata_dir         ${qt_dir}
166set qt_sysconf_dir          ${prefix}/etc/${qt_name}
167set qt_data_dir             ${prefix}/share/${qt_name}
168set qt_plugins_dir          ${prefix}/share/${qt_name}/plugins
169set qt_mkspecs_dir          ${prefix}/share/${qt_name}/mkspecs
170set qt_imports_dir          ${prefix}/share/${qt_name}/imports
171set qt_qml_dir              ${prefix}/share/${qt_name}/qml
172set qt_translations_dir     ${prefix}/share/${qt_name}/translations
173set qt_tests_dir            ${prefix}/share/${qt_name}/tests
174set qt_docs_dir             ${prefix}/share/doc/${qt_name}
175
176set qt_qmake_cmd            ${qt_dir}/bin/qmake
177set qt_moc_cmd              ${qt_dir}/bin/moc
178set qt_uic_cmd              ${qt_dir}/bin/uic
179set qt_lrelease_cmd         ${qt_dir}/bin/lrelease
180set qt_lupdate_cmd          ${qt_dir}/bin/lupdate
181
182if {${os.platform} eq "darwin"} {
183    set qt_apps_dir         ${applications_dir}/Qt5
184} else {
185    set qt_apps_dir         ${qt_bins_dir}
186}
187set qt_examples_dir         ${qt_apps_dir}/examples
188set qt_demos_dir            ${qt_apps_dir}/demos
189
190global qt_qmake_spec
191global qt_qmake_spec_32
192global qt_qmake_spec_64
193
194PortGroup                   compiler_blacklist_versions 1.0
195PortGroup                   macports_clang_selection 1.0
196if {${os.platform} eq "darwin"} {
197    compiler.whitelist      clang
198#     compiler.whitelist      clang macports-clang-3.7 macports-clang-3.6 macports-clang-3.5 macports-clang-3.4
199}
200compiler.blacklist-append   macports-llvm-gcc-4.2 llvm-gcc-4.2
201compiler.blacklist-append   gcc-4.2 apple-gcc-4.2 gcc-4.0
202# compiler.blacklist-append   macports-clang-3.1 macports-clang-3.0 macports-clang-3.2 macports-clang-3.3
203compiler.blacklist-append   {clang < 500}
204# # starting with the one-but-newest macports-clang in the whitelist, check it it is
205# # installed and blacklist the other values so that the automatic selection mechanism
206# # will select the installed whitelisted version.
207# foreach v {3.6 3.5 3.4} {
208#     if {[file exists ${prefix}/libexec/llvm-${v}/bin/clang]} {
209#         foreach o {3.7 3.6 3.5 3.4} {
210#             if {${o} ne ${v}} {
211#                 compiler.blacklist-append   macports-clang-${o}
212#             }
213#         }
214#     }
215# }
216if {${os.platform} eq "darwin"} {
217    if {${os.platform} > 10} {
218        whitelist_macports_clang_versions   {3.7 3.6 3.5 3.4}
219    } else {
220        whitelist_macports_clang_versions   {3.5 3.4}
221    }
222    blacklist_macports_clang_versions       {< 3.4}
223}
224
225# set Qt understood arch types, based on user preference
226options qt_arch_types
227default qt_arch_types {[string map {i386 x86} [get_canonical_archs]]}
228
229if {${os.platform} eq "darwin"} {
230    set qt_qmake_spec_32 macx-clang-32
231    set qt_qmake_spec_64 macx-clang
232} elseif {${os.platform} eq "linux"} {
233    set qt_qmake_spec_32 linux-g++
234    set qt_qmake_spec_64 linux-g++-64
235    compiler.blacklist-append   clang
236}
237
238if { ![option universal_variant] || ![variant_isset universal] } {
239    if { ${build_arch} eq "i386" } {
240        set qt_qmake_spec ${qt_qmake_spec_32}
241    } else {
242        set qt_qmake_spec ${qt_qmake_spec_64}
243    }
244} else {
245    set qt_qmake_spec ""
246}
247
248# standard PKGCONFIG path
249global qt_pkg_config_dir
250set qt_pkg_config_dir   ${prefix}/lib/pkgconfig
251
252# data used by qmake
253global qt_host_data_dir
254set qt_host_data_dir   ${prefix}/share/${qt_name} 
255
256# standard cmake info for Qt5
257global qt_cmake_defines
258set qt_cmake_defines    \
259    "-DQT_QT_INCLUDE_DIR=${qt_includes_dir} \
260     -DQT_QMAKESPEC=${qt_qmake_spec} \
261     -DQT_ZLIB_LIBRARY=${prefix}/lib/libz.dylib \
262     -DQT_PNG_LIBRARY=${prefix}/lib/libpng.dylib"
263
264if {${os.platform} eq "darwin"} {
265    # extensions on shared libraries
266    set qt_libs_ext     dylib
267    # extensions on plugins created by Qt's build system
268    set qt_plugins_ext  dylib
269} else {
270    set qt_libs_ext     so
271    set qt_plugins_ext  so
272}
273
274# allow for depending on either qt5[-mac] or qt5[-mac]-devel or qt5[-mac]*-kde, simultaneously
275
276set qt5_stubports   {qtbase qtdeclarative qtserialport qtsensors \
277                qtquick1 qtwebchannel qtimageformats qtsvg qtmacextras \
278                qtlocation qtxmlpatterns qtcanvas3d qtgraphicaleffects qtmultimedia \
279                qtscript qt3d qtconnectivity qttools qtquickcontrols qtenginio \
280                qtwebkit-examples qtwebsockets qttranslations docs mysql-plugin \
281                sqlite-plugin}
282
283if {![info exists building_qt5]} {
284    if {${os.platform} eq "darwin"} {
285
286        # see if the framework install exists, and if so depend on it;
287        # if not, depend on the library version
288
289        global qt5_dependency
290#         if {[info exists qt5_is_concurrent]} {
291            if {[file exists ${qt_frameworks_dir}/QtCore.framework/QtCore]} {
292                set qt5_pathlibspec path:libexec/${qt_name}/Library/Frameworks/QtCore.framework/QtCore
293            } else {
294                set qt5_pathlibspec path:libexec/${qt_name}/lib/libQtCore.${qt_libs_ext}
295            }
296#         } else {
297#             if {[file exists ${qt_frameworks_dir}/QtCore.framework/QtCore]} {
298#                 set qt5_pathlibspec path:Library/Frameworks/QtCore.framework/QtCore
299#             } else {
300#                 set qt5_pathlibspec path:lib/libQtCore.${qt_libs_ext}
301#             }
302#         }
303        set qt5_dependency ${qt5_pathlibspec}:qt5-kde
304        depends_lib-append ${qt5_dependency} \
305                path:libexec/${qt_name}/Library/Frameworks/QtWebKit.framework/QtWebKit:qt5-kde-qtwebkit
306        if {[info exists qt5.depends_qtwebengine] && ${qt5.depends_qtwebengine}} {
307            depends_lib-append \
308                path:libexec/${qt_name}/Library/Frameworks/QtWebEngineCore.framework/QtWebEngineCore:qt5-kde-qtwebengine
309        }
310    } elseif {${os.platform} eq "linux"} {
311        set qt5_pathlibspec path:libexec/${qt_name}/lib/libQt5Core.${qt_libs_ext}
312        set qt5_dependency ${qt5_pathlibspec}:qt5-kde
313        depends_lib-append ${qt5_dependency} \
314                path:libexec/${qt_name}/lib/libQt5WebKit.${qt_libs_ext}:qt5-kde-qtwebkit
315        if {[info exists qt5.depends_qtwebengine] && ${qt5.depends_qtwebengine}} {
316            depends_lib-append \
317                path:libexec/${qt_name}/lib/libQt5WebEngineCore.${qt_libs_ext}:qt5-kde-qtwebengine
318        }
319    }
320}
321
322if {${os.platform} eq "darwin"} {
323    variant LTO description {Build with Link-Time Optimisation (LTO) (currently not 100% compatible with SSE4+ and 3DNow intrinsics)} {}
324} else {
325    variant LTO description {Build with Link-Time Optimisation (LTO) (experimental)} {}
326}
327
328if {![info exists building_qt5] && [variant_exists LTO] && [variant_isset LTO]} {
329    configure.cflags-append     -flto
330    configure.cxxflags-append   -flto
331    configure.objcflags-append  -flto
332    configure.objcxxflags-append  -flto
333    # ${configure.optflags} is a list, and that can lead to strange effects
334    # in certain situations if we don't treat it as such here.
335    foreach opt ${configure.optflags} {
336        configure.ldflags-append ${opt}
337    }
338    configure.ldflags-append    -flto
339    # assume any compiler not clang will be gcc
340    if {![string match "*clang*" ${configure.compiler}]} {
341        configure.cflags-append         -fuse-linker-plugin -ffat-lto-objects
342        configure.cxxflags-append       -fuse-linker-plugin -ffat-lto-objects
343        configure.objcflags-append      -fuse-linker-plugin -ffat-lto-objects
344        configure.objcxxflags-append    -fuse-linker-plugin -ffat-lto-objects
345        configure.ldflags-append        -fuse-linker-plugin
346    }
347}
348
349# standard configure environment, when not building qt5
350
351if {![info exists building_qt5]} {
352    configure.env-append \
353        QTDIR=${qt_dir} \
354        QMAKE=${qt_qmake_cmd} \
355        MOC=${qt_moc_cmd}
356
357    if { ![option universal_variant] || ![variant_isset universal] } {
358        configure.env-append QMAKESPEC=${qt_qmake_spec}
359    } else {
360        set merger_configure_env(i386)   "QMAKESPEC=${qt_qmake_spec_32}"
361        set merger_configure_env(x86_64) "QMAKESPEC=${qt_qmake_spec_64}"
362        set merger_arch_flag             yes
363        set merger_arch_compiler         yes
364    }
365
366    # make sure the Qt binaries' directory is in the path, if it is
367    # not the current prefix
368
369    if {${qt_dir} ne ${prefix}} {
370        configure.env-append PATH=${qt_dir}/bin:$env(PATH)
371    }
372} else {
373    configure.env-append QMAKE_NO_DEFAULTS=""
374}
375
376# standard build environment, when not building qt5
377
378if {![info exists building_qt5]} {
379    build.env-append \
380        QTDIR=${qt_dir} \
381        QMAKE=${qt_qmake_cmd} \
382        MOC=${qt_moc_cmd}
383
384    if { ![option universal_variant] || ![variant_isset universal] } {
385        build.env-append QMAKESPEC=${qt_qmake_spec}
386    } else {
387        set merger_build_env(i386)   "QMAKESPEC=${qt_qmake_spec_32}"
388        set merger_build_env(x86_64) "QMAKESPEC=${qt_qmake_spec_64}"
389        set merger_arch_flag             yes
390        set merger_arch_compiler         yes
391    }
392
393    # make sure the Qt binaries' directory is in the path, if it is
394    # not the current prefix
395
396    if {${qt_dir} ne ${prefix}} {
397        build.env-append    PATH=${qt_dir}/bin:$env(PATH)
398    }
399}
400
401# use PKGCONFIG for Qt discovery in configure scripts
402depends_build-append    port:pkgconfig
403
404# standard destroot environment
405if { ![option universal_variant] || ![variant_isset universal] } {
406    destroot.env-append \
407        INSTALL_ROOT=${destroot}
408} else {
409    foreach arch ${configure.universal_archs} {
410        lappend merger_destroot_env($arch) INSTALL_ROOT=${workpath}/destroot-${arch}
411    }
412}
413
414# standard destroot environment, when not building qt5
415
416if {![info exists building_qt5]} {
417    destroot.env-append \
418        QTDIR=${qt_dir} \
419        QMAKE=${qt_qmake_cmd} \
420        MOC=${qt_moc_cmd}
421
422    if { ![option universal_variant] || ![variant_isset universal] } {
423        build.env-append QMAKESPEC=${qt_qmake_spec}
424    } else {
425        set destroot_build_env(i386)   "QMAKESPEC=${qt_qmake_spec_32}"
426        set destroot_build_env(x86_64) "QMAKESPEC=${qt_qmake_spec_64}"
427    }
428
429    # make sure the Qt binaries' directory is in the path, if it is
430    # not the current prefix
431
432    if {${qt_dir} ne ${prefix}} {
433        destroot.env-append PATH=${qt_dir}/bin:$env(PATH)
434    }
435}
436
437# proc qt_branch {} {
438#     global version
439#     return [join [lrange [split ${version} .] 0 1] .]
440# }
441
442# provide a variant to prune provided translations
443PortGroup   locale_select 1.0
444# Qt translations don't go into ${prefix}/opt/local/share/locale:
445post-destroot {
446    if {![info exists keep_languages]} {
447        if {[file exists ${prefix}/etc/macports/locales.tcl] && [file exists ${destroot}${qt_translations_dir}]} {
448            if {[catch {source "${prefix}/etc/macports/locales.tcl"} err]} {
449                ui_error "Error reading ${prefix}/etc/macports/locales.tcl: $err"
450                return -code error "Error reading ${prefix}/etc/macports/locales.tcl"
451            }
452        }
453    }
454    if {[info exists keep_languages]} {
455        foreach l [glob -nocomplain ${destroot}${qt_translations_dir}/*.qm] {
456            set langcomps [split [file rootname [file tail ${l}]] _]
457            set simplelang [lindex ${langcomps} end]
458            set complang [join [lrange ${langcomps} end-1 end] _]
459            if {[lsearch -exact ${keep_languages} ${simplelang}] ne "-1"} {
460                ui_debug "won't delete ${l} (${simplelang})"
461            } elseif {[lsearch -exact ${keep_languages} ${complang}] ne "-1"} {
462                ui_debug "won't delete ${l} (${complang})"
463            } else {
464                ui_debug "rm ${l}"
465                file delete -force ${l}
466            }
467        }
468    }
469}
470
471array set qt5_component_lib {
472     qtwebkit path:libexec/${qt_name}/Library/Frameworks/QtWebKitCore.framework/QtWebKitCore
473     qtwebengine path:libexec/${qt_name}/Library/Frameworks/QtWebEngine.framework/QtWebEngine
474}