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

Contents of /eclass/qt4-r2.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.18 - (hide annotations) (download)
Mon Feb 13 00:53:28 2012 UTC (2 years, 7 months ago) by pesa
Branch: MAIN
Changes since 1.17: +1 -14 lines
Finally remove ${S} fallback, it was deprecated 3 months ago.

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

  ViewVC Help
Powered by ViewVC 1.1.20