| 1 | # Copyright 2009 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.1 2009/12/15 16:32:43 ayoy Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.13 2011/11/12 18:26:59 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 | |
|
|
| 53 | # Fallback to ${WORKDIR}/${MY_P} when ${WORKDIR}/${P} doesn't exist. |
|
|
| 54 | # Feel free to re-implement this |
|
|
| 55 | if [[ "${S}" == "${WORKDIR}/${P}" && ! -d ${S} && -d ${WORKDIR}/${MY_P} ]]; then |
|
|
| 56 | ewarn "Falling back to '${WORKDIR}/${MY_P}'" |
|
|
| 57 | S="${WORKDIR}/${MY_P}" |
|
|
| 58 | fi |
|
|
| 59 | } |
50 | } |
| 60 | |
51 | |
| 61 | # @ECLASS-VARIABLE: PATCHES |
52 | # @ECLASS-VARIABLE: PATCHES |
| 62 | # @DESCRIPTION: |
53 | # @DESCRIPTION: |
| 63 | # In case you have patches to apply, specify them in PATCHES variable. Make sure |
54 | # 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. |
55 | # to specify the full path. This variable is used in src_prepare phase. |
| 65 | # example: |
56 | # example: |
| 66 | # PATCHES=( "${FILESDIR}"/mypatch.patch |
57 | # PATCHES=( "${FILESDIR}"/mypatch.patch |
| 67 | # "${FILESDIR}"/mypatch2.patch ) |
58 | # "${FILESDIR}"/mypatch2.patch ) |
| 68 | # |
59 | |
| 69 | # @FUNCTION: qt4-r2_src_prepare |
60 | # @FUNCTION: qt4-r2_src_prepare |
| 70 | # @DESCRIPTION: |
61 | # @DESCRIPTION: |
| 71 | # Default src_prepare function for packages that depend on qt4. If you have to |
62 | # 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, |
63 | # override src_prepare in your ebuild, you should call qt4-r2_src_prepare in it, |
| 73 | # otherwise autopatcher will not work! |
64 | # otherwise autopatcher will not work! |
| … | |
… | |
| 106 | |
97 | |
| 107 | # @ECLASS-VARIABLE: DOCS |
98 | # @ECLASS-VARIABLE: DOCS |
| 108 | # @DESCRIPTION: |
99 | # @DESCRIPTION: |
| 109 | # Use this variable if you want to install any documentation. |
100 | # Use this variable if you want to install any documentation. |
| 110 | # example: DOCS="README AUTHORS" |
101 | # example: DOCS="README AUTHORS" |
| 111 | # |
102 | |
| 112 | # @ECLASS-VARIABLE: DOCSDIR |
103 | # @ECLASS-VARIABLE: DOCSDIR |
| 113 | # @DESCRIPTION: |
104 | # @DESCRIPTION: |
| 114 | # Directory containing documentation. If not specified, ${S} will be used |
105 | # Directory containing documentation. If not specified, ${S} will be used |
| 115 | # instead. |
106 | # instead. |
| 116 | # |
107 | |
| 117 | # @FUNCTION: qt4-r2_src_install |
108 | # @FUNCTION: qt4-r2_src_install |
| 118 | # @DESCRIPTION: |
109 | # @DESCRIPTION: |
| 119 | # Default src_install function for qt4-based packages. Installs compiled code, |
110 | # Default src_install function for qt4-based packages. Installs compiled code, |
| 120 | # documentation (via DOCS variable) and translations (via LANGS and |
111 | # documentation (via DOCS variable) and translations (via LANGS and |
| 121 | # LANGSLONG variables). |
112 | # LANGSLONG variables). |
| … | |
… | |
| 123 | debug-print-function $FUNCNAME "$@" |
114 | debug-print-function $FUNCNAME "$@" |
| 124 | |
115 | |
| 125 | emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" |
116 | emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed" |
| 126 | |
117 | |
| 127 | # install documentation |
118 | # install documentation |
| 128 | if [[ -n "${DOCS}" ]]; then |
119 | if [[ -n ${DOCS} ]]; then |
| 129 | local dir=${DOCSDIR:-${S}} |
120 | local dir=${DOCSDIR:-${S}} |
| 130 | for doc in ${DOCS}; do |
121 | for doc in ${DOCS}; do |
| 131 | dodoc "${dir}/${doc}" || die "dodoc failed" |
122 | dodoc "${dir}/${doc}" || die "dodoc failed" |
| 132 | done |
123 | done |
| 133 | fi |
124 | fi |
| … | |
… | |
| 151 | 1) |
142 | 1) |
| 152 | echo "${pro_files[0]}" |
143 | echo "${pro_files[0]}" |
| 153 | ;; |
144 | ;; |
| 154 | *) |
145 | *) |
| 155 | for pro_file in "${pro_files[@]}"; do |
146 | for pro_file in "${pro_files[@]}"; do |
| 156 | if [[ "${pro_file}" == "${dir_name}" || |
147 | if [[ ${pro_file} == "${dir_name}" || ${pro_file} == "${PN}.pro" ]]; then |
| 157 | "${pro_file}" == "${PN}.pro" ]]; then |
|
|
| 158 | echo "${pro_file}" |
148 | echo "${pro_file}" |
| 159 | break |
149 | break |
| 160 | fi |
150 | fi |
| 161 | done |
151 | done |
| 162 | ;; |
152 | ;; |
| … | |
… | |
| 178 | # directory specified inside the top-level project file by the SUBDIRS |
168 | # directory specified inside the top-level project file by the SUBDIRS |
| 179 | # variable. |
169 | # variable. |
| 180 | eqmake4() { |
170 | eqmake4() { |
| 181 | ebegin "Running qmake" |
171 | ebegin "Running qmake" |
| 182 | |
172 | |
| 183 | local qmake_args="$@" |
173 | local qmake_args=("$@") |
| 184 | |
174 | |
| 185 | # check if project file was passed as a first argument |
175 | # check if project file was passed as a first argument |
| 186 | # if not, then search for it |
176 | # if not, then search for it |
| 187 | local regexp='.*\.pro' |
177 | local regexp='.*\.pro' |
| 188 | if ! [[ "${1}" =~ ${regexp} ]]; then |
178 | if ! [[ ${1} =~ ${regexp} ]]; then |
| 189 | local project_file="$(_find_project_file)" |
179 | local project_file="$(_find_project_file)" |
| 190 | if [[ -z "${project_file}" ]]; then |
180 | if [[ -z ${project_file} ]]; then |
| 191 | echo |
181 | echo |
| 192 | eerror "No project file found in ${S}!" |
182 | eerror "No project file found in ${S}!" |
| 193 | eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" |
183 | eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" |
| 194 | echo |
184 | echo |
| 195 | die "eqmake4 failed" |
185 | die "eqmake4 failed" |
| 196 | fi |
186 | fi |
| 197 | qmake_args="${qmake_args} ${project_file}" |
187 | qmake_args+=("${project_file}") |
| 198 | fi |
188 | fi |
| 199 | |
189 | |
| 200 | # make sure CONFIG variable is correctly set for both release and debug builds |
190 | # make sure CONFIG variable is correctly set |
|
|
191 | # for both release and debug builds |
| 201 | local CONFIG_ADD="release" |
192 | local CONFIG_ADD="release" |
| 202 | local CONFIG_REMOVE="debug" |
193 | local CONFIG_REMOVE="debug" |
| 203 | if has debug ${IUSE} && use debug; then |
194 | if has debug ${IUSE} && use debug; then |
| 204 | CONFIG_ADD="debug" |
195 | CONFIG_ADD="debug" |
| 205 | CONFIG_REMOVE="release" |
196 | CONFIG_REMOVE="release" |
| … | |
… | |
| 240 | eerror "An error occurred while processing ${file}" |
231 | eerror "An error occurred while processing ${file}" |
| 241 | die "eqmake4 failed to process '${file}'" |
232 | die "eqmake4 failed to process '${file}'" |
| 242 | fi |
233 | fi |
| 243 | done < <(find . -type f -name "*.pr[io]" -printf '%P\n' 2>/dev/null) |
234 | done < <(find . -type f -name "*.pr[io]" -printf '%P\n' 2>/dev/null) |
| 244 | |
235 | |
| 245 | /usr/bin/qmake -makefile -nocache \ |
236 | [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX= |
|
|
237 | |
|
|
238 | "${EPREFIX}"/usr/bin/qmake \ |
|
|
239 | -makefile \ |
|
|
240 | -config ${CONFIG_ADD} \ |
| 246 | QTDIR=/usr/$(get_libdir) \ |
241 | QTDIR="${EPREFIX}"/usr/$(get_libdir) \ |
| 247 | QMAKE=/usr/bin/qmake \ |
242 | QMAKE="${EPREFIX}"/usr/bin/qmake \ |
| 248 | QMAKE_CC=$(tc-getCC) \ |
243 | QMAKE_CC="$(tc-getCC)" \ |
| 249 | QMAKE_CXX=$(tc-getCXX) \ |
244 | QMAKE_CXX="$(tc-getCXX)" \ |
| 250 | QMAKE_LINK=$(tc-getCXX) \ |
245 | QMAKE_LINK="$(tc-getCXX)" \ |
| 251 | QMAKE_CFLAGS_RELEASE="${CFLAGS}" \ |
246 | QMAKE_CFLAGS_RELEASE="${CFLAGS}" \ |
| 252 | QMAKE_CFLAGS_DEBUG="${CFLAGS}" \ |
247 | QMAKE_CFLAGS_DEBUG="${CFLAGS}" \ |
| 253 | QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ |
248 | QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ |
| 254 | QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ |
249 | QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ |
| 255 | QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ |
250 | QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ |
| 256 | QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ |
251 | QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ |
| 257 | QMAKE_RPATH= \ |
252 | QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \ |
|
|
253 | QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \ |
|
|
254 | QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \ |
| 258 | QMAKE_STRIP= \ |
255 | QMAKE_STRIP= \ |
| 259 | ${qmake_args} |
256 | "${qmake_args[@]}" |
| 260 | |
257 | |
| 261 | # was qmake successful? |
258 | # was qmake successful? |
| 262 | if ! eend $? ; then |
259 | if ! eend $? ; then |
| 263 | echo |
260 | echo |
| 264 | eerror "Running qmake has failed! (see above for details)" |
261 | eerror "Running qmake has failed! (see above for details)" |