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

Contents of /eclass/qmake-utils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Jul 28 21:19:52 2014 UTC (2 months, 3 weeks ago) by pesa
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +4 -2 lines
Set also QMAKE_LINK_{C_,}SHLIB

1 # Copyright 1999-2014 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.2 2014/07/11 08:21:58 ulm 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 if [[ -z ${_QMAKE_UTILS_ECLASS} ]]; then
15 _QMAKE_UTILS_ECLASS=1
16
17 inherit eutils multilib toolchain-funcs
18
19 # @FUNCTION: qmake-utils_find_pro_file
20 # @RETURN: zero or one qmake .pro file names
21 # @INTERNAL
22 # @DESCRIPTION:
23 # Outputs a project file name that can be passed to eqmake.
24 # 0 *.pro files found --> outputs null string;
25 # 1 *.pro file found --> outputs its name;
26 # 2 or more *.pro files found --> if "${PN}.pro" or
27 # "$(basename ${S}).pro" are there, outputs one of them.
28 qmake-utils_find_pro_file() {
29 local dir_name=$(basename "${S}")
30
31 # set nullglob to avoid expanding *.pro to the literal
32 # string "*.pro" when there are no matching files
33 eshopts_push -s nullglob
34 local pro_files=(*.pro)
35 eshopts_pop
36
37 case ${#pro_files[@]} in
38 0)
39 : ;;
40 1)
41 echo "${pro_files}"
42 ;;
43 *)
44 for pro_file in "${pro_files[@]}"; do
45 if [[ ${pro_file%.pro} == ${dir_name} || ${pro_file%.pro} == ${PN} ]]; then
46 echo "${pro_file}"
47 break
48 fi
49 done
50 ;;
51 esac
52 }
53
54 # @VARIABLE: EQMAKE4_EXCLUDE
55 # @DEFAULT_UNSET
56 # @DESCRIPTION:
57 # List of files to be excluded from eqmake4 CONFIG processing.
58 # Paths are relative to the current working directory (usually ${S}).
59 #
60 # Example: EQMAKE4_EXCLUDE="ignore/me.pro foo/*"
61
62 # @FUNCTION: eqmake4
63 # @USAGE: [project_file] [parameters to qmake]
64 # @DESCRIPTION:
65 # Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will
66 # look for it in the current directory (${S}, non-recursively). If more
67 # than one project file are found, then ${PN}.pro is processed, provided
68 # that it exists. Otherwise eqmake4 fails.
69 #
70 # All other arguments are appended unmodified to qmake command line.
71 #
72 # For recursive build systems, i.e. those based on the subdirs template,
73 # you should run eqmake4 on the top-level project file only, unless you
74 # have a valid reason to do otherwise. During the building, qmake will
75 # be automatically re-invoked with the right arguments on every directory
76 # specified inside the top-level project file.
77 eqmake4() {
78 debug-print-function ${FUNCNAME} "$@"
79
80 has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=
81
82 ebegin "Running qmake"
83
84 local qmake_args=("$@")
85
86 # check if project file was passed as a first argument
87 # if not, then search for it
88 local regexp='.*\.pro'
89 if ! [[ ${1} =~ ${regexp} ]]; then
90 local project_file=$(qmake-utils_find_pro_file)
91 if [[ -z ${project_file} ]]; then
92 echo
93 eerror "No project files found in '${PWD}'!"
94 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
95 echo
96 die "eqmake4 failed"
97 fi
98 qmake_args+=("${project_file}")
99 fi
100
101 # make sure CONFIG variable is correctly set
102 # for both release and debug builds
103 local config_add="release"
104 local config_remove="debug"
105 if has debug ${IUSE} && use debug; then
106 config_add="debug"
107 config_remove="release"
108 fi
109
110 local awkscript='BEGIN {
111 printf "### eqmake4 was here ###\n" > file;
112 printf "CONFIG -= debug_and_release %s\n", remove >> file;
113 printf "CONFIG += %s\n\n", add >> file;
114 fixed=0;
115 }
116 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
117 if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
118 fixed=1;
119 }
120 }
121 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
122 if (gsub("\\<" add "\\>", "") > 0) {
123 fixed=1;
124 }
125 }
126 {
127 print >> file;
128 }
129 END {
130 print fixed;
131 }'
132
133 [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_push -o noglob
134
135 local file
136 while read file; do
137 local excl
138 for excl in ${EQMAKE4_EXCLUDE}; do
139 [[ ${file} == ${excl} ]] && continue 2
140 done
141 grep -q '^### eqmake4 was here ###$' "${file}" && continue
142
143 local retval=$({
144 rm -f "${file}" || echo FAIL
145 awk -v file="${file}" \
146 -v add=${config_add} \
147 -v remove=${config_remove} \
148 -- "${awkscript}" || echo FAIL
149 } < "${file}")
150
151 if [[ ${retval} == 1 ]]; then
152 einfo " - fixed CONFIG in ${file}"
153 elif [[ ${retval} != 0 ]]; then
154 eerror " - error while processing ${file}"
155 die "eqmake4 failed to process ${file}"
156 fi
157 done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null)
158
159 [[ -n ${EQMAKE4_EXCLUDE} ]] && eshopts_pop
160
161 "${EPREFIX}"/usr/bin/qmake \
162 -makefile \
163 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
164 QMAKE="${EPREFIX}"/usr/bin/qmake \
165 QMAKE_AR="$(tc-getAR) cqs" \
166 QMAKE_CC="$(tc-getCC)" \
167 QMAKE_CXX="$(tc-getCXX)" \
168 QMAKE_LINK="$(tc-getCXX)" \
169 QMAKE_LINK_C="$(tc-getCC)" \
170 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
171 QMAKE_RANLIB= \
172 QMAKE_STRIP= \
173 QMAKE_CFLAGS="${CFLAGS}" \
174 QMAKE_CFLAGS_RELEASE= \
175 QMAKE_CFLAGS_DEBUG= \
176 QMAKE_CXXFLAGS="${CXXFLAGS}" \
177 QMAKE_CXXFLAGS_RELEASE= \
178 QMAKE_CXXFLAGS_DEBUG= \
179 QMAKE_LFLAGS="${LDFLAGS}" \
180 QMAKE_LFLAGS_RELEASE= \
181 QMAKE_LFLAGS_DEBUG= \
182 QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \
183 QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \
184 QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \
185 "${qmake_args[@]}"
186
187 # was qmake successful?
188 if ! eend $? ; then
189 echo
190 eerror "Running qmake has failed! (see above for details)"
191 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
192 echo
193 die "eqmake4 failed"
194 fi
195 }
196
197 # @FUNCTION: eqmake5
198 # @USAGE: [arguments for qmake]
199 # @DESCRIPTION:
200 # Wrapper for Qt5's qmake. All arguments are passed to qmake.
201 #
202 # For recursive build systems, i.e. those based on the subdirs template,
203 # you should run eqmake5 on the top-level project file only, unless you
204 # have a valid reason to do otherwise. During the building, qmake will
205 # be automatically re-invoked with the right arguments on every directory
206 # specified inside the top-level project file.
207 eqmake5() {
208 debug-print-function ${FUNCNAME} "$@"
209
210 has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=
211
212 ebegin "Running qmake"
213
214 "${EPREFIX}"/usr/$(get_libdir)/qt5/bin/qmake \
215 -makefile \
216 QMAKE_AR="$(tc-getAR) cqs" \
217 QMAKE_CC="$(tc-getCC)" \
218 QMAKE_LINK_C="$(tc-getCC)" \
219 QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
220 QMAKE_CXX="$(tc-getCXX)" \
221 QMAKE_LINK="$(tc-getCXX)" \
222 QMAKE_LINK_SHLIB="$(tc-getCXX)" \
223 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
224 QMAKE_RANLIB= \
225 QMAKE_STRIP= \
226 QMAKE_CFLAGS="${CFLAGS}" \
227 QMAKE_CFLAGS_RELEASE= \
228 QMAKE_CFLAGS_DEBUG= \
229 QMAKE_CXXFLAGS="${CXXFLAGS}" \
230 QMAKE_CXXFLAGS_RELEASE= \
231 QMAKE_CXXFLAGS_DEBUG= \
232 QMAKE_LFLAGS="${LDFLAGS}" \
233 QMAKE_LFLAGS_RELEASE= \
234 QMAKE_LFLAGS_DEBUG= \
235 "$@"
236
237 # was qmake successful?
238 if ! eend $? ; then
239 echo
240 eerror "Running qmake has failed! (see above for details)"
241 eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
242 echo
243 die "eqmake5 failed"
244 fi
245 }
246
247 fi

  ViewVC Help
Powered by ViewVC 1.1.20