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

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

  ViewVC Help
Powered by ViewVC 1.1.20