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

Contents of /eclass/qt4-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations) (download)
Sat Nov 12 18:26:59 2011 UTC (3 years ago) by pesa
Branch: MAIN
Changes since 1.12: +12 -21 lines
Remove ${S} fallback from src_unpack, set qt@g.o as maintainer, remove unnecessary quoting.

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

  ViewVC Help
Powered by ViewVC 1.1.20