/[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.20 Revision 1.31
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2014 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.20 2012/04/19 22:43:40 pesa Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.31 2014/11/01 23:48:16 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 qmake-utils
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
26# 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
27# that you set this variable before inheriting qt4-r2 eclass. 43# that you set this variable before inheriting qt4-r2 eclass.
28# Example: 44#
29# @CODE 45# Example: LANGS="de el it ja"
30# LANGS="en el de"
31# @CODE
32for x in ${LANGS}; do 46for x in ${LANGS}; do
33 IUSE+=" linguas_${x}" 47 IUSE+=" linguas_${x}"
34done 48done
35 49
36# @ECLASS-VARIABLE: LANGSLONG 50# @ECLASS-VARIABLE: LANGSLONG
37# @DEFAULT_UNSET 51# @DEFAULT_UNSET
38# @DESCRIPTION: 52# @DESCRIPTION:
39# 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.
40# Remember to set this variable before inheriting qt4-r2 eclass. 54# Remember to set this variable before inheriting qt4-r2 eclass.
41# 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"
42for x in ${LANGSLONG}; do 58for x in ${LANGSLONG}; do
43 IUSE+=" linguas_${x%_*}" 59 IUSE+=" linguas_${x%_*}"
44done 60done
45unset x 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
46 77
47# @FUNCTION: qt4-r2_src_unpack 78# @FUNCTION: qt4-r2_src_unpack
48# @DESCRIPTION: 79# @DESCRIPTION:
49# 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
50# 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
52qt4-r2_src_unpack() { 83qt4-r2_src_unpack() {
53 debug-print-function $FUNCNAME "$@" 84 debug-print-function $FUNCNAME "$@"
54 85
55 base_src_unpack "$@" 86 base_src_unpack "$@"
56} 87}
57
58# @ECLASS-VARIABLE: PATCHES
59# @DEFAULT_UNSET
60# @DESCRIPTION:
61# In case you have patches to apply, specify them here. Make sure to
62# specify the full path. This variable is used in src_prepare phase.
63# Example:
64# @CODE
65# PATCHES=( "${FILESDIR}"/mypatch.patch
66# "${FILESDIR}"/mypatch2.patch )
67# @CODE
68 88
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,
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=$(qmake-utils_find_pro_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 "$@"
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# @DEFAULT_UNSET
109# @DESCRIPTION:
110# Use this variable if you want to install any documentation.
111# Example:
112# @CODE
113# DOCS="README AUTHORS"
114# @CODE
115
116# @ECLASS-VARIABLE: DOCSDIR
117# @DESCRIPTION:
118# Directory containing documentation, defaults to ${S}.
119
120# @FUNCTION: qt4-r2_src_install 127# @FUNCTION: qt4-r2_src_install
121# @DESCRIPTION: 128# @DESCRIPTION:
122# Default src_install function for qt4-based packages. Installs compiled code 129# Default src_install function for qt4-based packages. Installs compiled code,
123# and misc documentation (via DOCS variable). 130# and documentation (via DOCS and HTML_DOCS variables).
124qt4-r2_src_install() { 131qt4-r2_src_install() {
125 debug-print-function $FUNCNAME "$@" 132 debug-print-function $FUNCNAME "$@"
126 133
127 emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" 134 base_src_install INSTALL_ROOT="${D}" "$@"
128 135 einstalldocs
129 # install documentation
130 local doc= dir=${DOCSDIR:-${S}}
131 for doc in ${DOCS}; do
132 dodoc "${dir}/${doc}" || die "dodoc failed"
133 done
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 local dir_name=$(basename "${S}")
146
147 eshopts_push -s nullglob
148 local pro_files=(*.pro)
149 eshopts_pop
150
151 case ${#pro_files[@]} in
152 1)
153 echo "${pro_files[0]}"
154 ;;
155 *)
156 for pro_file in "${pro_files[@]}"; do
157 if [[ ${pro_file} == "${dir_name}.pro" || ${pro_file} == "${PN}.pro" ]]; then
158 echo "${pro_file}"
159 break
160 fi
161 done
162 ;;
163 esac
164}
165
166# @FUNCTION: eqmake4
167# @USAGE: [project_file] [parameters to qmake]
168# @DESCRIPTION:
169# Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will
170# look for it in the current directory (${S}, non-recursively). If more
171# than one project file are found, then ${PN}.pro is processed, provided
172# that it exists. Otherwise eqmake4 fails.
173#
174# All other arguments are appended unmodified to qmake command line. For
175# recursive build systems, i.e. those based on the subdirs template, you
176# should run eqmake4 on the top-level project file only, unless you have
177# strong reasons to do things differently. During the building, qmake
178# will be automatically re-invoked with the right arguments on every
179# directory specified inside the top-level project file.
180eqmake4() {
181 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
182
183 ebegin "Running qmake"
184
185 local qmake_args=("$@")
186
187 # check if project file was passed as a first argument
188 # if not, then search for it
189 local regexp='.*\.pro'
190 if ! [[ ${1} =~ ${regexp} ]]; then
191 local project_file=$(_find_project_file)
192 if [[ -z ${project_file} ]]; then
193 echo
194 eerror "No project files found in '${PWD}'!"
195 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
196 echo
197 die "eqmake4 failed"
198 fi
199 qmake_args+=("${project_file}")
200 fi
201
202 # make sure CONFIG variable is correctly set
203 # for both release and debug builds
204 local config_add="release"
205 local config_remove="debug"
206 if has debug ${IUSE} && use debug; then
207 config_add="debug"
208 config_remove="release"
209 fi
210 local awkscript='BEGIN {
211 printf "### eqmake4 was here ###\n" > file;
212 printf "CONFIG -= debug_and_release %s\n", remove >> file;
213 printf "CONFIG += %s\n\n", add >> file;
214 fixed=0;
215 }
216 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
217 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
218 fixed=1;
219 }
220 }
221 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
222 if (gsub("\\<" add "\\>", "") > 0) {
223 fixed=1;
224 }
225 }
226 {
227 print >> file;
228 }
229 END {
230 print fixed;
231 }'
232 local file=
233 while read file; do
234 grep -q '^### eqmake4 was here ###$' "${file}" && continue
235 local retval=$({
236 rm -f "${file}" || echo FAIL
237 awk -v file="${file}" \
238 -v add=${config_add} \
239 -v remove=${config_remove} \
240 -- "${awkscript}" || echo FAIL
241 } < "${file}")
242 if [[ ${retval} == 1 ]]; then
243 einfo " - fixed CONFIG in ${file}"
244 elif [[ ${retval} != 0 ]]; then
245 eerror " - error while processing ${file}"
246 die "eqmake4 failed to process ${file}"
247 fi
248 done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null)
249
250 "${EPREFIX}"/usr/bin/qmake \
251 -makefile \
252 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
253 QMAKE="${EPREFIX}"/usr/bin/qmake \
254 QMAKE_CC="$(tc-getCC)" \
255 QMAKE_CXX="$(tc-getCXX)" \
256 QMAKE_LINK="$(tc-getCXX)" \
257 QMAKE_CFLAGS="${CFLAGS}" \
258 QMAKE_CFLAGS_RELEASE= \
259 QMAKE_CFLAGS_DEBUG= \
260 QMAKE_CXXFLAGS="${CXXFLAGS}" \
261 QMAKE_CXXFLAGS_RELEASE= \
262 QMAKE_CXXFLAGS_DEBUG= \
263 QMAKE_LFLAGS="${LDFLAGS}" \
264 QMAKE_LFLAGS_RELEASE= \
265 QMAKE_LFLAGS_DEBUG= \
266 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \
267 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \
268 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \
269 QMAKE_STRIP= \
270 "${qmake_args[@]}"
271
272 # was qmake successful?
273 if ! eend $? ; then
274 echo
275 eerror "Running qmake has failed! (see above for details)"
276 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
277 echo
278 die "eqmake4 failed"
279 fi
280
281 return 0
282} 136}
283 137
284EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install 138EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.20