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

Diff of /eclass/wxwidgets.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.9 Revision 1.28
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.28 2009/09/07 00:29:47 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 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. Otherwise the system
17# profile will be used, meaning whatever the user happened to set it to
18# through eselect-wxwidgets.
16# 19#
17# set-wxconfig 20# Ebuilds are also required to set the variable WX_GTK_VER, containing
18# Arguments: (wxGTK 2.4) wxgtk, wxgtk2, or wxgtk2u 21# the wxGTK SLOT the ebuild requires.
19# Arguments: (wxGTK 2.6) gtk-ansi gtk2-ansi unicode base-ansi base-unicode mac-ansi mac-unicode 22#
20# Note: Don't call this function directly from ebuilds 23# Simple Usage:
24#
25# @CODE
26# WX_GTK_VER="2.8"
27#
28# inherit wxwidgets
29#
30# DEPEND="=x11-libs/wxGTK-2.8*" (or x11-libs/wxGTK:2.8 for >=EAPI 1)
31# RDEPEND="${DEPEND}"
32# [...]
33# @CODE
34#
35# 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#
38# If you need more control over which profile(s) you need to use, see the
39# need-wxwidgets function below.
21 40
22ECLASS=wxwidgets 41inherit eutils multilib
23INHERITED="$INHERITED $ECLASS" 42
43case "${EAPI:-0}" in
44 0|1)
45 EXPORT_FUNCTIONS pkg_setup
46 ;;
47 *)
48 ;;
49esac
50
51# 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
54if [[ -z ${WX_CONFIG} ]]; then
55 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 if [[ -f /usr/$(get_libdir)/wx/config/${wxconf} ]]; then
66 [[ ${wxtoolkit} == "base" ]] && WXBASE_DIE=1 # see wxwidgets_pkg_setup
67 else
68 continue
69 fi
70 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
78fi
79
80# @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# Note that with an EAPI 2 ebuild you should just DEPEND on x11-libs/wxGTK:2.8[X]
93# and ignore all this nonsense.
94
95wxwidgets_pkg_setup() {
96 [[ -n $WXBASE_DIE ]] && check_wxuse X
97}
98
99# @FUNCTION: need-wxwidgets
100# @USAGE: <configuration>
101# @DESCRIPTION:
102#
103# need-wxwidgets is called with one argument, the wxGTK configuration to use.
104#
105# Available configurations are:
106#
107# ansi
108# unicode
109# base-ansi
110# base-unicode
111#
112# Note that in >=wxGTK-2.8, only the unicode versions are available. The
113# eclass will automatically map ansi to unicode for you if WX_GTK_VER is
114# set to 2.8 or later.
115#
116# 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.
24 124
25need-wxwidgets() { 125need-wxwidgets() {
26 debug-print-function $FUNCNAME $* 126 debug-print-function $FUNCNAME $*
27 #If you want to use wxGTK-2.6* export WX_GTK_VER in your ebuild: 127
28 if [ "${WX_GTK_VER}" = "2.6" ]; then 128 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 fi
136
137 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
145 debug-print "WX_GTK_VER is ${WX_GTK_VER}"
146
29 case $1 in 147 case $1 in
30 gtk) set-wxconfig gtk-ansi;; 148 ansi)
31 gtk2) set-wxconfig gtk2-ansi;; 149 debug-print-section ansi
32 unicode) set-wxconfig gtk2-unicode;; 150 if [[ ${WX_GTK_VER} == 2.6 ]]; then
33 base) set-wxconfig base-ansi;; 151 wxchar="ansi"
34 base-unicode) set-wxconfig base-unicode;; 152 else
35 mac) set-wxconfig mac-ansi;; 153 wxchar="unicode"
36 mac-unicode) set-wxconfig mac-unicode;; 154 fi
37 *) echo "!!! $FUNCNAME: Error: wxGTK was not comipled with $1." 155 check_wxuse X
38 echo "!!! Adjust your USE flags or re-emerge wxGTK with version you want." 156 ;;
39 exit 1;; 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 ;;
40 esac 192 esac
41 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 # wxBase can be provided by both gtk2 and base installations
200 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* X; then
201 wxtoolkit="gtk2"
42 else 202 else
43 WX_GTK_VER="2.4" 203 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 204 fi
205
206 debug-print "wxtoolkit is ${wxtoolkit}"
207
208 # debug or release?
209 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* debug; then
210 wxdebug="debug"
211 else
212 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 fi
229
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 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
240 einfo "Using wxWidgets: ${wxconf}"
241 echo
53} 242}
54 243
55 244
56set-wxconfig() { 245# @FUNCTION: check_wxuse
246# @USAGE: <USE flag>
247# @DESCRIPTION:
248#
249# Provides a consistant way to check if wxGTK was built with a particular USE
250# flag enabled.
57 251
252check_wxuse() {
58 debug-print-function $FUNCNAME $* 253 debug-print-function $FUNCNAME $*
59 254
60 if [ "${WX_GTK_VER}" = "2.6" ] ; then 255 if [[ -z ${WX_GTK_VER} ]]; then
61 wxconfig_prefix="/usr/lib/wx/config" 256 echo
62 wxconfig_name="${1}-release-${WX_GTK_VER}" 257 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
63 wxconfig="${wxconfig_prefix}/${wxconfig_name}" 258 echo
64 wxconfig_debug_name="${1}-debug-${WX_GTK_VER}" 259 die "WX_GTK_VER missing"
65 wxconfig_debug="${wxconfig_prefix}/${wxconfig_debug_name}" 260 fi
261
262 ebegin "Checking wxGTK-${WX_GTK_VER} for ${1} support"
263 if built_with_use =x11-libs/wxGTK-${WX_GTK_VER}* "${1}"; then
264 eend 0
66 else 265 else
67 # Default is 2.4: 266 eend 1
68 wxconfig_prefix="/usr/bin" 267 echo
69 wxconfig_name="${1}-${WX_GTK_VER}-config" 268 eerror "${FUNCNAME} - You have requested functionality that requires ${1} support to"
70 wxconfig="${wxconfig_prefix}/${wxconfig_name}" 269 eerror "have been built into x11-libs/wxGTK."
71 wxconfig_debug_name="${1}d-${WX_GTK_VER}-config" 270 eerror
72 wxconfig_debug="${wxconfig_prefix}/${wxconfig_debug_name}" 271 eerror "Please re-merge =x11-libs/wxGTK-${WX_GTK_VER}* with the ${1} USE flag enabled."
73 fi 272 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 273 fi
107} 274}
108

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20