1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: wxwidgets.eclass
7 # @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
8 # @BLURB: Manages build configuration for wxGTK-using packages.
10 # This eclass sets up the proper environment for ebuilds using the wxGTK
11 # libraries. Ebuilds using wxPython do not need to inherit this eclass.
13 # More specifically, this eclass controls the configuration chosen by the
14 # /usr/bin/wx-config wrapper.
16 # Using the eclass is simple:
18 # - set WX_GTK_VER equal to a SLOT of wxGTK
19 # - call setup-wxwidgets()
21 # The configuration chosen is based on the version required and the flags
22 # wxGTK was built with.
24 if [[ -z ${_WXWIDGETS_ECLASS} ]]; then
30 inherit eutils multilib
32 # This was used to set up a sane default for ebuilds so they could
33 # avoid calling need-wxwidgets if they didn't need a particular build.
34 # This was a bad idea for a couple different reasons, and because
35 # get_libdir() is now illegal in global scope in EAPI 6 we can't do it
36 # anymore. All ebuilds must now use setup-wxwidgets and this code is
37 # only here for backwards compatability.
38 if [[ -z ${WX_CONFIG} ]]; then
39 if [[ -n ${WX_GTK_VER} ]]; then
40 for _wxtoolkit in mac gtk2 base; do
41 # newer versions don't have a seperate debug config
42 for _wxdebug in xxx release- debug-; do
43 _wxconf="${_wxtoolkit}-unicode-${_wxdebug/xxx/}${WX_GTK_VER}"
45 [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf} ]] \
48 WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf}"
49 WX_ECLASS_CONFIG="${WX_CONFIG}"
52 [[ -n ${WX_CONFIG} ]] && break
54 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
61 6) inherit multilib ;; # compatibility only, not needed by eclass
63 *) die "${ECLASS}: EAPI ${EAPI:-0} is not supported" ;;
66 # @FUNCTION: setup-wxwidgets
68 # Call this in your ebuild to set up the environment for wxGTK. Besides
69 # controlling the wx-config wrapper this exports WX_CONFIG containing
70 # the path to the config in case it needs to be passed to a build system.
72 # In wxGTK-2.9 and later it also controls the level of debugging output
73 # from the libraries. In these versions debugging features are enabled
74 # by default and need to be disabled at the package level. Because this
75 # causes many warning dialogs to pop up during runtime we add -DNDEBUG to
76 # CPPFLAGS to disable debugging features (unless your ebuild has a debug
77 # USE flag and it's enabled). If you don't like this behavior you can set
78 # WX_DISABLE_NDEBUG to override it.
80 # See: http://docs.wxwidgets.org/trunk/overview_debugging.html
83 local wxtoolkit wxdebug wxconf
85 [[ -z ${WX_GTK_VER} ]] \
86 && die "WX_GTK_VER must be set before calling $FUNCNAME."
88 case "${WX_GTK_VER}" in
91 if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
92 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
97 if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
98 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
104 has_version x11-libs/wxGTK:${WX_GTK_VER}[debug] && wxdebug="debug-"
107 die "Invalid WX_GTK_VER: must be set to a valid wxGTK SLOT"
112 if has_version "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
114 elif ! has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then
118 wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
120 [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]] \
121 && die "Failed to find configuration ${wxconf}"
123 export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
124 export WX_ECLASS_CONFIG="${WX_CONFIG}"
127 einfo "Requested wxWidgets: ${WX_GTK_VER}"
128 einfo "Using wxWidgets: ${wxconf}"