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

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

  ViewVC Help
Powered by ViewVC 1.1.20