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