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

Contents of /eclass/wxwidgets.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (hide annotations) (download)
Mon Sep 7 00:29:47 2009 UTC (5 years, 10 months ago) by dirtyepic
Branch: MAIN
Changes since 1.27: +10 -5 lines
Only export pkg_setup in EAPI 0/1.  EAPI 2 ebuilds should use USE deps.

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.28 # $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.27 2009/08/29 00:34:42 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.28 case "${EAPI:-0}" in
44     0|1)
45     EXPORT_FUNCTIONS pkg_setup
46     ;;
47     *)
48     ;;
49     esac
50 dirtyepic 1.26
51 dirtyepic 1.20 # 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.
53 pythonhead 1.1
54 dirtyepic 1.21 if [[ -z ${WX_CONFIG} ]]; then
55 dirtyepic 1.20 if [[ -n ${WX_GTK_VER} ]]; then
56     if [[ ${WX_GTK_VER} == 2.6 ]]; then
57     wxchar="ansi"
58     elif [[ ${WX_GTK_VER} == 2.8 ]]; then
59     wxchar="unicode"
60     fi
61    
62     for wxtoolkit in gtk2 base; do
63     for wxdebug in release debug; do
64     wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}"
65 dirtyepic 1.26 if [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
66 dirtyepic 1.28 [[ ${wxtoolkit} == "base" ]] && WXBASE_DIE=1 # see wxwidgets_pkg_setup
67 dirtyepic 1.26 else
68     continue
69     fi
70 dirtyepic 1.20 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
71     WX_ECLASS_CONFIG="${WX_CONFIG}"
72     break
73     done
74     [[ -n ${WX_CONFIG} ]] && break
75     done
76     [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
77     fi
78     fi
79 pythonhead 1.1
80 dirtyepic 1.26 # @FUNCTION: wxwidgets_pkg_setup
81     # @DESCRIPTION:
82     #
83     # 99.99% of the time, packages building against wxGTK need the GTK libraries.
84     # When using the "Simple Usage" case above (WX_GTK_VER before inherit), we have
85     # to take into account that the user may have only installed the base libraries
86     # (with USE="-X"). Since we can't die in global scope we instead check for
87     # the presence of a base profile and then die here if found.
88     #
89     # If you do need to build against the wxBase libraries, you'll have to use
90     # need-wxwidgets to do so.
91     #
92 dirtyepic 1.28 # Note that with an EAPI 2 ebuild you should just DEPEND on x11-libs/wxGTK:2.8[X]
93 dirtyepic 1.26 # and ignore all this nonsense.
94    
95     wxwidgets_pkg_setup() {
96     [[ -n $WXBASE_DIE ]] && check_wxuse X
97     }
98 dirtyepic 1.20
99     # @FUNCTION: need-wxwidgets
100     # @USAGE: <configuration>
101     # @DESCRIPTION:
102 dirtyepic 1.24 #
103 dirtyepic 1.20 # need-wxwidgets is called with one argument, the wxGTK configuration to use.
104     #
105     # Available configurations are:
106     #
107 dirtyepic 1.24 # ansi
108     # unicode
109     # base-ansi
110     # base-unicode
111 dirtyepic 1.20 #
112     # Note that in >=wxGTK-2.8, only the unicode versions are available. The
113 dirtyepic 1.24 # eclass will automatically map ansi to unicode for you if WX_GTK_VER is
114     # set to 2.8 or later.
115 dirtyepic 1.20 #
116 dirtyepic 1.24 # There is one deprecated configuration, "gtk2", which is equivalent to ansi.
117     # This is leftover from 2.4 when we had gtk1 and gtk2 builds and shouldn't
118     # be used by new ebuilds.
119     #
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 pythonhead 1.1
125     need-wxwidgets() {
126     debug-print-function $FUNCNAME $*
127    
128 dirtyepic 1.20 local wxtoolkit wxchar wxdebug wxconf
129    
130     if [[ -z ${WX_GTK_VER} ]]; then
131     echo
132     eerror "WX_GTK_VER must be set before calling $FUNCNAME."
133     echo
134     die "WX_GTK_VER missing"
135 pythonhead 1.4 fi
136 pythonhead 1.1
137 dirtyepic 1.20 if [[ ${WX_GTK_VER} != 2.6 \
138     && ${WX_GTK_VER} != 2.8 ]]; then
139     echo
140     eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT."
141     echo
142     die "Invalid WX_GTK_VER"
143     fi
144 pythonhead 1.1
145 dirtyepic 1.20 debug-print "WX_GTK_VER is ${WX_GTK_VER}"
146 pythonhead 1.1
147 dirtyepic 1.20 case $1 in
148     ansi)
149     debug-print-section ansi
150     if [[ ${WX_GTK_VER} == 2.6 ]]; then
151     wxchar="ansi"
152     else
153     wxchar="unicode"
154     fi
155     check_wxuse X
156     ;;
157     unicode)
158     debug-print-section unicode
159     check_wxuse X
160     [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode
161     wxchar="unicode"
162     ;;
163     base)
164     debug-print-section base
165     if [[ ${WX_GTK_VER} == 2.6 ]]; then
166     wxchar="ansi"
167     else
168     wxchar="unicode"
169     fi
170     ;;
171     base-unicode)
172     debug-print-section base-unicode
173     [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode
174     wxchar="unicode"
175     ;;
176     # backwards compatibility
177     gtk2)
178     debug-print-section gtk2
179     if [[ ${WX_GTK_VER} == 2.6 ]]; then
180     wxchar="ansi"
181     else
182     wxchar="unicode"
183     fi
184     check_wxuse X
185     ;;
186     *)
187     echo
188     eerror "Invalid $FUNCNAME argument: $1"
189     echo
190     die "Invalid argument"
191     ;;
192     esac
193    
194     debug-print "wxchar is ${wxchar}"
195    
196     # since we're no longer in global scope we call built_with_use instead of
197     # all the crazy looping
198    
199 dirtyepic 1.24 # wxBase can be provided by both gtk2 and base installations
200 swegener 1.23 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X; then
201 dirtyepic 1.20 wxtoolkit="gtk2"
202 pythonhead 1.4 else
203 dirtyepic 1.20 wxtoolkit="base"
204     fi
205    
206     debug-print "wxtoolkit is ${wxtoolkit}"
207    
208     # debug or release?
209 swegener 1.23 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug; then
210 dirtyepic 1.20 wxdebug="debug"
211 pythonhead 1.1 else
212 dirtyepic 1.20 wxdebug="release"
213     fi
214    
215     debug-print "wxdebug is ${wxdebug}"
216    
217     # put it all together
218     wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}"
219    
220     debug-print "wxconf is ${wxconf}"
221    
222     # if this doesn't work, something is seriously screwed
223     if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
224     echo
225     eerror "Failed to find configuration ${wxconf}"
226     echo
227     die "Missing wx-config"
228 pythonhead 1.1 fi
229 dirtyepic 1.20
230     debug-print "Found config ${wxconf} - setting WX_CONFIG"
231    
232     export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
233    
234     debug-print "WX_CONFIG is ${WX_CONFIG}"
235    
236     export WX_ECLASS_CONFIG="${WX_CONFIG}"
237    
238     echo
239 dirtyepic 1.22 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
240     einfo "Using wxWidgets: ${wxconf}"
241 dirtyepic 1.20 echo
242 pythonhead 1.1 }
243    
244 dirtyepic 1.20
245     # @FUNCTION: check_wxuse
246     # @USAGE: <USE flag>
247     # @DESCRIPTION:
248 dirtyepic 1.24 #
249 dirtyepic 1.20 # Provides a consistant way to check if wxGTK was built with a particular USE
250     # flag enabled.
251    
252 dirtyepic 1.19 check_wxuse() {
253 dirtyepic 1.20 debug-print-function $FUNCNAME $*
254    
255 leio 1.25 if [[ -z ${WX_GTK_VER} ]]; then
256     echo
257     eerror "WX_GTK_VER must be set before calling $FUNCNAME."
258     echo
259     die "WX_GTK_VER missing"
260     fi
261 dirtyepic 1.19
262     ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
263 swegener 1.23 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"; then
264 dirtyepic 1.19 eend 0
265     else
266     eend 1
267     echo
268     eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to"
269     eerror "have been built into x11-libs/wxGTK."
270     eerror
271     eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled."
272     die "Missing USE flags."
273     fi
274     }

  ViewVC Help
Powered by ViewVC 1.1.20