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

Diff of /eclass/wxwidgets.eclass

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

Revision 1.20 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.20 2007/10/14 02:46:29 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.
22# 19#
20# 1. set WX_GTK_VER to a valid wxGTK SLOT
21# 2. inherit wxwidgets
22# 3. add an appropriate DEPEND
23# 4. done
23# 24#
24# Simple Usage: 25# @CODE
26# WX_GTK_VER="2.8"
25# 27#
26# inherit wxwidgets 28# inherit wxwidgets
29#
27# DEPEND="=x11-libs/wxGTK-2.6*" 30# DEPEND="x11-libs/wxGTK:2.8[X]"
28# RDEPEND="=x11-libs/wxGTK-2.6*" 31# RDEPEND="${DEPEND}"
29# WX_GTK_VER="2.6" 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. (Note: we lock 37# "unicode").
34# the DEPEND to the needed SLOT to prevent another SLOT from fulfilling the
35# dependency.)
36# 38#
37# 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
38# 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}".
39 47
40inherit eutils multilib 48inherit eutils multilib
49
50case "${EAPI:-0}" in
51 0|1)
52 EXPORT_FUNCTIONS pkg_setup
53 ;;
54 *)
55 ;;
56esac
41 57
42# 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
43# can be overridden with need-wxwidgets later if need be. 59# can be overridden with need-wxwidgets later if need be.
44 60
61# ensure this only runs once
45if [[ -n ${WX_CONFIG} ]]; then 62if [[ -z ${WX_CONFIG} ]]; then
63 # and only if WX_GTK_VER is set before inherit
46 if [[ -n ${WX_GTK_VER} ]]; then 64 if [[ -n ${WX_GTK_VER} ]]; then
47 if [[ ${WX_GTK_VER} == 2.6 ]]; then 65 if [[ ${WX_GTK_VER} == 2.6 ]]; then
48 wxchar="ansi" 66 wxchar="ansi"
49 elif [[ ${WX_GTK_VER} == 2.8 ]]; then 67 else
50 wxchar="unicode" 68 wxchar="unicode"
51 fi 69 fi
52
53 for wxtoolkit in gtk2 base; do 70 for wxtoolkit in gtk2 base; do
71 # newer versions don't have a seperate debug profile
54 for wxdebug in release debug; do 72 for wxdebug in xxx release- debug-; do
55 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 73 wxconf="${wxtoolkit}-${wxchar}-${wxdebug/xxx/}${WX_GTK_VER}"
56 [[ -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
57 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" 80 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
58 # TODO: needed for the wx-config wrapper
59 WX_ECLASS_CONFIG="${WX_CONFIG}" 81 WX_ECLASS_CONFIG="${WX_CONFIG}"
60 break 82 break
61 done 83 done
62 [[ -n ${WX_CONFIG} ]] && break 84 [[ -n ${WX_CONFIG} ]] && break
63 done 85 done
64 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG 86 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
65 fi 87 fi
66fi 88fi
67 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}
68 105
69# @FUNCTION: need-wxwidgets 106# @FUNCTION: need-wxwidgets
70# @USAGE: <configuration> 107# @USAGE: <configuration>
71# @DESCRIPTION: 108# @DESCRIPTION:
72# need-wxwidgets is called with one argument, the wxGTK configuration to use.
73# 109#
74# Available configurations are: 110# Available configurations are:
75# 111#
76# ansi 112# [2.6] ansi [>=2.8] unicode
77# unicode 113# unicode base-unicode
78# base-ansi 114# base
79# base-unicode 115# base-unicode
80# 116#
81# 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
82# 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
83# later. 119# configure scripts will force wxGTK on if they find ${WX_CONFIG} set.
84# 120#
85# There is one deprecated configuration, gtk2, that is equivalent to ansi. 121# @CODE
86# 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
87# 132#
88# This function will set the variable WX_CONFIG to the path of the wx-config
89# script to use. In most cases you shouldn't have to use it since the
90# /usr/bin/wx-config wrapper points to ${WX_CONFIG} when called from portage.
91 133
92need-wxwidgets() { 134need-wxwidgets() {
93 debug-print-function $FUNCNAME $* 135 debug-print-function $FUNCNAME $*
94 136
95 local wxtoolkit wxchar wxdebug wxconf 137 local wxtoolkit wxchar wxdebug wxconf
99 eerror "WX_GTK_VER must be set before calling $FUNCNAME." 141 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
100 echo 142 echo
101 die "WX_GTK_VER missing" 143 die "WX_GTK_VER missing"
102 fi 144 fi
103 145
104 if [[ ${WX_GTK_VER} != 2.6 \ 146 if [[ ${WX_GTK_VER} != 2.6 && ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; then
105 && ${WX_GTK_VER} != 2.8 ]]; then
106 echo 147 echo
107 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."
108 echo 149 echo
109 die "Invalid WX_GTK_VER" 150 die "Invalid WX_GTK_VER"
110 fi 151 fi
158 ;; 199 ;;
159 esac 200 esac
160 201
161 debug-print "wxchar is ${wxchar}" 202 debug-print "wxchar is ${wxchar}"
162 203
163 # since we're no longer in global scope we call built_with_use instead of 204 # TODO: remove built_with_use
164 # all the crazy looping
165 205
166 # base can be provided by both gtk2 and base installations 206 # wxBase can be provided by both gtk2 and base installations
167 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
168 wxtoolkit="gtk2" 208 wxtoolkit="gtk2"
169 else 209 else
170 wxtoolkit="base" 210 wxtoolkit="base"
171 fi 211 fi
172 212
173 debug-print "wxtoolkit is ${wxtoolkit}" 213 debug-print "wxtoolkit is ${wxtoolkit}"
174 214
175 # debug or release? 215 # debug or release?
216 if [[ ${WX_GTK_VER} == 2.6 || ${WX_GTK_VER} == 2.8 ]]; then
176 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
177 wxdebug="debug" 218 wxdebug="debug-"
178 else 219 else
179 wxdebug="release" 220 wxdebug="release-"
221 fi
180 fi 222 fi
181 223
182 debug-print "wxdebug is ${wxdebug}" 224 debug-print "wxdebug is ${wxdebug}"
183 225
184 # put it all together 226 # put it all together
185 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 227 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}${WX_GTK_VER}"
186 228
187 debug-print "wxconf is ${wxconf}" 229 debug-print "wxconf is ${wxconf}"
188 230
189 # if this doesn't work, something is seriously screwed 231 # if this doesn't work, something is seriously screwed
190 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then 232 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
194 die "Missing wx-config" 236 die "Missing wx-config"
195 fi 237 fi
196 238
197 debug-print "Found config ${wxconf} - setting WX_CONFIG" 239 debug-print "Found config ${wxconf} - setting WX_CONFIG"
198 240
199 # This is exported as some configure scripts will check for its presence in
200 # the environment.
201 export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" 241 export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
202 242
203 debug-print "WX_CONFIG is ${WX_CONFIG}" 243 debug-print "WX_CONFIG is ${WX_CONFIG}"
204 244
205 # TODO: Used by the wx-config wrapper
206 export WX_ECLASS_CONFIG="${WX_CONFIG}" 245 export WX_ECLASS_CONFIG="${WX_CONFIG}"
207 246
208 echo 247 echo
209 einfo "Requested: ${1} ${WX_GTK_VER}" 248 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
210 einfo "Using: ${wxconf}" 249 einfo "Using wxWidgets: ${wxconf}"
211 echo 250 echo
212} 251}
213 252
214 253
215# @FUNCTION: check_wxuse 254# @FUNCTION: check_wxuse
216# @USAGE: <USE flag> 255# @USAGE: <USE flag>
217# @DESCRIPTION: 256# @DESCRIPTION:
257#
218# 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
219# flag enabled. 259# flag enabled. A better way is EAPI 2 USE dependencies (hint hint).
220 260
221check_wxuse() { 261check_wxuse() {
222 debug-print-function $FUNCNAME $* 262 debug-print-function $FUNCNAME $*
223 263
224 [[ -n ${WX_GTK_VER} ]] \ 264 if [[ -z ${WX_GTK_VER} ]]; then
265 echo
225 || _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
226 270
271 # TODO: Remove built_with_use
227 272
228 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support" 273 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
229 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
230 eend 0 275 eend 0
231 else 276 else
232 eend 1 277 eend 1
233 echo 278 echo
234 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.20  
changed lines
  Added in v.1.31

  ViewVC Help
Powered by ViewVC 1.1.20