/[gentoo-x86]/eclass/qt4.eclass
Gentoo

Contents of /eclass/qt4.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.41 - (hide annotations) (download)
Sat Jun 21 15:12:48 2008 UTC (5 years, 9 months ago) by swegener
Branch: MAIN
Changes since 1.40: +3 -3 lines
don't use command substitution, like all good boys do

1 caleb 1.1 # Copyright 2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 swegener 1.41 # $Header: /var/cvsroot/gentoo-x86/eclass/qt4.eclass,v 1.40 2008/05/15 17:28:59 ingmar Exp $
4 troll 1.29
5     # @ECLASS: qt4.eclass
6     # @MAINTAINER:
7     # Caleb Tennis <caleb@gentoo.org>
8 ingmar 1.38 # @BLURB: Eclass for Qt4 packages
9 troll 1.29 # @DESCRIPTION:
10     # This eclass contains various functions that may be useful
11     # when dealing with packages using Qt4 libraries.
12    
13 caleb 1.4 # 08.16.06 - Renamed qt_min_* to qt4_min_* to avoid conflicts with the qt3 eclass.
14     # - Caleb Tennis <caleb@gentoo.org>
15 caleb 1.1
16 caleb 1.20 inherit eutils multilib toolchain-funcs versionator
17 caleb 1.1
18     QTPKG="x11-libs/qt-"
19 caleb 1.30 QT4MAJORVERSIONS="4.4 4.3 4.2 4.1 4.0"
20 ingmar 1.40 QT4VERSIONS="4.4.0 4.4.0_beta1 4.4.0_rc1 4.3.4-r1 4.3.4 4.3.3 4.3.2-r1 4.3.2 4.3.1-r1 4.3.1 4.3.0-r2 4.3.0-r1 4.3.0 4.3.0_rc1 4.3.0_beta1 4.2.3-r1 4.2.3 4.2.2 4.2.1 4.2.0-r2 4.2.0-r1 4.2.0 4.1.4-r2 4.1.4-r1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.0.1 4.0.0"
21 caleb 1.1
22 troll 1.29 # @FUNCTION: qt4_min_version
23     # @USAGE: [minimum version]
24     # @DESCRIPTION:
25     # This function should be called in package DEPENDs whenever it depends on qt4.
26     # Simple example - in your depend, do something like this:
27     # DEPEND="$(qt4_min_version 4.2)"
28 ingmar 1.37 # if the package can be build with qt-4.2 or higher.
29     #
30     # For builds that use an EAPI with support for SLOT dependencies, this will
31     # return a SLOT dependency, rather than a list of versions.
32 caleb 1.4 qt4_min_version() {
33 ingmar 1.37 case ${EAPI:-0} in
34     # EAPIs without SLOT dependencies
35     0) echo "|| ("
36     qt4_min_version_list "$@"
37     echo ")"
38     ;;
39     # EAPIS with SLOT dependencies.
40     *) echo ">=${QTPKG}${1}:4"
41     ;;
42     esac
43 caleb 1.1 }
44    
45 caleb 1.4 qt4_min_version_list() {
46 caleb 1.1 local MINVER="$1"
47     local VERSIONS=""
48    
49     case "${MINVER}" in
50     4|4.0|4.0.0) VERSIONS="=${QTPKG}4*";;
51 caleb 1.30 4.1|4.1.0|4.2|4.2.0|4.3|4.3.0|4.4|4.4.0)
52 caleb 1.1 for x in ${QT4MAJORVERSIONS}; do
53 swegener 1.41 if version_is_at_least "${MINVER}" "${x}"; then
54 caleb 1.1 VERSIONS="${VERSIONS} =${QTPKG}${x}*"
55     fi
56     done
57     ;;
58     4*)
59     for x in ${QT4VERSIONS}; do
60 swegener 1.41 if version_is_at_least "${MINVER}" "${x}"; then
61 caleb 1.1 VERSIONS="${VERSIONS} =${QTPKG}${x}"
62     fi
63     done
64     ;;
65     *) VERSIONS="=${QTPKG}4*";;
66     esac
67    
68     echo "${VERSIONS}"
69     }
70 caleb 1.16
71 troll 1.29 # @FUNCTION: qt4_pkg_setup
72     # @MAINTAINER:
73     # Caleb Tennis <caleb@gentoo.org>
74     # Przemyslaw Maciag <troll@gentoo.org>
75     # @DESCRIPTION:
76     # Default pkg_setup function for packages that depends on qt4. If you have to
77     # create ebuilds own pkg_setup in your ebuild, call qt4_pkg_setup in it.
78     # This function uses two global vars from ebuild:
79     # - QT4_BUILT_WITH_USE_CHECK - contains use flags that need to be turned on for
80     # =x11-libs/qt-4*
81     # - QT4_OPTIONAL_BUILT_WITH_USE_CHECK - qt4 flags that provides some
82     # functionality, but can alternatively be disabled in ${CATEGORY}/${PN}
83     # (so qt4 don't have to be recompiled)
84 caleb 1.31 #
85     # flags to watch for for Qt4.4:
86     # zlib png | opengl dbus qt3support | sqlite3 ssl
87 caleb 1.16 qt4_pkg_setup() {
88 caleb 1.31
89     QT4_BEST_VERSION="$(best_version =x11-libs/qt-4*)"
90     QT4_MINOR_VERSION="$(get_version_component_range 2 ${QT4_BEST_VERSION/*qt-/})"
91    
92 troll 1.29 local requiredflags=""
93 caleb 1.20 for x in ${QT4_BUILT_WITH_USE_CHECK}; do
94 caleb 1.31 if [[ "${QT4_MINOR_VERSION}" -ge 4 ]]; then
95     # The use flags are different in 4.4 and above, and it's a split package, so this is used to catch
96     # the various use flag combos specified in the ebuilds to make sure we don't error out.
97    
98     if [[ ${x} == zlib || ${x} == png ]]; then
99     # Qt 4.4+ is built with zlib and png by default, so the use flags aren't needed
100     continue;
101     elif [[ ${x} == opengl || ${x} == dbus || ${x} == qt3support ]]; then
102     # Make sure the qt-${x} package has been already installed
103    
104     if ! has_version x11-libs/qt-${x}; then
105     eerror "You must first install the x11-libs/qt-${x} package."
106 caleb 1.32 die "Install x11-libs/qt-${x}"
107 caleb 1.31 fi
108 caleb 1.32 elif [[ ${x} == ssl ]]; then
109     if ! has_version x11-libs/qt-core || ! built_with_use x11-libs/qt-core ssl; then
110 caleb 1.31 eerror "You must first install the x11-libs/qt-core package with the ssl flag enabled."
111 caleb 1.34 die "Install x11-libs/qt-core with USE=\"ssl\""
112 caleb 1.31 fi
113 caleb 1.32 elif [[ ${x} == sqlite3 ]]; then
114     if ! has_version x11-libs/qt-sql || ! built_with_use x11-libs/qt-sql sqlite; then
115 caleb 1.31 eerror "You must first install the x11-libs/qt-sql package with the sqlite flag enabled."
116 swegener 1.33 die "Install x11-libs/qt-sql with USE=\"sqlite\""
117 caleb 1.31 fi
118     fi
119     elif ! built_with_use =x11-libs/qt-4* ${x}; then
120 troll 1.29 requiredflags="${requiredflags} ${x}"
121     fi
122     done
123    
124     local optionalflags=""
125     for x in ${QT4_OPTIONAL_BUILT_WITH_USE_CHECK}; do
126     if use ${x} && ! built_with_use =x11-libs/qt-4* ${x}; then
127     optionalflags="${optionalflags} ${x}"
128 caleb 1.16 fi
129     done
130 troll 1.29
131     local diemessage=""
132     if [[ ${requiredflags} != "" ]]; then
133     eerror
134     eerror "(1) In order to compile ${CATEGORY}/${PN} first you need to build"
135     eerror "=x11-libs/qt-4* with USE=\"${requiredflags}\" flag(s)"
136     eerror
137     diemessage="(1) recompile qt4 with \"${requiredflags}\" USE flag(s) ; "
138     fi
139     if [[ ${optionalflags} != "" ]]; then
140     eerror
141     eerror "(2) You are trying to compile ${CATEGORY}/${PN} package with"
142     eerror "USE=\"${optionalflags}\""
143     eerror "while qt4 is built without this particular flag(s): it will"
144     eerror "not work."
145     eerror
146     eerror "Possible solutions to this problem are:"
147     eerror "a) install package ${CATEGORY}/${PN} without \"${optionalflags}\" USE flag(s)"
148     eerror "b) re-emerge qt4 with \"${optionalflags}\" USE flag(s)"
149     eerror
150     diemessage="${diemessage}(2) recompile qt4 with \"${optionalflags}\" USE flag(s) or disable them for ${PN} package\n"
151     fi
152    
153     [[ ${diemessage} != "" ]] && die "can't emerge ${CATEGORY}/${PN}: ${diemessage}"
154 caleb 1.16 }
155 caleb 1.20
156 troll 1.29 # @FUNCTION: eqmake4
157     # @USAGE: [.pro file] [additional parameters to qmake]
158     # @MAINTAINER:
159     # Przemyslaw Maciag <troll@gentoo.org>
160     # Davide Pesavento <davidepesa@gmail.com>
161     # @DESCRIPTION:
162     # Runs qmake on the specified .pro file (defaults to
163     # ${PN}.pro if eqmake4 was called with no argument).
164     # Additional parameters are passed unmodified to qmake.
165 caleb 1.20 eqmake4() {
166     local LOGFILE="${T}/qmake-$$.out"
167     local projprofile="${1}"
168 troll 1.29 [[ -z ${projprofile} ]] && projprofile="${PN}.pro"
169 caleb 1.20 shift 1
170    
171     ebegin "Processing qmake ${projprofile}"
172    
173     # file exists?
174 troll 1.29 if [[ ! -f ${projprofile} ]]; then
175 caleb 1.20 echo
176     eerror "Project .pro file \"${projprofile}\" does not exists"
177     eerror "qmake cannot handle non-existing .pro files"
178     echo
179     eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org"
180     echo
181     die "Project file not found in ${PN} sources"
182     fi
183    
184     echo >> ${LOGFILE}
185     echo "****** qmake ${projprofile} ******" >> ${LOGFILE}
186     echo >> ${LOGFILE}
187    
188     # as a workaround for broken qmake, put everything into file
189 caleb 1.22 if has debug ${IUSE} && use debug; then
190 troll 1.29 echo -e "\nCONFIG -= release\nCONFIG += no_fixpath debug" >> ${projprofile}
191 caleb 1.20 else
192 troll 1.29 echo -e "\nCONFIG -= debug\nCONFIG += no_fixpath release" >> ${projprofile}
193 caleb 1.20 fi
194    
195     /usr/bin/qmake ${projprofile} \
196     QTDIR=/usr/$(get_libdir) \
197     QMAKE=/usr/bin/qmake \
198     QMAKE_CC=$(tc-getCC) \
199     QMAKE_CXX=$(tc-getCXX) \
200     QMAKE_LINK=$(tc-getCXX) \
201     QMAKE_CFLAGS_RELEASE="${CFLAGS}" \
202     QMAKE_CFLAGS_DEBUG="${CFLAGS}" \
203     QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \
204     QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \
205     QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \
206     QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \
207     QMAKE_RPATH= \
208 flameeyes 1.36 "${@}" >> ${LOGFILE} 2>&1
209 caleb 1.20
210     local result=$?
211     eend ${result}
212    
213     # was qmake successful?
214 troll 1.29 if [[ ${result} -ne 0 ]]; then
215 caleb 1.20 echo
216     eerror "Running qmake on \"${projprofile}\" has failed"
217     echo
218     eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org"
219     echo
220     die "qmake failed on ${projprofile}"
221     fi
222    
223     return ${result}
224     }
225    
226     EXPORT_FUNCTIONS pkg_setup

  ViewVC Help
Powered by ViewVC 1.1.20