1 |
commit: d11a5636128d2fa3c8be327e270396e9879d113b |
2 |
Author: Davide Pesavento <davidepesa <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri May 31 09:02:34 2013 +0000 |
4 |
Commit: Davide Pesavento <pesa <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri May 31 09:02:34 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/qt.git;a=commit;h=d11a5636 |
7 |
|
8 |
First version of qmake-utils.eclass |
9 |
|
10 |
--- |
11 |
eclass/qmake-utils.eclass | 190 ++++++++++++++++++++++++++++++++++++++++++++++ |
12 |
1 file changed, 190 insertions(+) |
13 |
|
14 |
diff --git a/eclass/qmake-utils.eclass b/eclass/qmake-utils.eclass |
15 |
new file mode 100644 |
16 |
index 0000000..6fa2734 |
17 |
--- /dev/null |
18 |
+++ b/eclass/qmake-utils.eclass |
19 |
@@ -0,0 +1,190 @@ |
20 |
+# Copyright 1999-2013 Gentoo Foundation |
21 |
+# Distributed under the terms of the GNU General Public License v2 |
22 |
+# $Header: $ |
23 |
+ |
24 |
+# @ECLASS: qmake-utils.eclass |
25 |
+# @MAINTAINER: |
26 |
+# Qt herd <qt@g.o> |
27 |
+# @AUTHOR: |
28 |
+# Davide Pesavento <pesa@g.o> |
29 |
+# @BLURB: Common functions for qmake-based packages. |
30 |
+# @DESCRIPTION: |
31 |
+# Utility eclass providing wrapper functions for Qt4 and Qt5 qmake. |
32 |
+# Requires EAPI=2 or later. |
33 |
+ |
34 |
+case ${EAPI} in |
35 |
+ 2|3|4|5) : ;; |
36 |
+ *) die "qmake-utils.eclass: unsupported EAPI=${EAPI:-0}" ;; |
37 |
+esac |
38 |
+ |
39 |
+inherit multilib toolchain-funcs |
40 |
+ |
41 |
+# @FUNCTION: eqmake4 |
42 |
+# @USAGE: [project_file] [parameters to qmake] |
43 |
+# @DESCRIPTION: |
44 |
+# Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will |
45 |
+# look for it in the current directory (${S}, non-recursively). If more |
46 |
+# than one project file are found, then ${PN}.pro is processed, provided |
47 |
+# that it exists. Otherwise eqmake4 fails. |
48 |
+# |
49 |
+# All other arguments are appended unmodified to qmake command line. |
50 |
+# For recursive build systems, i.e. those based on the subdirs template, |
51 |
+# you should run eqmake5 on the top-level project file only, unless you |
52 |
+# have a valid reason to do otherwise. During the building, qmake will |
53 |
+# be automatically re-invoked with the right arguments on every directory |
54 |
+# specified inside the top-level project file. |
55 |
+eqmake4() { |
56 |
+ debug-print-function ${FUNCNAME} "$@" |
57 |
+ |
58 |
+ [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX= |
59 |
+ |
60 |
+ ebegin "Running qmake" |
61 |
+ |
62 |
+ local qmake_args=("$@") |
63 |
+ |
64 |
+ # check if project file was passed as a first argument |
65 |
+ # if not, then search for it |
66 |
+ local regexp='.*\.pro' |
67 |
+ if ! [[ ${1} =~ ${regexp} ]]; then |
68 |
+ local project_file=$(_find_project_file) |
69 |
+ if [[ -z ${project_file} ]]; then |
70 |
+ echo |
71 |
+ eerror "No project files found in '${PWD}'!" |
72 |
+ eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/" |
73 |
+ echo |
74 |
+ die "eqmake4 failed" |
75 |
+ fi |
76 |
+ qmake_args+=("${project_file}") |
77 |
+ fi |
78 |
+ |
79 |
+ # make sure CONFIG variable is correctly set |
80 |
+ # for both release and debug builds |
81 |
+ local config_add="release" |
82 |
+ local config_remove="debug" |
83 |
+ if has debug ${IUSE} && use debug; then |
84 |
+ config_add="debug" |
85 |
+ config_remove="release" |
86 |
+ fi |
87 |
+ local awkscript='BEGIN { |
88 |
+ printf "### eqmake4 was here ###\n" > file; |
89 |
+ printf "CONFIG -= debug_and_release %s\n", remove >> file; |
90 |
+ printf "CONFIG += %s\n\n", add >> file; |
91 |
+ fixed=0; |
92 |
+ } |
93 |
+ /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ { |
94 |
+ if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) { |
95 |
+ fixed=1; |
96 |
+ } |
97 |
+ } |
98 |
+ /^[[:blank:]]*CONFIG[[:blank:]]*-=/ { |
99 |
+ if (gsub("\\<" add "\\>", "") > 0) { |
100 |
+ fixed=1; |
101 |
+ } |
102 |
+ } |
103 |
+ { |
104 |
+ print >> file; |
105 |
+ } |
106 |
+ END { |
107 |
+ print fixed; |
108 |
+ }' |
109 |
+ local file= |
110 |
+ while read file; do |
111 |
+ grep -q '^### eqmake4 was here ###$' "${file}" && continue |
112 |
+ local retval=$({ |
113 |
+ rm -f "${file}" || echo FAIL |
114 |
+ awk -v file="${file}" \ |
115 |
+ -v add=${config_add} \ |
116 |
+ -v remove=${config_remove} \ |
117 |
+ -- "${awkscript}" || echo FAIL |
118 |
+ } < "${file}") |
119 |
+ if [[ ${retval} == 1 ]]; then |
120 |
+ einfo " - fixed CONFIG in ${file}" |
121 |
+ elif [[ ${retval} != 0 ]]; then |
122 |
+ eerror " - error while processing ${file}" |
123 |
+ die "eqmake4 failed to process ${file}" |
124 |
+ fi |
125 |
+ done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null) |
126 |
+ |
127 |
+ "${EPREFIX}"/usr/bin/qmake \ |
128 |
+ -makefile \ |
129 |
+ QTDIR="${EPREFIX}"/usr/$(get_libdir) \ |
130 |
+ QMAKE="${EPREFIX}"/usr/bin/qmake \ |
131 |
+ QMAKE_AR="$(tc-getAR) cqs" \ |
132 |
+ QMAKE_CC="$(tc-getCC)" \ |
133 |
+ QMAKE_CXX="$(tc-getCXX)" \ |
134 |
+ QMAKE_LINK="$(tc-getCXX)" \ |
135 |
+ QMAKE_LINK_C="$(tc-getCC)" \ |
136 |
+ QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \ |
137 |
+ QMAKE_RANLIB= \ |
138 |
+ QMAKE_STRIP= \ |
139 |
+ QMAKE_CFLAGS="${CFLAGS}" \ |
140 |
+ QMAKE_CFLAGS_RELEASE= \ |
141 |
+ QMAKE_CFLAGS_DEBUG= \ |
142 |
+ QMAKE_CXXFLAGS="${CXXFLAGS}" \ |
143 |
+ QMAKE_CXXFLAGS_RELEASE= \ |
144 |
+ QMAKE_CXXFLAGS_DEBUG= \ |
145 |
+ QMAKE_LFLAGS="${LDFLAGS}" \ |
146 |
+ QMAKE_LFLAGS_RELEASE= \ |
147 |
+ QMAKE_LFLAGS_DEBUG= \ |
148 |
+ QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \ |
149 |
+ QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \ |
150 |
+ QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \ |
151 |
+ "${qmake_args[@]}" |
152 |
+ |
153 |
+ # was qmake successful? |
154 |
+ if ! eend $? ; then |
155 |
+ echo |
156 |
+ eerror "Running qmake has failed! (see above for details)" |
157 |
+ eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/" |
158 |
+ echo |
159 |
+ die "eqmake4 failed" |
160 |
+ fi |
161 |
+} |
162 |
+ |
163 |
+# @FUNCTION: eqmake5 |
164 |
+# @USAGE: [arguments for qmake] |
165 |
+# @DESCRIPTION: |
166 |
+# Wrapper for Qt5's qmake. All arguments are passed to qmake. |
167 |
+# |
168 |
+# For recursive build systems, i.e. those based on the subdirs template, |
169 |
+# you should run eqmake5 on the top-level project file only, unless you |
170 |
+# have a valid reason to do otherwise. During the building, qmake will |
171 |
+# be automatically re-invoked with the right arguments on every directory |
172 |
+# specified inside the top-level project file. |
173 |
+eqmake5() { |
174 |
+ debug-print-function ${FUNCNAME} "$@" |
175 |
+ |
176 |
+ [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX= |
177 |
+ |
178 |
+ ebegin "Running qmake" |
179 |
+ |
180 |
+ "${EPREFIX}"/usr/$(get_libdir)/qt5/bin/qmake \ |
181 |
+ -makefile \ |
182 |
+ QMAKE_AR="$(tc-getAR) cqs" \ |
183 |
+ QMAKE_CC="$(tc-getCC)" \ |
184 |
+ QMAKE_CXX="$(tc-getCXX)" \ |
185 |
+ QMAKE_LINK="$(tc-getCXX)" \ |
186 |
+ QMAKE_LINK_C="$(tc-getCC)" \ |
187 |
+ QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \ |
188 |
+ QMAKE_RANLIB= \ |
189 |
+ QMAKE_STRIP= \ |
190 |
+ QMAKE_CFLAGS="${CFLAGS}" \ |
191 |
+ QMAKE_CFLAGS_RELEASE= \ |
192 |
+ QMAKE_CFLAGS_DEBUG= \ |
193 |
+ QMAKE_CXXFLAGS="${CXXFLAGS}" \ |
194 |
+ QMAKE_CXXFLAGS_RELEASE= \ |
195 |
+ QMAKE_CXXFLAGS_DEBUG= \ |
196 |
+ QMAKE_LFLAGS="${LDFLAGS}" \ |
197 |
+ QMAKE_LFLAGS_RELEASE= \ |
198 |
+ QMAKE_LFLAGS_DEBUG= \ |
199 |
+ "$@" |
200 |
+ |
201 |
+ # was qmake successful? |
202 |
+ if ! eend $? ; then |
203 |
+ echo |
204 |
+ eerror "Running qmake has failed! (see above for details)" |
205 |
+ eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/" |
206 |
+ echo |
207 |
+ die "eqmake5 failed" |
208 |
+ fi |
209 |
+} |