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

Diff of /eclass/wxwidgets.eclass

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

Revision 1.28 Revision 1.29
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.28 2009/09/07 00:29:47 dirtyepic Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.29 2010/02/16 01:06:24 dirtyepic Exp $
4 4
5# @ECLASS: wxwidgets.eclass 5# @ECLASS: wxwidgets.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# wxwidgets@gentoo.org 7# wxwidgets@gentoo.org
8# @BLURB: Manages build configuration for wxGTK-using packages. 8# @BLURB: Manages build configuration for wxGTK-using packages.
11# (release, debug, ansi, unicode, etc.) most of which can be installed 11# (release, debug, ansi, unicode, etc.) most of which can be installed
12# side-by-side. The purpose of this eclass is to provide ebuilds the ability 12# side-by-side. The purpose of this eclass is to provide ebuilds the ability
13# to build against a specific type of profile without interfering with the 13# to build against a specific type of profile without interfering with the
14# user-set system configuration. 14# user-set system configuration.
15# 15#
16# Ebuilds that use wxGTK _must_ inherit this eclass. Otherwise the system 16# Ebuilds that use wxGTK _must_ inherit this eclass.
17# profile will be used, meaning whatever the user happened to set it to
18# through eselect-wxwidgets.
19# 17#
20# Ebuilds are also required to set the variable WX_GTK_VER, containing 18# - Using this eclass -
21# the wxGTK SLOT the ebuild requires.
22# 19#
23# 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
24# 24#
25# @CODE 25# @CODE
26# WX_GTK_VER="2.8" 26# WX_GTK_VER="2.8"
27# 27#
28# inherit wxwidgets 28# inherit wxwidgets
29# 29#
30# DEPEND="=x11-libs/wxGTK-2.8*" (or x11-libs/wxGTK:2.8 for >=EAPI 1) 30# DEPEND="x11-libs/wxGTK:2.8[X]"
31# RDEPEND="${DEPEND}" 31# RDEPEND="${DEPEND}"
32# [...] 32# [...]
33# @CODE 33# @CODE
34# 34#
35# In this case the eclass will use the default configuration, which is the GTK 35# This will get you the default configuration, which is what you want 99%
36# libraries and either the "ansi" (in 2.6) or "unicode" (>=2.8) charsets. 36# of the time (in 2.6 the default is "ansi", all other versions default to
37# "unicode").
37# 38#
38# If you need more control over which profile(s) you need to use, see the 39# If your package has optional wxGTK support controlled by a USE flag or you
39# 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}".
40 47
41inherit eutils multilib 48inherit eutils multilib
42 49
43case "${EAPI:-0}" in 50case "${EAPI:-0}" in
44 0|1) 51 0|1)
49esac 56esac
50 57
51# 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
52# can be overridden with need-wxwidgets later if need be. 59# can be overridden with need-wxwidgets later if need be.
53 60
61# ensure this only runs once
54if [[ -z ${WX_CONFIG} ]]; then 62if [[ -z ${WX_CONFIG} ]]; then
63 # and only if WX_GTK_VER is set before inherit
55 if [[ -n ${WX_GTK_VER} ]]; then 64 if [[ -n ${WX_GTK_VER} ]]; then
56 if [[ ${WX_GTK_VER} == 2.6 ]]; then 65 if [[ ${WX_GTK_VER} == 2.6 ]]; then
57 wxchar="ansi" 66 wxchar="ansi"
58 elif [[ ${WX_GTK_VER} == 2.8 ]]; then 67 else
59 wxchar="unicode" 68 wxchar="unicode"
60 fi 69 fi
61
62 for wxtoolkit in gtk2 base; do 70 for wxtoolkit in gtk2 base; do
71 # newer versions don't have a seperate debug profile
63 for wxdebug in release debug; do 72 for wxdebug in xxx release- debug-; do
64 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 73 wxconf="${wxtoolkit}-${wxchar}-${wxdebug/xxx/}${WX_GTK_VER}"
65 if [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then 74 if [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
75 # if this is a wxBase install, die in pkg_setup
66 [[ ${wxtoolkit} == "base" ]] && WXBASE_DIE=1 # see wxwidgets_pkg_setup 76 [[ ${wxtoolkit} == "base" ]] && WXBASE_DIE=1
67 else 77 else
68 continue 78 continue
69 fi 79 fi
70 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" 80 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
71 WX_ECLASS_CONFIG="${WX_CONFIG}" 81 WX_ECLASS_CONFIG="${WX_CONFIG}"
78fi 88fi
79 89
80# @FUNCTION: wxwidgets_pkg_setup 90# @FUNCTION: wxwidgets_pkg_setup
81# @DESCRIPTION: 91# @DESCRIPTION:
82# 92#
83# 99.99% of the time, packages building against wxGTK need the GTK libraries. 93# It's possible for wxGTK to be installed with USE="-X", resulting in something
84# When using the "Simple Usage" case above (WX_GTK_VER before inherit), we have 94# called wxBase. There's only ever been a couple packages in the tree that use
85# to take into account that the user may have only installed the base libraries 95# wxBase so this is probably not what you want. Whenever possible, use EAPI 2
86# (with USE="-X"). Since we can't die in global scope we instead check for 96# USE dependencies(tm) to ensure that wxGTK was built with USE="X". This
87# the presence of a base profile and then die here if found. 97# function is only exported for EAPI 0 or 1 and catches any remaining cases.
88# 98#
89# If you do need to build against the wxBase libraries, you'll have to use 99# If you do use wxBase, don't set WX_GTK_VER before inherit. Use
90# need-wxwidgets to do so. 100# need-wxwidgets() instead.
91#
92# Note that with an EAPI 2 ebuild you should just DEPEND on x11-libs/wxGTK:2.8[X]
93# and ignore all this nonsense.
94 101
95wxwidgets_pkg_setup() { 102wxwidgets_pkg_setup() {
96 [[ -n $WXBASE_DIE ]] && check_wxuse X 103 [[ -n $WXBASE_DIE ]] && check_wxuse X
97} 104}
98 105
99# @FUNCTION: need-wxwidgets 106# @FUNCTION: need-wxwidgets
100# @USAGE: <configuration> 107# @USAGE: <configuration>
101# @DESCRIPTION: 108# @DESCRIPTION:
102# 109#
103# need-wxwidgets is called with one argument, the wxGTK configuration to use.
104#
105# Available configurations are: 110# Available configurations are:
106# 111#
107# ansi 112# [2.6] ansi [>=2.8] unicode
108# unicode 113# unicode base-unicode
109# base-ansi 114# base
110# base-unicode 115# base-unicode
111# 116#
112# 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
113# eclass will automatically map ansi to unicode for you if WX_GTK_VER is 118# WX_GTK_VER inside a conditional rather than before inherit. Some broken
114# set to 2.8 or later. 119# configure scripts will force wxGTK on if they find ${WX_CONFIG} set.
115# 120#
116# There is one deprecated configuration, "gtk2", which is equivalent to ansi. 121# @CODE
117# This is leftover from 2.4 when we had gtk1 and gtk2 builds and shouldn't 122# src_configure() {
118# be used by new ebuilds. 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
119# 132#
120# This function will export the variable WX_CONFIG, containing the absolute
121# path to the wx-config script to use. In most cases you shouldn't need to
122# use it since the /usr/bin/wx-config wrapper will already point to that
123# location when called from the eclass, but it's here if you do.
124 133
125need-wxwidgets() { 134need-wxwidgets() {
126 debug-print-function $FUNCNAME $* 135 debug-print-function $FUNCNAME $*
127 136
128 local wxtoolkit wxchar wxdebug wxconf 137 local wxtoolkit wxchar wxdebug wxconf
132 eerror "WX_GTK_VER must be set before calling $FUNCNAME." 141 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
133 echo 142 echo
134 die "WX_GTK_VER missing" 143 die "WX_GTK_VER missing"
135 fi 144 fi
136 145
137 if [[ ${WX_GTK_VER} != 2.6 \ 146 if [[ ${WX_GTK_VER} != 2.6 && ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; then
138 && ${WX_GTK_VER} != 2.8 ]]; then
139 echo 147 echo
140 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."
141 echo 149 echo
142 die "Invalid WX_GTK_VER" 150 die "Invalid WX_GTK_VER"
143 fi 151 fi
191 ;; 199 ;;
192 esac 200 esac
193 201
194 debug-print "wxchar is ${wxchar}" 202 debug-print "wxchar is ${wxchar}"
195 203
196 # since we're no longer in global scope we call built_with_use instead of 204 # TODO: remove built_with_use
197 # all the crazy looping
198 205
199 # wxBase can be provided by both gtk2 and base installations 206 # wxBase can be provided by both gtk2 and base installations
200 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
201 wxtoolkit="gtk2" 208 wxtoolkit="gtk2"
202 else 209 else
204 fi 211 fi
205 212
206 debug-print "wxtoolkit is ${wxtoolkit}" 213 debug-print "wxtoolkit is ${wxtoolkit}"
207 214
208 # debug or release? 215 # debug or release?
216 if [[ ${WX_GTK_VER} == 2.6 || ${WX_GTK_VER} == 2.8 ]]; then
209 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
210 wxdebug="debug" 218 wxdebug="debug-"
211 else 219 else
212 wxdebug="release" 220 wxdebug="release-"
221 fi
213 fi 222 fi
214 223
215 debug-print "wxdebug is ${wxdebug}" 224 debug-print "wxdebug is ${wxdebug}"
216 225
217 # put it all together 226 # put it all together
218 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 227 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}${WX_GTK_VER}"
219 228
220 debug-print "wxconf is ${wxconf}" 229 debug-print "wxconf is ${wxconf}"
221 230
222 # if this doesn't work, something is seriously screwed 231 # if this doesn't work, something is seriously screwed
223 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then 232 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
245# @FUNCTION: check_wxuse 254# @FUNCTION: check_wxuse
246# @USAGE: <USE flag> 255# @USAGE: <USE flag>
247# @DESCRIPTION: 256# @DESCRIPTION:
248# 257#
249# 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
250# flag enabled. 259# flag enabled. A better way is EAPI 2 USE dependencies (hint hint).
251 260
252check_wxuse() { 261check_wxuse() {
253 debug-print-function $FUNCNAME $* 262 debug-print-function $FUNCNAME $*
254 263
255 if [[ -z ${WX_GTK_VER} ]]; then 264 if [[ -z ${WX_GTK_VER} ]]; then
256 echo 265 echo
257 eerror "WX_GTK_VER must be set before calling $FUNCNAME." 266 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
258 echo 267 echo
259 die "WX_GTK_VER missing" 268 die "WX_GTK_VER missing"
260 fi 269 fi
270
271 # TODO: Remove built_with_use
261 272
262 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support" 273 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
263 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
264 eend 0 275 eend 0
265 else 276 else

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29

  ViewVC Help
Powered by ViewVC 1.1.20