| 1 |
hwoarang |
1.54 |
# Copyright 2005-2009 Gentoo Foundation
|
| 2 |
caleb |
1.1 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
hwoarang |
1.56 |
# $Header: /var/cvsroot/gentoo-x86/eclass/qt4.eclass,v 1.55 2009/05/12 10:35:32 hwoarang Exp $
|
| 4 |
troll |
1.29 |
|
| 5 |
|
|
# @ECLASS: qt4.eclass
|
| 6 |
|
|
# @MAINTAINER:
|
| 7 |
yngwin |
1.51 |
# Ben de Groot <yngwin@gentoo.org>,
|
| 8 |
|
|
# Markos Chandras <hwoarang@gentoo.org>,
|
| 9 |
|
|
# Caleb Tennis <caleb@gentoo.org>,
|
| 10 |
|
|
# Przemyslaw Maciag <troll@gentoo.org>,
|
| 11 |
|
|
# Davide Pesavento <davidepesa@gmail.com>
|
| 12 |
ingmar |
1.38 |
# @BLURB: Eclass for Qt4 packages
|
| 13 |
troll |
1.29 |
# @DESCRIPTION:
|
| 14 |
|
|
# This eclass contains various functions that may be useful
|
| 15 |
|
|
# when dealing with packages using Qt4 libraries.
|
| 16 |
|
|
|
| 17 |
yngwin |
1.51 |
inherit base eutils multilib toolchain-funcs versionator
|
| 18 |
caleb |
1.16 |
|
| 19 |
hwoarang |
1.56 |
export XDG_CONFIG_HOME="${T}"
|
| 20 |
|
|
|
| 21 |
zlin |
1.44 |
qt4_monolithic_to_split_flag() {
|
| 22 |
|
|
case ${1} in
|
| 23 |
|
|
zlib)
|
| 24 |
|
|
# Qt 4.4+ is always built with zlib enabled, so this flag isn't needed
|
| 25 |
|
|
;;
|
| 26 |
|
|
gif|jpeg|png)
|
| 27 |
|
|
# qt-gui always installs with these enabled
|
| 28 |
|
|
checkpkgs+=" x11-libs/qt-gui"
|
| 29 |
|
|
;;
|
| 30 |
|
|
dbus|opengl)
|
| 31 |
|
|
# Make sure the qt-${1} package has been installed already
|
| 32 |
|
|
checkpkgs+=" x11-libs/qt-${1}"
|
| 33 |
|
|
;;
|
| 34 |
|
|
qt3support)
|
| 35 |
|
|
checkpkgs+=" x11-libs/qt-${1}"
|
| 36 |
|
|
checkflags+=" x11-libs/qt-core:${1} x11-libs/qt-gui:${1} x11-libs/qt-sql:${1}"
|
| 37 |
|
|
;;
|
| 38 |
|
|
ssl)
|
| 39 |
|
|
# qt-core controls this flag
|
| 40 |
|
|
checkflags+=" x11-libs/qt-core:${1}"
|
| 41 |
|
|
;;
|
| 42 |
|
|
cups|mng|nas|nis|tiff|xinerama|input_devices_wacom)
|
| 43 |
|
|
# qt-gui controls these flags
|
| 44 |
|
|
checkflags+=" x11-libs/qt-gui:${1}"
|
| 45 |
|
|
;;
|
| 46 |
|
|
firebird|mysql|odbc|postgres|sqlite3)
|
| 47 |
|
|
# qt-sql controls these flags. sqlite2 is no longer supported so it uses sqlite instead of sqlite3.
|
| 48 |
|
|
checkflags+=" x11-libs/qt-sql:${1%3}"
|
| 49 |
|
|
;;
|
| 50 |
|
|
accessibility)
|
| 51 |
|
|
eerror "(QA message): Use guiaccessibility and/or qt3accessibility to specify which of qt-gui and qt-qt3support are relevant for this package."
|
| 52 |
|
|
# deal with this gracefully by checking the flag for what is available
|
| 53 |
|
|
for y in gui qt3support; do
|
| 54 |
|
|
has_version x11-libs/qt-${y} && checkflags+=" x11-libs/qt-${y}:${1}"
|
| 55 |
|
|
done
|
| 56 |
|
|
;;
|
| 57 |
|
|
guiaccessibility)
|
| 58 |
|
|
checkflags+=" x11-libs/qt-gui:accessibility"
|
| 59 |
|
|
;;
|
| 60 |
|
|
qt3accessibility)
|
| 61 |
|
|
checkflags+=" x11-libs/qt-qt3support:accessibility"
|
| 62 |
|
|
;;
|
| 63 |
|
|
debug|doc|examples|glib|pch|sqlite|*)
|
| 64 |
|
|
# packages probably shouldn't be checking these flags so we don't handle them currently
|
| 65 |
|
|
eerror "qt4.eclass currently doesn't handle the use flag ${1} in QT4_BUILT_WITH_USE_CHECK for qt-4.4. This is either an"
|
| 66 |
|
|
eerror "eclass bug or an ebuild bug. Please report it at http://bugs.gentoo.org/"
|
| 67 |
|
|
((fatalerrors+=1))
|
| 68 |
|
|
;;
|
| 69 |
|
|
esac
|
| 70 |
|
|
}
|
| 71 |
|
|
|
| 72 |
troll |
1.29 |
# @FUNCTION: qt4_pkg_setup
|
| 73 |
|
|
# @DESCRIPTION:
|
| 74 |
|
|
# Default pkg_setup function for packages that depends on qt4. If you have to
|
| 75 |
|
|
# create ebuilds own pkg_setup in your ebuild, call qt4_pkg_setup in it.
|
| 76 |
|
|
# This function uses two global vars from ebuild:
|
| 77 |
|
|
# - QT4_BUILT_WITH_USE_CHECK - contains use flags that need to be turned on for
|
| 78 |
|
|
# =x11-libs/qt-4*
|
| 79 |
|
|
# - QT4_OPTIONAL_BUILT_WITH_USE_CHECK - qt4 flags that provides some
|
| 80 |
|
|
# functionality, but can alternatively be disabled in ${CATEGORY}/${PN}
|
| 81 |
|
|
# (so qt4 don't have to be recompiled)
|
| 82 |
caleb |
1.31 |
#
|
| 83 |
yngwin |
1.51 |
# NOTE: Using the above vars is now deprecated in favor of eapi-2 use deps
|
| 84 |
|
|
#
|
| 85 |
caleb |
1.31 |
# flags to watch for for Qt4.4:
|
| 86 |
|
|
# zlib png | opengl dbus qt3support | sqlite3 ssl
|
| 87 |
caleb |
1.16 |
qt4_pkg_setup() {
|
| 88 |
zlin |
1.44 |
local x y checkpkgs checkflags fatalerrors=0 requiredflags=""
|
| 89 |
caleb |
1.31 |
|
| 90 |
zlin |
1.44 |
# lots of has_version calls can be very expensive
|
| 91 |
|
|
if [[ -n ${QT4_BUILT_WITH_USE_CHECK}${QT4_OPTIONAL_BUILT_WITH_USE_CHECK} ]]; then
|
| 92 |
yngwin |
1.51 |
ewarn "QA notice: The QT4_BUILT_WITH_USE functionality is deprecated and"
|
| 93 |
|
|
ewarn "will be removed from future versions of qt4.eclass. Please update"
|
| 94 |
|
|
ewarn "the ebuild to use eapi-2 use dependencies instead."
|
| 95 |
zlin |
1.44 |
has_version x11-libs/qt-core && local QT44=true
|
| 96 |
|
|
fi
|
| 97 |
caleb |
1.31 |
|
| 98 |
caleb |
1.20 |
for x in ${QT4_BUILT_WITH_USE_CHECK}; do
|
| 99 |
zlin |
1.44 |
if [[ -n ${QT44} ]]; then
|
| 100 |
|
|
# The use flags are different in 4.4 and above, and it's split packages, so this is used to catch
|
| 101 |
|
|
# the various use flag combos specified in the ebuilds to make sure we don't error out for no reason.
|
| 102 |
|
|
qt4_monolithic_to_split_flag ${x}
|
| 103 |
gentoofan23 |
1.42 |
else
|
| 104 |
zlin |
1.44 |
[[ ${x} == *accessibility ]] && x=${x#gui} && x=${x#qt3}
|
| 105 |
gentoofan23 |
1.42 |
if ! built_with_use =x11-libs/qt-4* ${x}; then
|
| 106 |
|
|
requiredflags="${requiredflags} ${x}"
|
| 107 |
caleb |
1.31 |
fi
|
| 108 |
troll |
1.29 |
fi
|
| 109 |
|
|
done
|
| 110 |
|
|
|
| 111 |
|
|
local optionalflags=""
|
| 112 |
|
|
for x in ${QT4_OPTIONAL_BUILT_WITH_USE_CHECK}; do
|
| 113 |
zlin |
1.44 |
if use ${x}; then
|
| 114 |
|
|
if [[ -n ${QT44} ]]; then
|
| 115 |
|
|
# The use flags are different in 4.4 and above, and it's split packages, so this is used to catch
|
| 116 |
|
|
# the various use flag combos specified in the ebuilds to make sure we don't error out for no reason.
|
| 117 |
|
|
qt4_monolithic_to_split_flag ${x}
|
| 118 |
|
|
elif ! built_with_use =x11-libs/qt-4* ${x}; then
|
| 119 |
|
|
optionalflags="${optionalflags} ${x}"
|
| 120 |
|
|
fi
|
| 121 |
|
|
fi
|
| 122 |
|
|
done
|
| 123 |
|
|
|
| 124 |
|
|
# The use flags are different in 4.4 and above, and it's split packages, so this is used to catch
|
| 125 |
|
|
# the various use flag combos specified in the ebuilds to make sure we don't error out for no reason.
|
| 126 |
|
|
for y in ${checkpkgs}; do
|
| 127 |
|
|
if ! has_version ${y}; then
|
| 128 |
|
|
eerror "You must first install the ${y} package. It should be added to the dependencies for this package (${CATEGORY}/${PN}). See bug #217161."
|
| 129 |
|
|
((fatalerrors+=1))
|
| 130 |
|
|
fi
|
| 131 |
|
|
done
|
| 132 |
|
|
for y in ${checkflags}; do
|
| 133 |
|
|
if ! has_version ${y%:*}; then
|
| 134 |
|
|
eerror "You must first install the ${y%:*} package with the ${y##*:} flag enabled."
|
| 135 |
|
|
eerror "It should be added to the dependencies for this package (${CATEGORY}/${PN}). See bug #217161."
|
| 136 |
|
|
((fatalerrors+=1))
|
| 137 |
|
|
else
|
| 138 |
|
|
if ! built_with_use ${y%:*} ${y##*:}; then
|
| 139 |
|
|
eerror "You must first install the ${y%:*} package with the ${y##*:} flag enabled."
|
| 140 |
|
|
((fatalerrors+=1))
|
| 141 |
|
|
fi
|
| 142 |
caleb |
1.16 |
fi
|
| 143 |
|
|
done
|
| 144 |
troll |
1.29 |
|
| 145 |
|
|
local diemessage=""
|
| 146 |
zlin |
1.44 |
if [[ ${fatalerrors} -ne 0 ]]; then
|
| 147 |
|
|
diemessage="${fatalerrors} fatal errors were detected. Please read the above error messages and act accordingly."
|
| 148 |
|
|
fi
|
| 149 |
|
|
if [[ -n ${requiredflags} ]]; then
|
| 150 |
troll |
1.29 |
eerror
|
| 151 |
|
|
eerror "(1) In order to compile ${CATEGORY}/${PN} first you need to build"
|
| 152 |
|
|
eerror "=x11-libs/qt-4* with USE=\"${requiredflags}\" flag(s)"
|
| 153 |
|
|
eerror
|
| 154 |
|
|
diemessage="(1) recompile qt4 with \"${requiredflags}\" USE flag(s) ; "
|
| 155 |
|
|
fi
|
| 156 |
zlin |
1.44 |
if [[ -n ${optionalflags} ]]; then
|
| 157 |
troll |
1.29 |
eerror
|
| 158 |
|
|
eerror "(2) You are trying to compile ${CATEGORY}/${PN} package with"
|
| 159 |
|
|
eerror "USE=\"${optionalflags}\""
|
| 160 |
|
|
eerror "while qt4 is built without this particular flag(s): it will"
|
| 161 |
|
|
eerror "not work."
|
| 162 |
|
|
eerror
|
| 163 |
|
|
eerror "Possible solutions to this problem are:"
|
| 164 |
|
|
eerror "a) install package ${CATEGORY}/${PN} without \"${optionalflags}\" USE flag(s)"
|
| 165 |
|
|
eerror "b) re-emerge qt4 with \"${optionalflags}\" USE flag(s)"
|
| 166 |
|
|
eerror
|
| 167 |
|
|
diemessage="${diemessage}(2) recompile qt4 with \"${optionalflags}\" USE flag(s) or disable them for ${PN} package\n"
|
| 168 |
|
|
fi
|
| 169 |
|
|
|
| 170 |
zlin |
1.44 |
[[ -n ${diemessage} ]] && die "can't install ${CATEGORY}/${PN}: ${diemessage}"
|
| 171 |
caleb |
1.16 |
}
|
| 172 |
caleb |
1.20 |
|
| 173 |
yngwin |
1.51 |
# @ECLASS-VARIABLE: PATCHES
|
| 174 |
|
|
# @DESCRIPTION:
|
| 175 |
|
|
# In case you have patches to apply, specify them in the PATCHES variable.
|
| 176 |
|
|
# Make sure to specify the full path. This variable is necessary for the
|
| 177 |
|
|
# src_prepare phase.
|
| 178 |
|
|
# example:
|
| 179 |
|
|
# PATCHES="${FILESDIR}/mypatch.patch
|
| 180 |
|
|
# ${FILESDIR}/mypatch2.patch"
|
| 181 |
|
|
#
|
| 182 |
|
|
# @FUNCTION: qt4_src_prepare
|
| 183 |
|
|
# @DESCRIPTION:
|
| 184 |
|
|
# Default src_prepare function for packages that depend on qt4. If you have to
|
| 185 |
|
|
# override src_prepare in your ebuild, you should call qt4_src_prepare in it,
|
| 186 |
|
|
# otherwise autopatcher will not work!
|
| 187 |
|
|
qt4_src_prepare() {
|
| 188 |
|
|
debug-print-function $FUNCNAME "$@"
|
| 189 |
|
|
base_src_prepare
|
| 190 |
|
|
}
|
| 191 |
|
|
|
| 192 |
|
|
# @FUNCTION: qt4_src_configure
|
| 193 |
|
|
# @DESCRIPTION:
|
| 194 |
|
|
# Default src_configure function for packages that depend on qt4. If you have to
|
| 195 |
|
|
# override src_configure in your ebuild, call qt4_src_configure in it.
|
| 196 |
yngwin |
1.52 |
#qt4_src_configure() {
|
| 197 |
|
|
# debug-print-function $FUNCNAME "$@"
|
| 198 |
|
|
# eqmake4
|
| 199 |
|
|
#}
|
| 200 |
yngwin |
1.51 |
|
| 201 |
|
|
# @FUNCTION: qt4_src_compile
|
| 202 |
|
|
# @DESCRIPTION:
|
| 203 |
|
|
# Default src_compile function for packages that depend on qt4. If you have to
|
| 204 |
|
|
# override src_compile in your ebuild (probably you don't need to), call
|
| 205 |
|
|
# qt4_src_compile in it.
|
| 206 |
yngwin |
1.52 |
#qt4_src_compile() {
|
| 207 |
|
|
# debug-print-function $FUNCNAME "$@"
|
| 208 |
|
|
# case "${EAPI:-0}" in
|
| 209 |
|
|
# 2)
|
| 210 |
|
|
# emake || die "emake failed"
|
| 211 |
|
|
# ;;
|
| 212 |
|
|
# 0|1)
|
| 213 |
|
|
# qt4_src_prepare
|
| 214 |
|
|
# qt4_src_configure
|
| 215 |
|
|
# emake || die "emake failed"
|
| 216 |
|
|
# ;;
|
| 217 |
|
|
# esac
|
| 218 |
|
|
#}
|
| 219 |
yngwin |
1.51 |
|
| 220 |
troll |
1.29 |
# @FUNCTION: eqmake4
|
| 221 |
|
|
# @USAGE: [.pro file] [additional parameters to qmake]
|
| 222 |
|
|
# @DESCRIPTION:
|
| 223 |
hwoarang |
1.53 |
# Runs qmake on the specified .pro file (defaults to ${PN}.pro if called
|
| 224 |
|
|
# without arguments). Additional parameters are appended unmodified to
|
| 225 |
|
|
# qmake command line. For recursive build systems, i.e. those based on
|
| 226 |
|
|
# the subdirs template, you should run eqmake4 on the top-level project
|
| 227 |
|
|
# file only, unless you have strong reasons to do things differently.
|
| 228 |
|
|
# During the building, qmake will be automatically re-invoked with the
|
| 229 |
|
|
# right arguments on every directory specified inside the top-level
|
| 230 |
|
|
# project file by the SUBDIRS variable.
|
| 231 |
caleb |
1.20 |
eqmake4() {
|
| 232 |
hwoarang |
1.53 |
local projectfile="${1:-${PN}.pro}"
|
| 233 |
|
|
shift
|
| 234 |
caleb |
1.20 |
|
| 235 |
hwoarang |
1.53 |
if [[ ! -f ${projectfile} ]]; then
|
| 236 |
caleb |
1.20 |
echo
|
| 237 |
hwoarang |
1.53 |
eerror "Project file '${projectfile#${WORKDIR}/}' does not exists!"
|
| 238 |
|
|
eerror "eqmake4 cannot handle non-existing project files."
|
| 239 |
|
|
eerror
|
| 240 |
|
|
eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
|
| 241 |
caleb |
1.20 |
echo
|
| 242 |
hwoarang |
1.53 |
die "Project file not found in ${CATEGORY}/${PN} sources."
|
| 243 |
caleb |
1.20 |
fi
|
| 244 |
|
|
|
| 245 |
hwoarang |
1.53 |
ebegin "Running qmake on ${projectfile}"
|
| 246 |
caleb |
1.20 |
|
| 247 |
hwoarang |
1.53 |
# make sure CONFIG variable is correctly set for both release and debug builds
|
| 248 |
|
|
local CONFIG_ADD="release"
|
| 249 |
|
|
local CONFIG_REMOVE="debug"
|
| 250 |
caleb |
1.22 |
if has debug ${IUSE} && use debug; then
|
| 251 |
hwoarang |
1.53 |
CONFIG_ADD="debug"
|
| 252 |
|
|
CONFIG_REMOVE="release"
|
| 253 |
caleb |
1.20 |
fi
|
| 254 |
hwoarang |
1.53 |
local awkscript='BEGIN {
|
| 255 |
|
|
printf "### eqmake4 was here ###\n" > file;
|
| 256 |
|
|
fixed=0;
|
| 257 |
|
|
}
|
| 258 |
|
|
/^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
|
| 259 |
|
|
for (i=1; i <= NF; i++) {
|
| 260 |
|
|
if ($i ~ rem || $i ~ /debug_and_release/)
|
| 261 |
|
|
{ $i=add; fixed=1; }
|
| 262 |
|
|
}
|
| 263 |
|
|
}
|
| 264 |
|
|
/^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
|
| 265 |
|
|
for (i=1; i <= NF; i++) {
|
| 266 |
|
|
if ($i ~ add) { $i=rem; fixed=1; }
|
| 267 |
|
|
}
|
| 268 |
|
|
}
|
| 269 |
|
|
{
|
| 270 |
|
|
print >> file;
|
| 271 |
|
|
}
|
| 272 |
|
|
END {
|
| 273 |
|
|
printf "CONFIG -= debug_and_release %s\n", rem >> file;
|
| 274 |
|
|
printf "CONFIG += %s\n", add >> file;
|
| 275 |
|
|
print fixed;
|
| 276 |
|
|
}'
|
| 277 |
hwoarang |
1.55 |
local filepath=
|
| 278 |
|
|
while read filepath; do
|
| 279 |
|
|
local file="${filepath#./}"
|
| 280 |
hwoarang |
1.53 |
grep -q '^### eqmake4 was here ###$' "${file}" && continue
|
| 281 |
|
|
local retval=$({
|
| 282 |
|
|
rm -f "${file}" || echo "FAILED"
|
| 283 |
|
|
awk -v file="${file}" -- "${awkscript}" add=${CONFIG_ADD} rem=${CONFIG_REMOVE} || echo "FAILED"
|
| 284 |
|
|
} < "${file}")
|
| 285 |
|
|
if [[ ${retval} == 1 ]]; then
|
| 286 |
|
|
einfo " Fixed CONFIG in ${file}"
|
| 287 |
|
|
elif [[ ${retval} != 0 ]]; then
|
| 288 |
|
|
eerror " An error occurred while processing ${file}"
|
| 289 |
|
|
die "eqmake4 failed to process '${file}'."
|
| 290 |
|
|
fi
|
| 291 |
hwoarang |
1.55 |
done < <(find "$(dirname "${projectfile}")" -type f -name "*.pr[io]" 2>/dev/null)
|
| 292 |
caleb |
1.20 |
|
| 293 |
hwoarang |
1.53 |
/usr/bin/qmake -makefile -nocache \
|
| 294 |
caleb |
1.20 |
QTDIR=/usr/$(get_libdir) \
|
| 295 |
|
|
QMAKE=/usr/bin/qmake \
|
| 296 |
|
|
QMAKE_CC=$(tc-getCC) \
|
| 297 |
|
|
QMAKE_CXX=$(tc-getCXX) \
|
| 298 |
|
|
QMAKE_LINK=$(tc-getCXX) \
|
| 299 |
|
|
QMAKE_CFLAGS_RELEASE="${CFLAGS}" \
|
| 300 |
|
|
QMAKE_CFLAGS_DEBUG="${CFLAGS}" \
|
| 301 |
|
|
QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \
|
| 302 |
|
|
QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \
|
| 303 |
|
|
QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \
|
| 304 |
|
|
QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \
|
| 305 |
|
|
QMAKE_RPATH= \
|
| 306 |
hwoarang |
1.50 |
QMAKE_STRIP= \
|
| 307 |
hwoarang |
1.53 |
"${projectfile}" "${@}"
|
| 308 |
caleb |
1.20 |
|
| 309 |
hwoarang |
1.53 |
eend $?
|
| 310 |
caleb |
1.20 |
|
| 311 |
|
|
# was qmake successful?
|
| 312 |
hwoarang |
1.53 |
if [[ $? -ne 0 ]]; then
|
| 313 |
caleb |
1.20 |
echo
|
| 314 |
hwoarang |
1.53 |
eerror "Running qmake on '${projectfile#${WORKDIR}/}' has failed!"
|
| 315 |
|
|
eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
|
| 316 |
caleb |
1.20 |
echo
|
| 317 |
hwoarang |
1.53 |
die "qmake failed on '${projectfile}'."
|
| 318 |
caleb |
1.20 |
fi
|
| 319 |
|
|
|
| 320 |
hwoarang |
1.53 |
return 0
|
| 321 |
caleb |
1.20 |
}
|
| 322 |
|
|
|
| 323 |
yngwin |
1.51 |
case ${EAPI:-0} in
|
| 324 |
|
|
2)
|
| 325 |
yngwin |
1.52 |
EXPORT_FUNCTIONS pkg_setup src_prepare
|
| 326 |
yngwin |
1.51 |
;;
|
| 327 |
|
|
0|1)
|
| 328 |
yngwin |
1.52 |
EXPORT_FUNCTIONS pkg_setup
|
| 329 |
yngwin |
1.51 |
;;
|
| 330 |
|
|
esac
|