| 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.9 2005/05/11 23:45:18 pythonhead Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.21 2007/10/18 03:25:56 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 | # dirtyepic@gentoo.org |
| 10 | # FUNCTIONS: |
8 | # wxwindows@gentoo.org |
| 11 | # need-wxwidgets: |
9 | # @BLURB: Manages build configuration for wxGTK-using packages. |
| 12 | # Arguments: |
10 | # @DESCRIPTION: |
| 13 | # 2.4: gtk gtk2 unicode |
11 | # The wxGTK libraries come in several different possible configurations |
| 14 | # 2.6: gtk gtk2 unicode base base-unicode mac mac-unicode |
12 | # (release/debug, ansi/unicode, etc.), most of which can be installed |
|
|
13 | # side-by-side. The purpose of this eclass is to give ebuilds the ability to |
|
|
14 | # specify what particular flavour they require to build against without |
|
|
15 | # interfering with the user-set system configuration. |
| 15 | # |
16 | # |
|
|
17 | # Ebuilds that use wxGTK must inherit this eclass. Otherwise the system |
|
|
18 | # default will be used, which would be anything the user set it to. |
| 16 | # |
19 | # |
| 17 | # set-wxconfig |
20 | # Ebuilds are also required to set the global variable WX_GTK_VER, containing |
| 18 | # Arguments: (wxGTK 2.4) wxgtk, wxgtk2, or wxgtk2u |
21 | # the wxGTK SLOT the ebuild requires. Note that in order for this to work, |
| 19 | # Arguments: (wxGTK 2.6) gtk-ansi gtk2-ansi unicode base-ansi base-unicode mac-ansi mac-unicode |
22 | # WX_GTK_VER needs to be set before inheriting the eclass. |
| 20 | # Note: Don't call this function directly from ebuilds |
23 | # |
|
|
24 | # Simple Usage: |
|
|
25 | # |
|
|
26 | # WX_GTK_VER="2.6" |
|
|
27 | # inherit wxwidgets |
|
|
28 | # DEPEND="=x11-libs/wxGTK-2.6*" |
|
|
29 | # RDEPEND="=x11-libs/wxGTK-2.6*" |
|
|
30 | # |
|
|
31 | # That's it. The eclass will select a sane default configuration to use. In |
|
|
32 | # wxGTK-2.6 the default is ansi. In wxGTK-2.8 and later it's unicode. These |
|
|
33 | # are the defaults because they are always guaranteed to exist. |
|
|
34 | # |
|
|
35 | # You'll often find yourself in need of a bit more control. For that see the |
|
|
36 | # need-wxwidgets function below. |
| 21 | |
37 | |
| 22 | ECLASS=wxwidgets |
38 | inherit eutils multilib |
| 23 | INHERITED="$INHERITED $ECLASS" |
39 | |
|
|
40 | # We do this globally so ebuilds can get sane defaults just by inheriting. They |
|
|
41 | # can be overridden with need-wxwidgets later if need be. |
|
|
42 | |
|
|
43 | if [[ -z ${WX_CONFIG} ]]; then |
|
|
44 | if [[ -n ${WX_GTK_VER} ]]; then |
|
|
45 | if [[ ${WX_GTK_VER} == 2.6 ]]; then |
|
|
46 | wxchar="ansi" |
|
|
47 | elif [[ ${WX_GTK_VER} == 2.8 ]]; then |
|
|
48 | wxchar="unicode" |
|
|
49 | fi |
|
|
50 | |
|
|
51 | for wxtoolkit in gtk2 base; do |
|
|
52 | for wxdebug in release debug; do |
|
|
53 | wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" |
|
|
54 | [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]] || continue |
|
|
55 | WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" |
|
|
56 | # TODO: needed for the wx-config wrapper |
|
|
57 | WX_ECLASS_CONFIG="${WX_CONFIG}" |
|
|
58 | break |
|
|
59 | done |
|
|
60 | [[ -n ${WX_CONFIG} ]] && break |
|
|
61 | done |
|
|
62 | [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG |
|
|
63 | fi |
|
|
64 | fi |
|
|
65 | |
|
|
66 | |
|
|
67 | # @FUNCTION: need-wxwidgets |
|
|
68 | # @USAGE: <configuration> |
|
|
69 | # @DESCRIPTION: |
|
|
70 | # need-wxwidgets is called with one argument, the wxGTK configuration to use. |
|
|
71 | # |
|
|
72 | # Available configurations are: |
|
|
73 | # |
|
|
74 | # ansi |
|
|
75 | # unicode |
|
|
76 | # base-ansi |
|
|
77 | # base-unicode |
|
|
78 | # |
|
|
79 | # Note that in >=wxGTK-2.8, only the unicode versions are available. The |
|
|
80 | # eclass will automatically map ansi to unicode if WX_GTK_VER is set to 2.8 or |
|
|
81 | # later. |
|
|
82 | # |
|
|
83 | # There is one deprecated configuration, gtk2, that is equivalent to ansi. |
|
|
84 | # It is around for historical reasons and shouldn't be used by new ebuilds. |
|
|
85 | # |
|
|
86 | # This function will set the variable WX_CONFIG to the path of the wx-config |
|
|
87 | # script to use. In most cases you shouldn't have to use it since the |
|
|
88 | # /usr/bin/wx-config wrapper points to ${WX_CONFIG} when called from portage. |
| 24 | |
89 | |
| 25 | need-wxwidgets() { |
90 | need-wxwidgets() { |
| 26 | debug-print-function $FUNCNAME $* |
91 | debug-print-function $FUNCNAME $* |
| 27 | #If you want to use wxGTK-2.6* export WX_GTK_VER in your ebuild: |
92 | |
| 28 | if [ "${WX_GTK_VER}" = "2.6" ]; then |
93 | local wxtoolkit wxchar wxdebug wxconf |
|
|
94 | |
|
|
95 | if [[ -z ${WX_GTK_VER} ]]; then |
|
|
96 | echo |
|
|
97 | eerror "WX_GTK_VER must be set before calling $FUNCNAME." |
|
|
98 | echo |
|
|
99 | die "WX_GTK_VER missing" |
|
|
100 | fi |
|
|
101 | |
|
|
102 | if [[ ${WX_GTK_VER} != 2.6 \ |
|
|
103 | && ${WX_GTK_VER} != 2.8 ]]; then |
|
|
104 | echo |
|
|
105 | eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT." |
|
|
106 | echo |
|
|
107 | die "Invalid WX_GTK_VER" |
|
|
108 | fi |
|
|
109 | |
|
|
110 | debug-print "WX_GTK_VER is ${WX_GTK_VER}" |
|
|
111 | |
| 29 | case $1 in |
112 | case $1 in |
| 30 | gtk) set-wxconfig gtk-ansi;; |
113 | ansi) |
| 31 | gtk2) set-wxconfig gtk2-ansi;; |
114 | debug-print-section ansi |
| 32 | unicode) set-wxconfig gtk2-unicode;; |
115 | if [[ ${WX_GTK_VER} == 2.6 ]]; then |
| 33 | base) set-wxconfig base-ansi;; |
116 | wxchar="ansi" |
| 34 | base-unicode) set-wxconfig base-unicode;; |
117 | else |
| 35 | mac) set-wxconfig mac-ansi;; |
118 | wxchar="unicode" |
| 36 | mac-unicode) set-wxconfig mac-unicode;; |
119 | fi |
| 37 | *) echo "!!! $FUNCNAME: Error: wxGTK was not comipled with $1." |
120 | check_wxuse X |
| 38 | echo "!!! Adjust your USE flags or re-emerge wxGTK with version you want." |
121 | ;; |
| 39 | exit 1;; |
122 | unicode) |
|
|
123 | debug-print-section unicode |
|
|
124 | check_wxuse X |
|
|
125 | [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode |
|
|
126 | wxchar="unicode" |
|
|
127 | ;; |
|
|
128 | base) |
|
|
129 | debug-print-section base |
|
|
130 | if [[ ${WX_GTK_VER} == 2.6 ]]; then |
|
|
131 | wxchar="ansi" |
|
|
132 | else |
|
|
133 | wxchar="unicode" |
|
|
134 | fi |
|
|
135 | ;; |
|
|
136 | base-unicode) |
|
|
137 | debug-print-section base-unicode |
|
|
138 | [[ ${WX_GTK_VER} == 2.6 ]] && check_wxuse unicode |
|
|
139 | wxchar="unicode" |
|
|
140 | ;; |
|
|
141 | # backwards compatibility |
|
|
142 | gtk2) |
|
|
143 | debug-print-section gtk2 |
|
|
144 | if [[ ${WX_GTK_VER} == 2.6 ]]; then |
|
|
145 | wxchar="ansi" |
|
|
146 | else |
|
|
147 | wxchar="unicode" |
|
|
148 | fi |
|
|
149 | check_wxuse X |
|
|
150 | ;; |
|
|
151 | *) |
|
|
152 | echo |
|
|
153 | eerror "Invalid $FUNCNAME argument: $1" |
|
|
154 | echo |
|
|
155 | die "Invalid argument" |
|
|
156 | ;; |
| 40 | esac |
157 | esac |
| 41 | |
158 | |
|
|
159 | debug-print "wxchar is ${wxchar}" |
|
|
160 | |
|
|
161 | # since we're no longer in global scope we call built_with_use instead of |
|
|
162 | # all the crazy looping |
|
|
163 | |
|
|
164 | # base can be provided by both gtk2 and base installations |
|
|
165 | if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X); then |
|
|
166 | wxtoolkit="gtk2" |
| 42 | else |
167 | else |
| 43 | WX_GTK_VER="2.4" |
168 | wxtoolkit="base" |
| 44 | case $1 in |
|
|
| 45 | gtk) set-wxconfig wxgtk;; |
|
|
| 46 | gtk2) set-wxconfig wxgtk2;; |
|
|
| 47 | unicode) set-wxconfig wxgtk2u;; |
|
|
| 48 | *) echo "!!! $FUNCNAME: Error: wxGTK was not comipled with $1." |
|
|
| 49 | echo "!!! Adjust your USE flags or re-emerge wxGTK with version you want." |
|
|
| 50 | exit 1;; |
|
|
| 51 | esac |
|
|
| 52 | fi |
169 | fi |
|
|
170 | |
|
|
171 | debug-print "wxtoolkit is ${wxtoolkit}" |
|
|
172 | |
|
|
173 | # debug or release? |
|
|
174 | if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug); then |
|
|
175 | wxdebug="debug" |
|
|
176 | else |
|
|
177 | wxdebug="release" |
|
|
178 | fi |
|
|
179 | |
|
|
180 | debug-print "wxdebug is ${wxdebug}" |
|
|
181 | |
|
|
182 | # put it all together |
|
|
183 | wxconf="${wxtoolkit}-${wxchar}-${wxdebug}-${WX_GTK_VER}" |
|
|
184 | |
|
|
185 | debug-print "wxconf is ${wxconf}" |
|
|
186 | |
|
|
187 | # if this doesn't work, something is seriously screwed |
|
|
188 | if [[ ! -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then |
|
|
189 | echo |
|
|
190 | eerror "Failed to find configuration ${wxconf}" |
|
|
191 | echo |
|
|
192 | die "Missing wx-config" |
|
|
193 | fi |
|
|
194 | |
|
|
195 | debug-print "Found config ${wxconf} - setting WX_CONFIG" |
|
|
196 | |
|
|
197 | # This is exported as some configure scripts will check for its presence in |
|
|
198 | # the environment. |
|
|
199 | export WX_CONFIG="/usr/$(get_libdir)/wx/config/${wxconf}" |
|
|
200 | |
|
|
201 | debug-print "WX_CONFIG is ${WX_CONFIG}" |
|
|
202 | |
|
|
203 | # TODO: Used by the wx-config wrapper |
|
|
204 | export WX_ECLASS_CONFIG="${WX_CONFIG}" |
|
|
205 | |
|
|
206 | echo |
|
|
207 | einfo "Requested: ${1} ${WX_GTK_VER}" |
|
|
208 | einfo "Using: ${wxconf}" |
|
|
209 | echo |
| 53 | } |
210 | } |
| 54 | |
211 | |
| 55 | |
212 | |
| 56 | set-wxconfig() { |
213 | # @FUNCTION: check_wxuse |
|
|
214 | # @USAGE: <USE flag> |
|
|
215 | # @DESCRIPTION: |
|
|
216 | # Provides a consistant way to check if wxGTK was built with a particular USE |
|
|
217 | # flag enabled. |
| 57 | |
218 | |
|
|
219 | check_wxuse() { |
| 58 | debug-print-function $FUNCNAME $* |
220 | debug-print-function $FUNCNAME $* |
| 59 | |
221 | |
| 60 | if [ "${WX_GTK_VER}" = "2.6" ] ; then |
222 | [[ -n ${WX_GTK_VER} ]] \ |
| 61 | wxconfig_prefix="/usr/lib/wx/config" |
223 | || _wxerror "WX_GTK_VER must be set before calling" |
| 62 | wxconfig_name="${1}-release-${WX_GTK_VER}" |
224 | |
| 63 | wxconfig="${wxconfig_prefix}/${wxconfig_name}" |
225 | |
| 64 | wxconfig_debug_name="${1}-debug-${WX_GTK_VER}" |
226 | ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support" |
| 65 | wxconfig_debug="${wxconfig_prefix}/${wxconfig_debug_name}" |
227 | if $(built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"); then |
|
|
228 | eend 0 |
| 66 | else |
229 | else |
| 67 | # Default is 2.4: |
230 | eend 1 |
| 68 | wxconfig_prefix="/usr/bin" |
231 | echo |
| 69 | wxconfig_name="${1}-${WX_GTK_VER}-config" |
232 | eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to" |
| 70 | wxconfig="${wxconfig_prefix}/${wxconfig_name}" |
233 | eerror "have been built into x11-libs/wxGTK." |
| 71 | wxconfig_debug_name="${1}d-${WX_GTK_VER}-config" |
234 | eerror |
| 72 | wxconfig_debug="${wxconfig_prefix}/${wxconfig_debug_name}" |
235 | eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled." |
| 73 | fi |
236 | 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 |
237 | fi |
| 107 | } |
238 | } |
| 108 | |
|
|