/[gentoo-x86]/eclass/qmake-utils.eclass
Gentoo

Contents of /eclass/qmake-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations) (download)
Mon Jun 29 00:27:17 2015 UTC (3 years, 9 months ago) by pesa
Branch: MAIN
CVS Tags: HEAD
Changes since 1.11: +21 -11 lines
Introduce qt{4,5}_get_plugindir(). Rephrase some eclass doc.

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/qmake-utils.eclass,v 1.11 2015/06/22 14:18:19 pesa Exp $
4
5 # @ECLASS: qmake-utils.eclass
6 # @MAINTAINER:
7 # Qt herd <qt@gentoo.org>
8 # @AUTHOR:
9 # Davide Pesavento <pesa@gentoo.org>
10 # @BLURB: Common functions for qmake-based packages.
11 # @DESCRIPTION:
12 # Utility eclass providing wrapper functions for Qt4 and Qt5 qmake.
13 #
14 # This eclass does not set any metadata variables nor export any phase
15 # functions. It can be inherited safely.
16
17 if [[ -z ${_QMAKE_UTILS_ECLASS} ]]; then
18 _QMAKE_UTILS_ECLASS=1
19
20 inherit eutils multilib toolchain-funcs
21
22 # @FUNCTION: qt4_get_bindir
23 # @DESCRIPTION:
24 # Echoes the directory where Qt4 binaries are installed.
25 # EPREFIX is already prepended to the returned path.
26 qt4_get_bindir() {
27 has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=
28
29 local qtbindir=${EPREFIX}$(qt4_get_libdir)/bin
30 if [[ -d ${qtbindir} ]]; then
31 echo ${qtbindir}
32 else
33 echo ${EPREFIX}/usr/bin
34 fi
35 }
36
37 # @FUNCTION: qt4_get_headerdir
38 # @DESCRIPTION:
39 # Echoes the directory where Qt4 headers are installed.
40 qt4_get_headerdir() {
41 echo /usr/include/qt4
42 }
43
44 # @FUNCTION: qt4_get_libdir
45 # @DESCRIPTION:
46 # Echoes the directory where Qt4 libraries are installed.
47 qt4_get_libdir() {
48 echo /usr/$(get_libdir)/qt4
49 }
50
51 # @FUNCTION: qt4_get_mkspecsdir
52 # @DESCRIPTION:
53 # Echoes the directory where Qt4 mkspecs are installed.
54 qt4_get_mkspecsdir() {
55 echo /usr/share/qt4/mkspecs
56 }
57
58 # @FUNCTION: qt4_get_plugindir
59 # @DESCRIPTION:
60 # Echoes the directory where Qt4 plugins are installed.
61 qt4_get_plugindir() {
62 echo $(qt4_get_libdir)/plugins
63 }
64
65 # @FUNCTION: qt5_get_bindir
66 # @DESCRIPTION:
67 # Echoes the directory where Qt5 binaries are installed.
68 # EPREFIX is already prepended to the returned path.
69 qt5_get_bindir() {
70 has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=
71
72 echo ${EPREFIX}$(qt5_get_libdir)/qt5/bin
73 }
74
75 # @FUNCTION: qt5_get_headerdir
76 # @DESCRIPTION:
77 # Echoes the directory where Qt5 headers are installed.
78 qt5_get_headerdir() {
79 echo /usr/include/qt5
80 }
81
82 # @FUNCTION: qt5_get_libdir
83 # @DESCRIPTION:
84 # Echoes the directory where Qt5 libraries are installed.
85 qt5_get_libdir() {
86 echo /usr/$(get_libdir)
87 }
88
89 # @FUNCTION: qt5_get_mkspecsdir
90 # @DESCRIPTION:
91 # Echoes the directory where Qt5 mkspecs are installed.
92 qt5_get_mkspecsdir() {
93 echo $(qt5_get_libdir)/qt5/mkspecs
94 }
95
96 # @FUNCTION: qt5_get_plugindir
97 # @DESCRIPTION:
98 # Echoes the directory where Qt5 plugins are installed.
99 qt5_get_plugindir() {
100 echo $(qt5_get_libdir)/qt5/plugins
101 }
102
103 # @FUNCTION: qmake-utils_find_pro_file
104 # @RETURN: zero or one qmake .pro file names
105 # @INTERNAL
106 # @DESCRIPTION:
107 # Outputs a project file name that can be passed to eqmake.
108 # 0 *.pro files found --> outputs null string;
109 # 1 *.pro file found --> outputs its name;
110 # 2 or more *.pro files found --> if "${PN}.pro" or
111 # "$(basename ${S}).pro" are there, outputs one of them.
112 qmake-utils_find_pro_file() {
113 local dir_name=$(basename "${S}")
114
115 # set nullglob to avoid expanding *.pro to the literal
116 # string "*.pro" when there are no matching files
117 eshopts_push -s nullglob
118 local pro_files=(*.pro)
119 eshopts_pop
120
121 case ${#pro_files[@]} in
122 0)
123 : ;;
124 1)
125 echo "${pro_files}"
126 ;;
127 *)
128 for pro_file in "${pro_files[@]}"; do
129 if [[ ${pro_file%.pro} == ${dir_name} || ${pro_file%.pro} == ${PN} ]]; then
130 echo "${pro_file}"
131 break
132 fi
133 done
134 ;;
135 esac
136 }
137
138 # @VARIABLE: EQMAKE4_EXCLUDE
139 # @DEFAULT_UNSET
140 # @DESCRIPTION:
141 # List of files to be excluded from eqmake4 CONFIG processing.
142 # Paths are relative to the current working directory (usually ${S}).
143 #
144 # Example: EQMAKE4_EXCLUDE="ignore/me.pro foo/*"
145
146 # @FUNCTION: eqmake4
147 # @USAGE: [project_file] [parameters to qmake]
148 # @DESCRIPTION:
149 # Wrapper for Qt4's qmake. If project_file is not specified, eqmake4 looks
150 # for one in the current directory (non-recursively). If multiple project
151 # files are found, then ${PN}.pro is used, if it exists, otherwise eqmake4
152 # will not be able to continue.
153 #
154 # All other arguments are appended unmodified to qmake command line.
155 #
156 # For recursive build systems, i.e. those based on the subdirs template,
157 # you should run eqmake4 on the top-level project file only, unless you
158 # have a valid reason to do otherwise. During the building, qmake will
159 # be automatically re-invoked with the right arguments on every directory
160 # specified inside the top-level project file.
161 eqmake4() {
162 debug-print-function ${FUNCNAME} "$@"
163
164 has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=
165
166 ebegin "Running qmake"
167
168 local qmake_args=("$@")
169
170 # Check if the project file name was passed as first argument. If not, look for candidates.
171 local regexp='.*\.pro'
172 if ! [[ ${1} =~ ${regexp} ]]; then
173 local project_file=$(qmake-utils_find_pro_file)
174 if [[ -z ${project_file} ]]; then
175 echo
176 eerror "No project files found in '${PWD}'"
177 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
178 echo
179 die "eqmake4 failed"
180 fi
181 qmake_args+=("${project_file}")
182 fi
183
184 # Make sure the CONFIG variable is correctly set for both release and debug builds.
185 local config_add=release
186 local config_remove=debug
187 if use_if_iuse debug; then
188 config_add=debug
189 config_remove=release
190 fi
191
192 local awkscript='BEGIN {
193 printf "### eqmake4 was here ###\n" > file;
194 printf "CONFIG -= debug_and_release %s\n", remove >> file;
195 printf "CONFIG += %s\n\n", add >> file;
196 fixed=0;
197 }
198 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
199 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
200 fixed=1;
201 }
202 }
203 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
204 if (gsub("\\<" add "\\>", "") > 0) {
205 fixed=1;
206 }
207 }
208 {
209 print >> file;
210 }
211 END {
212 print fixed;
213 }'
214
215 [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_push -o noglob
216
217 local file
218 while read file; do
219 local excl
220 for excl in ${EQMAKE4_EXCLUDE}; do
221 [[ ${file} == ${excl} ]] && continue 2
222 done
223 grep -q '^### eqmake4 was here ###$' "${file}" && continue
224
225 local retval=$({
226 rm -f "${file}" || echo FAIL
227 awk -v file="${file}" \
228 -v add=${config_add} \
229 -v remove=${config_remove} \
230 -- "${awkscript}" || echo FAIL
231 } < "${file}")
232
233 if [[ ${retval} == 1 ]]; then
234 einfo " - fixed CONFIG in ${file}"
235 elif [[ ${retval} != 0 ]]; then
236 eerror " - error while processing ${file}"
237 die "eqmake4 failed to process ${file}"
238 fi
239 done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null)
240
241 [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_pop
242
243 "$(qt4_get_bindir)"/qmake \
244 -makefile \
245 QMAKE_AR="$(tc-getAR) cqs" \
246 QMAKE_CC="$(tc-getCC)" \
247 QMAKE_CXX="$(tc-getCXX)" \
248 QMAKE_LINK="$(tc-getCXX)" \
249 QMAKE_LINK_C="$(tc-getCC)" \
250 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
251 QMAKE_RANLIB= \
252 QMAKE_STRIP= \
253 QMAKE_CFLAGS="${CFLAGS}" \
254 QMAKE_CFLAGS_RELEASE= \
255 QMAKE_CFLAGS_DEBUG= \
256 QMAKE_CXXFLAGS="${CXXFLAGS}" \
257 QMAKE_CXXFLAGS_RELEASE= \
258 QMAKE_CXXFLAGS_DEBUG= \
259 QMAKE_LFLAGS="${LDFLAGS}" \
260 QMAKE_LFLAGS_RELEASE= \
261 QMAKE_LFLAGS_DEBUG= \
262 QMAKE_LIBDIR_QT="${EPREFIX}$(qt4_get_libdir)" \
263 QMAKE_LIBDIR_X11="${EPREFIX}/usr/$(get_libdir)" \
264 QMAKE_LIBDIR_OPENGL="${EPREFIX}/usr/$(get_libdir)" \
265 "${qmake_args[@]}"
266
267 if ! eend $? ; then
268 echo
269 eerror "Running qmake has failed! (see above for details)"
270 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
271 echo
272 die "eqmake4 failed"
273 fi
274 }
275
276 # @FUNCTION: eqmake5
277 # @USAGE: [arguments for qmake]
278 # @DESCRIPTION:
279 # Wrapper for Qt5's qmake. All arguments are passed to qmake.
280 #
281 # For recursive build systems, i.e. those based on the subdirs template,
282 # you should run eqmake5 on the top-level project file only, unless you
283 # have a valid reason to do otherwise. During the building, qmake will
284 # be automatically re-invoked with the right arguments on every directory
285 # specified inside the top-level project file.
286 eqmake5() {
287 debug-print-function ${FUNCNAME} "$@"
288
289 ebegin "Running qmake"
290
291 "$(qt5_get_bindir)"/qmake \
292 -makefile \
293 QMAKE_AR="$(tc-getAR) cqs" \
294 QMAKE_CC="$(tc-getCC)" \
295 QMAKE_LINK_C="$(tc-getCC)" \
296 QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
297 QMAKE_CXX="$(tc-getCXX)" \
298 QMAKE_LINK="$(tc-getCXX)" \
299 QMAKE_LINK_SHLIB="$(tc-getCXX)" \
300 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
301 QMAKE_RANLIB= \
302 QMAKE_STRIP= \
303 QMAKE_CFLAGS="${CFLAGS}" \
304 QMAKE_CFLAGS_RELEASE= \
305 QMAKE_CFLAGS_DEBUG= \
306 QMAKE_CXXFLAGS="${CXXFLAGS}" \
307 QMAKE_CXXFLAGS_RELEASE= \
308 QMAKE_CXXFLAGS_DEBUG= \
309 QMAKE_LFLAGS="${LDFLAGS}" \
310 QMAKE_LFLAGS_RELEASE= \
311 QMAKE_LFLAGS_DEBUG= \
312 "$@"
313
314 if ! eend $? ; then
315 echo
316 eerror "Running qmake has failed! (see above for details)"
317 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
318 echo
319 die "eqmake5 failed"
320 fi
321 }
322
323 fi

  ViewVC Help
Powered by ViewVC 1.1.20