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

Diff of /eclass/qt4-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.28 Revision 1.29
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 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/qt4-r2.eclass,v 1.28 2013/06/03 08:41:19 pesa Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.29 2013/12/21 20:11:55 pesa Exp $
4 4
5# @ECLASS: qt4-r2.eclass 5# @ECLASS: qt4-r2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Qt herd <qt@gentoo.org> 7# Qt herd <qt@gentoo.org>
8# @BLURB: Eclass for Qt4-based packages, second edition. 8# @BLURB: Eclass for Qt4-based packages, second edition.
13case ${EAPI} in 13case ${EAPI} in
14 2|3|4|5) : ;; 14 2|3|4|5) : ;;
15 *) die "qt4-r2.eclass: unsupported EAPI=${EAPI:-0}" ;; 15 *) die "qt4-r2.eclass: unsupported EAPI=${EAPI:-0}" ;;
16esac 16esac
17 17
18inherit base eutils multilib toolchain-funcs 18inherit base qmake-utils
19 19
20export XDG_CONFIG_HOME="${T}" 20export XDG_CONFIG_HOME="${T}"
21 21
22# @ECLASS-VARIABLE: DOCS 22# @ECLASS-VARIABLE: DOCS
23# @DEFAULT_UNSET 23# @DEFAULT_UNSET
102# Default src_configure function for packages that depend on qt4. If you have to 102# Default src_configure function for packages that depend on qt4. If you have to
103# override src_configure in your ebuild, call qt4-r2_src_configure in it. 103# override src_configure in your ebuild, call qt4-r2_src_configure in it.
104qt4-r2_src_configure() { 104qt4-r2_src_configure() {
105 debug-print-function $FUNCNAME "$@" 105 debug-print-function $FUNCNAME "$@"
106 106
107 local project_file=$(_find_project_file) 107 local project_file=$(qmake-utils_find_pro_file)
108 108
109 if [[ -n ${project_file} ]]; then 109 if [[ -n ${project_file} ]]; then
110 eqmake4 "${project_file}" 110 eqmake4 "${project_file}"
111 else 111 else
112 base_src_configure "$@" 112 base_src_configure "$@"
140 if [[ -n ${HTML_DOCS} ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then 140 if [[ -n ${HTML_DOCS} ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
141 dohtml -r ${HTML_DOCS} || die "dohtml failed" 141 dohtml -r ${HTML_DOCS} || die "dohtml failed"
142 fi 142 fi
143} 143}
144 144
145# @VARIABLE: EQMAKE4_EXCLUDE
146# @DEFAULT_UNSET
147# @DESCRIPTION:
148# List of files to be excluded from eqmake4 CONFIG processing.
149# Paths are relative to the current working directory (usually ${S}).
150#
151# Example: EQMAKE4_EXCLUDE="ignore/me.pro foo/*"
152
153# @FUNCTION: eqmake4
154# @USAGE: [project_file] [parameters to qmake]
155# @DESCRIPTION:
156# Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will
157# look for it in the current directory (${S}, non-recursively). If more
158# than one project file are found, then ${PN}.pro is processed, provided
159# that it exists. Otherwise eqmake4 fails.
160#
161# All other arguments are appended unmodified to qmake command line.
162#
163# For recursive build systems, i.e. those based on the subdirs template,
164# you should run eqmake4 on the top-level project file only, unless you
165# have a valid reason to do otherwise. During the building, qmake will
166# be automatically re-invoked with the right arguments on every directory
167# specified inside the top-level project file.
168eqmake4() {
169 debug-print-function ${FUNCNAME} "$@"
170
171 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
172
173 ebegin "Running qmake"
174
175 local qmake_args=("$@")
176
177 # check if project file was passed as a first argument
178 # if not, then search for it
179 local regexp='.*\.pro'
180 if ! [[ ${1} =~ ${regexp} ]]; then
181 local project_file=$(_find_project_file)
182 if [[ -z ${project_file} ]]; then
183 echo
184 eerror "No project files found in '${PWD}'!"
185 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
186 echo
187 die "eqmake4 failed"
188 fi
189 qmake_args+=("${project_file}")
190 fi
191
192 # make sure CONFIG variable is correctly set
193 # for both release and debug builds
194 local config_add="release"
195 local config_remove="debug"
196 if has debug ${IUSE} && use debug; then
197 config_add="debug"
198 config_remove="release"
199 fi
200
201 local awkscript='BEGIN {
202 printf "### eqmake4 was here ###\n" > file;
203 printf "CONFIG -= debug_and_release %s\n", remove >> file;
204 printf "CONFIG += %s\n\n", add >> file;
205 fixed=0;
206 }
207 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
208 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
209 fixed=1;
210 }
211 }
212 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
213 if (gsub("\\<" add "\\>", "") > 0) {
214 fixed=1;
215 }
216 }
217 {
218 print >> file;
219 }
220 END {
221 print fixed;
222 }'
223
224 [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_push -o noglob
225
226 local file
227 while read file; do
228 local excl
229 for excl in ${EQMAKE4_EXCLUDE}; do
230 [[ ${file} == ${excl} ]] && continue 2
231 done
232 grep -q '^### eqmake4 was here ###$' "${file}" && continue
233
234 local retval=$({
235 rm -f "${file}" || echo FAIL
236 awk -v file="${file}" \
237 -v add=${config_add} \
238 -v remove=${config_remove} \
239 -- "${awkscript}" || echo FAIL
240 } < "${file}")
241
242 if [[ ${retval} == 1 ]]; then
243 einfo " - fixed CONFIG in ${file}"
244 elif [[ ${retval} != 0 ]]; then
245 eerror " - error while processing ${file}"
246 die "eqmake4 failed to process ${file}"
247 fi
248 done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null)
249
250 [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_pop
251
252 "${EPREFIX}"/usr/bin/qmake \
253 -makefile \
254 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
255 QMAKE="${EPREFIX}"/usr/bin/qmake \
256 QMAKE_AR="$(tc-getAR) cqs" \
257 QMAKE_CC="$(tc-getCC)" \
258 QMAKE_CXX="$(tc-getCXX)" \
259 QMAKE_LINK="$(tc-getCXX)" \
260 QMAKE_LINK_C="$(tc-getCC)" \
261 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
262 QMAKE_RANLIB= \
263 QMAKE_STRIP= \
264 QMAKE_CFLAGS="${CFLAGS}" \
265 QMAKE_CFLAGS_RELEASE= \
266 QMAKE_CFLAGS_DEBUG= \
267 QMAKE_CXXFLAGS="${CXXFLAGS}" \
268 QMAKE_CXXFLAGS_RELEASE= \
269 QMAKE_CXXFLAGS_DEBUG= \
270 QMAKE_LFLAGS="${LDFLAGS}" \
271 QMAKE_LFLAGS_RELEASE= \
272 QMAKE_LFLAGS_DEBUG= \
273 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \
274 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \
275 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \
276 "${qmake_args[@]}"
277
278 # was qmake successful?
279 if ! eend $? ; then
280 echo
281 eerror "Running qmake has failed! (see above for details)"
282 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
283 echo
284 die "eqmake4 failed"
285 fi
286}
287
288# Internal function, used by eqmake4 and qt4-r2_src_configure.
289# Outputs a project file name that can be passed to eqmake4. Sets nullglob
290# locally to avoid expanding *.pro as "*.pro" when there are no matching files.
291# 0 *.pro files found --> outputs null string
292# 1 *.pro file found --> outputs its name
293# 2 or more *.pro files found --> if ${PN}.pro or $(basename ${S}).pro
294# are there, outputs any of them
295_find_project_file() {
296 local dir_name=$(basename "${S}")
297
298 eshopts_push -s nullglob
299 local pro_files=(*.pro)
300 eshopts_pop
301
302 case ${#pro_files[@]} in
303 1)
304 echo "${pro_files[0]}"
305 ;;
306 *)
307 for pro_file in "${pro_files[@]}"; do
308 if [[ ${pro_file} == "${dir_name}.pro" || ${pro_file} == "${PN}.pro" ]]; then
309 echo "${pro_file}"
310 break
311 fi
312 done
313 ;;
314 esac
315}
316
317EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install 145EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

  ViewVC Help
Powered by ViewVC 1.1.20