1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: wxwidgets.eclass
7 # @BLURB: Manages build configuration for wxGTK-using packages.
9 # This eclass sets up the proper environment for ebuilds using the wxGTK
10 # libraries. Ebuilds using wxPython do not need to inherit this eclass.
12 # More specifically, this eclass controls the configuration chosen by the
13 # /usr/bin/wx-config wrapper.
15 # Using the eclass is simple:
17 # - set WX_GTK_VER equal to a SLOT of wxGTK
18 # - call setup-wxwidgets()
20 # The configuration chosen is based on the version required and the flags
21 # wxGTK was built with.
23 if [[ -z ${_WXWIDGETS_ECLASS} ]]; then
27 inherit eutils flag-o-matic multilib
29 # This was used to set up a sane default for ebuilds so they could
30 # avoid calling need-wxwidgets if they didn't need a particular build.
31 # This was a bad idea for a couple different reasons, and because
32 # get_libdir() is now illegal in global scope in EAPI 6 we can't do it
33 # anymore. All ebuilds must now use setup-wxwidgets and this code is
34 # only here for backwards compatability.
35 if [[ -z ${WX_CONFIG} ]]; then
36 if [[ -n ${WX_GTK_VER} ]]; then
37 for _wxtoolkit in mac gtk2 base; do
38 # newer versions don't have a seperate debug config
39 for _wxdebug in xxx release- debug-; do
40 _wxconf="${_wxtoolkit}-unicode-${_wxdebug/xxx/}${WX_GTK_VER}"
42 [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf} ]] \
45 WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf}"
46 WX_ECLASS_CONFIG="${WX_CONFIG}"
49 [[ -n ${WX_CONFIG} ]] && break
51 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
59 inherit flag-o-matic multilib
62 die "EAPI=${EAPI:-0} is not supported"
66 # @FUNCTION: setup-wxwidgets
69 # Call this in your ebuild to set up the environment for wxGTK. Besides
70 # controlling the wx-config wrapper this exports WX_CONFIG containing
71 # the path to the config in case it needs to be passed to a build system.
73 # In wxGTK-2.9 and later it also controls the level of debugging output
74 # from the libraries. In these versions debugging features are enabled
75 # by default and need to be disabled at the package level. Because this
76 # causes many warning dialogs to pop up during runtime we add -DNDEBUG to
77 # CPPFLAGS to disable debugging features (unless your ebuild has a debug
78 # USE flag and it's enabled). If you don't like this behavior you can set
79 # WX_DISABLE_NDEBUG to override it.
81 # See: http://docs.wxwidgets.org/trunk/overview_debugging.html
84 local wxtoolkit wxdebug wxconf
86 [[ -z ${WX_GTK_VER} ]] \
87 && die "WX_GTK_VER must be set before calling $FUNCNAME."
89 case "${WX_GTK_VER}" in
92 if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
93 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
98 if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
99 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
105 has_version x11-libs/wxGTK:${WX_GTK_VER}[debug] && wxdebug="debug-"
108 die "Invalid WX_GTK_VER: must be set to a valid wxGTK SLOT"
113 if has_version "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
115 elif ! has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then
119 wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
121 [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]] \
122 && die "Failed to find configuration ${wxconf}"
124 export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
125 export WX_ECLASS_CONFIG="${WX_CONFIG}"
128 einfo "Requested wxWidgets: ${WX_GTK_VER}"
129 einfo "Using wxWidgets: ${wxconf}"