/[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.11 Revision 1.18
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2012 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.11 2011/03/19 16:34:39 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.18 2012/02/13 00:53:28 pesa Exp $
4 4
5# @ECLASS: qt4-r2.eclass 5# @ECLASS: qt4-r2.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ben de Groot <yngwin@gentoo.org>, 7# Qt herd <qt@gentoo.org>
8# Markos Chandras <hwoarang@gentoo.org>,
9# Davide Pesavento <davidepesa@gmail.com>,
10# Dominik Kapusta <ayoy@gentoo.org>
11# @BLURB: Eclass for Qt4 packages, second edition 8# @BLURB: Eclass for Qt4-based packages, second edition.
12# @DESCRIPTION: 9# @DESCRIPTION:
13# This eclass contains various functions that may be useful when 10# This eclass contains various functions that may be useful when
14# dealing with packages using Qt4 libraries. Requires EAPI=2. 11# dealing with packages using Qt4 libraries. Requires EAPI=2 or later.
15 12
16case ${EAPI} in 13case ${EAPI} in
17 2|3|4) : ;; 14 2|3|4) : ;;
18 *) die "EAPI=${EAPI} is not supported" ;; 15 *) die "EAPI=${EAPI} is not supported by ${ECLASS} eclass." ;;
19esac 16esac
20 17
21inherit base eutils multilib toolchain-funcs 18inherit base eutils multilib toolchain-funcs
22 19
23export XDG_CONFIG_HOME="${T}" 20export XDG_CONFIG_HOME="${T}"
24 21
25# @ECLASS-VARIABLE: LANGS 22# @ECLASS-VARIABLE: LANGS
23# @DEFAULT_UNSET
26# @DESCRIPTION: 24# @DESCRIPTION:
27# In case your Qt4 application provides various translations, use this variable 25# In case your Qt4 application provides various translations, use this variable
28# to specify them in order to populate "linguas_*" IUSE automatically. Make sure 26# to specify them in order to populate "linguas_*" IUSE automatically. Make sure
29# that you set this variable BEFORE inheriting qt4-r2 eclass. 27# that you set this variable before inheriting qt4-r2 eclass.
28# Example:
29# @CODE
30# example: LANGS="en el de" 30# LANGS="en el de"
31# @CODE
31for x in ${LANGS}; do 32for x in ${LANGS}; do
32 IUSE="${IUSE} linguas_${x}" 33 IUSE="${IUSE} linguas_${x}"
33done 34done
34 35
35# @ECLASS-VARIABLE: LANGSLONG 36# @ECLASS-VARIABLE: LANGSLONG
37# @DEFAULT_UNSET
36# @DESCRIPTION: 38# @DESCRIPTION:
37# Same as above, but this variable is for LINGUAS that must be in long format. 39# Same as above, but this variable is for LINGUAS that must be in long format.
38# Remember to set this variable BEFORE inheriting qt4-r2 eclass. 40# Remember to set this variable before inheriting qt4-r2 eclass.
39# Look at ${PORTDIR}/profiles/desc/linguas.desc for details. 41# Look at ${PORTDIR}/profiles/desc/linguas.desc for details.
40for x in ${LANGSLONG}; do 42for x in ${LANGSLONG}; do
41 IUSE="${IUSE} linguas_${x%_*}" 43 IUSE="${IUSE} linguas_${x%_*}"
42done 44done
43 45
46# Default src_unpack function for packages that depend on qt4. If you have to 48# Default src_unpack function for packages that depend on qt4. If you have to
47# override src_unpack in your ebuild (probably you don't need to), call 49# override src_unpack in your ebuild (probably you don't need to), call
48# qt4-r2_src_unpack in it. 50# qt4-r2_src_unpack in it.
49qt4-r2_src_unpack() { 51qt4-r2_src_unpack() {
50 debug-print-function $FUNCNAME "$@" 52 debug-print-function $FUNCNAME "$@"
53
51 base_src_unpack "$@" 54 base_src_unpack "$@"
52
53 # Fallback to ${WORKDIR}/${MY_P} when ${WORKDIR}/${P} doesn't exist.
54 # Feel free to re-implement this
55 if [[ "${S}" == "${WORKDIR}/${P}" && ! -d ${S} && -d ${WORKDIR}/${MY_P} ]]; then
56 ewarn "Falling back to '${WORKDIR}/${MY_P}'"
57 S="${WORKDIR}/${MY_P}"
58 fi
59} 55}
60 56
61# @ECLASS-VARIABLE: PATCHES 57# @ECLASS-VARIABLE: PATCHES
58# @DEFAULT_UNSET
62# @DESCRIPTION: 59# @DESCRIPTION:
63# In case you have patches to apply, specify them in PATCHES variable. Make sure 60# In case you have patches to apply, specify them here. Make sure to
64# to specify the full path. This variable is used in src_prepare phase. 61# specify the full path. This variable is used in src_prepare phase.
65# example: 62# Example:
63# @CODE
66# PATCHES=( "${FILESDIR}"/mypatch.patch 64# PATCHES=( "${FILESDIR}"/mypatch.patch
67# "${FILESDIR}"/mypatch2.patch ) 65# "${FILESDIR}"/mypatch2.patch )
68# 66# @CODE
67
69# @FUNCTION: qt4-r2_src_prepare 68# @FUNCTION: qt4-r2_src_prepare
70# @DESCRIPTION: 69# @DESCRIPTION:
71# Default src_prepare function for packages that depend on qt4. If you have to 70# Default src_prepare function for packages that depend on qt4. If you have to
72# override src_prepare in your ebuild, you should call qt4-r2_src_prepare in it, 71# override src_prepare in your ebuild, you should call qt4-r2_src_prepare in it,
73# otherwise autopatcher will not work! 72# otherwise autopatcher will not work!
103 102
104 base_src_compile "$@" 103 base_src_compile "$@"
105} 104}
106 105
107# @ECLASS-VARIABLE: DOCS 106# @ECLASS-VARIABLE: DOCS
107# @DEFAULT_UNSET
108# @DESCRIPTION: 108# @DESCRIPTION:
109# Use this variable if you want to install any documentation. 109# Use this variable if you want to install any documentation.
110# Example:
111# @CODE
110# example: DOCS="README AUTHORS" 112# DOCS="README AUTHORS"
111# 113# @CODE
114
112# @ECLASS-VARIABLE: DOCSDIR 115# @ECLASS-VARIABLE: DOCSDIR
113# @DESCRIPTION: 116# @DESCRIPTION:
114# Directory containing documentation. If not specified, ${S} will be used 117# Directory containing documentation, defaults to ${S}.
115# instead. 118
116#
117# @FUNCTION: qt4-r2_src_install 119# @FUNCTION: qt4-r2_src_install
118# @DESCRIPTION: 120# @DESCRIPTION:
119# Default src_install function for qt4-based packages. Installs compiled code, 121# Default src_install function for qt4-based packages. Installs compiled code
120# documentation (via DOCS variable) and translations (via LANGS and 122# and misc documentation (via DOCS variable).
121# LANGSLONG variables).
122qt4-r2_src_install() { 123qt4-r2_src_install() {
123 debug-print-function $FUNCNAME "$@" 124 debug-print-function $FUNCNAME "$@"
124 125
125 emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" 126 emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed"
126 127
127 # install documentation 128 # install documentation
128 if [[ -n "${DOCS}" ]]; then
129 local dir=${DOCSDIR:-${S}} 129 local doc dir="${DOCSDIR:-${S}}"
130 for doc in ${DOCS}; do 130 for doc in ${DOCS}; do
131 dodoc "${dir}/${doc}" || die "dodoc failed" 131 dodoc "${dir}/${doc}" || die "dodoc failed"
132 done 132 done
133 fi
134} 133}
135 134
136# Internal function, used by eqmake4 and qt4-r2_src_configure 135# Internal function, used by eqmake4 and qt4-r2_src_configure
137# Look for project files: 136# Look for project files:
138# 0 *.pro files found - output null string 137# 0 *.pro files found - output null string
151 1) 150 1)
152 echo "${pro_files[0]}" 151 echo "${pro_files[0]}"
153 ;; 152 ;;
154 *) 153 *)
155 for pro_file in "${pro_files[@]}"; do 154 for pro_file in "${pro_files[@]}"; do
156 if [[ "${pro_file}" == "${dir_name}" || 155 if [[ ${pro_file} == "${dir_name}" || ${pro_file} == "${PN}.pro" ]]; then
157 "${pro_file}" == "${PN}.pro" ]]; then
158 echo "${pro_file}" 156 echo "${pro_file}"
159 break 157 break
160 fi 158 fi
161 done 159 done
162 ;; 160 ;;
163 esac 161 esac
164} 162}
165 163
166# @FUNCTION: eqmake4 164# @FUNCTION: eqmake4
167# @USAGE: [project file] [parameters to qmake] 165# @USAGE: [project_file] [parameters to qmake]
168# @DESCRIPTION: 166# @DESCRIPTION:
169# Wrapper for Qt4's qmake. If project file isn't specified eqmake4 will 167# Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will
170# look for it in current directory (${S}, non-recursively). If more than 168# look for it in the current directory (${S}, non-recursively). If more
171# one project file is found, the ${PN}.pro is processed, provided that it 169# than one project file are found, then ${PN}.pro is processed, provided
172# exists. Otherwise eqmake4 fails. 170# that it exists. Otherwise eqmake4 fails.
171#
173# All the arguments are appended unmodified to qmake command line. For 172# All other arguments are appended unmodified to qmake command line. For
174# recursive build systems, i.e. those based on the subdirs template, you 173# recursive build systems, i.e. those based on the subdirs template, you
175# should run eqmake4 on the top-level project file only, unless you have 174# should run eqmake4 on the top-level project file only, unless you have
176# strong reasons to do things differently. During the building, qmake 175# strong reasons to do things differently. During the building, qmake
177# will be automatically re-invoked with the right arguments on every 176# will be automatically re-invoked with the right arguments on every
178# directory specified inside the top-level project file by the SUBDIRS 177# directory specified inside the top-level project file.
179# variable.
180eqmake4() { 178eqmake4() {
181 ebegin "Running qmake" 179 ebegin "Running qmake"
182 180
183 local qmake_args=("$@") 181 local qmake_args=("$@")
184 182
185 # check if project file was passed as a first argument 183 # check if project file was passed as a first argument
186 # if not, then search for it 184 # if not, then search for it
187 local regexp='.*\.pro' 185 local regexp='.*\.pro'
188 if ! [[ "${1}" =~ ${regexp} ]]; then 186 if ! [[ ${1} =~ ${regexp} ]]; then
189 local project_file="$(_find_project_file)" 187 local project_file="$(_find_project_file)"
190 if [[ -z "${project_file}" ]]; then 188 if [[ -z ${project_file} ]]; then
191 echo 189 echo
192 eerror "No project file found in ${S}!" 190 eerror "No project file found in ${S}!"
193 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" 191 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
194 echo 192 echo
195 die "eqmake4 failed" 193 die "eqmake4 failed"
196 fi 194 fi
197 qmake_args+=("${project_file}") 195 qmake_args+=("${project_file}")
198 fi 196 fi
199 197
200 # make sure CONFIG variable is correctly set for both release and debug builds 198 # make sure CONFIG variable is correctly set
199 # for both release and debug builds
201 local CONFIG_ADD="release" 200 local CONFIG_ADD="release"
202 local CONFIG_REMOVE="debug" 201 local CONFIG_REMOVE="debug"
203 if has debug ${IUSE} && use debug; then 202 if has debug ${IUSE} && use debug; then
204 CONFIG_ADD="debug" 203 CONFIG_ADD="debug"
205 CONFIG_REMOVE="release" 204 CONFIG_REMOVE="release"
206 fi 205 fi
207 local awkscript='BEGIN { 206 local awkscript='BEGIN {
208 printf "### eqmake4 was here ###\n" > file; 207 printf "### eqmake4 was here ###\n" > file;
208 printf "CONFIG -= debug_and_release %s\n", remove >> file;
209 printf "CONFIG += %s\n\n", add >> file;
209 fixed=0; 210 fixed=0;
210 } 211 }
211 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ { 212 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
212 for (i=1; i <= NF; i++) { 213 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
213 if ($i ~ rem || $i ~ /debug_and_release/) 214 fixed=1;
214 { $i=add; fixed=1; }
215 } 215 }
216 } 216 }
217 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ { 217 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
218 for (i=1; i <= NF; i++) { 218 if (gsub("\\<" add "\\>", "") > 0) {
219 if ($i ~ add) { $i=rem; fixed=1; } 219 fixed=1;
220 } 220 }
221 } 221 }
222 { 222 {
223 print >> file; 223 print >> file;
224 } 224 }
225 END { 225 END {
226 printf "\nCONFIG -= debug_and_release %s\n", rem >> file;
227 printf "CONFIG += %s\n", add >> file;
228 print fixed; 226 print fixed;
229 }' 227 }'
230 local file= 228 local file=
231 while read file; do 229 while read file; do
232 grep -q '^### eqmake4 was here ###$' "${file}" && continue 230 grep -q '^### eqmake4 was here ###$' "${file}" && continue
233 local retval=$({ 231 local retval=$({
234 rm -f "${file}" || echo "FAILED" 232 rm -f "${file}" || echo FAIL
235 awk -v file="${file}" -- "${awkscript}" add=${CONFIG_ADD} rem=${CONFIG_REMOVE} || echo "FAILED" 233 awk -v file="${file}" \
234 -v add=${CONFIG_ADD} \
235 -v remove=${CONFIG_REMOVE} \
236 -- "${awkscript}" || echo FAIL
236 } < "${file}") 237 } < "${file}")
237 if [[ ${retval} == 1 ]]; then 238 if [[ ${retval} == 1 ]]; then
238 einfo " - fixed CONFIG in ${file}" 239 einfo " - fixed CONFIG in ${file}"
239 elif [[ ${retval} != 0 ]]; then 240 elif [[ ${retval} != 0 ]]; then
240 eerror "An error occurred while processing ${file}" 241 eerror "An error occurred while processing ${file}"
244 245
245 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX= 246 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
246 247
247 "${EPREFIX}"/usr/bin/qmake \ 248 "${EPREFIX}"/usr/bin/qmake \
248 -makefile \ 249 -makefile \
249 -config ${CONFIG_ADD} \
250 QTDIR="${EPREFIX}"/usr/$(get_libdir) \ 250 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
251 QMAKE="${EPREFIX}"/usr/bin/qmake \ 251 QMAKE="${EPREFIX}"/usr/bin/qmake \
252 QMAKE_CC="$(tc-getCC)" \ 252 QMAKE_CC="$(tc-getCC)" \
253 QMAKE_CXX="$(tc-getCXX)" \ 253 QMAKE_CXX="$(tc-getCXX)" \
254 QMAKE_LINK="$(tc-getCXX)" \ 254 QMAKE_LINK="$(tc-getCXX)" \

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.20