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

Contents of /eclass/wxwidgets.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.30 - (hide annotations) (download)
Thu Jun 30 04:14:38 2011 UTC (3 years, 5 months ago) by dirtyepic
Branch: MAIN
Changes since 1.29: +2 -2 lines
Inherit base (bug #372831 by Gert Wollny).

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.30 # $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.29 2010/02/16 01:06:24 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.29 # Ebuilds that use wxGTK _must_ inherit this eclass.
17 dirtyepic 1.20 #
18 dirtyepic 1.29 # - Using this eclass -
19 dirtyepic 1.20 #
20 dirtyepic 1.29 # 1. set WX_GTK_VER to a valid wxGTK SLOT
21     # 2. inherit wxwidgets
22     # 3. add an appropriate DEPEND
23     # 4. done
24 dirtyepic 1.20 #
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.29 # DEPEND="x11-libs/wxGTK:2.8[X]"
31 dirtyepic 1.24 # RDEPEND="${DEPEND}"
32     # [...]
33     # @CODE
34     #
35 dirtyepic 1.29 # This will get you the default configuration, which is what you want 99%
36     # of the time (in 2.6 the default is "ansi", all other versions default to
37     # "unicode").
38     #
39     # If your package has optional wxGTK support controlled by a USE flag or you
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}".
47 dirtyepic 1.20
48 dirtyepic 1.30 inherit base eutils multilib
49 pythonhead 1.1
50 dirtyepic 1.28 case "${EAPI:-0}" in
51     0|1)
52     EXPORT_FUNCTIONS pkg_setup
53     ;;
54     *)
55     ;;
56     esac
57 dirtyepic 1.26
58 dirtyepic 1.20 # We do this globally so ebuilds can get sane defaults just by inheriting. They
59     # can be overridden with need-wxwidgets later if need be.
60 pythonhead 1.1
61 dirtyepic 1.29 # ensure this only runs once
62 dirtyepic 1.21 if [[ -z ${WX_CONFIG} ]]; then
63 dirtyepic 1.29 # and only if WX_GTK_VER is set before inherit
64 dirtyepic 1.20 if [[ -n ${WX_GTK_VER} ]]; then
65     if [[ ${WX_GTK_VER} == 2.6 ]]; then
66     wxchar="ansi"
67 dirtyepic 1.29 else
68 dirtyepic 1.20 wxchar="unicode"
69     fi
70     for wxtoolkit in gtk2 base; do
71 dirtyepic 1.29 # newer versions don't have a seperate debug profile
72     for wxdebug in xxx release- debug-; do
73     wxconf="${wxtoolkit}-${wxchar}-${wxdebug/xxx/}${WX_GTK_VER}"
74 dirtyepic 1.26 if [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
75 dirtyepic 1.29 # if this is a wxBase install, die in pkg_setup
76     [[ ${wxtoolkit} == "base" ]] && WXBASE_DIE=1
77 dirtyepic 1.26 else
78     continue
79     fi
80 dirtyepic 1.20 WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
81     WX_ECLASS_CONFIG="${WX_CONFIG}"
82     break
83     done
84     [[ -n ${WX_CONFIG} ]] && break
85     done
86     [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
87     fi
88     fi
89 pythonhead 1.1
90 dirtyepic 1.26 # @FUNCTION: wxwidgets_pkg_setup
91     # @DESCRIPTION:
92     #
93 dirtyepic 1.29 # 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 dirtyepic 1.26 #
99 dirtyepic 1.29 # If you do use wxBase, don't set WX_GTK_VER before inherit. Use
100     # need-wxwidgets() instead.
101 dirtyepic 1.26
102     wxwidgets_pkg_setup() {
103     [[ -n $WXBASE_DIE ]] && check_wxuse X
104     }
105 dirtyepic 1.20
106     # @FUNCTION: need-wxwidgets
107     # @USAGE: <configuration>
108     # @DESCRIPTION:
109 dirtyepic 1.24 #
110 dirtyepic 1.29 # Available configurations are:
111     #
112     # [2.6] ansi [>=2.8] unicode
113     # unicode base-unicode
114     # base
115     # base-unicode
116     #
117     # If your package has optional wxGTK support controlled by a USE flag, set
118     # WX_GTK_VER inside a conditional rather than before inherit. Some broken
119     # configure scripts will force wxGTK on if they find ${WX_CONFIG} set.
120 dirtyepic 1.20 #
121 dirtyepic 1.29 # @CODE
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
132 dirtyepic 1.20 #
133 pythonhead 1.1
134     need-wxwidgets() {
135     debug-print-function $FUNCNAME $*
136    
137 dirtyepic 1.20 local wxtoolkit wxchar wxdebug wxconf
138    
139     if [[ -z ${WX_GTK_VER} ]]; then
140     echo
141     eerror "WX_GTK_VER must be set before calling $FUNCNAME."
142     echo
143     die "WX_GTK_VER missing"
144 pythonhead 1.4 fi
145 pythonhead 1.1
146 dirtyepic 1.29 if [[ ${WX_GTK_VER} != 2.6 && ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; then
147 dirtyepic 1.20 echo
148     eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT."
149     echo
150     die "Invalid WX_GTK_VER"
151     fi
152 pythonhead 1.1
153 dirtyepic 1.20 debug-print "WX_GTK_VER is ${WX_GTK_VER}"
154 pythonhead 1.1
155 dirtyepic 1.20 case $1 in
156     ansi)
157     debug-print-section ansi
158     if [[ ${WX_GTK_VER} == 2.6 ]]; then
159     wxchar="ansi"
160     else
161     wxchar="unicode"
162     fi
163     check_wxuse X
164     ;;
165     unicode)
166     debug-print-section unicode
167     check_wxuse X
168     [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode
169     wxchar="unicode"
170     ;;
171     base)
172     debug-print-section base
173     if [[ ${WX_GTK_VER} == 2.6 ]]; then
174     wxchar="ansi"
175     else
176     wxchar="unicode"
177     fi
178     ;;
179     base-unicode)
180     debug-print-section base-unicode
181     [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode
182     wxchar="unicode"
183     ;;
184     # backwards compatibility
185     gtk2)
186     debug-print-section gtk2
187     if [[ ${WX_GTK_VER} == 2.6 ]]; then
188     wxchar="ansi"
189     else
190     wxchar="unicode"
191     fi
192     check_wxuse X
193     ;;
194     *)
195     echo
196     eerror "Invalid $FUNCNAME argument: $1"
197     echo
198     die "Invalid argument"
199     ;;
200     esac
201    
202     debug-print "wxchar is ${wxchar}"
203    
204 dirtyepic 1.29 # TODO: remove built_with_use
205 dirtyepic 1.20
206 dirtyepic 1.24 # wxBase can be provided by both gtk2 and base installations
207 swegener 1.23 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X; then
208 dirtyepic 1.20 wxtoolkit="gtk2"
209 pythonhead 1.4 else
210 dirtyepic 1.20 wxtoolkit="base"
211     fi
212    
213     debug-print "wxtoolkit is ${wxtoolkit}"
214    
215     # debug or release?
216 dirtyepic 1.29 if [[ ${WX_GTK_VER} == 2.6 || ${WX_GTK_VER} == 2.8 ]]; then
217     if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug; then
218     wxdebug="debug-"
219     else
220     wxdebug="release-"
221     fi
222 dirtyepic 1.20 fi
223    
224     debug-print "wxdebug is ${wxdebug}"
225    
226     # put it all together
227 dirtyepic 1.29 wxconf="${wxtoolkit}-${wxchar}-${wxdebug}${WX_GTK_VER}"
228 dirtyepic 1.20
229     debug-print "wxconf is ${wxconf}"
230    
231     # if this doesn't work, something is seriously screwed
232     if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
233     echo
234     eerror "Failed to find configuration ${wxconf}"
235     echo
236     die "Missing wx-config"
237 pythonhead 1.1 fi
238 dirtyepic 1.20
239     debug-print "Found config ${wxconf} - setting WX_CONFIG"
240    
241     export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}"
242    
243     debug-print "WX_CONFIG is ${WX_CONFIG}"
244    
245     export WX_ECLASS_CONFIG="${WX_CONFIG}"
246    
247     echo
248 dirtyepic 1.22 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
249     einfo "Using wxWidgets: ${wxconf}"
250 dirtyepic 1.20 echo
251 pythonhead 1.1 }
252    
253 dirtyepic 1.20
254     # @FUNCTION: check_wxuse
255     # @USAGE: <USE flag>
256     # @DESCRIPTION:
257 dirtyepic 1.24 #
258 dirtyepic 1.20 # Provides a consistant way to check if wxGTK was built with a particular USE
259 dirtyepic 1.29 # flag enabled. A better way is EAPI 2 USE dependencies (hint hint).
260 dirtyepic 1.20
261 dirtyepic 1.19 check_wxuse() {
262 dirtyepic 1.20 debug-print-function $FUNCNAME $*
263    
264 leio 1.25 if [[ -z ${WX_GTK_VER} ]]; then
265     echo
266     eerror "WX_GTK_VER must be set before calling $FUNCNAME."
267     echo
268     die "WX_GTK_VER missing"
269     fi
270 dirtyepic 1.19
271 dirtyepic 1.29 # TODO: Remove built_with_use
272    
273 dirtyepic 1.19 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
274 swegener 1.23 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"; then
275 dirtyepic 1.19 eend 0
276     else
277     eend 1
278     echo
279     eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to"
280     eerror "have been built into x11-libs/wxGTK."
281     eerror
282     eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled."
283     die "Missing USE flags."
284     fi
285     }

  ViewVC Help
Powered by ViewVC 1.1.20