| 1 | # Copyright 1999-2010 Gentoo Foundation |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.2 2010/01/14 21:25:17 abcd Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.14 2011/11/12 20:46:39 pesa Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: qt4-r2.eclass |
5 | # @ECLASS: qt4-r2.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Ben de Groot <yngwin@gentoo.org>, |
7 | # Qt herd <qt@gentoo.org> |
| 8 | # Markos Chandras <hwoarang@gentoo.org>, |
|
|
| 9 | # Davide Pesavento <davidepesa@gmail.com>, |
|
|
| 10 | # Dominik Kapusta <ayoy@gentoo.org> |
|
|
| 11 | # @BLURB: Eclass for Qt4 packages, second edition |
8 | # @BLURB: Eclass for Qt4-based packages, second edition. |
| 12 | # @DESCRIPTION: |
9 | # @DESCRIPTION: |
| 13 | # This eclass contains various functions that may be useful when |
10 | # This eclass contains various functions that may be useful when |
| 14 | # dealing with packages using Qt4 libraries. Requires EAPI=2. |
11 | # dealing with packages using Qt4 libraries. Requires EAPI=2 or later. |
| 15 | |
12 | |
| 16 | case ${EAPI} in |
13 | case ${EAPI} in |
| 17 | 2) : ;; |
14 | 2|3|4) : ;; |
| 18 | *) DEPEND="EAPI-INCOMPATIBLE" ;; |
15 | *) die "EAPI=${EAPI} is not supported by ${ECLASS} eclass." ;; |
| 19 | esac |
16 | esac |
| 20 | |
17 | |
| 21 | inherit base eutils multilib toolchain-funcs |
18 | inherit base eutils multilib toolchain-funcs |
| 22 | |
19 | |
| 23 | export XDG_CONFIG_HOME="${T}" |
20 | export XDG_CONFIG_HOME="${T}" |
| … | |
… | |
| 46 | # Default src_unpack function for packages that depend on qt4. If you have to |
43 | # Default src_unpack function for packages that depend on qt4. If you have to |
| 47 | # override src_unpack in your ebuild (probably you don't need to), call |
44 | # override src_unpack in your ebuild (probably you don't need to), call |
| 48 | # qt4-r2_src_unpack in it. |
45 | # qt4-r2_src_unpack in it. |
| 49 | qt4-r2_src_unpack() { |
46 | qt4-r2_src_unpack() { |
| 50 | debug-print-function $FUNCNAME "$@" |
47 | debug-print-function $FUNCNAME "$@" |
|
|
48 | |
| 51 | base_src_unpack "$@" |
49 | base_src_unpack "$@" |
| 52 | |
50 | |
| 53 | # Fallback to ${WORKDIR}/${MY_P} when ${WORKDIR}/${P} doesn't exist. |
51 | # Fallback to ${WORKDIR}/${MY_P} when ${WORKDIR}/${P} doesn't exist. |
| 54 | # Feel free to re-implement this |
52 | # This is a hack that was never meant to be used by ebuilds in tree. |
| 55 | if [[ "${S}" == "${WORKDIR}/${P}" && ! -d ${S} && -d ${WORKDIR}/${MY_P} ]]; then |
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 |
| 56 | ewarn "Falling back to '${WORKDIR}/${MY_P}'" |
60 | einfo "Falling back to '${WORKDIR}/${MY_P}'" |
| 57 | S="${WORKDIR}/${MY_P}" |
61 | S="${WORKDIR}/${MY_P}" |
| 58 | fi |
62 | fi |
| 59 | } |
63 | } |
| 60 | |
64 | |
| 61 | # @ECLASS-VARIABLE: PATCHES |
65 | # @ECLASS-VARIABLE: PATCHES |
| … | |
… | |
| 63 | # In case you have patches to apply, specify them in PATCHES variable. Make sure |
67 | # In case you have patches to apply, specify them in PATCHES variable. Make sure |
| 64 | # to specify the full path. This variable is used in src_prepare phase. |
68 | # to specify the full path. This variable is used in src_prepare phase. |
| 65 | # example: |
69 | # example: |
| 66 | # PATCHES=( "${FILESDIR}"/mypatch.patch |
70 | # PATCHES=( "${FILESDIR}"/mypatch.patch |
| 67 | # "${FILESDIR}"/mypatch2.patch ) |
71 | # "${FILESDIR}"/mypatch2.patch ) |
| 68 | # |
72 | |
| 69 | # @FUNCTION: qt4-r2_src_prepare |
73 | # @FUNCTION: qt4-r2_src_prepare |
| 70 | # @DESCRIPTION: |
74 | # @DESCRIPTION: |
| 71 | # Default src_prepare function for packages that depend on qt4. If you have to |
75 | # Default src_prepare function for packages that depend on qt4. If you have to |
| 72 | # override src_prepare in your ebuild, you should call qt4-r2_src_prepare in it, |
76 | # override src_prepare in your ebuild, you should call qt4-r2_src_prepare in it, |
| 73 | # otherwise autopatcher will not work! |
77 | # otherwise autopatcher will not work! |
| … | |
… | |
| 106 | |
110 | |
| 107 | # @ECLASS-VARIABLE: DOCS |
111 | # @ECLASS-VARIABLE: DOCS |
| 108 | # @DESCRIPTION: |
112 | # @DESCRIPTION: |
| 109 | # Use this variable if you want to install any documentation. |
113 | # Use this variable if you want to install any documentation. |
| 110 | # example: DOCS="README AUTHORS" |
114 | # example: DOCS="README AUTHORS" |
| 111 | # |
115 | |
| 112 | # @ECLASS-VARIABLE: DOCSDIR |
116 | # @ECLASS-VARIABLE: DOCSDIR |
| 113 | # @DESCRIPTION: |
117 | # @DESCRIPTION: |
| 114 | # Directory containing documentation. If not specified, ${S} will be used |
118 | # Directory containing documentation. If not specified, ${S} will be used |
| 115 | # instead. |
119 | # instead. |
| 116 | # |
120 | |
| 117 | # @FUNCTION: qt4-r2_src_install |
121 | # @FUNCTION: qt4-r2_src_install |
| 118 | # @DESCRIPTION: |
122 | # @DESCRIPTION: |
| 119 | # Default src_install function for qt4-based packages. Installs compiled code, |
123 | # Default src_install function for qt4-based packages. Installs compiled code, |
| 120 | # documentation (via DOCS variable) and translations (via LANGS and |
124 | # documentation (via DOCS variable) and translations (via LANGS and |
| 121 | # LANGSLONG variables). |
125 | # LANGSLONG variables). |
| … | |
… | |
| 123 | debug-print-function $FUNCNAME "$@" |
127 | debug-print-function $FUNCNAME "$@" |
| 124 | |
128 | |
| 125 | emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" |
129 | emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" |
| 126 | |
130 | |
| 127 | # install documentation |
131 | # install documentation |
| 128 | if [[ -n "${DOCS}" ]]; then |
132 | if [[ -n ${DOCS} ]]; then |
| 129 | local dir=${DOCSDIR:-${S}} |
133 | local dir=${DOCSDIR:-${S}} |
| 130 | for doc in ${DOCS}; do |
134 | for doc in ${DOCS}; do |
| 131 | dodoc "${dir}/${doc}" || die "dodoc failed" |
135 | dodoc "${dir}/${doc}" || die "dodoc failed" |
| 132 | done |
136 | done |
| 133 | fi |
137 | fi |
| … | |
… | |
| 151 | 1) |
155 | 1) |
| 152 | echo "${pro_files[0]}" |
156 | echo "${pro_files[0]}" |
| 153 | ;; |
157 | ;; |
| 154 | *) |
158 | *) |
| 155 | for pro_file in "${pro_files[@]}"; do |
159 | for pro_file in "${pro_files[@]}"; do |
| 156 | if [[ "${pro_file}" == "${dir_name}" || |
160 | if [[ ${pro_file} == "${dir_name}" || ${pro_file} == "${PN}.pro" ]]; then |
| 157 | "${pro_file}" == "${PN}.pro" ]]; then |
|
|
| 158 | echo "${pro_file}" |
161 | echo "${pro_file}" |
| 159 | break |
162 | break |
| 160 | fi |
163 | fi |
| 161 | done |
164 | done |
| 162 | ;; |
165 | ;; |
| … | |
… | |
| 178 | # directory specified inside the top-level project file by the SUBDIRS |
181 | # directory specified inside the top-level project file by the SUBDIRS |
| 179 | # variable. |
182 | # variable. |
| 180 | eqmake4() { |
183 | eqmake4() { |
| 181 | ebegin "Running qmake" |
184 | ebegin "Running qmake" |
| 182 | |
185 | |
| 183 | local qmake_args="$@" |
186 | local qmake_args=("$@") |
| 184 | |
187 | |
| 185 | # check if project file was passed as a first argument |
188 | # check if project file was passed as a first argument |
| 186 | # if not, then search for it |
189 | # if not, then search for it |
| 187 | local regexp='.*\.pro' |
190 | local regexp='.*\.pro' |
| 188 | if ! [[ "${1}" =~ ${regexp} ]]; then |
191 | if ! [[ ${1} =~ ${regexp} ]]; then |
| 189 | local project_file="$(_find_project_file)" |
192 | local project_file="$(_find_project_file)" |
| 190 | if [[ -z "${project_file}" ]]; then |
193 | if [[ -z ${project_file} ]]; then |
| 191 | echo |
194 | echo |
| 192 | eerror "No project file found in ${S}!" |
195 | eerror "No project file found in ${S}!" |
| 193 | eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" |
196 | eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" |
| 194 | echo |
197 | echo |
| 195 | die "eqmake4 failed" |
198 | die "eqmake4 failed" |
| 196 | fi |
199 | fi |
| 197 | qmake_args="${qmake_args} ${project_file}" |
200 | qmake_args+=("${project_file}") |
| 198 | fi |
201 | fi |
| 199 | |
202 | |
| 200 | # make sure CONFIG variable is correctly set for both release and debug builds |
203 | # make sure CONFIG variable is correctly set |
|
|
204 | # for both release and debug builds |
| 201 | local CONFIG_ADD="release" |
205 | local CONFIG_ADD="release" |
| 202 | local CONFIG_REMOVE="debug" |
206 | local CONFIG_REMOVE="debug" |
| 203 | if has debug ${IUSE} && use debug; then |
207 | if has debug ${IUSE} && use debug; then |
| 204 | CONFIG_ADD="debug" |
208 | CONFIG_ADD="debug" |
| 205 | CONFIG_REMOVE="release" |
209 | CONFIG_REMOVE="release" |
| … | |
… | |
| 242 | fi |
246 | fi |
| 243 | done < <(find . -type f -name "*.pr[io]" -printf '%P\n' 2>/dev/null) |
247 | done < <(find . -type f -name "*.pr[io]" -printf '%P\n' 2>/dev/null) |
| 244 | |
248 | |
| 245 | [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX= |
249 | [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX= |
| 246 | |
250 | |
| 247 | "${EPREFIX}"/usr/bin/qmake -makefile -nocache \ |
251 | "${EPREFIX}"/usr/bin/qmake \ |
|
|
252 | -makefile \ |
|
|
253 | -config ${CONFIG_ADD} \ |
| 248 | QTDIR="${EPREFIX}"/usr/$(get_libdir) \ |
254 | QTDIR="${EPREFIX}"/usr/$(get_libdir) \ |
| 249 | QMAKE="${EPREFIX}"/usr/bin/qmake \ |
255 | QMAKE="${EPREFIX}"/usr/bin/qmake \ |
| 250 | QMAKE_CC=$(tc-getCC) \ |
256 | QMAKE_CC="$(tc-getCC)" \ |
| 251 | QMAKE_CXX=$(tc-getCXX) \ |
257 | QMAKE_CXX="$(tc-getCXX)" \ |
| 252 | QMAKE_LINK=$(tc-getCXX) \ |
258 | QMAKE_LINK="$(tc-getCXX)" \ |
| 253 | QMAKE_CFLAGS_RELEASE="${CFLAGS}" \ |
259 | QMAKE_CFLAGS_RELEASE="${CFLAGS}" \ |
| 254 | QMAKE_CFLAGS_DEBUG="${CFLAGS}" \ |
260 | QMAKE_CFLAGS_DEBUG="${CFLAGS}" \ |
| 255 | QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ |
261 | QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ |
| 256 | QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ |
262 | QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ |
| 257 | QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ |
263 | QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ |
| 258 | QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ |
264 | QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ |
| 259 | QMAKE_RPATH= \ |
265 | QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \ |
|
|
266 | QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \ |
|
|
267 | QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \ |
| 260 | QMAKE_STRIP= \ |
268 | QMAKE_STRIP= \ |
| 261 | ${qmake_args} |
269 | "${qmake_args[@]}" |
| 262 | |
270 | |
| 263 | # was qmake successful? |
271 | # was qmake successful? |
| 264 | if ! eend $? ; then |
272 | if ! eend $? ; then |
| 265 | echo |
273 | echo |
| 266 | eerror "Running qmake has failed! (see above for details)" |
274 | eerror "Running qmake has failed! (see above for details)" |