1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: wxwidgets.eclass
8 # @BLURB: Manages build configuration for wxGTK-using packages.
10 # This eclass gives ebuilds the ability to build against a specific wxGTK
11 # SLOT and profile without interfering with the system configuration. Any
12 # ebuild with a x11-libs/wxGTK dependency must use this eclass.
14 # There are two ways to do it:
16 # - set WX_GTK_VER before inheriting the eclass
17 # - set WX_GTK_VER and call need-wxwidgets from a phase function
19 # (where WX_GTK_VER is the SLOT you want)
21 # If your package has optional support for wxGTK (ie. by a USE flag) then
22 # you should use need-wxwidgets. This is important because some packages
23 # will force-enable wxGTK if they find WX_CONFIG set in the environment.
29 # DEPEND="wxwidgets? ( x11-libs/wxGTK:2.8[X?] )"
32 # if use wxwidgets; then
35 # need-wxwidgets unicode
37 # need-wxwidgets base-unicode
40 # econf --with-wx-config="${WX_CONFIG}"
44 # That's about as complicated as it gets. 99% of ebuilds can get away with:
48 # DEPEND="wxwidgets? ( x11-libs/wxGTK:2.8[X] )
50 # WX_GTK_VER=2.8 need-wxwidgets unicode
53 # Note: unless you know your package works with wxbase (which is very
54 # doubtful), always depend on wxGTK[X].
56 # Debugging: In wxGTK 3.0 and later debugging support is enabled in the
57 # library by default and needs to be controlled at the package level.
58 # Use the -DNDEBUG preprocessor flag to disable debugging features.
59 # (Using need-wxwidgets will do this for you, see below.)
61 if [[ -z ${_WXWIDGETS_ECLASS} ]]; then
65 inherit eutils flag-o-matic multilib
68 die "EAPI=${EAPI:-0} is not supported"
72 # We do this in global scope so ebuilds can get sane defaults just by
74 if [[ -z ${WX_CONFIG} ]]; then
75 if [[ -n ${WX_GTK_VER} ]]; then
76 for _wxtoolkit in mac gtk2 base; do
77 # newer versions don't have a seperate debug profile
78 for _wxdebug in xxx release- debug-; do
79 _wxconf="${_wxtoolkit}-unicode-${_wxdebug/xxx/}${WX_GTK_VER}"
81 [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf} ]] || continue
83 WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf}"
84 WX_ECLASS_CONFIG="${WX_CONFIG}"
87 [[ -n ${WX_CONFIG} ]] && break
89 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
96 # @FUNCTION: need-wxwidgets
100 # Available profiles are:
103 # base-unicode (USE="-X")
105 # This lets you choose which config file from /usr/lib/wx/config is used when
106 # building the package. It also exports ${WX_CONFIG} with the full path to
109 # If your ebuild does not have a debug USE flag, or it has one and it is
110 # disabled, -DNDEBUG will be automatically added to CPPFLAGS. This can be
111 # overridden by setting WX_DISABLE_DEBUG if you want to handle it yourself.
114 local wxtoolkit wxdebug wxconf
116 if [[ -z ${WX_GTK_VER} ]]; then
117 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
122 if [[ ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 && ${WX_GTK_VER} != 3.0 ]]; then
123 eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT."
129 unicode|base-unicode) ;;
130 *) eerror "Invalid $FUNCNAME profile: $1"
136 # wxbase is provided by both gtk2 and base installations
137 if has_version "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
139 elif has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then
145 # 2.8 has a separate debug element
146 if [[ ${WX_GTK_VER} == 2.8 ]]; then
147 if has_version "x11-libs/wxGTK:${WX_GTK_VER}[debug]"; then
153 if [[ -z ${WX_DISABLE_DEBUG} ]]; then
154 use_if_iuse debug || append-cppflags -DNDEBUG
158 wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
160 if [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]]; then
162 eerror "Failed to find configuration ${wxconf}"
167 export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
168 export WX_ECLASS_CONFIG="${WX_CONFIG}"
171 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
172 einfo "Using wxWidgets: ${wxconf}"