/[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.14 Revision 1.18
1# Copyright 1999-2011 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.14 2011/11/12 20:46:39 pesa 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# 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.
9# @DESCRIPTION: 9# @DESCRIPTION:
10# This eclass contains various functions that may be useful when 10# This eclass contains various functions that may be useful when
11# dealing with packages using Qt4 libraries. Requires EAPI=2 or later. 11# dealing with packages using Qt4 libraries. Requires EAPI=2 or later.
12 12
13case ${EAPI} in 13case ${EAPI} in
14 2|3|4) : ;; 14 2|3|4) : ;;
15 *) die "EAPI=${EAPI} is not supported by ${ECLASS} eclass." ;; 15 *) die "EAPI=${EAPI} is not supported by ${ECLASS} eclass." ;;
16esac 16esac
17 17
18inherit base eutils multilib toolchain-funcs 18inherit base eutils multilib toolchain-funcs
19 19
20export XDG_CONFIG_HOME="${T}" 20export XDG_CONFIG_HOME="${T}"
21 21
22# @ECLASS-VARIABLE: LANGS 22# @ECLASS-VARIABLE: LANGS
23# @DEFAULT_UNSET
23# @DESCRIPTION: 24# @DESCRIPTION:
24# In case your Qt4 application provides various translations, use this variable 25# In case your Qt4 application provides various translations, use this variable
25# 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
26# 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
27# example: LANGS="en el de" 30# LANGS="en el de"
31# @CODE
28for x in ${LANGS}; do 32for x in ${LANGS}; do
29 IUSE="${IUSE} linguas_${x}" 33 IUSE="${IUSE} linguas_${x}"
30done 34done
31 35
32# @ECLASS-VARIABLE: LANGSLONG 36# @ECLASS-VARIABLE: LANGSLONG
37# @DEFAULT_UNSET
33# @DESCRIPTION: 38# @DESCRIPTION:
34# 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.
35# Remember to set this variable BEFORE inheriting qt4-r2 eclass. 40# Remember to set this variable before inheriting qt4-r2 eclass.
36# Look at ${PORTDIR}/profiles/desc/linguas.desc for details. 41# Look at ${PORTDIR}/profiles/desc/linguas.desc for details.
37for x in ${LANGSLONG}; do 42for x in ${LANGSLONG}; do
38 IUSE="${IUSE} linguas_${x%_*}" 43 IUSE="${IUSE} linguas_${x%_*}"
39done 44done
40 45
45# qt4-r2_src_unpack in it. 50# qt4-r2_src_unpack in it.
46qt4-r2_src_unpack() { 51qt4-r2_src_unpack() {
47 debug-print-function $FUNCNAME "$@" 52 debug-print-function $FUNCNAME "$@"
48 53
49 base_src_unpack "$@" 54 base_src_unpack "$@"
50
51 # Fallback to ${WORKDIR}/${MY_P} when ${WORKDIR}/${P} doesn't exist.
52 # This is a hack that was never meant to be used by ebuilds in tree.
53 if [[ ${S} == "${WORKDIR}/${P}" && ! -d ${S} && -d ${WORKDIR}/${MY_P} ]]; then
54 echo
55 eqawarn "*** DEPRECATION NOTICE ***"
56 eqawarn
57 eqawarn "\${S} fallback is deprecated and will be removed on 12/12/2011."
58 eqawarn "Please set the correct value for \${S} variable inside the ebuild."
59 echo
60 einfo "Falling back to '${WORKDIR}/${MY_P}'"
61 S="${WORKDIR}/${MY_P}"
62 fi
63} 55}
64 56
65# @ECLASS-VARIABLE: PATCHES 57# @ECLASS-VARIABLE: PATCHES
58# @DEFAULT_UNSET
66# @DESCRIPTION: 59# @DESCRIPTION:
67# 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
68# 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.
69# example: 62# Example:
63# @CODE
70# PATCHES=( "${FILESDIR}"/mypatch.patch 64# PATCHES=( "${FILESDIR}"/mypatch.patch
71# "${FILESDIR}"/mypatch2.patch ) 65# "${FILESDIR}"/mypatch2.patch )
66# @CODE
72 67
73# @FUNCTION: qt4-r2_src_prepare 68# @FUNCTION: qt4-r2_src_prepare
74# @DESCRIPTION: 69# @DESCRIPTION:
75# 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
76# 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,
107 102
108 base_src_compile "$@" 103 base_src_compile "$@"
109} 104}
110 105
111# @ECLASS-VARIABLE: DOCS 106# @ECLASS-VARIABLE: DOCS
107# @DEFAULT_UNSET
112# @DESCRIPTION: 108# @DESCRIPTION:
113# 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
114# example: DOCS="README AUTHORS" 112# DOCS="README AUTHORS"
113# @CODE
115 114
116# @ECLASS-VARIABLE: DOCSDIR 115# @ECLASS-VARIABLE: DOCSDIR
117# @DESCRIPTION: 116# @DESCRIPTION:
118# Directory containing documentation. If not specified, ${S} will be used 117# Directory containing documentation, defaults to ${S}.
119# instead.
120 118
121# @FUNCTION: qt4-r2_src_install 119# @FUNCTION: qt4-r2_src_install
122# @DESCRIPTION: 120# @DESCRIPTION:
123# Default src_install function for qt4-based packages. Installs compiled code, 121# Default src_install function for qt4-based packages. Installs compiled code
124# documentation (via DOCS variable) and translations (via LANGS and 122# and misc documentation (via DOCS variable).
125# LANGSLONG variables).
126qt4-r2_src_install() { 123qt4-r2_src_install() {
127 debug-print-function $FUNCNAME "$@" 124 debug-print-function $FUNCNAME "$@"
128 125
129 emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" 126 emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed"
130 127
131 # install documentation 128 # install documentation
132 if [[ -n ${DOCS} ]]; then
133 local dir=${DOCSDIR:-${S}} 129 local doc dir="${DOCSDIR:-${S}}"
134 for doc in ${DOCS}; do 130 for doc in ${DOCS}; do
135 dodoc "${dir}/${doc}" || die "dodoc failed" 131 dodoc "${dir}/${doc}" || die "dodoc failed"
136 done 132 done
137 fi
138} 133}
139 134
140# Internal function, used by eqmake4 and qt4-r2_src_configure 135# Internal function, used by eqmake4 and qt4-r2_src_configure
141# Look for project files: 136# Look for project files:
142# 0 *.pro files found - output null string 137# 0 *.pro files found - output null string
165 ;; 160 ;;
166 esac 161 esac
167} 162}
168 163
169# @FUNCTION: eqmake4 164# @FUNCTION: eqmake4
170# @USAGE: [project file] [parameters to qmake] 165# @USAGE: [project_file] [parameters to qmake]
171# @DESCRIPTION: 166# @DESCRIPTION:
172# 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
173# 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
174# 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
175# exists. Otherwise eqmake4 fails. 170# that it exists. Otherwise eqmake4 fails.
171#
176# All the arguments are appended unmodified to qmake command line. For 172# All other arguments are appended unmodified to qmake command line. For
177# 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
178# 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
179# strong reasons to do things differently. During the building, qmake 175# strong reasons to do things differently. During the building, qmake
180# will be automatically re-invoked with the right arguments on every 176# will be automatically re-invoked with the right arguments on every
181# directory specified inside the top-level project file by the SUBDIRS 177# directory specified inside the top-level project file.
182# variable.
183eqmake4() { 178eqmake4() {
184 ebegin "Running qmake" 179 ebegin "Running qmake"
185 180
186 local qmake_args=("$@") 181 local qmake_args=("$@")
187 182
208 CONFIG_ADD="debug" 203 CONFIG_ADD="debug"
209 CONFIG_REMOVE="release" 204 CONFIG_REMOVE="release"
210 fi 205 fi
211 local awkscript='BEGIN { 206 local awkscript='BEGIN {
212 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;
213 fixed=0; 210 fixed=0;
214 } 211 }
215 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ { 212 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
216 for (i=1; i <= NF; i++) { 213 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
217 if ($i ~ rem || $i ~ /debug_and_release/) 214 fixed=1;
218 { $i=add; fixed=1; }
219 } 215 }
220 } 216 }
221 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ { 217 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
222 for (i=1; i <= NF; i++) { 218 if (gsub("\\<" add "\\>", "") > 0) {
223 if ($i ~ add) { $i=rem; fixed=1; } 219 fixed=1;
224 } 220 }
225 } 221 }
226 { 222 {
227 print >> file; 223 print >> file;
228 } 224 }
229 END { 225 END {
230 printf "\nCONFIG -= debug_and_release %s\n", rem >> file;
231 printf "CONFIG += %s\n", add >> file;
232 print fixed; 226 print fixed;
233 }' 227 }'
234 local file= 228 local file=
235 while read file; do 229 while read file; do
236 grep -q '^### eqmake4 was here ###$' "${file}" && continue 230 grep -q '^### eqmake4 was here ###$' "${file}" && continue
237 local retval=$({ 231 local retval=$({
238 rm -f "${file}" || echo "FAILED" 232 rm -f "${file}" || echo FAIL
239 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
240 } < "${file}") 237 } < "${file}")
241 if [[ ${retval} == 1 ]]; then 238 if [[ ${retval} == 1 ]]; then
242 einfo " - fixed CONFIG in ${file}" 239 einfo " - fixed CONFIG in ${file}"
243 elif [[ ${retval} != 0 ]]; then 240 elif [[ ${retval} != 0 ]]; then
244 eerror "An error occurred while processing ${file}" 241 eerror "An error occurred while processing ${file}"
248 245
249 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX= 246 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
250 247
251 "${EPREFIX}"/usr/bin/qmake \ 248 "${EPREFIX}"/usr/bin/qmake \
252 -makefile \ 249 -makefile \
253 -config ${CONFIG_ADD} \
254 QTDIR="${EPREFIX}"/usr/$(get_libdir) \ 250 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
255 QMAKE="${EPREFIX}"/usr/bin/qmake \ 251 QMAKE="${EPREFIX}"/usr/bin/qmake \
256 QMAKE_CC="$(tc-getCC)" \ 252 QMAKE_CC="$(tc-getCC)" \
257 QMAKE_CXX="$(tc-getCXX)" \ 253 QMAKE_CXX="$(tc-getCXX)" \
258 QMAKE_LINK="$(tc-getCXX)" \ 254 QMAKE_LINK="$(tc-getCXX)" \

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

  ViewVC Help
Powered by ViewVC 1.1.20