Ticket #46238: qt4-1.0.tcl

File qt4-1.0.tcl, 10.4 KB (added by RJVB (René Bertin), 9 years ago)

minor corrections

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# $Id: qt4-1.0.tcl 124176 2014-08-20 07:57:31Z ryandesign@macports.org $
3
4# Copyright (c) 2010-2014 The MacPorts Project
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are
9# met:
10#
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16# 3. Neither the name of Apple Computer, Inc. nor the names of its
17#    contributors may be used to endorse or promote products derived from
18#    this software without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31#
32#
33# This portgroup defines standard settings when using Qt4.
34#
35# Usage:
36# PortGroup     qt4 1.0
37
38# check for +debug variant of this port, and make sure Qt was
39# installed with +debug as well; if not, error out.
40platform darwin {
41    pre-extract {
42        if {[variant_exists debug] && \
43            [variant_isset debug] && \
44           ![info exists building_qt4]} {
45            if {![file exists ${qt_frameworks_dir}/QtCore.framework/QtCore_debug]} {
46                return -code error "\n\nERROR:\n\
47In order to install this port as +debug,
48Qt4 must also be installed with +debug.\n"
49            }
50        }
51    }
52}
53
54if {[info exists name] && ${subport} ne "${name}-transitional"} {
55    # exclusive mode doesn't make sense for the transitional subport ...
56    variant exclusive description {Builds and installs Qt4-mac the older way, such that other Qt versions can NOT be installed alongside it} {}
57}
58
59# standard Qt4 name
60global qt_name
61set qt_name             qt4
62
63# standard install directory
64    global qt_dir
65    global qt_dir_rel
66# standard Qt documents directory
67    global qt_docs_dir
68# standard Qt plugins directory
69    global qt_plugins_dir
70# standard Qt mkspecs directory
71    global qt_mkspecs_dir
72# standard Qt imports directory
73    global qt_imports_dir
74# standard Qt includes directory
75    global qt_includes_dir
76# standard Qt libraries directory
77    global qt_libs_dir
78# standard Qt libraries directory
79    global qt_frameworks_dir
80    global qt_frameworks_dir_rel
81# standard Qt non-.app executables directory
82    global qt_bins_dir
83# standard Qt data directory
84    global qt_data_dir
85# standard Qt translations directory
86    global qt_translations_dir
87# standard Qt sysconf directory
88    global qt_sysconf_dir
89# standard Qt examples directory
90    global qt_examples_dir
91# standard Qt demos directory
92    global qt_demos_dir
93# standard CMake module directory for Qt-related files
94    global qt_cmake_module_dir
95# standard qmake command location
96    global qt_qmake_cmd
97# standard moc command location
98    global qt_moc_cmd
99# standard uic command location
100    global qt_uic_cmd
101# standard lrelease command location
102    global qt_lrelease_cmd
103
104global qt4_is_concurrent
105if {![variant_isset exclusive]} {
106    if {![info exists building_qt4] || ![info exists name] || ${name} ne "qt4-mac" || ${subport} eq "${name}-transitional"} {
107        #exec ls -l ${prefix}/libexec/${qt_name}/bin/qmake
108        if {[file exists ${prefix}/libexec/${qt_name}/bin/qmake]} {
109            # we have a "concurrent" install, which means we must look for the various components
110            # in different locations (esp. qmake)
111            set qt4_is_concurrent   1
112            set auto_concurrent 1
113        }
114    } else {
115        if {![info exists qt4_is_concurrent]} {
116            ui_msg "NB:\nQt4 has been or will be installed in concurrent mode\n"
117        }
118        # we're asking for the standard concurrent install. No need to guess anything, give the user what s/he wants
119        set qt4_is_concurrent   1
120        set auto_concurrent     1
121    }
122}
123
124if {[info exists qt4_is_concurrent]} {
125    set qt_dir              ${prefix}/libexec/${qt_name}
126    set qt_dir_rel          libexec/${qt_name}
127    set qt_docs_dir         ${prefix}/share/doc/${qt_name}
128    set qt_plugins_dir      ${prefix}/share/${qt_name}/plugins
129    set qt_mkspecs_dir      ${prefix}/share/${qt_name}/mkspecs
130    set qt_imports_dir      ${prefix}/share/${qt_name}/imports
131    set qt_includes_dir     ${prefix}/include/${qt_name}
132    set qt_libs_dir         ${qt_dir}/lib
133    set qt_frameworks_dir   ${qt_dir}/Library/Frameworks
134    set qt_bins_dir         ${qt_dir}/bin
135    set qt_data_dir         ${prefix}/share/${qt_name}
136    set qt_translations_dir ${prefix}/share/${qt_name}/translations
137    set qt_sysconf_dir      ${prefix}/etc/${qt_name}
138    set qt_examples_dir     ${prefix}/share/${qt_name}/examples
139    set qt_demos_dir        ${prefix}/share/${qt_name}/demos
140    # no need to change the cmake_module_dir, though I'd have preferred to
141    # put it into ${prefix}/lib/cmake as qt5-mac also does, and which is the place Linux uses
142    set qt_cmake_module_dir ${prefix}/share/cmake/Modules
143    set qt_qmake_cmd        ${qt_dir}/bin/qmake
144    set qt_moc_cmd          ${qt_dir}/bin/moc
145    set qt_uic_cmd          ${qt_dir}/bin/uic
146    set qt_lrelease_cmd     ${qt_dir}/bin/lrelease
147} else {
148    set qt_dir              ${prefix}
149    set qt_dir_rel          ""
150    set qt_docs_dir         ${qt_dir}/share/doc/${qt_name}
151    set qt_plugins_dir      ${qt_dir}/share/${qt_name}/plugins
152    set qt_mkspecs_dir      ${qt_dir}/share/${qt_name}/mkspecs
153    set qt_imports_dir      ${qt_dir}/share/${qt_name}/imports
154    set qt_includes_dir     ${qt_dir}/include
155    set qt_libs_dir         ${qt_dir}/lib
156    set qt_frameworks_dir   ${qt_dir}/Library/Frameworks
157    set qt_bins_dir         ${qt_dir}/bin
158    set qt_data_dir         ${qt_dir}/share/${qt_name}
159    set qt_translations_dir ${qt_dir}/share/${qt_name}/translations
160    set qt_sysconf_dir      ${qt_dir}/etc/${qt_name}
161    set qt_examples_dir     ${qt_dir}/share/${qt_name}/examples
162    set qt_demos_dir        ${qt_dir}/share/${qt_name}/demos
163    set qt_cmake_module_dir ${qt_dir}/share/cmake/Modules
164    set qt_qmake_cmd        ${qt_dir}/bin/qmake
165    set qt_moc_cmd          ${qt_dir}/bin/moc
166    set qt_uic_cmd          ${qt_dir}/bin/uic
167    set qt_lrelease_cmd     ${qt_dir}/bin/lrelease
168}
169set qt_frameworks_dir_rel   ${qt_dir_rel}/Library/Frameworks
170
171# standard Qt .app executables directory, if created
172global qt_apps_dir
173set qt_apps_dir         ${applications_dir}/Qt4
174
175# standard qmake spec
176global qt_qmake_spec
177set qt_qmake_spec       macx-g++
178
179# standard PKGCONFIG path
180global qt_pkg_config_dir
181set qt_pkg_config_dir   ${prefix}/lib/pkgconfig
182
183# standard cmake info for Qt4
184global qt_cmake_defines
185set qt_cmake_defines    \
186    "-DQT_QT_INCLUDE_DIR=${qt_includes_dir} \
187     -DQT_QMAKESPEC=${qt_qmake_spec} \
188     -DQT_ZLIB_LIBRARY=${prefix}/lib/libz.dylib \
189     -DQT_PNG_LIBRARY=${prefix}/lib/libpng.dylib"
190
191# set Qt understood arch types, based on user preference
192options qt_arch_types
193default qt_arch_types {[string map {i386 x86} [get_canonical_archs]]}
194
195# allow for depending on either qt4-mac and qt4-mac-devel, simultaneously
196
197if {![info exists building_qt4]} {
198    if {${os.platform} eq "darwin"} {
199
200        # see if the framework install exists, and if so depend on it;
201        # if not, depend on the library version
202
203        if {[info exists qt4_is_concurrent]} {
204            if {[file exists ${qt_frameworks_dir}/QtCore/QtCore]} {
205                depends_lib-append path:libexec/${qt_name}/Library/Frameworks/QtCore/QtCore:qt4-mac
206            } else {
207                depends_lib-append path:libexec/${qt_name}/lib/libQtCore.4.dylib:qt4-mac
208            }
209        } else {
210            if {[file exists ${qt_frameworks_dir}/QtCore/QtCore]} {
211                depends_lib-append path:Library/Frameworks/QtCore/QtCore:qt4-mac
212            } else {
213                depends_lib-append path:lib/libQtCore.4.dylib:qt4-mac
214            }
215        }
216
217    } else {
218        depends_lib-append      path:lib/libQtCore.so.4:qt4-x11
219    }
220}
221
222# standard configure environment, when not building qt4
223
224if {![info exists building_qt4]} {
225    configure.env-append \
226        QTDIR=${qt_dir} \
227        QMAKE=${qt_qmake_cmd} \
228        QMAKESPEC=${qt_qmake_spec} \
229        MOC=${qt_moc_cmd}
230
231    # make sure the Qt binaries' directory is in the path, if it is
232    # not the current prefix
233
234    if {${qt_dir} ne ${prefix}} {
235        configure.env-append PATH=${qt_dir}/bin:$env(PATH)
236    }
237} else {
238    configure.env-append QMAKE_NO_DEFAULTS=""
239}
240
241# standard build environment, when not building qt4
242
243if {![info exists building_qt4]} {
244    build.env-append \
245        QTDIR=${qt_dir} \
246        QMAKE=${qt_qmake_cmd} \
247        QMAKESPEC=${qt_qmake_spec} \
248        MOC=${qt_moc_cmd}
249
250    # make sure the Qt binaries' directory is in the path, if it is
251    # not the current prefix
252
253    if {${qt_dir} ne ${prefix}} {
254        build.env-append    PATH=${qt_dir}/bin:$env(PATH)
255    }
256} else {
257    build.env-append QMAKE_NO_DEFAULTS=""
258}
259
260# use PKGCONFIG for Qt discovery in configure scripts
261depends_build-append    port:pkgconfig
262
263# standard destroot environment
264
265destroot.env-append \
266    INSTALL_ROOT=${destroot} \
267    DESTDIR=${destroot}
268
269# standard destroot environment, when not building qt4
270
271if {![info exists building_qt4]} {
272    destroot.env-append \
273        QTDIR=${qt_dir} \
274        QMAKE=${qt_qmake_cmd} \
275        QMAKESPEC=${qt_qmake_spec} \
276        MOC=${qt_moc_cmd}
277
278    # make sure the Qt binaries' directory is in the path, if it is
279    # not the current prefix
280
281    if {${qt_dir} ne ${prefix}} {
282        destroot.env-append PATH=${qt_dir}/bin:$env(PATH)
283    }
284} else {
285    destroot.env-append QMAKE_NO_DEFAULTS=""
286}