/[gentoo-x86]/eclass/qt4-r2.eclass
Gentoo

Contents of /eclass/qt4-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (show annotations) (download)
Thu Oct 4 03:52:35 2012 UTC (23 months, 2 weeks ago) by pesa
Branch: MAIN
Changes since 1.22: +3 -3 lines
Rephrase "unsupported EAPI" die message.

1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.22 2012/09/27 16:35:41 axs Exp $
4
5 # @ECLASS: qt4-r2.eclass
6 # @MAINTAINER:
7 # Qt herd <qt@gentoo.org>
8 # @BLURB: Eclass for Qt4-based packages, second edition.
9 # @DESCRIPTION:
10 # This eclass contains various functions that may be useful when
11 # dealing with packages using Qt4 libraries. Requires EAPI=2 or later.
12
13 case ${EAPI} in
14 2|3|4|5) : ;;
15 *) die "qt4-r2.eclass: unsupported EAPI=${EAPI:-0}" ;;
16 esac
17
18 inherit base eutils multilib toolchain-funcs
19
20 export 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/" )
37
38 # @ECLASS-VARIABLE: LANGS
39 # @DEFAULT_UNSET
40 # @DESCRIPTION:
41 # In case your Qt4 application provides various translations, use this variable
42 # to specify them in order to populate "linguas_*" IUSE automatically. Make sure
43 # that you set this variable before inheriting qt4-r2 eclass.
44 # Example:
45 # @CODE
46 # LANGS="en el de"
47 # @CODE
48 for x in ${LANGS}; do
49 IUSE+=" linguas_${x}"
50 done
51
52 # @ECLASS-VARIABLE: LANGSLONG
53 # @DEFAULT_UNSET
54 # @DESCRIPTION:
55 # Same as above, but this variable is for LINGUAS that must be in long format.
56 # Remember to set this variable before inheriting qt4-r2 eclass.
57 # Look at ${PORTDIR}/profiles/desc/linguas.desc for details.
58 for x in ${LANGSLONG}; do
59 IUSE+=" linguas_${x%_*}"
60 done
61 unset 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
77
78 # @FUNCTION: qt4-r2_src_unpack
79 # @DESCRIPTION:
80 # Default src_unpack function for packages that depend on qt4. If you have to
81 # override src_unpack in your ebuild (probably you don't need to), call
82 # qt4-r2_src_unpack in it.
83 qt4-r2_src_unpack() {
84 debug-print-function $FUNCNAME "$@"
85
86 base_src_unpack "$@"
87 }
88
89 # @FUNCTION: qt4-r2_src_prepare
90 # @DESCRIPTION:
91 # Default src_prepare function for packages that depend on qt4. If you have to
92 # override src_prepare in your ebuild, you should call qt4-r2_src_prepare in it,
93 # otherwise autopatcher will not work!
94 qt4-r2_src_prepare() {
95 debug-print-function $FUNCNAME "$@"
96
97 base_src_prepare "$@"
98 }
99
100 # @FUNCTION: qt4-r2_src_configure
101 # @DESCRIPTION:
102 # Default src_configure function for packages that depend on qt4. If you have to
103 # override src_configure in your ebuild, call qt4-r2_src_configure in it.
104 qt4-r2_src_configure() {
105 debug-print-function $FUNCNAME "$@"
106
107 local project_file=$(_find_project_file)
108
109 if [[ -n ${project_file} ]]; then
110 eqmake4 "${project_file}"
111 else
112 base_src_configure "$@"
113 fi
114 }
115
116 # @FUNCTION: qt4-r2_src_compile
117 # @DESCRIPTION:
118 # Default src_compile function for packages that depend on qt4. If you have to
119 # override src_compile in your ebuild (probably you don't need to), call
120 # qt4-r2_src_compile in it.
121 qt4-r2_src_compile() {
122 debug-print-function $FUNCNAME "$@"
123
124 base_src_compile "$@"
125 }
126
127 # @FUNCTION: qt4-r2_src_install
128 # @DESCRIPTION:
129 # Default src_install function for qt4-based packages. Installs compiled code
130 # documentation (via DOCS and HTML_DOCS variables).
131
132 qt4-r2_src_install() {
133 debug-print-function $FUNCNAME "$@"
134
135 base_src_install INSTALL_ROOT="${D}" "$@"
136
137 # backward compatibility for non-array variables
138 if [[ -n ${DOCS} ]] && [[ "$(declare -p DOCS 2>/dev/null 2>&1)" != "declare -a"* ]]; then
139 dodoc ${DOCS} || die "dodoc failed"
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
144 }
145
146 # Internal function, used by eqmake4 and qt4-r2_src_configure
147 # Look for project files:
148 # 0 *.pro files found - output null string
149 # 1 *.pro file found - output its name
150 # 2 or more *.pro files found - if ${PN}.pro or $(basename ${S}).pro
151 # are there, output any of them
152 # Outputs a project file argument used by eqmake4. Sets nullglob locally
153 # to avoid expanding *.pro as "*.pro" when there are no matching files.
154 _find_project_file() {
155 local dir_name=$(basename "${S}")
156
157 eshopts_push -s nullglob
158 local pro_files=(*.pro)
159 eshopts_pop
160
161 case ${#pro_files[@]} in
162 1)
163 echo "${pro_files[0]}"
164 ;;
165 *)
166 for pro_file in "${pro_files[@]}"; do
167 if [[ ${pro_file} == "${dir_name}.pro" || ${pro_file} == "${PN}.pro" ]]; then
168 echo "${pro_file}"
169 break
170 fi
171 done
172 ;;
173 esac
174 }
175
176 # @FUNCTION: eqmake4
177 # @USAGE: [project_file] [parameters to qmake]
178 # @DESCRIPTION:
179 # Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will
180 # look for it in the current directory (${S}, non-recursively). If more
181 # than one project file are found, then ${PN}.pro is processed, provided
182 # that it exists. Otherwise eqmake4 fails.
183 #
184 # All other arguments are appended unmodified to qmake command line. For
185 # recursive build systems, i.e. those based on the subdirs template, you
186 # should run eqmake4 on the top-level project file only, unless you have
187 # strong reasons to do things differently. During the building, qmake
188 # will be automatically re-invoked with the right arguments on every
189 # directory specified inside the top-level project file.
190 eqmake4() {
191 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
192
193 ebegin "Running qmake"
194
195 local qmake_args=("$@")
196
197 # check if project file was passed as a first argument
198 # if not, then search for it
199 local regexp='.*\.pro'
200 if ! [[ ${1} =~ ${regexp} ]]; then
201 local project_file=$(_find_project_file)
202 if [[ -z ${project_file} ]]; then
203 echo
204 eerror "No project files found in '${PWD}'!"
205 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
206 echo
207 die "eqmake4 failed"
208 fi
209 qmake_args+=("${project_file}")
210 fi
211
212 # make sure CONFIG variable is correctly set
213 # for both release and debug builds
214 local config_add="release"
215 local config_remove="debug"
216 if has debug ${IUSE} && use debug; then
217 config_add="debug"
218 config_remove="release"
219 fi
220 local awkscript='BEGIN {
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;
224 fixed=0;
225 }
226 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
227 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
228 fixed=1;
229 }
230 }
231 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
232 if (gsub("\\<" add "\\>", "") > 0) {
233 fixed=1;
234 }
235 }
236 {
237 print >> file;
238 }
239 END {
240 print fixed;
241 }'
242 local file=
243 while read file; do
244 grep -q '^### eqmake4 was here ###$' "${file}" && continue
245 local retval=$({
246 rm -f "${file}" || echo FAIL
247 awk -v file="${file}" \
248 -v add=${config_add} \
249 -v remove=${config_remove} \
250 -- "${awkscript}" || echo FAIL
251 } < "${file}")
252 if [[ ${retval} == 1 ]]; then
253 einfo " - fixed CONFIG in ${file}"
254 elif [[ ${retval} != 0 ]]; then
255 eerror " - error while processing ${file}"
256 die "eqmake4 failed to process ${file}"
257 fi
258 done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null)
259
260 "${EPREFIX}"/usr/bin/qmake \
261 -makefile \
262 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
263 QMAKE="${EPREFIX}"/usr/bin/qmake \
264 QMAKE_CC="$(tc-getCC)" \
265 QMAKE_CXX="$(tc-getCXX)" \
266 QMAKE_LINK="$(tc-getCXX)" \
267 QMAKE_CFLAGS="${CFLAGS}" \
268 QMAKE_CFLAGS_RELEASE= \
269 QMAKE_CFLAGS_DEBUG= \
270 QMAKE_CXXFLAGS="${CXXFLAGS}" \
271 QMAKE_CXXFLAGS_RELEASE= \
272 QMAKE_CXXFLAGS_DEBUG= \
273 QMAKE_LFLAGS="${LDFLAGS}" \
274 QMAKE_LFLAGS_RELEASE= \
275 QMAKE_LFLAGS_DEBUG= \
276 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \
277 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \
278 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \
279 QMAKE_STRIP= \
280 "${qmake_args[@]}"
281
282 # was qmake successful?
283 if ! eend $? ; then
284 echo
285 eerror "Running qmake has failed! (see above for details)"
286 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
287 echo
288 die "eqmake4 failed"
289 fi
290
291 return 0
292 }
293
294 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install

  ViewVC Help
Powered by ViewVC 1.1.20