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