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

Contents of /eclass/qt4-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Sat Nov 12 20:46:39 2011 UTC (2 years, 7 months ago) by pesa
Branch: MAIN
Changes since 1.13: +14 -1 lines
Restore ${S} fallback, but with a deprecation notice saying that it will be removed in 30 days.

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

  ViewVC Help
Powered by ViewVC 1.1.20