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

Contents of /eclass/qt4-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations) (download)
Mon Dec 26 11:47:47 2011 UTC (2 years, 3 months ago) by pesa
Branch: MAIN
Changes since 1.14: +40 -31 lines
Improve eclass doc.

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

  ViewVC Help
Powered by ViewVC 1.1.20