/[gentoo-x86]/eclass/wxwidgets.eclass
Gentoo

Diff of /eclass/wxwidgets.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.21 Revision 1.31
1# Copyright 1999-2007 Gentoo Foundation 1# Copyright 1999-2007 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.21 2007/10/18 03:25:56 dirtyepic Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.31 2011/07/17 19:58:39 dirtyepic Exp $
4 4
5# @ECLASS: wxwidgets.eclass 5# @ECLASS: wxwidgets.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# dirtyepic@gentoo.org
8# wxwindows@gentoo.org 7# wxwidgets@gentoo.org
9# @BLURB: Manages build configuration for wxGTK-using packages. 8# @BLURB: Manages build configuration for wxGTK-using packages.
10# @DESCRIPTION: 9# @DESCRIPTION:
11# The wxGTK libraries come in several different possible configurations 10# The wxGTK libraries come in several different possible configurations
12# (release/debug, ansi/unicode, etc.), most of which can be installed 11# (release, debug, ansi, unicode, etc.) most of which can be installed
13# side-by-side. The purpose of this eclass is to give ebuilds the ability to 12# side-by-side. The purpose of this eclass is to provide ebuilds the ability
14# specify what particular flavour they require to build against without 13# to build against a specific type of profile without interfering with the
15# interfering with the user-set system configuration. 14# user-set system configuration.
16# 15#
17# Ebuilds that use wxGTK must inherit this eclass. Otherwise the system 16# Ebuilds that use wxGTK _must_ inherit this eclass.
18# default will be used, which would be anything the user set it to.
19# 17#
20# Ebuilds are also required to set the global variable WX_GTK_VER, containing 18# - Using this eclass -
21# the wxGTK SLOT the ebuild requires. Note that in order for this to work,
22# WX_GTK_VER needs to be set before inheriting the eclass.
23# 19#
24# Simple Usage: 20# 1. set WX_GTK_VER to a valid wxGTK SLOT
21# 2. inherit wxwidgets
22# 3. add an appropriate DEPEND
23# 4. done
25# 24#
25# @CODE
26# WX_GTK_VER="2.6" 26# WX_GTK_VER="2.8"
27#
27# inherit wxwidgets 28# inherit wxwidgets
29#
28# DEPEND="=x11-libs/wxGTK-2.6*" 30# DEPEND="x11-libs/wxGTK:2.8[X]"
29# RDEPEND="=x11-libs/wxGTK-2.6*" 31# RDEPEND="${DEPEND}"
32# [...]
33# @CODE
30# 34#
31# That's it. The eclass will select a sane default configuration to use. In 35# This will get you the default configuration, which is what you want 99%
32# wxGTK-2.6 the default is ansi. In wxGTK-2.8 and later it's unicode. These 36# of the time (in 2.6 the default is "ansi", all other versions default to
33# are the defaults because they are always guaranteed to exist. 37# "unicode").
34# 38#
35# You'll often find yourself in need of a bit more control. For that see the 39# If your package has optional wxGTK support controlled by a USE flag or you
36# need-wxwidgets function below. 40# need to use the wxBase libraries (USE="-X") then you should not set
41# WX_GTK_VER before inherit and instead refer to the need-wxwidgets function
42# below.
43#
44# The variable WX_CONFIG is exported, containing the absolute path to the
45# wx-config file to use. Most configure scripts use this path if it's set in
46# the environment or accept --with-wx-config="${WX_CONFIG}".
37 47
38inherit eutils multilib 48inherit eutils multilib
49
50case "${EAPI:-0}" in
51 0|1)
52 EXPORT_FUNCTIONS pkg_setup
53 ;;
54 *)
55 ;;
56esac
39 57
40# We do this globally so ebuilds can get sane defaults just by inheriting. They 58# We do this globally so ebuilds can get sane defaults just by inheriting. They
41# can be overridden with need-wxwidgets later if need be. 59# can be overridden with need-wxwidgets later if need be.
42 60
61# ensure this only runs once
43if [[ -z ${WX_CONFIG} ]]; then 62if [[ -z ${WX_CONFIG} ]]; then
63 # and only if WX_GTK_VER is set before inherit
44 if [[ -n ${WX_GTK_VER} ]]; then 64 if [[ -n ${WX_GTK_VER} ]]; then
45 if [[ ${WX_GTK_VER} == 2.6 ]]; then 65 if [[ ${WX_GTK_VER} == 2.6 ]]; then
46 wxchar="ansi" 66 wxchar="ansi"
47 elif [[ ${WX_GTK_VER} == 2.8 ]]; then 67 else
48 wxchar="unicode" 68 wxchar="unicode"
49 fi 69 fi
50
51 for wxtoolkit in gtk2 base; do 70 for wxtoolkit in gtk2 base; do
71 # newer versions don't have a seperate debug profile
52 for wxdebug in release debug; do 72 for wxdebug in xxx release- debug-; do
53 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 73 wxconf="${wxtoolkit}-${wxchar}-${wxdebug/xxx/}${WX_GTK_VER}"
54 [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]] || continue 74 if [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
75 # if this is a wxBase install, die in pkg_setup
76 [[ ${wxtoolkit} == "base" ]] && WXBASE_DIE=1
77 else
78 continue
79 fi
55 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" 80 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
56 # TODO: needed for the wx-config wrapper
57 WX_ECLASS_CONFIG="${WX_CONFIG}" 81 WX_ECLASS_CONFIG="${WX_CONFIG}"
58 break 82 break
59 done 83 done
60 [[ -n ${WX_CONFIG} ]] && break 84 [[ -n ${WX_CONFIG} ]] && break
61 done 85 done
62 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG 86 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
63 fi 87 fi
64fi 88fi
65 89
90# @FUNCTION: wxwidgets_pkg_setup
91# @DESCRIPTION:
92#
93# It's possible for wxGTK to be installed with USE="-X", resulting in something
94# called wxBase. There's only ever been a couple packages in the tree that use
95# wxBase so this is probably not what you want. Whenever possible, use EAPI 2
96# USE dependencies(tm) to ensure that wxGTK was built with USE="X". This
97# function is only exported for EAPI 0 or 1 and catches any remaining cases.
98#
99# If you do use wxBase, don't set WX_GTK_VER before inherit. Use
100# need-wxwidgets() instead.
101
102wxwidgets_pkg_setup() {
103 [[ -n $WXBASE_DIE ]] && check_wxuse X
104}
66 105
67# @FUNCTION: need-wxwidgets 106# @FUNCTION: need-wxwidgets
68# @USAGE: <configuration> 107# @USAGE: <configuration>
69# @DESCRIPTION: 108# @DESCRIPTION:
70# need-wxwidgets is called with one argument, the wxGTK configuration to use.
71# 109#
72# Available configurations are: 110# Available configurations are:
73# 111#
74# ansi 112# [2.6] ansi [>=2.8] unicode
75# unicode 113# unicode base-unicode
76# base-ansi 114# base
77# base-unicode 115# base-unicode
78# 116#
79# Note that in >=wxGTK-2.8, only the unicode versions are available. The 117# If your package has optional wxGTK support controlled by a USE flag, set
80# eclass will automatically map ansi to unicode if WX_GTK_VER is set to 2.8 or 118# WX_GTK_VER inside a conditional rather than before inherit. Some broken
81# later. 119# configure scripts will force wxGTK on if they find ${WX_CONFIG} set.
82# 120#
83# There is one deprecated configuration, gtk2, that is equivalent to ansi. 121# @CODE
84# It is around for historical reasons and shouldn't be used by new ebuilds. 122# src_configure() {
123# if use wxwidgets; then
124# WX_GTK_VER="2.8"
125# if use X; then
126# need-wxwidgets unicode
127# else
128# need-wxwidgets base-unicode
129# fi
130# fi
131# @CODE
85# 132#
86# This function will set the variable WX_CONFIG to the path of the wx-config
87# script to use. In most cases you shouldn't have to use it since the
88# /usr/bin/wx-config wrapper points to ${WX_CONFIG} when called from portage.
89 133
90need-wxwidgets() { 134need-wxwidgets() {
91 debug-print-function $FUNCNAME $* 135 debug-print-function $FUNCNAME $*
92 136
93 local wxtoolkit wxchar wxdebug wxconf 137 local wxtoolkit wxchar wxdebug wxconf
97 eerror "WX_GTK_VER must be set before calling $FUNCNAME." 141 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
98 echo 142 echo
99 die "WX_GTK_VER missing" 143 die "WX_GTK_VER missing"
100 fi 144 fi
101 145
102 if [[ ${WX_GTK_VER} != 2.6 \ 146 if [[ ${WX_GTK_VER} != 2.6 && ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; then
103 && ${WX_GTK_VER} != 2.8 ]]; then
104 echo 147 echo
105 eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT." 148 eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT."
106 echo 149 echo
107 die "Invalid WX_GTK_VER" 150 die "Invalid WX_GTK_VER"
108 fi 151 fi
156 ;; 199 ;;
157 esac 200 esac
158 201
159 debug-print "wxchar is ${wxchar}" 202 debug-print "wxchar is ${wxchar}"
160 203
161 # since we're no longer in global scope we call built_with_use instead of 204 # TODO: remove built_with_use
162 # all the crazy looping
163 205
164 # base can be provided by both gtk2 and base installations 206 # wxBase can be provided by both gtk2 and base installations
165 if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X); then 207 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X; then
166 wxtoolkit="gtk2" 208 wxtoolkit="gtk2"
167 else 209 else
168 wxtoolkit="base" 210 wxtoolkit="base"
169 fi 211 fi
170 212
171 debug-print "wxtoolkit is ${wxtoolkit}" 213 debug-print "wxtoolkit is ${wxtoolkit}"
172 214
173 # debug or release? 215 # debug or release?
216 if [[ ${WX_GTK_VER} == 2.6 || ${WX_GTK_VER} == 2.8 ]]; then
174 if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug); then 217 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug; then
175 wxdebug="debug" 218 wxdebug="debug-"
176 else 219 else
177 wxdebug="release" 220 wxdebug="release-"
221 fi
178 fi 222 fi
179 223
180 debug-print "wxdebug is ${wxdebug}" 224 debug-print "wxdebug is ${wxdebug}"
181 225
182 # put it all together 226 # put it all together
183 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 227 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}${WX_GTK_VER}"
184 228
185 debug-print "wxconf is ${wxconf}" 229 debug-print "wxconf is ${wxconf}"
186 230
187 # if this doesn't work, something is seriously screwed 231 # if this doesn't work, something is seriously screwed
188 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then 232 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
192 die "Missing wx-config" 236 die "Missing wx-config"
193 fi 237 fi
194 238
195 debug-print "Found config ${wxconf} - setting WX_CONFIG" 239 debug-print "Found config ${wxconf} - setting WX_CONFIG"
196 240
197 # This is exported as some configure scripts will check for its presence in
198 # the environment.
199 export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" 241 export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
200 242
201 debug-print "WX_CONFIG is ${WX_CONFIG}" 243 debug-print "WX_CONFIG is ${WX_CONFIG}"
202 244
203 # TODO: Used by the wx-config wrapper
204 export WX_ECLASS_CONFIG="${WX_CONFIG}" 245 export WX_ECLASS_CONFIG="${WX_CONFIG}"
205 246
206 echo 247 echo
207 einfo "Requested: ${1} ${WX_GTK_VER}" 248 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
208 einfo "Using: ${wxconf}" 249 einfo "Using wxWidgets: ${wxconf}"
209 echo 250 echo
210} 251}
211 252
212 253
213# @FUNCTION: check_wxuse 254# @FUNCTION: check_wxuse
214# @USAGE: <USE flag> 255# @USAGE: <USE flag>
215# @DESCRIPTION: 256# @DESCRIPTION:
257#
216# Provides a consistant way to check if wxGTK was built with a particular USE 258# Provides a consistant way to check if wxGTK was built with a particular USE
217# flag enabled. 259# flag enabled. A better way is EAPI 2 USE dependencies (hint hint).
218 260
219check_wxuse() { 261check_wxuse() {
220 debug-print-function $FUNCNAME $* 262 debug-print-function $FUNCNAME $*
221 263
222 [[ -n ${WX_GTK_VER} ]] \ 264 if [[ -z ${WX_GTK_VER} ]]; then
265 echo
223 || _wxerror "WX_GTK_VER must be set before calling" 266 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
267 echo
268 die "WX_GTK_VER missing"
269 fi
224 270
271 # TODO: Remove built_with_use
225 272
226 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support" 273 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
227 if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"); then 274 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"; then
228 eend 0 275 eend 0
229 else 276 else
230 eend 1 277 eend 1
231 echo 278 echo
232 eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to" 279 eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to"

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.20