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

Diff of /eclass/wxwidgets.eclass

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

Revision 1.25 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.25 2007/12/25 14:46:29 leio 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# wxwindows@gentoo.org 7# wxwidgets@gentoo.org
8# @BLURB: Manages build configuration for wxGTK-using packages. 8# @BLURB: Manages build configuration for wxGTK-using packages.
9# @DESCRIPTION: 9# @DESCRIPTION:
10# The wxGTK libraries come in several different possible configurations 10# The wxGTK libraries come in several different possible configurations
11# (release/debug, ansi/unicode, etc.) some 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 without interfering with the user-set 13# to build against a specific type of profile without interfering with the
14# 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# default will be used, which would be anything the user set it to through
18# 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. You can either set this before the
22# inherit line to get the default type for that SLOT, or later before calling
23# the need-wxwidgets function.
24# 19#
25# 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
26# 24#
27# @CODE 25# @CODE
28# WX_GTK_VER="2.6" 26# WX_GTK_VER="2.8"
29# 27#
30# inherit wxwidgets 28# inherit wxwidgets
31# 29#
32# DEPEND="=x11-libs/wxGTK-2.6*" (or x11-libs/wxGTK:2.6 for EAPI 1) 30# DEPEND="x11-libs/wxGTK:2.8[X]"
33# RDEPEND="${DEPEND}" 31# RDEPEND="${DEPEND}"
34# [...] 32# [...]
35# @CODE 33# @CODE
36# 34#
37# The eclass will select the default configuration, which is "ansi" in 2.6 35# This will get you the default configuration, which is what you want 99%
38# and "unicode" in >=2.8. These are the defaults because they're always 36# of the time (in 2.6 the default is "ansi", all other versions default to
39# guaranteed to exist. 37# "unicode").
40# 38#
41# If you need more control over which version you need to use, see the 39# If your package has optional wxGTK support controlled by a USE flag or you
42# 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}".
43 47
44inherit eutils multilib 48inherit eutils multilib
49
50case "${EAPI:-0}" in
51 0|1)
52 EXPORT_FUNCTIONS pkg_setup
53 ;;
54 *)
55 ;;
56esac
45 57
46# 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
47# can be overridden with need-wxwidgets later if need be. 59# can be overridden with need-wxwidgets later if need be.
48 60
61# ensure this only runs once
49if [[ -z ${WX_CONFIG} ]]; then 62if [[ -z ${WX_CONFIG} ]]; then
63 # and only if WX_GTK_VER is set before inherit
50 if [[ -n ${WX_GTK_VER} ]]; then 64 if [[ -n ${WX_GTK_VER} ]]; then
51 if [[ ${WX_GTK_VER} == 2.6 ]]; then 65 if [[ ${WX_GTK_VER} == 2.6 ]]; then
52 wxchar="ansi" 66 wxchar="ansi"
53 elif [[ ${WX_GTK_VER} == 2.8 ]]; then 67 else
54 wxchar="unicode" 68 wxchar="unicode"
55 fi 69 fi
56
57 for wxtoolkit in gtk2 base; do 70 for wxtoolkit in gtk2 base; do
71 # newer versions don't have a seperate debug profile
58 for wxdebug in release debug; do 72 for wxdebug in xxx release- debug-; do
59 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 73 wxconf="${wxtoolkit}-${wxchar}-${wxdebug/xxx/}${WX_GTK_VER}"
60 [[ -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
61 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" 80 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
62 # TODO: needed for the wx-config wrapper
63 WX_ECLASS_CONFIG="${WX_CONFIG}" 81 WX_ECLASS_CONFIG="${WX_CONFIG}"
64 break 82 break
65 done 83 done
66 [[ -n ${WX_CONFIG} ]] && break 84 [[ -n ${WX_CONFIG} ]] && break
67 done 85 done
68 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG 86 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
69 fi 87 fi
70fi 88fi
71 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}
72 105
73# @FUNCTION: need-wxwidgets 106# @FUNCTION: need-wxwidgets
74# @USAGE: <configuration> 107# @USAGE: <configuration>
75# @DESCRIPTION: 108# @DESCRIPTION:
76# 109#
77# need-wxwidgets is called with one argument, the wxGTK configuration to use.
78#
79# Available configurations are: 110# Available configurations are:
80# 111#
81# ansi 112# [2.6] ansi [>=2.8] unicode
82# unicode 113# unicode base-unicode
83# base-ansi 114# base
84# base-unicode 115# base-unicode
85# 116#
86# 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
87# 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
88# set to 2.8 or later. 119# configure scripts will force wxGTK on if they find ${WX_CONFIG} set.
89# 120#
90# There is one deprecated configuration, "gtk2", which is equivalent to ansi. 121# @CODE
91# This is leftover from 2.4 when we had gtk1 and gtk2 builds and shouldn't 122# src_configure() {
92# 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
93# 132#
94# This function will export the variable WX_CONFIG, containing the absolute
95# path to the wx-config script to use. In most cases you shouldn't need to
96# use it since the /usr/bin/wx-config wrapper will already point to that
97# location when called from the eclass, but it's here if you do.
98 133
99need-wxwidgets() { 134need-wxwidgets() {
100 debug-print-function $FUNCNAME $* 135 debug-print-function $FUNCNAME $*
101 136
102 local wxtoolkit wxchar wxdebug wxconf 137 local wxtoolkit wxchar wxdebug wxconf
106 eerror "WX_GTK_VER must be set before calling $FUNCNAME." 141 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
107 echo 142 echo
108 die "WX_GTK_VER missing" 143 die "WX_GTK_VER missing"
109 fi 144 fi
110 145
111 if [[ ${WX_GTK_VER} != 2.6 \ 146 if [[ ${WX_GTK_VER} != 2.6 && ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; then
112 && ${WX_GTK_VER} != 2.8 ]]; then
113 echo 147 echo
114 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."
115 echo 149 echo
116 die "Invalid WX_GTK_VER" 150 die "Invalid WX_GTK_VER"
117 fi 151 fi
165 ;; 199 ;;
166 esac 200 esac
167 201
168 debug-print "wxchar is ${wxchar}" 202 debug-print "wxchar is ${wxchar}"
169 203
170 # since we're no longer in global scope we call built_with_use instead of 204 # TODO: remove built_with_use
171 # all the crazy looping
172 205
173 # wxBase can be provided by both gtk2 and base installations 206 # wxBase can be provided by both gtk2 and base installations
174 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
175 wxtoolkit="gtk2" 208 wxtoolkit="gtk2"
176 else 209 else
178 fi 211 fi
179 212
180 debug-print "wxtoolkit is ${wxtoolkit}" 213 debug-print "wxtoolkit is ${wxtoolkit}"
181 214
182 # debug or release? 215 # debug or release?
216 if [[ ${WX_GTK_VER} == 2.6 || ${WX_GTK_VER} == 2.8 ]]; then
183 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
184 wxdebug="debug" 218 wxdebug="debug-"
185 else 219 else
186 wxdebug="release" 220 wxdebug="release-"
221 fi
187 fi 222 fi
188 223
189 debug-print "wxdebug is ${wxdebug}" 224 debug-print "wxdebug is ${wxdebug}"
190 225
191 # put it all together 226 # put it all together
192 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" 227 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}${WX_GTK_VER}"
193 228
194 debug-print "wxconf is ${wxconf}" 229 debug-print "wxconf is ${wxconf}"
195 230
196 # if this doesn't work, something is seriously screwed 231 # if this doesn't work, something is seriously screwed
197 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then 232 if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
219# @FUNCTION: check_wxuse 254# @FUNCTION: check_wxuse
220# @USAGE: <USE flag> 255# @USAGE: <USE flag>
221# @DESCRIPTION: 256# @DESCRIPTION:
222# 257#
223# 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
224# flag enabled. 259# flag enabled. A better way is EAPI 2 USE dependencies (hint hint).
225 260
226check_wxuse() { 261check_wxuse() {
227 debug-print-function $FUNCNAME $* 262 debug-print-function $FUNCNAME $*
228 263
229 if [[ -z ${WX_GTK_VER} ]]; then 264 if [[ -z ${WX_GTK_VER} ]]; then
230 echo 265 echo
231 eerror "WX_GTK_VER must be set before calling $FUNCNAME." 266 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
232 echo 267 echo
233 die "WX_GTK_VER missing" 268 die "WX_GTK_VER missing"
234 fi 269 fi
270
271 # TODO: Remove built_with_use
235 272
236 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support" 273 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
237 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
238 eend 0 275 eend 0
239 else 276 else

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

  ViewVC Help
Powered by ViewVC 1.1.20