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

Diff of /eclass/wxwidgets.eclass

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

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

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20