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

Contents of /eclass/wxwidgets.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.35 - (show annotations) (download)
Sat Nov 16 08:21:23 2013 UTC (13 months ago) by dirtyepic
Branch: MAIN
Changes since 1.34: +13 -61 lines
Drop support for 2.6.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.34 2013/08/16 07:59:17 heroxbd Exp $
4
5 # @ECLASS: wxwidgets.eclass
6 # @MAINTAINER:
7 # wxwidgets@gentoo.org
8 # @BLURB: Manages build configuration for wxGTK-using packages.
9 # @DESCRIPTION:
10 # The wxGTK libraries come in several different possible configurations
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
13 # to build against a specific type of profile without interfering with the
14 # user-set system configuration.
15 #
16 # Ebuilds that use wxGTK _must_ inherit this eclass.
17 #
18 # - Using this eclass -
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
24 #
25 # @CODE
26 # WX_GTK_VER="2.8"
27 #
28 # inherit wxwidgets
29 #
30 # DEPEND="x11-libs/wxGTK:2.8[X]"
31 # RDEPEND="${DEPEND}"
32 # [...]
33 # @CODE
34 #
35 # This will get you the default configuration, which is what you want 99%
36 # of the time.
37 #
38 # If your package has optional wxGTK support controlled by a USE flag or you
39 # need to use the wxBase libraries (USE="-X") then you should not set
40 # WX_GTK_VER before inherit and instead refer to the need-wxwidgets function
41 # below.
42 #
43 # The variable WX_CONFIG is exported, containing the absolute path to the
44 # wx-config file to use. Most configure scripts use this path if it's set in
45 # the environment or accept --with-wx-config="${WX_CONFIG}".
46
47 inherit eutils multilib
48
49 case "${EAPI:-0}" in
50 0|1)
51 EXPORT_FUNCTIONS pkg_setup
52 ;;
53 *)
54 ;;
55 esac
56
57 # We do this globally so ebuilds can get sane defaults just by inheriting. They
58 # can be overridden with need-wxwidgets later if need be.
59
60 # ensure this only runs once
61 if [[ -z ${WX_CONFIG} ]]; then
62 # and only if WX_GTK_VER is set before inherit
63 if [[ -n ${WX_GTK_VER} ]]; then
64 for wxtoolkit in gtk2 base; do
65 # newer versions don't have a seperate debug profile
66 for wxdebug in xxx release- debug-; do
67 wxconf="${wxtoolkit}-unicode-${wxdebug/xxx/}${WX_GTK_VER}"
68 if [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]]; then
69 # if this is a wxBase install, die in pkg_setup
70 [[ ${wxtoolkit} == "base" ]] && WXBASE_DIE=1
71 else
72 continue
73 fi
74 WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
75 WX_ECLASS_CONFIG="${WX_CONFIG}"
76 break
77 done
78 [[ -n ${WX_CONFIG} ]] && break
79 done
80 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
81 fi
82 fi
83
84 # @FUNCTION: wxwidgets_pkg_setup
85 # @DESCRIPTION:
86 #
87 # It's possible for wxGTK to be installed with USE="-X", resulting in something
88 # called wxBase. There's only ever been a couple packages in the tree that use
89 # wxBase so this is probably not what you want. Whenever possible, use EAPI 2
90 # USE dependencies(tm) to ensure that wxGTK was built with USE="X". This
91 # function is only exported for EAPI 0 or 1 and catches any remaining cases.
92 #
93 # If you do use wxBase, don't set WX_GTK_VER before inherit. Use
94 # need-wxwidgets() instead.
95
96 wxwidgets_pkg_setup() {
97 [[ -n $WXBASE_DIE ]] && check_wxuse X
98 }
99
100 # @FUNCTION: need-wxwidgets
101 # @USAGE: <configuration>
102 # @DESCRIPTION:
103 #
104 # Available configurations are:
105 #
106 # unicode (USE="X")
107 # base-unicode (USE="-X")
108 #
109 # If your package has optional wxGTK support controlled by a USE flag, set
110 # WX_GTK_VER inside a conditional rather than before inherit. Some broken
111 # configure scripts will force wxGTK on if they find ${WX_CONFIG} set.
112 #
113 # @CODE
114 # src_configure() {
115 # if use wxwidgets; then
116 # WX_GTK_VER="2.8"
117 # if use X; then
118 # need-wxwidgets unicode
119 # else
120 # need-wxwidgets base-unicode
121 # fi
122 # fi
123 # @CODE
124 #
125
126 need-wxwidgets() {
127 debug-print-function $FUNCNAME $*
128
129 local wxtoolkit wxdebug wxconf
130
131 if [[ -z ${WX_GTK_VER} ]]; then
132 echo
133 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
134 echo
135 die "WX_GTK_VER missing"
136 fi
137
138 if [[ ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; 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
145 debug-print "WX_GTK_VER is ${WX_GTK_VER}"
146
147 case $1 in
148 unicode|base-unicode) ;;
149 *)
150 eerror "Invalid $FUNCNAME argument: $1"
151 echo
152 die
153 ;;
154 esac
155
156 # TODO: remove built_with_use
157
158 # wxBase can be provided by both gtk2 and base installations
159 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X; then
160 wxtoolkit="gtk2"
161 else
162 wxtoolkit="base"
163 fi
164
165 debug-print "wxtoolkit is ${wxtoolkit}"
166
167 # 2.8 has a separate debug tuple
168 if [[ ${WX_GTK_VER} == 2.8 ]]; then
169 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug; then
170 wxdebug="debug-"
171 else
172 wxdebug="release-"
173 fi
174 fi
175
176 debug-print "wxdebug is ${wxdebug}"
177
178 # put it all together
179 wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
180
181 debug-print "wxconf is ${wxconf}"
182
183 # if this doesn't work, something is seriously screwed
184 if [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]]; then
185 echo
186 eerror "Failed to find configuration ${wxconf}"
187 echo
188 die "Missing wx-config"
189 fi
190
191 debug-print "Found config ${wxconf} - setting WX_CONFIG"
192
193 export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
194
195 debug-print "WX_CONFIG is ${WX_CONFIG}"
196
197 export WX_ECLASS_CONFIG="${WX_CONFIG}"
198
199 echo
200 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
201 einfo "Using wxWidgets: ${wxconf}"
202 echo
203 }
204
205
206 # @FUNCTION: check_wxuse
207 # @USAGE: <USE flag>
208 # @DESCRIPTION:
209 #
210 # Provides a consistant way to check if wxGTK was built with a particular USE
211 # flag enabled. A better way is EAPI 2 USE dependencies (hint hint).
212
213 check_wxuse() {
214 debug-print-function $FUNCNAME $*
215
216 if [[ -z ${WX_GTK_VER} ]]; then
217 echo
218 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
219 echo
220 die "WX_GTK_VER missing"
221 fi
222
223 # TODO: Remove built_with_use
224
225 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
226 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"; then
227 eend 0
228 else
229 eend 1
230 echo
231 eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to"
232 eerror "have been built into x11-libs/wxGTK."
233 eerror
234 eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled."
235 die "Missing USE flags."
236 fi
237 }

  ViewVC Help
Powered by ViewVC 1.1.20