/[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.18 Revision 1.23
1# Copyright 1999-2012 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.18 2012/02/13 00:53:28 pesa Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.23 2012/10/04 03:52:35 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|5) : ;;
15 *) die "EAPI=${EAPI} is not supported by ${ECLASS} eclass." ;; 15 *) die "qt4-r2.eclass: unsupported EAPI=${EAPI:-0}" ;;
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
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/" )
21 37
22# @ECLASS-VARIABLE: LANGS 38# @ECLASS-VARIABLE: LANGS
23# @DEFAULT_UNSET 39# @DEFAULT_UNSET
24# @DESCRIPTION: 40# @DESCRIPTION:
25# In case your Qt4 application provides various translations, use this variable 41# In case your Qt4 application provides various translations, use this variable
28# Example: 44# Example:
29# @CODE 45# @CODE
30# LANGS="en el de" 46# LANGS="en el de"
31# @CODE 47# @CODE
32for x in ${LANGS}; do 48for x in ${LANGS}; do
33 IUSE="${IUSE} linguas_${x}" 49 IUSE+=" linguas_${x}"
34done 50done
35 51
36# @ECLASS-VARIABLE: LANGSLONG 52# @ECLASS-VARIABLE: LANGSLONG
37# @DEFAULT_UNSET 53# @DEFAULT_UNSET
38# @DESCRIPTION: 54# @DESCRIPTION:
39# 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.
40# Remember to set this variable before inheriting qt4-r2 eclass. 56# Remember to set this variable before inheriting qt4-r2 eclass.
41# Look at ${PORTDIR}/profiles/desc/linguas.desc for details. 57# Look at ${PORTDIR}/profiles/desc/linguas.desc for details.
42for x in ${LANGSLONG}; do 58for x in ${LANGSLONG}; do
43 IUSE="${IUSE} linguas_${x%_*}" 59 IUSE+=" linguas_${x%_*}"
44done 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
45 77
46# @FUNCTION: qt4-r2_src_unpack 78# @FUNCTION: qt4-r2_src_unpack
47# @DESCRIPTION: 79# @DESCRIPTION:
48# 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
49# 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
52 debug-print-function $FUNCNAME "$@" 84 debug-print-function $FUNCNAME "$@"
53 85
54 base_src_unpack "$@" 86 base_src_unpack "$@"
55} 87}
56 88
57# @ECLASS-VARIABLE: PATCHES
58# @DEFAULT_UNSET
59# @DESCRIPTION:
60# In case you have patches to apply, specify them here. Make sure to
61# specify the full path. This variable is used in src_prepare phase.
62# Example:
63# @CODE
64# PATCHES=( "${FILESDIR}"/mypatch.patch
65# "${FILESDIR}"/mypatch2.patch )
66# @CODE
67
68# @FUNCTION: qt4-r2_src_prepare 89# @FUNCTION: qt4-r2_src_prepare
69# @DESCRIPTION: 90# @DESCRIPTION:
70# 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
71# 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,
72# otherwise autopatcher will not work! 93# otherwise autopatcher will not work!
81# 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
82# 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.
83qt4-r2_src_configure() { 104qt4-r2_src_configure() {
84 debug-print-function $FUNCNAME "$@" 105 debug-print-function $FUNCNAME "$@"
85 106
86 local project_file="$(_find_project_file)" 107 local project_file=$(_find_project_file)
87 108
88 if [[ -n ${project_file} ]]; then 109 if [[ -n ${project_file} ]]; then
89 eqmake4 ${project_file} 110 eqmake4 "${project_file}"
90 else 111 else
91 base_src_configure "$@" 112 base_src_configure "$@"
92 fi 113 fi
93} 114}
94 115
101 debug-print-function $FUNCNAME "$@" 122 debug-print-function $FUNCNAME "$@"
102 123
103 base_src_compile "$@" 124 base_src_compile "$@"
104} 125}
105 126
106# @ECLASS-VARIABLE: DOCS
107# @DEFAULT_UNSET
108# @DESCRIPTION:
109# Use this variable if you want to install any documentation.
110# Example:
111# @CODE
112# DOCS="README AUTHORS"
113# @CODE
114
115# @ECLASS-VARIABLE: DOCSDIR
116# @DESCRIPTION:
117# Directory containing documentation, defaults to ${S}.
118
119# @FUNCTION: qt4-r2_src_install 127# @FUNCTION: qt4-r2_src_install
120# @DESCRIPTION: 128# @DESCRIPTION:
121# Default src_install function for qt4-based packages. Installs compiled code 129# Default src_install function for qt4-based packages. Installs compiled code
122# and misc documentation (via DOCS variable). 130# documentation (via DOCS and HTML_DOCS variables).
131
123qt4-r2_src_install() { 132qt4-r2_src_install() {
124 debug-print-function $FUNCNAME "$@" 133 debug-print-function $FUNCNAME "$@"
125 134
126 emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" 135 base_src_install INSTALL_ROOT="${D}" "$@"
127 136
128 # install documentation 137 # backward compatibility for non-array variables
129 local doc dir="${DOCSDIR:-${S}}" 138 if [[ -n ${DOCS} ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
130 for doc in ${DOCS}; do
131 dodoc "${dir}/${doc}" || die "dodoc failed" 139 dodoc ${DOCS} || die "dodoc failed"
132 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"
143 fi
133} 144}
134 145
135# Internal function, used by eqmake4 and qt4-r2_src_configure 146# Internal function, used by eqmake4 and qt4-r2_src_configure
136# Look for project files: 147# Look for project files:
137# 0 *.pro files found - output null string 148# 0 *.pro files found - output null string
139# 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
140# are there, output any of them 151# are there, output any of them
141# Outputs a project file argument used by eqmake4. Sets nullglob locally 152# Outputs a project file argument used by eqmake4. Sets nullglob locally
142# 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.
143_find_project_file() { 154_find_project_file() {
155 local dir_name=$(basename "${S}")
156
144 shopt -s nullglob 157 eshopts_push -s nullglob
145 local pro_files=(*.pro) 158 local pro_files=(*.pro)
146 shopt -u nullglob 159 eshopts_pop
147 local dir_name="$(basename ${S})"
148 160
149 case ${#pro_files[@]} in 161 case ${#pro_files[@]} in
150 1) 162 1)
151 echo "${pro_files[0]}" 163 echo "${pro_files[0]}"
152 ;; 164 ;;
153 *) 165 *)
154 for pro_file in "${pro_files[@]}"; do 166 for pro_file in "${pro_files[@]}"; do
155 if [[ ${pro_file} == "${dir_name}" || ${pro_file} == "${PN}.pro" ]]; then 167 if [[ ${pro_file} == "${dir_name}.pro" || ${pro_file} == "${PN}.pro" ]]; then
156 echo "${pro_file}" 168 echo "${pro_file}"
157 break 169 break
158 fi 170 fi
159 done 171 done
160 ;; 172 ;;
174# 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
175# strong reasons to do things differently. During the building, qmake 187# strong reasons to do things differently. During the building, qmake
176# will be automatically re-invoked with the right arguments on every 188# will be automatically re-invoked with the right arguments on every
177# directory specified inside the top-level project file. 189# directory specified inside the top-level project file.
178eqmake4() { 190eqmake4() {
191 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
192
179 ebegin "Running qmake" 193 ebegin "Running qmake"
180 194
181 local qmake_args=("$@") 195 local qmake_args=("$@")
182 196
183 # check if project file was passed as a first argument 197 # check if project file was passed as a first argument
184 # if not, then search for it 198 # if not, then search for it
185 local regexp='.*\.pro' 199 local regexp='.*\.pro'
186 if ! [[ ${1} =~ ${regexp} ]]; then 200 if ! [[ ${1} =~ ${regexp} ]]; then
187 local project_file="$(_find_project_file)" 201 local project_file=$(_find_project_file)
188 if [[ -z ${project_file} ]]; then 202 if [[ -z ${project_file} ]]; then
189 echo 203 echo
190 eerror "No project file found in ${S}!" 204 eerror "No project files found in '${PWD}'!"
191 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/"
192 echo 206 echo
193 die "eqmake4 failed" 207 die "eqmake4 failed"
194 fi 208 fi
195 qmake_args+=("${project_file}") 209 qmake_args+=("${project_file}")
196 fi 210 fi
197 211
198 # make sure CONFIG variable is correctly set 212 # make sure CONFIG variable is correctly set
199 # for both release and debug builds 213 # for both release and debug builds
200 local CONFIG_ADD="release" 214 local config_add="release"
201 local CONFIG_REMOVE="debug" 215 local config_remove="debug"
202 if has debug ${IUSE} && use debug; then 216 if has debug ${IUSE} && use debug; then
203 CONFIG_ADD="debug" 217 config_add="debug"
204 CONFIG_REMOVE="release" 218 config_remove="release"
205 fi 219 fi
206 local awkscript='BEGIN { 220 local awkscript='BEGIN {
207 printf "### eqmake4 was here ###\n" > file; 221 printf "### eqmake4 was here ###\n" > file;
208 printf "CONFIG -= debug_and_release %s\n", remove >> file; 222 printf "CONFIG -= debug_and_release %s\n", remove >> file;
209 printf "CONFIG += %s\n\n", add >> file; 223 printf "CONFIG += %s\n\n", add >> file;
229 while read file; do 243 while read file; do
230 grep -q '^### eqmake4 was here ###$' "${file}" && continue 244 grep -q '^### eqmake4 was here ###$' "${file}" && continue
231 local retval=$({ 245 local retval=$({
232 rm -f "${file}" || echo FAIL 246 rm -f "${file}" || echo FAIL
233 awk -v file="${file}" \ 247 awk -v file="${file}" \
234 -v add=${CONFIG_ADD} \ 248 -v add=${config_add} \
235 -v remove=${CONFIG_REMOVE} \ 249 -v remove=${config_remove} \
236 -- "${awkscript}" || echo FAIL 250 -- "${awkscript}" || echo FAIL
237 } < "${file}") 251 } < "${file}")
238 if [[ ${retval} == 1 ]]; then 252 if [[ ${retval} == 1 ]]; then
239 einfo " - fixed CONFIG in ${file}" 253 einfo " - fixed CONFIG in ${file}"
240 elif [[ ${retval} != 0 ]]; then 254 elif [[ ${retval} != 0 ]]; then
241 eerror "An error occurred while processing ${file}" 255 eerror " - error while processing ${file}"
242 die "eqmake4 failed to process '${file}'" 256 die "eqmake4 failed to process ${file}"
243 fi 257 fi
244 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)
245
246 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
247 259
248 "${EPREFIX}"/usr/bin/qmake \ 260 "${EPREFIX}"/usr/bin/qmake \
249 -makefile \ 261 -makefile \
250 QTDIR="${EPREFIX}"/usr/$(get_libdir) \ 262 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
251 QMAKE="${EPREFIX}"/usr/bin/qmake \ 263 QMAKE="${EPREFIX}"/usr/bin/qmake \
252 QMAKE_CC="$(tc-getCC)" \ 264 QMAKE_CC="$(tc-getCC)" \
253 QMAKE_CXX="$(tc-getCXX)" \ 265 QMAKE_CXX="$(tc-getCXX)" \
254 QMAKE_LINK="$(tc-getCXX)" \ 266 QMAKE_LINK="$(tc-getCXX)" \
255 QMAKE_CFLAGS_RELEASE="${CFLAGS}" \
256 QMAKE_CFLAGS_DEBUG="${CFLAGS}" \ 267 QMAKE_CFLAGS="${CFLAGS}" \
257 QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ 268 QMAKE_CFLAGS_RELEASE= \
269 QMAKE_CFLAGS_DEBUG= \
258 QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ 270 QMAKE_CXXFLAGS="${CXXFLAGS}" \
259 QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ 271 QMAKE_CXXFLAGS_RELEASE= \
272 QMAKE_CXXFLAGS_DEBUG= \
260 QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ 273 QMAKE_LFLAGS="${LDFLAGS}" \
274 QMAKE_LFLAGS_RELEASE= \
275 QMAKE_LFLAGS_DEBUG= \
261 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \ 276 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \
262 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \ 277 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \
263 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \ 278 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \
264 QMAKE_STRIP= \ 279 QMAKE_STRIP= \
265 "${qmake_args[@]}" 280 "${qmake_args[@]}"

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

  ViewVC Help
Powered by ViewVC 1.1.20