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