kde-plasma/breeze-gtk: x86 stable wrt bug #613144
[gentoo.git] / eclass / wxwidgets.eclass
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: wxwidgets.eclass
5 # @MAINTAINER:
6 # wxwidgets@gentoo.org
7 # @BLURB: Manages build configuration for wxGTK-using packages.
8 # @DESCRIPTION:
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.
11 #
12 #  More specifically, this eclass controls the configuration chosen by the
13 #  /usr/bin/wx-config wrapper.
14 #
15 #  Using the eclass is simple:
16 #
17 #    - set WX_GTK_VER equal to a SLOT of wxGTK
18 #    - call setup-wxwidgets()
19 #
20 #  The configuration chosen is based on the version required and the flags
21 #  wxGTK was built with.
22
23 if [[ -z ${_WXWIDGETS_ECLASS} ]]; then
24
25 case ${EAPI} in
26         0|1|2|3|4|5)
27                 inherit eutils flag-o-matic multilib
28
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}"
41
42                                                 [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf} ]] \
43                                                         || continue
44
45                                                 WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf}"
46                                                 WX_ECLASS_CONFIG="${WX_CONFIG}"
47                                                 break
48                                         done
49                                         [[ -n ${WX_CONFIG} ]] && break
50                                 done
51                                 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
52                         fi
53                 fi
54                 unset _wxtoolkit
55                 unset _wxdebug
56                 unset _wxconf
57                 ;;
58         6)
59                 inherit flag-o-matic multilib
60                 ;;
61         *)
62                 die "EAPI=${EAPI:-0} is not supported"
63                 ;;
64 esac
65
66 # @FUNCTION:    setup-wxwidgets
67 # @DESCRIPTION:
68 #
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.
72 #
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.
80 #
81 #  See: http://docs.wxwidgets.org/trunk/overview_debugging.html
82
83 setup-wxwidgets() {
84         local wxtoolkit wxdebug wxconf
85
86         [[ -z ${WX_GTK_VER} ]] \
87                 && die "WX_GTK_VER must be set before calling $FUNCNAME."
88
89         case "${WX_GTK_VER}" in
90                 3.0-gtk3)
91                         wxtoolkit=gtk3
92                         if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
93                                 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
94                         fi
95                         ;;
96                 2.9|3.0)
97                         wxtoolkit=gtk2
98                         if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
99                                 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
100                         fi
101                         ;;
102                 2.8)
103                         wxtoolkit=gtk2
104                         wxdebug="release-"
105                         has_version x11-libs/wxGTK:${WX_GTK_VER}[debug] && wxdebug="debug-"
106                         ;;
107                 *)
108                         die "Invalid WX_GTK_VER: must be set to a valid wxGTK SLOT"
109                         ;;
110         esac
111
112         # toolkit overrides
113         if has_version "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
114                 wxtoolkit="mac"
115         elif ! has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then
116                 wxtoolkit="base"
117         fi
118
119         wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
120
121         [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]] \
122                 && die "Failed to find configuration ${wxconf}"
123
124         export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
125         export WX_ECLASS_CONFIG="${WX_CONFIG}"
126
127         echo
128         einfo "Requested wxWidgets:        ${WX_GTK_VER}"
129         einfo "Using wxWidgets:            ${wxconf}"
130         echo
131 }
132
133 # deprecated
134 need-wxwidgets() {
135         setup-wxwidgets
136 }
137
138 _WXWIDGETS_ECLASS=1
139 fi