| 1 |
dirtyepic |
1.19 |
# Copyright 1999-2007 Gentoo Foundation
|
| 2 |
pythonhead |
1.1 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
dirtyepic |
1.27 |
# $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.26 2008/11/26 06:49:34 dirtyepic Exp $
|
| 4 |
dirtyepic |
1.20 |
|
| 5 |
|
|
# @ECLASS: wxwidgets.eclass
|
| 6 |
|
|
# @MAINTAINER:
|
| 7 |
dirtyepic |
1.27 |
# wxwidgets@gentoo.org
|
| 8 |
dirtyepic |
1.20 |
# @BLURB: Manages build configuration for wxGTK-using packages.
|
| 9 |
|
|
# @DESCRIPTION:
|
| 10 |
|
|
# The wxGTK libraries come in several different possible configurations
|
| 11 |
dirtyepic |
1.26 |
# (release, debug, ansi, unicode, etc.) most of which can be installed
|
| 12 |
dirtyepic |
1.24 |
# side-by-side. The purpose of this eclass is to provide ebuilds the ability
|
| 13 |
dirtyepic |
1.26 |
# to build against a specific type of profile without interfering with the
|
| 14 |
|
|
# user-set system configuration.
|
| 15 |
dirtyepic |
1.20 |
#
|
| 16 |
dirtyepic |
1.26 |
# Ebuilds that use wxGTK _must_ inherit this eclass. Otherwise the system
|
| 17 |
|
|
# profile will be used, meaning whatever the user happened to set it to
|
| 18 |
|
|
# through eselect-wxwidgets.
|
| 19 |
dirtyepic |
1.20 |
#
|
| 20 |
dirtyepic |
1.24 |
# Ebuilds are also required to set the variable WX_GTK_VER, containing
|
| 21 |
dirtyepic |
1.26 |
# the wxGTK SLOT the ebuild requires.
|
| 22 |
dirtyepic |
1.20 |
#
|
| 23 |
|
|
# Simple Usage:
|
| 24 |
|
|
#
|
| 25 |
dirtyepic |
1.24 |
# @CODE
|
| 26 |
dirtyepic |
1.26 |
# WX_GTK_VER="2.8"
|
| 27 |
dirtyepic |
1.20 |
#
|
| 28 |
dirtyepic |
1.24 |
# inherit wxwidgets
|
| 29 |
|
|
#
|
| 30 |
dirtyepic |
1.26 |
# DEPEND="=x11-libs/wxGTK-2.8*" (or x11-libs/wxGTK:2.8 for >=EAPI 1)
|
| 31 |
dirtyepic |
1.24 |
# RDEPEND="${DEPEND}"
|
| 32 |
|
|
# [...]
|
| 33 |
|
|
# @CODE
|
| 34 |
|
|
#
|
| 35 |
dirtyepic |
1.26 |
# In this case the eclass will use the default configuration, which is the GTK
|
| 36 |
|
|
# libraries and either the "ansi" (in 2.6) or "unicode" (>=2.8) charsets.
|
| 37 |
dirtyepic |
1.24 |
#
|
| 38 |
dirtyepic |
1.26 |
# If you need more control over which profile(s) you need to use, see the
|
| 39 |
dirtyepic |
1.20 |
# need-wxwidgets function below.
|
| 40 |
|
|
|
| 41 |
|
|
inherit eutils multilib
|
| 42 |
pythonhead |
1.1 |
|
| 43 |
dirtyepic |
1.26 |
EXPORT_FUNCTIONS pkg_setup
|
| 44 |
|
|
|
| 45 |
dirtyepic |
1.20 |
# We do this globally so ebuilds can get sane defaults just by inheriting. They
|
| 46 |
|
|
# can be overridden with need-wxwidgets later if need be.
|
| 47 |
pythonhead |
1.1 |
|
| 48 |
dirtyepic |
1.21 |
if [[ -z ${WX_CONFIG} ]]; then
|
| 49 |
dirtyepic |
1.20 |
if [[ -n ${WX_GTK_VER} ]]; then
|
| 50 |
|
|
if [[ ${WX_GTK_VER} == 2.6 ]]; then
|
| 51 |
|
|
wxchar="ansi"
|
| 52 |
|
|
elif [[ ${WX_GTK_VER} == 2.8 ]]; then
|
| 53 |
|
|
wxchar="unicode"
|
| 54 |
|
|
fi
|
| 55 |
|
|
|
| 56 |
|
|
for wxtoolkit in gtk2 base; do
|
| 57 |
|
|
for wxdebug in release debug; do
|
| 58 |
|
|
wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}"
|
| 59 |
dirtyepic |
1.26 |
if [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
|
| 60 |
|
|
[[ $wxtoolkit == "base" ]] && WXBASE_DIE=1 # see wxwidgets_pkg_setup
|
| 61 |
|
|
else
|
| 62 |
|
|
continue
|
| 63 |
|
|
fi
|
| 64 |
dirtyepic |
1.20 |
WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
|
| 65 |
|
|
# TODO: needed for the wx-config wrapper
|
| 66 |
|
|
WX_ECLASS_CONFIG="${WX_CONFIG}"
|
| 67 |
|
|
break
|
| 68 |
|
|
done
|
| 69 |
|
|
[[ -n ${WX_CONFIG} ]] && break
|
| 70 |
|
|
done
|
| 71 |
|
|
[[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
|
| 72 |
|
|
fi
|
| 73 |
|
|
fi
|
| 74 |
pythonhead |
1.1 |
|
| 75 |
dirtyepic |
1.26 |
# @FUNCTION: wxwidgets_pkg_setup
|
| 76 |
|
|
# @DESCRIPTION:
|
| 77 |
|
|
#
|
| 78 |
|
|
# 99.99% of the time, packages building against wxGTK need the GTK libraries.
|
| 79 |
|
|
# When using the "Simple Usage" case above (WX_GTK_VER before inherit), we have
|
| 80 |
|
|
# to take into account that the user may have only installed the base libraries
|
| 81 |
|
|
# (with USE="-X"). Since we can't die in global scope we instead check for
|
| 82 |
|
|
# the presence of a base profile and then die here if found.
|
| 83 |
|
|
#
|
| 84 |
|
|
# If you do need to build against the wxBase libraries, you'll have to use
|
| 85 |
|
|
# need-wxwidgets to do so.
|
| 86 |
|
|
#
|
| 87 |
|
|
# Note that with an EAPI 2 ebuild you can just DEPEND on x11-libs/wxGTK:2.8[X]
|
| 88 |
|
|
# and ignore all this nonsense.
|
| 89 |
|
|
|
| 90 |
|
|
wxwidgets_pkg_setup() {
|
| 91 |
|
|
[[ -n $WXBASE_DIE ]] && check_wxuse X
|
| 92 |
|
|
}
|
| 93 |
dirtyepic |
1.20 |
|
| 94 |
|
|
# @FUNCTION: need-wxwidgets
|
| 95 |
|
|
# @USAGE: <configuration>
|
| 96 |
|
|
# @DESCRIPTION:
|
| 97 |
dirtyepic |
1.24 |
#
|
| 98 |
dirtyepic |
1.20 |
# need-wxwidgets is called with one argument, the wxGTK configuration to use.
|
| 99 |
|
|
#
|
| 100 |
|
|
# Available configurations are:
|
| 101 |
|
|
#
|
| 102 |
dirtyepic |
1.24 |
# ansi
|
| 103 |
|
|
# unicode
|
| 104 |
|
|
# base-ansi
|
| 105 |
|
|
# base-unicode
|
| 106 |
dirtyepic |
1.20 |
#
|
| 107 |
|
|
# Note that in >=wxGTK-2.8, only the unicode versions are available. The
|
| 108 |
dirtyepic |
1.24 |
# eclass will automatically map ansi to unicode for you if WX_GTK_VER is
|
| 109 |
|
|
# set to 2.8 or later.
|
| 110 |
dirtyepic |
1.20 |
#
|
| 111 |
dirtyepic |
1.24 |
# There is one deprecated configuration, "gtk2", which is equivalent to ansi.
|
| 112 |
|
|
# This is leftover from 2.4 when we had gtk1 and gtk2 builds and shouldn't
|
| 113 |
|
|
# be used by new ebuilds.
|
| 114 |
|
|
#
|
| 115 |
|
|
# This function will export the variable WX_CONFIG, containing the absolute
|
| 116 |
|
|
# path to the wx-config script to use. In most cases you shouldn't need to
|
| 117 |
|
|
# use it since the /usr/bin/wx-config wrapper will already point to that
|
| 118 |
|
|
# location when called from the eclass, but it's here if you do.
|
| 119 |
pythonhead |
1.1 |
|
| 120 |
|
|
need-wxwidgets() {
|
| 121 |
|
|
debug-print-function $FUNCNAME $*
|
| 122 |
|
|
|
| 123 |
dirtyepic |
1.20 |
local wxtoolkit wxchar wxdebug wxconf
|
| 124 |
|
|
|
| 125 |
|
|
if [[ -z ${WX_GTK_VER} ]]; then
|
| 126 |
|
|
echo
|
| 127 |
|
|
eerror "WX_GTK_VER must be set before calling $FUNCNAME."
|
| 128 |
|
|
echo
|
| 129 |
|
|
die "WX_GTK_VER missing"
|
| 130 |
pythonhead |
1.4 |
fi
|
| 131 |
pythonhead |
1.1 |
|
| 132 |
dirtyepic |
1.20 |
if [[ ${WX_GTK_VER} != 2.6 \
|
| 133 |
|
|
&& ${WX_GTK_VER} != 2.8 ]]; then
|
| 134 |
|
|
echo
|
| 135 |
|
|
eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT."
|
| 136 |
|
|
echo
|
| 137 |
|
|
die "Invalid WX_GTK_VER"
|
| 138 |
|
|
fi
|
| 139 |
pythonhead |
1.1 |
|
| 140 |
dirtyepic |
1.20 |
debug-print "WX_GTK_VER is ${WX_GTK_VER}"
|
| 141 |
pythonhead |
1.1 |
|
| 142 |
dirtyepic |
1.20 |
case $1 in
|
| 143 |
|
|
ansi)
|
| 144 |
|
|
debug-print-section ansi
|
| 145 |
|
|
if [[ ${WX_GTK_VER} == 2.6 ]]; then
|
| 146 |
|
|
wxchar="ansi"
|
| 147 |
|
|
else
|
| 148 |
|
|
wxchar="unicode"
|
| 149 |
|
|
fi
|
| 150 |
|
|
check_wxuse X
|
| 151 |
|
|
;;
|
| 152 |
|
|
unicode)
|
| 153 |
|
|
debug-print-section unicode
|
| 154 |
|
|
check_wxuse X
|
| 155 |
|
|
[[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode
|
| 156 |
|
|
wxchar="unicode"
|
| 157 |
|
|
;;
|
| 158 |
|
|
base)
|
| 159 |
|
|
debug-print-section base
|
| 160 |
|
|
if [[ ${WX_GTK_VER} == 2.6 ]]; then
|
| 161 |
|
|
wxchar="ansi"
|
| 162 |
|
|
else
|
| 163 |
|
|
wxchar="unicode"
|
| 164 |
|
|
fi
|
| 165 |
|
|
;;
|
| 166 |
|
|
base-unicode)
|
| 167 |
|
|
debug-print-section base-unicode
|
| 168 |
|
|
[[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode
|
| 169 |
|
|
wxchar="unicode"
|
| 170 |
|
|
;;
|
| 171 |
|
|
# backwards compatibility
|
| 172 |
|
|
gtk2)
|
| 173 |
|
|
debug-print-section gtk2
|
| 174 |
|
|
if [[ ${WX_GTK_VER} == 2.6 ]]; then
|
| 175 |
|
|
wxchar="ansi"
|
| 176 |
|
|
else
|
| 177 |
|
|
wxchar="unicode"
|
| 178 |
|
|
fi
|
| 179 |
|
|
check_wxuse X
|
| 180 |
|
|
;;
|
| 181 |
|
|
*)
|
| 182 |
|
|
echo
|
| 183 |
|
|
eerror "Invalid $FUNCNAME argument: $1"
|
| 184 |
|
|
echo
|
| 185 |
|
|
die "Invalid argument"
|
| 186 |
|
|
;;
|
| 187 |
|
|
esac
|
| 188 |
|
|
|
| 189 |
|
|
debug-print "wxchar is ${wxchar}"
|
| 190 |
|
|
|
| 191 |
|
|
# since we're no longer in global scope we call built_with_use instead of
|
| 192 |
|
|
# all the crazy looping
|
| 193 |
|
|
|
| 194 |
dirtyepic |
1.24 |
# wxBase can be provided by both gtk2 and base installations
|
| 195 |
swegener |
1.23 |
if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X; then
|
| 196 |
dirtyepic |
1.20 |
wxtoolkit="gtk2"
|
| 197 |
pythonhead |
1.4 |
else
|
| 198 |
dirtyepic |
1.20 |
wxtoolkit="base"
|
| 199 |
|
|
fi
|
| 200 |
|
|
|
| 201 |
|
|
debug-print "wxtoolkit is ${wxtoolkit}"
|
| 202 |
|
|
|
| 203 |
|
|
# debug or release?
|
| 204 |
swegener |
1.23 |
if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug; then
|
| 205 |
dirtyepic |
1.20 |
wxdebug="debug"
|
| 206 |
pythonhead |
1.1 |
else
|
| 207 |
dirtyepic |
1.20 |
wxdebug="release"
|
| 208 |
|
|
fi
|
| 209 |
|
|
|
| 210 |
|
|
debug-print "wxdebug is ${wxdebug}"
|
| 211 |
|
|
|
| 212 |
|
|
# put it all together
|
| 213 |
|
|
wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}"
|
| 214 |
|
|
|
| 215 |
|
|
debug-print "wxconf is ${wxconf}"
|
| 216 |
|
|
|
| 217 |
|
|
# if this doesn't work, something is seriously screwed
|
| 218 |
|
|
if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
|
| 219 |
|
|
echo
|
| 220 |
|
|
eerror "Failed to find configuration ${wxconf}"
|
| 221 |
|
|
echo
|
| 222 |
|
|
die "Missing wx-config"
|
| 223 |
pythonhead |
1.1 |
fi
|
| 224 |
dirtyepic |
1.20 |
|
| 225 |
|
|
debug-print "Found config ${wxconf} - setting WX_CONFIG"
|
| 226 |
|
|
|
| 227 |
|
|
export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
|
| 228 |
|
|
|
| 229 |
|
|
debug-print "WX_CONFIG is ${WX_CONFIG}"
|
| 230 |
|
|
|
| 231 |
|
|
export WX_ECLASS_CONFIG="${WX_CONFIG}"
|
| 232 |
|
|
|
| 233 |
|
|
echo
|
| 234 |
dirtyepic |
1.22 |
einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
|
| 235 |
|
|
einfo "Using wxWidgets: ${wxconf}"
|
| 236 |
dirtyepic |
1.20 |
echo
|
| 237 |
pythonhead |
1.1 |
}
|
| 238 |
|
|
|
| 239 |
dirtyepic |
1.20 |
|
| 240 |
|
|
# @FUNCTION: check_wxuse
|
| 241 |
|
|
# @USAGE: <USE flag>
|
| 242 |
|
|
# @DESCRIPTION:
|
| 243 |
dirtyepic |
1.24 |
#
|
| 244 |
dirtyepic |
1.20 |
# Provides a consistant way to check if wxGTK was built with a particular USE
|
| 245 |
|
|
# flag enabled.
|
| 246 |
|
|
|
| 247 |
dirtyepic |
1.19 |
check_wxuse() {
|
| 248 |
dirtyepic |
1.20 |
debug-print-function $FUNCNAME $*
|
| 249 |
|
|
|
| 250 |
leio |
1.25 |
if [[ -z ${WX_GTK_VER} ]]; then
|
| 251 |
|
|
echo
|
| 252 |
|
|
eerror "WX_GTK_VER must be set before calling $FUNCNAME."
|
| 253 |
|
|
echo
|
| 254 |
|
|
die "WX_GTK_VER missing"
|
| 255 |
|
|
fi
|
| 256 |
dirtyepic |
1.19 |
|
| 257 |
|
|
ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
|
| 258 |
swegener |
1.23 |
if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"; then
|
| 259 |
dirtyepic |
1.19 |
eend 0
|
| 260 |
|
|
else
|
| 261 |
|
|
eend 1
|
| 262 |
|
|
echo
|
| 263 |
|
|
eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to"
|
| 264 |
|
|
eerror "have been built into x11-libs/wxGTK."
|
| 265 |
|
|
eerror
|
| 266 |
|
|
eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled."
|
| 267 |
|
|
die "Missing USE flags."
|
| 268 |
|
|
fi
|
| 269 |
|
|
}
|