| 1 | # Copyright 1999-2005 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.7 2005/05/02 16:43:58 pythonhead Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.30 2011/06/30 04:14:38 dirtyepic Exp $ |
| 4 | # |
|
|
| 5 | # Author Rob Cakebread <pythonhead@gentoo.org> |
|
|
| 6 | |
4 | |
| 7 | # This eclass helps you find the correct wx-config script so ebuilds |
5 | # @ECLASS: wxwidgets.eclass |
| 8 | # can use gtk, gtk2 or gtk2+unicode versions of wxGTK |
6 | # @MAINTAINER: |
| 9 | |
7 | # wxwidgets@gentoo.org |
| 10 | # FUNCTIONS: |
8 | # @BLURB: Manages build configuration for wxGTK-using packages. |
| 11 | # need-wxwidgets: |
9 | # @DESCRIPTION: |
| 12 | # Arguments: |
10 | # The wxGTK libraries come in several different possible configurations |
| 13 | # 2.4: gtk gtk2 unicode |
11 | # (release, debug, ansi, unicode, etc.) most of which can be installed |
| 14 | # 2.6: gtk gtk2 gtk2-unicode base base-unicode mac mac-unicode |
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 | # |
15 | # |
|
|
16 | # Ebuilds that use wxGTK _must_ inherit this eclass. |
| 16 | # |
17 | # |
| 17 | # set-wxconfig |
18 | # - Using this eclass - |
| 18 | # Arguments: (wxGTK 2.4) wxgtk, wxgtk2, or wxgtk2u |
19 | # |
| 19 | # Arguments: (wxGTK 2.6) gtk-ansi gtk2-ansi gtk2-unicode base-ansi base-unicode mac-ansi mac-unicode |
20 | # 1. set WX_GTK_VER to a valid wxGTK SLOT |
| 20 | # Note: Don't call this function directly from ebuilds |
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 (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}". |
| 21 | |
47 | |
| 22 | ECLASS=wxwidgets |
48 | inherit base eutils multilib |
| 23 | INHERITED="$INHERITED $ECLASS" |
49 | |
|
|
50 | case "${EAPI:-0}" in |
|
|
51 | 0|1) |
|
|
52 | EXPORT_FUNCTIONS pkg_setup |
|
|
53 | ;; |
|
|
54 | *) |
|
|
55 | ;; |
|
|
56 | esac |
|
|
57 | |
|
|
58 | # 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 | |
|
|
61 | # ensure this only runs once |
|
|
62 | if [[ -z ${WX_CONFIG} ]]; then |
|
|
63 | # and only if WX_GTK_VER is set before inherit |
|
|
64 | if [[ -n ${WX_GTK_VER} ]]; then |
|
|
65 | if [[ ${WX_GTK_VER} == 2.6 ]]; then |
|
|
66 | wxchar="ansi" |
|
|
67 | else |
|
|
68 | wxchar="unicode" |
|
|
69 | fi |
|
|
70 | for wxtoolkit in gtk2 base; do |
|
|
71 | # 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 | 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 |
|
|
80 | 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 | |
|
|
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 | |
|
|
102 | wxwidgets_pkg_setup() { |
|
|
103 | [[ -n $WXBASE_DIE ]] && check_wxuse X |
|
|
104 | } |
|
|
105 | |
|
|
106 | # @FUNCTION: need-wxwidgets |
|
|
107 | # @USAGE: <configuration> |
|
|
108 | # @DESCRIPTION: |
|
|
109 | # |
|
|
110 | # 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 | # |
|
|
121 | # @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 | # |
| 24 | |
133 | |
| 25 | need-wxwidgets() { |
134 | need-wxwidgets() { |
| 26 | debug-print-function $FUNCNAME $* |
135 | debug-print-function $FUNCNAME $* |
| 27 | #If you want to use wxGTK-2.6* export WX_GTK_VER in your ebuild: |
136 | |
| 28 | if [ "${WX_GTK_VER}" = "2.6" ]; then |
137 | 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 | fi |
|
|
145 | |
|
|
146 | if [[ ${WX_GTK_VER} != 2.6 && ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; then |
|
|
147 | 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 | |
|
|
153 | debug-print "WX_GTK_VER is ${WX_GTK_VER}" |
|
|
154 | |
| 29 | case $1 in |
155 | case $1 in |
| 30 | gtk) set-wxconfig gtk-ansi;; |
156 | ansi) |
| 31 | gtk2) set-wxconfig gtk2-ansi;; |
157 | debug-print-section ansi |
| 32 | gtk2-unicode) set-wxconfig gtk2-unicode;; |
158 | if [[ ${WX_GTK_VER} == 2.6 ]]; then |
| 33 | base) set-wxconfig base-ansi;; |
159 | wxchar="ansi" |
| 34 | base-unicode) set-wxconfig base-unicode;; |
160 | else |
| 35 | mac) set-wxconfig mac-ansi;; |
161 | wxchar="unicode" |
| 36 | mac-unicode) set-wxconfig mac-unicode;; |
162 | fi |
| 37 | *) echo "!!! $FUNCNAME: Error: wxGTK was not comipled with $1." |
163 | check_wxuse X |
| 38 | echo "!!! Adjust your USE flags or re-emerge wxGTK with version you want." |
164 | ;; |
| 39 | exit 1;; |
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 | ;; |
| 40 | esac |
200 | esac |
| 41 | |
201 | |
|
|
202 | debug-print "wxchar is ${wxchar}" |
|
|
203 | |
|
|
204 | # TODO: remove built_with_use |
|
|
205 | |
|
|
206 | # wxBase can be provided by both gtk2 and base installations |
|
|
207 | if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X; then |
|
|
208 | wxtoolkit="gtk2" |
| 42 | else |
209 | else |
| 43 | WX_GTK_VER="2.4" |
210 | wxtoolkit="base" |
| 44 | case $1 in |
211 | fi |
| 45 | gtk) set-wxconfig wxgtk;; |
212 | |
| 46 | gtk2) set-wxconfig wxgtk2;; |
213 | debug-print "wxtoolkit is ${wxtoolkit}" |
| 47 | unicode) set-wxconfig wxgtk2u;; |
214 | |
| 48 | *) echo "!!! $FUNCNAME: Error: wxGTK was not comipled with $1." |
215 | # debug or release? |
| 49 | echo "!!! Adjust your USE flags or re-emerge wxGTK with version you want." |
216 | if [[ ${WX_GTK_VER} == 2.6 || ${WX_GTK_VER} == 2.8 ]]; then |
| 50 | exit 1;; |
217 | if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug; then |
| 51 | esac |
218 | wxdebug="debug-" |
|
|
219 | else |
|
|
220 | wxdebug="release-" |
| 52 | fi |
221 | fi |
|
|
222 | fi |
|
|
223 | |
|
|
224 | debug-print "wxdebug is ${wxdebug}" |
|
|
225 | |
|
|
226 | # put it all together |
|
|
227 | wxconf="${wxtoolkit}-${wxchar}-${wxdebug}${WX_GTK_VER}" |
|
|
228 | |
|
|
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 | fi |
|
|
238 | |
|
|
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 | einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}" |
|
|
249 | einfo "Using wxWidgets: ${wxconf}" |
|
|
250 | echo |
| 53 | } |
251 | } |
| 54 | |
252 | |
| 55 | |
253 | |
| 56 | set-wxconfig() { |
254 | # @FUNCTION: check_wxuse |
|
|
255 | # @USAGE: <USE flag> |
|
|
256 | # @DESCRIPTION: |
|
|
257 | # |
|
|
258 | # Provides a consistant way to check if wxGTK was built with a particular USE |
|
|
259 | # flag enabled. A better way is EAPI 2 USE dependencies (hint hint). |
| 57 | |
260 | |
|
|
261 | check_wxuse() { |
| 58 | debug-print-function $FUNCNAME $* |
262 | debug-print-function $FUNCNAME $* |
| 59 | |
263 | |
| 60 | if [ "${WX_GTK_VER}" = "2.6" ] ; then |
264 | if [[ -z ${WX_GTK_VER} ]]; then |
| 61 | wxconfig_prefix="/usr/lib/wx/config" |
265 | echo |
| 62 | wxconfig_name="${1}-release-${WX_GTK_VER}" |
266 | eerror "WX_GTK_VER must be set before calling $FUNCNAME." |
| 63 | wxconfig="${wxconfig_prefix}/${wxconfig_name}" |
267 | echo |
| 64 | wxconfig_debug_name="${1}-debug-${WX_GTK_VER}" |
268 | die "WX_GTK_VER missing" |
| 65 | wxconfig_debug="${wxconfig_prefix}/${wxconfig_debug_name}" |
269 | fi |
|
|
270 | |
|
|
271 | # TODO: Remove built_with_use |
|
|
272 | |
|
|
273 | ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support" |
|
|
274 | if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"; then |
|
|
275 | eend 0 |
| 66 | else |
276 | else |
| 67 | # Default is 2.4: |
277 | eend 1 |
| 68 | wxconfig_prefix="/usr/bin" |
278 | echo |
| 69 | wxconfig_name="${1}-${WX_GTK_VER}-config" |
279 | eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to" |
| 70 | wxconfig="${wxconfig_prefix}/${wxconfig_name}" |
280 | eerror "have been built into x11-libs/wxGTK." |
| 71 | wxconfig_debug_name="${1}d-${WX_GTK_VER}-config" |
281 | eerror |
| 72 | wxconfig_debug="${wxconfig_prefix}/${wxconfig_debug_name}" |
282 | eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled." |
| 73 | fi |
283 | die "Missing USE flags." |
| 74 | |
|
|
| 75 | if [ -e ${wxconfig} ] ; then |
|
|
| 76 | export WX_CONFIG=${wxconfig} |
|
|
| 77 | export WX_CONFIG_NAME=${wxconfig_name} |
|
|
| 78 | export WXBASE_CONFIG_NAME=${wxconfig_name} |
|
|
| 79 | echo " * Using ${wxconfig}" |
|
|
| 80 | elif [ -e ${wxconfig_debug} ] ; then |
|
|
| 81 | export WX_CONFIG=${wxconfig_debug} |
|
|
| 82 | export WX_CONFIG_NAME=${wxconfig_debug_name} |
|
|
| 83 | export WXBASE_CONFIG_NAME=${wxconfig_debug_name} |
|
|
| 84 | echo " * Using ${wxconfig_debug}" |
|
|
| 85 | else |
|
|
| 86 | echo "!!! $FUNCNAME: Error: Can't find normal or debug version:" |
|
|
| 87 | echo "!!! $FUNCNAME: ${wxconfig} not found" |
|
|
| 88 | echo "!!! $FUNCNAME: ${wxconfig_debug} not found" |
|
|
| 89 | case $1 in |
|
|
| 90 | wxgtk) echo "!!! You need to emerge wxGTK with wxgtk1 in your USE";; |
|
|
| 91 | wxgtkd) echo "!!! You need to emerge wxGTK with wxgtk1 in your USE";; |
|
|
| 92 | gtk-ansi) echo "!!! You need to emerge wxGTK with wxgtk1 in your USE";; |
|
|
| 93 | gtkd-ansi) echo "!!! You need to emerge wxGTK with wxgtk1 in your USE";; |
|
|
| 94 | |
|
|
| 95 | wxgtk2) echo "!!! You need to emerge wxGTK with gtk2 in your USE";; |
|
|
| 96 | wxgtk2d) echo "!!! You need to emerge wxGTK with gtk2 in your USE";; |
|
|
| 97 | gtk2-ansi) echo "!!! You need to emerge wxGTK with gtk2 in your USE";; |
|
|
| 98 | gtk2d-ansi) echo "!!! You need to emerge wxGTK with gtk2 in your USE";; |
|
|
| 99 | |
|
|
| 100 | wxgtk2u) echo "!!! You need to emerge wxGTK with unicode in your USE";; |
|
|
| 101 | wxgtk2ud) echo "!!! You need to emerge wxGTK with unicode in your USE";; |
|
|
| 102 | gtk2-unicode) echo "!!! You need to emerge wxGTK with unicode in your USE";; |
|
|
| 103 | gtk2d-unicode) echo "!!! You need to emerge wxGTK with unicode in your USE";; |
|
|
| 104 | esac |
|
|
| 105 | exit 1 |
|
|
| 106 | fi |
284 | fi |
| 107 | } |
285 | } |
| 108 | |
|
|