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

Contents of /eclass/qt4-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (hide annotations) (download)
Thu Nov 8 09:42:51 2012 UTC (22 months, 3 weeks ago) by pesa
Branch: MAIN
Changes since 1.23: +40 -38 lines
Partial sync with qt overlay. Apart from cosmetic changes, we now explicitly define QMAKE_{AR,RANLIB,OBJCOPY} in eqmake4(), thus fixing bug 440266.

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

  ViewVC Help
Powered by ViewVC 1.1.20