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