1 # Copyright 1999-2015 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 inherit eutils flag-o-matic multilib
63 # We do this in global scope so ebuilds can get sane defaults just by
65 if [[ -z ${WX_CONFIG} ]]; then
66 if [[ -n ${WX_GTK_VER} ]]; then
67 for wxtoolkit in mac gtk2 base; do
68 # newer versions don't have a seperate debug profile
69 for wxdebug in xxx release- debug-; do
70 wxconf="${wxtoolkit}-unicode-${wxdebug/xxx/}${WX_GTK_VER}"
72 [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]] || continue
74 WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
75 WX_ECLASS_CONFIG="${WX_CONFIG}"
78 [[ -n ${WX_CONFIG} ]] && break
80 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
84 # @FUNCTION: need-wxwidgets
88 # Available profiles are:
91 # base-unicode (USE="-X")
93 # This lets you choose which config file from /usr/lib/wx/config is used when
94 # building the package. It also exports ${WX_CONFIG} with the full path to
97 # If your ebuild does not have a debug USE flag, or it has one and it is
98 # disabled, -DNDEBUG will be automatically added to CPPFLAGS. This can be
99 # overridden by setting WX_DISABLE_DEBUG if you want to handle it yourself.
102 local wxtoolkit wxdebug wxconf
104 if [[ -z ${WX_GTK_VER} ]]; then
105 eerror "WX_GTK_VER must be set before calling $FUNCNAME."
110 if [[ ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 && ${WX_GTK_VER} != 3.0 ]]; then
111 eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT."
117 unicode|base-unicode) ;;
118 *) eerror "Invalid $FUNCNAME profile: $1"
124 # wxbase is provided by both gtk2 and base installations
125 if has_version "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
127 elif has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then
133 # 2.8 has a separate debug element
134 if [[ ${WX_GTK_VER} == 2.8 ]]; then
135 if has_version "x11-libs/wxGTK:${WX_GTK_VER}[debug]"; then
141 if [[ -z ${WX_DISABLE_DEBUG} ]]; then
142 use_if_iuse debug || append-cppflags -DNDEBUG
146 wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
148 if [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]]; then
150 eerror "Failed to find configuration ${wxconf}"
155 export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
156 export WX_ECLASS_CONFIG="${WX_CONFIG}"
159 einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}"
160 einfo "Using wxWidgets: ${wxconf}"