Ticket #48967: qt5-kde-1.0.tcl

File qt5-kde-1.0.tcl, 17.4 KB (added by RJVB (René Bertin), 9 years ago)

the PortGroup for port:qt5-kde which is used either when port:qt5-kde is installed or when a port prefers qt5-kde and no port:qt5* is installed yet.

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# PortGroup     qt5 1.0
39
40if { ![exists universal_variant] || [option universal_variant] } {
41    PortGroup muniversal 1.0
42    #universal_archs_supported i386 x86_64
43}
44
45# check for +debug variant of this port, and make sure Qt was
46# installed with +debug as well; if not, error out.
47platform darwin {
48    pre-extract {
49        if {[variant_exists debug] && \
50            [variant_isset debug] && \
51           ![info exists building_qt5]} {
52            if {![file exists ${qt_frameworks_dir}/QtCore.framework/QtCore_debug]} {
53                return -code error "\n\nERROR:\n\
54In order to install this port as +debug,
55Qt5 must also be installed with +debug.\n"
56            }
57        }
58    }
59}
60
61if {![variant_exists qt5kde]} {
62    # define a variant that will be set default when port:qt5-kde or port:qt5-kde-devel is
63    # installed. This means that a user doing a new install (or upgrade) of a port depending
64    # on Qt5 and with port:qt5-kde installed will request a variant the build bots should not
65    # consider a default variant. This meant to protect against pulling in a binary build against
66    # the wrong Qt5 port, which was relevant in the time of port:qt5-mac, and hopefully no
67    # longer now that port:qt5 installs to the same place as we do (but as an all-inclusive prefix).
68    variant qt5kde description {default variant set for port:qt5-kde* and ports that depend on them} {}
69}
70# it should no longer be necessary to set qt5kde but we will continue to do so for now.
71default_variants        +qt5kde
72
73# standard Qt5 name. This should be just "qt5" (or qt53 for instance when more
74# specific version info must be included). There is nothing but a historical reason
75# to call the Qt5 port itself qt5-mac, so that name should not appear on disk where
76# files could be installed that would be the distant descendants of files from qt4-x11
77global qt_name
78set qt_name             qt5
79
80# global definitions with explanation; set the actual values below for cleanness.
81# standard install directory
82    global qt_dir
83# idem, relative to ${prefix}
84    global qt_dir_rel
85# archdata: equal to qt_dir
86    global qt_archdata_dir
87# standard Qt documents directory
88    global qt_docs_dir
89# standard Qt plugins directory
90    global qt_plugins_dir
91# standard Qt mkspecs directory
92    global qt_mkspecs_dir
93# standard Qt imports directory
94    global qt_imports_dir
95# standard Qt qml directory
96    global qt_qml_dir
97# standard Qt includes directory, under ${prefix}/includes where they would be expected
98    global qt_includes_dir
99# standard Qt libraries directory
100    global qt_libs_dir
101# standard Qt libraries directory: OS X frameworks
102    global qt_frameworks_dir
103# idem, relative to ${prefix}
104    global qt_frameworks_dir_rel
105# standard Qt non-.app executables directory
106    global qt_bins_dir
107# standard Qt data directory
108    global qt_data_dir
109# standard Qt translations directory
110    global qt_translations_dir
111# standard Qt sysconf directory
112    global qt_sysconf_dir
113# standard Qt .app executables directory, if created
114    global qt_apps_dir
115# standard Qt examples directory
116    global qt_examples_dir
117# standard Qt demos directory
118    global qt_demos_dir
119# standard Qt tests directory
120    global qt_tests_dir
121# standard CMake module directory for Qt-related files
122    global qt_cmake_module_dir
123# standard qmake command location
124    global qt_qmake_cmd
125# standard moc command location
126    global qt_moc_cmd
127# standard uic command location
128    global qt_uic_cmd
129# standard lrelease command location
130    global qt_lrelease_cmd
131
132global qt5_is_concurrent
133# check if we're building qt5 itself. We're aiming to phase out exclusive installs, but we
134# keep the this block for now that handles detection of the nature of the installed port.
135if {![info exists building_qt5] || ![info exists name] \
136    || (${name} ne "qt5-mac" && ${name} ne "qt5-mac-devel" && ${name} ne "qt5-kde" && ${name} ne "qt5-kde-devel")} {
137    # no, this must be a dependent port: check the qt5 install:
138    if {[file exists ${prefix}/libexec/${qt_name}/bin/qmake]} {
139        # we have a "concurrent" install, which means we must look for the various components
140        # in different locations (esp. qmake)
141        set qt5_is_concurrent   1
142    }
143} else {
144    # we're building qt5, qt5-mac or one of its subports/variants
145    # we're asking for the standard concurrent install. No need to guess anything, give the user what s/he wants
146    set qt5_is_concurrent   1
147}
148
149set qt_dir                  ${prefix}/libexec/${qt_name}
150set qt_dir_rel              libexec/${qt_name}
151set qt_includes_dir         ${prefix}/include/${qt_name}
152set qt_libs_dir             ${qt_dir}/lib
153set qt_frameworks_dir       ${qt_dir}/Library/Frameworks
154set qt_frameworks_dir_rel   ${qt_dir_rel}/Library/Frameworks
155set qt_bins_dir             ${qt_dir}/bin
156set qt_cmake_module_dir     ${prefix}/lib/cmake
157set qt_archdata_dir         ${qt_dir}
158set qt_sysconf_dir          ${prefix}/etc/${qt_name}
159set qt_data_dir             ${prefix}/share/${qt_name}
160set qt_plugins_dir          ${prefix}/share/${qt_name}/plugins
161set qt_mkspecs_dir          ${prefix}/share/${qt_name}/mkspecs
162set qt_imports_dir          ${prefix}/share/${qt_name}/imports
163set qt_qml_dir              ${prefix}/share/${qt_name}/qml
164set qt_translations_dir     ${prefix}/share/${qt_name}/translations
165set qt_tests_dir            ${prefix}/share/${qt_name}/tests
166set qt_docs_dir             ${prefix}/share/doc/${qt_name}
167
168set qt_qmake_cmd            ${qt_dir}/bin/qmake
169set qt_moc_cmd              ${qt_dir}/bin/moc
170set qt_uic_cmd              ${qt_dir}/bin/uic
171set qt_lrelease_cmd         ${qt_dir}/bin/lrelease
172
173if {${os.platform} eq "darwin"} {
174    set qt_apps_dir         ${applications_dir}/Qt5
175} else {
176    set qt_apps_dir         ${qt_bins_dir}
177}
178set qt_examples_dir         ${qt_apps_dir}/examples
179set qt_demos_dir            ${qt_apps_dir}/demos
180
181global qt_qmake_spec
182global qt_qmake_spec_32
183global qt_qmake_spec_64
184
185PortGroup                   compiler_blacklist_versions 1.0
186PortGroup                   macports_clang_selection 1.0
187if {${os.platform} eq "darwin"} {
188    compiler.whitelist      clang
189#     compiler.whitelist      clang macports-clang-3.7 macports-clang-3.6 macports-clang-3.5 macports-clang-3.4
190}
191compiler.blacklist-append   macports-llvm-gcc-4.2 llvm-gcc-4.2
192compiler.blacklist-append   gcc-4.2 apple-gcc-4.2 gcc-4.0
193# compiler.blacklist-append   macports-clang-3.1 macports-clang-3.0 macports-clang-3.2 macports-clang-3.3
194compiler.blacklist-append   {clang < 500}
195# # starting with the one-but-newest macports-clang in the whitelist, check it it is
196# # installed and blacklist the other values so that the automatic selection mechanism
197# # will select the installed whitelisted version.
198# foreach v {3.6 3.5 3.4} {
199#     if {[file exists ${prefix}/libexec/llvm-${v}/bin/clang]} {
200#         foreach o {3.7 3.6 3.5 3.4} {
201#             if {${o} ne ${v}} {
202#                 compiler.blacklist-append   macports-clang-${o}
203#             }
204#         }
205#     }
206# }
207if {${os.platform} eq "darwin"} {
208    if {${os.platform} > 10} {
209        whitelist_macports_clang_versions   {3.7 3.6 3.5 3.4}
210    } else {
211        whitelist_macports_clang_versions   {3.5 3.4}
212    }
213    blacklist_macports_clang_versions       {< 3.4}
214}
215
216# set Qt understood arch types, based on user preference
217options qt_arch_types
218default qt_arch_types {[string map {i386 x86} [get_canonical_archs]]}
219
220if {${os.platform} eq "darwin"} {
221    set qt_qmake_spec_32 macx-clang-32
222    set qt_qmake_spec_64 macx-clang
223} elseif {${os.platform} eq "linux"} {
224    set qt_qmake_spec_32 linux-g++
225    set qt_qmake_spec_64 linux-g++-64
226    compiler.blacklist-append   clang
227}
228
229if { ![option universal_variant] || ![variant_isset universal] } {
230    if { ${build_arch} eq "i386" } {
231        set qt_qmake_spec ${qt_qmake_spec_32}
232    } else {
233        set qt_qmake_spec ${qt_qmake_spec_64}
234    }
235} else {
236    set qt_qmake_spec ""
237}
238
239# standard PKGCONFIG path
240global qt_pkg_config_dir
241set qt_pkg_config_dir   ${prefix}/lib/pkgconfig
242
243# data used by qmake
244global qt_host_data_dir
245set qt_host_data_dir   ${prefix}/share/${qt_name} 
246
247# standard cmake info for Qt5
248global qt_cmake_defines
249set qt_cmake_defines    \
250    "-DQT_QT_INCLUDE_DIR=${qt_includes_dir} \
251     -DQT_QMAKESPEC=${qt_qmake_spec} \
252     -DQT_ZLIB_LIBRARY=${prefix}/lib/libz.dylib \
253     -DQT_PNG_LIBRARY=${prefix}/lib/libpng.dylib"
254
255if {${os.platform} eq "darwin"} {
256    # extensions on shared libraries
257    set qt_libs_ext     dylib
258    # extensions on plugins created by Qt's build system
259    set qt_plugins_ext  dylib
260} else {
261    set qt_libs_ext     so
262    set qt_plugins_ext  so
263}
264
265# allow for depending on either qt5[-mac] or qt5[-mac]-devel or qt5[-mac]*-kde, simultaneously
266
267set qt5_stubports   {qtbase qtdeclarative qtserialport qtsensors qtwebkit \
268                qtquick1 qtwebchannel qtimageformats qtsvg qtmacextras \
269                qtlocation qtxmlpatterns qtcanvas3d qtgraphicaleffects qtmultimedia \
270                qtscript qt3d qtconnectivity qttools qtquickcontrols qtenginio \
271                qtwebkit-examples qtwebsockets qttranslations docs mysql-plugin \
272                sqlite-plugin}
273
274if {![info exists building_qt5]} {
275    if {${os.platform} eq "darwin"} {
276
277        # see if the framework install exists, and if so depend on it;
278        # if not, depend on the library version
279
280        global qt5_dependency
281        if {[info exists qt5_is_concurrent]} {
282            if {[file exists ${qt_frameworks_dir}/QtCore.framework/QtCore]} {
283                set qt5_pathlibspec path:libexec/${qt_name}/Library/Frameworks/QtCore.framework/QtCore
284            } else {
285                set qt5_pathlibspec path:libexec/${qt_name}/lib/libQtCore.${qt_libs_ext}
286            }
287        } else {
288            if {[file exists ${qt_frameworks_dir}/QtCore.framework/QtCore]} {
289                set qt5_pathlibspec path:Library/Frameworks/QtCore.framework/QtCore
290            } else {
291                set qt5_pathlibspec path:lib/libQtCore.${qt_libs_ext}
292            }
293        }
294        set qt5_dependency ${qt5_pathlibspec}:qt5-kde
295        depends_lib-append ${qt5_dependency}
296    } elseif {${os.platform} eq "linux"} {
297        set qt5_pathlibspec path:libexec/${qt_name}/lib/libQt5Core.${qt_libs_ext}
298        set qt5_dependency ${qt5_pathlibspec}:qt5-kde
299        depends_lib-append ${qt5_dependency}
300    }
301}
302
303if {${os.platform} eq "darwin"} {
304    variant LTO description {Build with Link-Time Optimisation (LTO) (currently not 100% compatible with SSE4+ and 3DNow intrinsics)} {}
305} else {
306    variant LTO description {Build with Link-Time Optimisation (LTO) (experimental)} {}
307}
308
309if {![info exists building_qt5] && [variant_exists LTO] && [variant_isset LTO]} {
310    configure.cflags-append     -flto
311    configure.cxxflags-append   -flto
312    configure.objcflags-append  -flto
313    configure.objcxxflags-append  -flto
314    # ${configure.optflags} is a list, and that can lead to strange effects
315    # in certain situations if we don't treat it as such here.
316    foreach opt ${configure.optflags} {
317        configure.ldflags-append ${opt}
318    }
319    configure.ldflags-append    -flto
320    # assume any compiler not clang will be gcc
321    if {![string match "*clang*" ${configure.compiler}]} {
322        configure.cflags-append         -fuse-linker-plugin -ffat-lto-objects
323        configure.cxxflags-append       -fuse-linker-plugin -ffat-lto-objects
324        configure.objcflags-append      -fuse-linker-plugin -ffat-lto-objects
325        configure.objcxxflags-append    -fuse-linker-plugin -ffat-lto-objects
326        configure.ldflags-append        -fuse-linker-plugin
327    }
328}
329
330# standard configure environment, when not building qt5
331
332if {![info exists building_qt5]} {
333    configure.env-append \
334        QTDIR=${qt_dir} \
335        QMAKE=${qt_qmake_cmd} \
336        MOC=${qt_moc_cmd}
337
338    if { ![option universal_variant] || ![variant_isset universal] } {
339        configure.env-append QMAKESPEC=${qt_qmake_spec}
340    } else {
341        set merger_configure_env(i386)   "QMAKESPEC=${qt_qmake_spec_32}"
342        set merger_configure_env(x86_64) "QMAKESPEC=${qt_qmake_spec_64}"
343        set merger_arch_flag             yes
344        set merger_arch_compiler         yes
345    }
346
347    # make sure the Qt binaries' directory is in the path, if it is
348    # not the current prefix
349
350    if {${qt_dir} ne ${prefix}} {
351        configure.env-append PATH=${qt_dir}/bin:$env(PATH)
352    }
353} else {
354    configure.env-append QMAKE_NO_DEFAULTS=""
355}
356
357# standard build environment, when not building qt5
358
359if {![info exists building_qt5]} {
360    build.env-append \
361        QTDIR=${qt_dir} \
362        QMAKE=${qt_qmake_cmd} \
363        MOC=${qt_moc_cmd}
364
365    if { ![option universal_variant] || ![variant_isset universal] } {
366        build.env-append QMAKESPEC=${qt_qmake_spec}
367    } else {
368        set merger_build_env(i386)   "QMAKESPEC=${qt_qmake_spec_32}"
369        set merger_build_env(x86_64) "QMAKESPEC=${qt_qmake_spec_64}"
370        set merger_arch_flag             yes
371        set merger_arch_compiler         yes
372    }
373
374    # make sure the Qt binaries' directory is in the path, if it is
375    # not the current prefix
376
377    if {${qt_dir} ne ${prefix}} {
378        build.env-append    PATH=${qt_dir}/bin:$env(PATH)
379    }
380}
381
382# use PKGCONFIG for Qt discovery in configure scripts
383depends_build-append    port:pkgconfig
384
385# standard destroot environment
386if { ![option universal_variant] || ![variant_isset universal] } {
387    destroot.env-append \
388        INSTALL_ROOT=${destroot}
389} else {
390    foreach arch ${configure.universal_archs} {
391        lappend merger_destroot_env($arch) INSTALL_ROOT=${workpath}/destroot-${arch}
392    }
393}
394
395# standard destroot environment, when not building qt5
396
397if {![info exists building_qt5]} {
398    destroot.env-append \
399        QTDIR=${qt_dir} \
400        QMAKE=${qt_qmake_cmd} \
401        MOC=${qt_moc_cmd}
402
403    if { ![option universal_variant] || ![variant_isset universal] } {
404        build.env-append QMAKESPEC=${qt_qmake_spec}
405    } else {
406        set destroot_build_env(i386)   "QMAKESPEC=${qt_qmake_spec_32}"
407        set destroot_build_env(x86_64) "QMAKESPEC=${qt_qmake_spec_64}"
408    }
409
410    # make sure the Qt binaries' directory is in the path, if it is
411    # not the current prefix
412
413    if {${qt_dir} ne ${prefix}} {
414        destroot.env-append PATH=${qt_dir}/bin:$env(PATH)
415    }
416}
417
418# proc qt_branch {} {
419#     global version
420#     return [join [lrange [split ${version} .] 0 1] .]
421# }
422
423# provide a variant to prune provided translations
424PortGroup   locale_select 1.0
425# Qt translations don't go into ${prefix}/opt/local/share/locale:
426post-destroot {
427    if {![info exists keep_languages]} {
428        if {[file exists ${prefix}/etc/macports/locales.tcl] && [file exists ${destroot}${qt_translations_dir}]} {
429            if {[catch {source "${prefix}/etc/macports/locales.tcl"} err]} {
430                ui_error "Error reading ${prefix}/etc/macports/locales.tcl: $err"
431                return -code error "Error reading ${prefix}/etc/macports/locales.tcl"
432            }
433        }
434    }
435    if {[info exists keep_languages]} {
436        foreach l [glob -nocomplain ${destroot}${qt_translations_dir}/*.qm] {
437            set langcomps [split [file rootname [file tail ${l}]] _]
438            set simplelang [lindex ${langcomps} end]
439            set complang [join [lrange ${langcomps} end-1 end] _]
440            if {[lsearch -exact ${keep_languages} ${simplelang}] ne "-1"} {
441                ui_debug "won't delete ${l} (${simplelang})"
442            } elseif {[lsearch -exact ${keep_languages} ${complang}] ne "-1"} {
443                ui_debug "won't delete ${l} (${complang})"
444            } else {
445                ui_debug "rm ${l}"
446                file delete -force ${l}
447            }
448        }
449    }
450}