/[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.10 Revision 1.24
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.10 2011/03/19 15:02:47 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.24 2012/11/08 09:42:51 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) : ;; 14 2|3|4|5) : ;;
18 *) die "EAPI=${EAPI} is not supported" ;; 15 *) die "qt4-r2.eclass: unsupported EAPI=${EAPI:-0}" ;;
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
22# @ECLASS-VARIABLE: DOCS
23# @DEFAULT_UNSET
24# @DESCRIPTION:
25# Array containing documents passed to dodoc command.
26# Paths can be absolute or relative to ${S}.
27#
28# Example: DOCS=( ChangeLog README "${WORKDIR}/doc_folder/" )
29
30# @ECLASS-VARIABLE: HTML_DOCS
31# @DEFAULT_UNSET
32# @DESCRIPTION:
33# Array containing documents passed to dohtml command.
34# Paths can be absolute or relative to ${S}.
35#
36# Example: HTML_DOCS=( "doc/document.html" "${WORKDIR}/html_folder/" )
37
25# @ECLASS-VARIABLE: LANGS 38# @ECLASS-VARIABLE: LANGS
39# @DEFAULT_UNSET
26# @DESCRIPTION: 40# @DESCRIPTION:
27# In case your Qt4 application provides various translations, use this variable 41# In case your Qt4 application provides various translations, use this variable
28# to specify them in order to populate "linguas_*" IUSE automatically. Make sure 42# to specify them in order to populate "linguas_*" IUSE automatically. Make sure
29# that you set this variable BEFORE inheriting qt4-r2 eclass. 43# that you set this variable before inheriting qt4-r2 eclass.
44#
30# example: LANGS="en el de" 45# Example: LANGS="de el it ja"
31for x in ${LANGS}; do 46for x in ${LANGS}; do
32 IUSE="${IUSE} linguas_${x}" 47 IUSE+=" linguas_${x}"
33done 48done
34 49
35# @ECLASS-VARIABLE: LANGSLONG 50# @ECLASS-VARIABLE: LANGSLONG
51# @DEFAULT_UNSET
36# @DESCRIPTION: 52# @DESCRIPTION:
37# Same as above, but this variable is for LINGUAS that must be in long format. 53# Same as LANGS, but this variable is for LINGUAS that must be in long format.
38# Remember to set this variable BEFORE inheriting qt4-r2 eclass. 54# Remember to set this variable before inheriting qt4-r2 eclass.
39# Look at ${PORTDIR}/profiles/desc/linguas.desc for details. 55# Look at ${PORTDIR}/profiles/desc/linguas.desc for details.
56#
57# Example: LANGSLONG="en_GB ru_RU"
40for x in ${LANGSLONG}; do 58for x in ${LANGSLONG}; do
41 IUSE="${IUSE} linguas_${x%_*}" 59 IUSE+=" linguas_${x%_*}"
42done 60done
61unset x
62
63# @ECLASS-VARIABLE: PATCHES
64# @DEFAULT_UNSET
65# @DESCRIPTION:
66# Array variable containing all the patches to be applied. This variable
67# is expected to be defined in the global scope of ebuilds. Make sure to
68# specify the full path. This variable is used in src_prepare phase.
69#
70# Example:
71# @CODE
72# PATCHES=(
73# "${FILESDIR}/mypatch.patch"
74# "${FILESDIR}/mypatch2.patch"
75# )
76# @CODE
43 77
44# @FUNCTION: qt4-r2_src_unpack 78# @FUNCTION: qt4-r2_src_unpack
45# @DESCRIPTION: 79# @DESCRIPTION:
46# Default src_unpack function for packages that depend on qt4. If you have to 80# 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 81# override src_unpack in your ebuild (probably you don't need to), call
48# qt4-r2_src_unpack in it. 82# qt4-r2_src_unpack in it.
49qt4-r2_src_unpack() { 83qt4-r2_src_unpack() {
50 debug-print-function $FUNCNAME "$@" 84 debug-print-function $FUNCNAME "$@"
85
51 base_src_unpack "$@" 86 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} 87}
60 88
61# @ECLASS-VARIABLE: PATCHES
62# @DESCRIPTION:
63# In case you have patches to apply, specify them in PATCHES variable. Make sure
64# to specify the full path. This variable is used in src_prepare phase.
65# example:
66# PATCHES=( "${FILESDIR}"/mypatch.patch
67# "${FILESDIR}"/mypatch2.patch )
68#
69# @FUNCTION: qt4-r2_src_prepare 89# @FUNCTION: qt4-r2_src_prepare
70# @DESCRIPTION: 90# @DESCRIPTION:
71# Default src_prepare function for packages that depend on qt4. If you have to 91# 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, 92# override src_prepare in your ebuild, you should call qt4-r2_src_prepare in it,
73# otherwise autopatcher will not work! 93# otherwise autopatcher will not work!
82# 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
83# 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.
84qt4-r2_src_configure() { 104qt4-r2_src_configure() {
85 debug-print-function $FUNCNAME "$@" 105 debug-print-function $FUNCNAME "$@"
86 106
87 local project_file="$(_find_project_file)" 107 local project_file=$(_find_project_file)
88 108
89 if [[ -n ${project_file} ]]; then 109 if [[ -n ${project_file} ]]; then
90 eqmake4 ${project_file} 110 eqmake4 "${project_file}"
91 else 111 else
92 base_src_configure "$@" 112 base_src_configure "$@"
93 fi 113 fi
94} 114}
95 115
102 debug-print-function $FUNCNAME "$@" 122 debug-print-function $FUNCNAME "$@"
103 123
104 base_src_compile "$@" 124 base_src_compile "$@"
105} 125}
106 126
107# @ECLASS-VARIABLE: DOCS
108# @DESCRIPTION:
109# Use this variable if you want to install any documentation.
110# example: DOCS="README AUTHORS"
111#
112# @ECLASS-VARIABLE: DOCSDIR
113# @DESCRIPTION:
114# Directory containing documentation. If not specified, ${S} will be used
115# instead.
116#
117# @FUNCTION: qt4-r2_src_install 127# @FUNCTION: qt4-r2_src_install
118# @DESCRIPTION: 128# @DESCRIPTION:
119# Default src_install function for qt4-based packages. Installs compiled code, 129# Default src_install function for qt4-based packages. Installs compiled code,
120# documentation (via DOCS variable) and translations (via LANGS and 130# documentation (via DOCS and HTML_DOCS variables).
121# LANGSLONG variables). 131
122qt4-r2_src_install() { 132qt4-r2_src_install() {
123 debug-print-function $FUNCNAME "$@" 133 debug-print-function $FUNCNAME "$@"
124 134
125 emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" 135 base_src_install INSTALL_ROOT="${D}" "$@"
126 136
127 # install documentation 137 # backward compatibility for non-array variables
128 if [[ -n "${DOCS}" ]]; then 138 if [[ -n ${DOCS} ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
129 local dir=${DOCSDIR:-${S}}
130 for doc in ${DOCS}; do
131 dodoc "${dir}/${doc}" || die "dodoc failed" 139 dodoc ${DOCS} || die "dodoc failed"
132 done
133 fi
134}
135
136# Internal function, used by eqmake4 and qt4-r2_src_configure
137# Look for project files:
138# 0 *.pro files found - output null string
139# 1 *.pro file found - output its name
140# 2 or more *.pro files found - if ${PN}.pro or $(basename ${S}).pro
141# are there, output any of them
142# Outputs a project file argument used by eqmake4. Sets nullglob locally
143# to avoid expanding *.pro as "*.pro" when there are no matching files.
144_find_project_file() {
145 shopt -s nullglob
146 local pro_files=(*.pro)
147 shopt -u nullglob
148 local dir_name="$(basename ${S})"
149
150 case ${#pro_files[@]} in
151 1)
152 echo "${pro_files[0]}"
153 ;;
154 *)
155 for pro_file in "${pro_files[@]}"; do
156 if [[ "${pro_file}" == "${dir_name}" ||
157 "${pro_file}" == "${PN}.pro" ]]; then
158 echo "${pro_file}"
159 break
160 fi 140 fi
161 done 141 if [[ -n ${HTML_DOCS} ]] && [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
162 ;; 142 dohtml -r ${HTML_DOCS} || die "dohtml failed"
163 esac 143 fi
164} 144}
165 145
166# @FUNCTION: eqmake4 146# @FUNCTION: eqmake4
167# @USAGE: [project file] [parameters to qmake] 147# @USAGE: [project_file] [parameters to qmake]
168# @DESCRIPTION: 148# @DESCRIPTION:
169# Wrapper for Qt4's qmake. If project file isn't specified eqmake4 will 149# 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 150# 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 151# than one project file are found, then ${PN}.pro is processed, provided
172# exists. Otherwise eqmake4 fails. 152# that it exists. Otherwise eqmake4 fails.
153#
173# All the arguments are appended unmodified to qmake command line. For 154# All other arguments are appended unmodified to qmake command line. For
174# recursive build systems, i.e. those based on the subdirs template, you 155# 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 156# should run eqmake4 on the top-level project file only, unless you have
176# strong reasons to do things differently. During the building, qmake 157# strong reasons to do things differently. During the building, qmake
177# will be automatically re-invoked with the right arguments on every 158# will be automatically re-invoked with the right arguments on every
178# directory specified inside the top-level project file by the SUBDIRS 159# directory specified inside the top-level project file.
179# variable.
180eqmake4() { 160eqmake4() {
161 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
162
181 ebegin "Running qmake" 163 ebegin "Running qmake"
182 164
183 local qmake_args=("$@") 165 local qmake_args=("$@")
184 166
185 # check if project file was passed as a first argument 167 # check if project file was passed as a first argument
186 # if not, then search for it 168 # if not, then search for it
187 local regexp='.*\.pro' 169 local regexp='.*\.pro'
188 if ! [[ "${1}" =~ ${regexp} ]]; then 170 if ! [[ ${1} =~ ${regexp} ]]; then
189 local project_file="$(_find_project_file)" 171 local project_file=$(_find_project_file)
190 if [[ -z "${project_file}" ]]; then 172 if [[ -z ${project_file} ]]; then
191 echo 173 echo
192 eerror "No project file found in ${S}!" 174 eerror "No project files found in '${PWD}'!"
193 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" 175 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
194 echo 176 echo
195 die "eqmake4 failed" 177 die "eqmake4 failed"
196 fi 178 fi
197 qmake_args+=("${project_file}") 179 qmake_args+=("${project_file}")
198 fi 180 fi
199 181
200 # make sure CONFIG variable is correctly set for both release and debug builds 182 # make sure CONFIG variable is correctly set
201 local CONFIG_ADD="release" 183 # for both release and debug builds
202 local CONFIG_REMOVE="debug" 184 local config_add="release"
185 local config_remove="debug"
203 if has debug ${IUSE} && use debug; then 186 if has debug ${IUSE} && use debug; then
204 CONFIG_ADD="debug" 187 config_add="debug"
205 CONFIG_REMOVE="release" 188 config_remove="release"
206 fi 189 fi
207 local awkscript='BEGIN { 190 local awkscript='BEGIN {
208 printf "### eqmake4 was here ###\n" > file; 191 printf "### eqmake4 was here ###\n" > file;
192 printf "CONFIG -= debug_and_release %s\n", remove >> file;
193 printf "CONFIG += %s\n\n", add >> file;
209 fixed=0; 194 fixed=0;
210 } 195 }
211 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ { 196 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
212 for (i=1; i <= NF; i++) { 197 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
213 if ($i ~ rem || $i ~ /debug_and_release/) 198 fixed=1;
214 { $i=add; fixed=1; }
215 } 199 }
216 } 200 }
217 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ { 201 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
218 for (i=1; i <= NF; i++) { 202 if (gsub("\\<" add "\\>", "") > 0) {
219 if ($i ~ add) { $i=rem; fixed=1; } 203 fixed=1;
220 } 204 }
221 } 205 }
222 { 206 {
223 print >> file; 207 print >> file;
224 } 208 }
225 END { 209 END {
226 printf "\nCONFIG -= debug_and_release %s\n", rem >> file;
227 printf "CONFIG += %s\n", add >> file;
228 print fixed; 210 print fixed;
229 }' 211 }'
230 local file= 212 local file=
231 while read file; do 213 while read file; do
232 grep -q '^### eqmake4 was here ###$' "${file}" && continue 214 grep -q '^### eqmake4 was here ###$' "${file}" && continue
233 local retval=$({ 215 local retval=$({
234 rm -f "${file}" || echo "FAILED" 216 rm -f "${file}" || echo FAIL
235 awk -v file="${file}" -- "${awkscript}" add=${CONFIG_ADD} rem=${CONFIG_REMOVE} || echo "FAILED" 217 awk -v file="${file}" \
218 -v add=${config_add} \
219 -v remove=${config_remove} \
220 -- "${awkscript}" || echo FAIL
236 } < "${file}") 221 } < "${file}")
237 if [[ ${retval} == 1 ]]; then 222 if [[ ${retval} == 1 ]]; then
238 einfo " - fixed CONFIG in ${file}" 223 einfo " - fixed CONFIG in ${file}"
239 elif [[ ${retval} != 0 ]]; then 224 elif [[ ${retval} != 0 ]]; then
240 eerror "An error occurred while processing ${file}" 225 eerror " - error while processing ${file}"
241 die "eqmake4 failed to process '${file}'" 226 die "eqmake4 failed to process ${file}"
242 fi 227 fi
243 done < <(find . -type f -name "*.pr[io]" -printf '%P\n' 2>/dev/null) 228 done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null)
244
245 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
246 229
247 "${EPREFIX}"/usr/bin/qmake \ 230 "${EPREFIX}"/usr/bin/qmake \
248 -makefile \ 231 -makefile \
249 -config ${CONFIG_ADD} \
250 QTDIR="${EPREFIX}"/usr/$(get_libdir) \ 232 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
251 QMAKE="${EPREFIX}"/usr/bin/qmake \ 233 QMAKE="${EPREFIX}"/usr/bin/qmake \
234 QMAKE_AR="$(tc-getAR) cqs" \
252 QMAKE_CC="$(tc-getCC)" \ 235 QMAKE_CC="$(tc-getCC)" \
253 QMAKE_CXX="$(tc-getCXX)" \ 236 QMAKE_CXX="$(tc-getCXX)" \
254 QMAKE_LINK="$(tc-getCXX)" \ 237 QMAKE_LINK="$(tc-getCXX)" \
255 QMAKE_CFLAGS_RELEASE="${CFLAGS}" \ 238 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
239 QMAKE_RANLIB= \
240 QMAKE_STRIP= \
256 QMAKE_CFLAGS_DEBUG="${CFLAGS}" \ 241 QMAKE_CFLAGS="${CFLAGS}" \
257 QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ 242 QMAKE_CFLAGS_RELEASE= \
243 QMAKE_CFLAGS_DEBUG= \
258 QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ 244 QMAKE_CXXFLAGS="${CXXFLAGS}" \
259 QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ 245 QMAKE_CXXFLAGS_RELEASE= \
246 QMAKE_CXXFLAGS_DEBUG= \
260 QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ 247 QMAKE_LFLAGS="${LDFLAGS}" \
248 QMAKE_LFLAGS_RELEASE= \
249 QMAKE_LFLAGS_DEBUG= \
261 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \ 250 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \
262 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \ 251 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \
263 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \ 252 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \
264 QMAKE_STRIP= \
265 "${qmake_args[@]}" 253 "${qmake_args[@]}"
266 254
267 # was qmake successful? 255 # was qmake successful?
268 if ! eend $? ; then 256 if ! eend $? ; then
269 echo 257 echo
274 fi 262 fi
275 263
276 return 0 264 return 0
277} 265}
278 266
267# Internal function, used by eqmake4 and qt4-r2_src_configure.
268# Outputs a project file name that can be passed to eqmake4. Sets nullglob
269# locally to avoid expanding *.pro as "*.pro" when there are no matching files.
270# 0 *.pro files found --> outputs null string
271# 1 *.pro file found --> outputs its name
272# 2 or more *.pro files found --> if ${PN}.pro or $(basename ${S}).pro
273# are there, outputs any of them
274_find_project_file() {
275 local dir_name=$(basename "${S}")
276
277 eshopts_push -s nullglob
278 local pro_files=(*.pro)
279 eshopts_pop
280
281 case ${#pro_files[@]} in
282 1)
283 echo "${pro_files[0]}"
284 ;;
285 *)
286 for pro_file in "${pro_files[@]}"; do
287 if [[ ${pro_file} == "${dir_name}.pro" || ${pro_file} == "${PN}.pro" ]]; then
288 echo "${pro_file}"
289 break
290 fi
291 done
292 ;;
293 esac
294}
295
279EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install 296EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.20