| 1 |
# Copyright 1999-2010 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-r2.eclass,v 1.7 2010/07/31 14:40:14 hwoarang Exp $
|
| 4 |
|
| 5 |
# @ECLASS: qt4-r2.eclass
|
| 6 |
# @MAINTAINER:
|
| 7 |
# Ben de Groot <yngwin@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
|
| 12 |
# @DESCRIPTION:
|
| 13 |
# This eclass contains various functions that may be useful when
|
| 14 |
# dealing with packages using Qt4 libraries. Requires EAPI=2.
|
| 15 |
|
| 16 |
case ${EAPI} in
|
| 17 |
2|3) : ;;
|
| 18 |
*) DEPEND="EAPI-INCOMPATIBLE" ;;
|
| 19 |
esac
|
| 20 |
|
| 21 |
inherit base eutils multilib toolchain-funcs
|
| 22 |
|
| 23 |
export XDG_CONFIG_HOME="${T}"
|
| 24 |
|
| 25 |
# @ECLASS-VARIABLE: LANGS
|
| 26 |
# @DESCRIPTION:
|
| 27 |
# In case your Qt4 application provides various translations, use this variable
|
| 28 |
# to specify them in order to populate "linguas_*" IUSE automatically. Make sure
|
| 29 |
# that you set this variable BEFORE inheriting qt4-r2 eclass.
|
| 30 |
# example: LANGS="en el de"
|
| 31 |
for x in ${LANGS}; do
|
| 32 |
IUSE="${IUSE} linguas_${x}"
|
| 33 |
done
|
| 34 |
|
| 35 |
# @ECLASS-VARIABLE: LANGSLONG
|
| 36 |
# @DESCRIPTION:
|
| 37 |
# Same as above, but this variable is for LINGUAS that must be in long format.
|
| 38 |
# Remember to set this variable BEFORE inheriting qt4-r2 eclass.
|
| 39 |
# Look at ${PORTDIR}/profiles/desc/linguas.desc for details.
|
| 40 |
for x in ${LANGSLONG}; do
|
| 41 |
IUSE="${IUSE} linguas_${x%_*}"
|
| 42 |
done
|
| 43 |
|
| 44 |
# @FUNCTION: qt4-r2_src_unpack
|
| 45 |
# @DESCRIPTION:
|
| 46 |
# 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
|
| 48 |
# qt4-r2_src_unpack in it.
|
| 49 |
qt4-r2_src_unpack() {
|
| 50 |
debug-print-function $FUNCNAME "$@"
|
| 51 |
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 |
}
|
| 60 |
|
| 61 |
# @ECLASS-VARIABLE: PATCHES
|
| 62 |
# @DESCRIPTION:
|
| 63 |
# 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.
|
| 65 |
# example:
|
| 66 |
# PATCHES=( "${FILESDIR}"/mypatch.patch
|
| 67 |
# "${FILESDIR}"/mypatch2.patch )
|
| 68 |
#
|
| 69 |
# @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 |
local project_file="$(_find_project_file)"
|
| 88 |
|
| 89 |
if [[ -n ${project_file} ]]; then
|
| 90 |
eqmake4 ${project_file}
|
| 91 |
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 |
# @DESCRIPTION:
|
| 109 |
# Use this variable if you want to install any documentation.
|
| 110 |
# example: DOCS="README AUTHORS"
|
| 111 |
#
|
| 112 |
# @ECLASS-VARIABLE: DOCSDIR
|
| 113 |
# @DESCRIPTION:
|
| 114 |
# Directory containing documentation. If not specified, ${S} will be used
|
| 115 |
# instead.
|
| 116 |
#
|
| 117 |
# @FUNCTION: qt4-r2_src_install
|
| 118 |
# @DESCRIPTION:
|
| 119 |
# Default src_install function for qt4-based packages. Installs compiled code,
|
| 120 |
# documentation (via DOCS variable) and translations (via LANGS and
|
| 121 |
# LANGSLONG variables).
|
| 122 |
qt4-r2_src_install() {
|
| 123 |
debug-print-function $FUNCNAME "$@"
|
| 124 |
|
| 125 |
emake INSTALL_ROOT="${D}" DESTDIR="${D}" install || die "emake install failed"
|
| 126 |
|
| 127 |
# install documentation
|
| 128 |
if [[ -n "${DOCS}" ]]; then
|
| 129 |
local dir=${DOCSDIR:-${S}}
|
| 130 |
for doc in ${DOCS}; do
|
| 131 |
dodoc "${dir}/${doc}" || die "dodoc failed"
|
| 132 |
done
|
| 133 |
fi
|
| 134 |
}
|
| 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 |
shopt -s nullglob
|
| 146 |
local pro_files=(*.pro)
|
| 147 |
shopt -u nullglob
|
| 148 |
local dir_name="$(basename ${S})"
|
| 149 |
|
| 150 |
case ${#pro_files[@]} in
|
| 151 |
1)
|
| 152 |
echo "${pro_files[0]}"
|
| 153 |
;;
|
| 154 |
*)
|
| 155 |
for pro_file in "${pro_files[@]}"; do
|
| 156 |
if [[ "${pro_file}" == "${dir_name}" ||
|
| 157 |
"${pro_file}" == "${PN}.pro" ]]; then
|
| 158 |
echo "${pro_file}"
|
| 159 |
break
|
| 160 |
fi
|
| 161 |
done
|
| 162 |
;;
|
| 163 |
esac
|
| 164 |
}
|
| 165 |
|
| 166 |
# @FUNCTION: eqmake4
|
| 167 |
# @USAGE: [project file] [parameters to qmake]
|
| 168 |
# @DESCRIPTION:
|
| 169 |
# Wrapper for Qt4's qmake. If project file isn't specified eqmake4 will
|
| 170 |
# look for it in current directory (${S}, non-recursively). If more than
|
| 171 |
# one project file is found, the ${PN}.pro is processed, provided that it
|
| 172 |
# exists. Otherwise eqmake4 fails.
|
| 173 |
# All the arguments are appended unmodified to qmake command line. For
|
| 174 |
# recursive build systems, i.e. those based on the subdirs template, you
|
| 175 |
# should run eqmake4 on the top-level project file only, unless you have
|
| 176 |
# strong reasons to do things differently. During the building, qmake
|
| 177 |
# will be automatically re-invoked with the right arguments on every
|
| 178 |
# directory specified inside the top-level project file by the SUBDIRS
|
| 179 |
# variable.
|
| 180 |
eqmake4() {
|
| 181 |
ebegin "Running qmake"
|
| 182 |
|
| 183 |
local qmake_args=("$@")
|
| 184 |
|
| 185 |
# check if project file was passed as a first argument
|
| 186 |
# if not, then search for it
|
| 187 |
local regexp='.*\.pro'
|
| 188 |
if ! [[ "${1}" =~ ${regexp} ]]; then
|
| 189 |
local project_file="$(_find_project_file)"
|
| 190 |
if [[ -z "${project_file}" ]]; then
|
| 191 |
echo
|
| 192 |
eerror "No project file found in ${S}!"
|
| 193 |
eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
|
| 194 |
echo
|
| 195 |
die "eqmake4 failed"
|
| 196 |
fi
|
| 197 |
qmake_args+=("${project_file}")
|
| 198 |
fi
|
| 199 |
|
| 200 |
# make sure CONFIG variable is correctly set for both release and debug builds
|
| 201 |
local CONFIG_ADD="release"
|
| 202 |
local CONFIG_REMOVE="debug"
|
| 203 |
if has debug ${IUSE} && use debug; then
|
| 204 |
CONFIG_ADD="debug"
|
| 205 |
CONFIG_REMOVE="release"
|
| 206 |
fi
|
| 207 |
local awkscript='BEGIN {
|
| 208 |
printf "### eqmake4 was here ###\n" > file;
|
| 209 |
fixed=0;
|
| 210 |
}
|
| 211 |
/^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
|
| 212 |
for (i=1; i <= NF; i++) {
|
| 213 |
if ($i ~ rem || $i ~ /debug_and_release/)
|
| 214 |
{ $i=add; fixed=1; }
|
| 215 |
}
|
| 216 |
}
|
| 217 |
/^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
|
| 218 |
for (i=1; i <= NF; i++) {
|
| 219 |
if ($i ~ add) { $i=rem; fixed=1; }
|
| 220 |
}
|
| 221 |
}
|
| 222 |
{
|
| 223 |
print >> file;
|
| 224 |
}
|
| 225 |
END {
|
| 226 |
printf "\nCONFIG -= debug_and_release %s\n", rem >> file;
|
| 227 |
printf "CONFIG += %s\n", add >> file;
|
| 228 |
print fixed;
|
| 229 |
}'
|
| 230 |
local file=
|
| 231 |
while read file; do
|
| 232 |
grep -q '^### eqmake4 was here ###$' "${file}" && continue
|
| 233 |
local retval=$({
|
| 234 |
rm -f "${file}" || echo "FAILED"
|
| 235 |
awk -v file="${file}" -- "${awkscript}" add=${CONFIG_ADD} rem=${CONFIG_REMOVE} || echo "FAILED"
|
| 236 |
} < "${file}")
|
| 237 |
if [[ ${retval} == 1 ]]; then
|
| 238 |
einfo " - fixed CONFIG in ${file}"
|
| 239 |
elif [[ ${retval} != 0 ]]; then
|
| 240 |
eerror "An error occurred while processing ${file}"
|
| 241 |
die "eqmake4 failed to process '${file}'"
|
| 242 |
fi
|
| 243 |
done < <(find . -type f -name "*.pr[io]" -printf '%P\n' 2>/dev/null)
|
| 244 |
|
| 245 |
[[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
|
| 246 |
|
| 247 |
"${EPREFIX}"/usr/bin/qmake \
|
| 248 |
-makefile -nocache \
|
| 249 |
-config ${CONFIG_ADD} \
|
| 250 |
QTDIR="${EPREFIX}"/usr/$(get_libdir) \
|
| 251 |
QMAKE="${EPREFIX}"/usr/bin/qmake \
|
| 252 |
QMAKE_CC="$(tc-getCC)" \
|
| 253 |
QMAKE_CXX="$(tc-getCXX)" \
|
| 254 |
QMAKE_LINK="$(tc-getCXX)" \
|
| 255 |
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 |
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 |
QMAKE_STRIP= \
|
| 265 |
"${qmake_args[@]}"
|
| 266 |
|
| 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
|