net-wireless/hostapd: use #!/sbin/openrc-run instead of #!/sbin/runscript
[gentoo.git] / eclass / wxwidgets.eclass
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: wxwidgets.eclass
6 # @MAINTAINER:
7 # wxwidgets@gentoo.org
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 case ${EAPI} in
27         0|1|2|3|4|5)
28                 inherit eutils flag-o-matic multilib
29
30                 # This was used to set up a sane default for ebuilds so they could
31                 # avoid calling need-wxwidgets if they didn't need a particular build.
32                 # This was a bad idea for a couple different reasons, and because
33                 # get_libdir() is now illegal in global scope in EAPI 6 we can't do it
34                 # anymore.  All ebuilds must now use setup-wxwidgets and this code is
35                 # only here for backwards compatability.
36                 if [[ -z ${WX_CONFIG} ]]; then
37                         if [[ -n ${WX_GTK_VER} ]]; then
38                                 for _wxtoolkit in mac gtk2 base; do
39                                         # newer versions don't have a seperate debug config
40                                         for _wxdebug in xxx release- debug-; do
41                                                 _wxconf="${_wxtoolkit}-unicode-${_wxdebug/xxx/}${WX_GTK_VER}"
42
43                                                 [[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf} ]] \
44                                                         || continue
45
46                                                 WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${_wxconf}"
47                                                 WX_ECLASS_CONFIG="${WX_CONFIG}"
48                                                 break
49                                         done
50                                         [[ -n ${WX_CONFIG} ]] && break
51                                 done
52                                 [[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG
53                         fi
54                 fi
55                 unset _wxtoolkit
56                 unset _wxdebug
57                 unset _wxconf
58                 ;;
59         6)
60                 inherit flag-o-matic multilib
61                 ;;
62         *)
63                 die "EAPI=${EAPI:-0} is not supported"
64                 ;;
65 esac
66
67 # @FUNCTION:    setup-wxwidgets
68 # @DESCRIPTION:
69 #
70 #  Call this in your ebuild to set up the environment for wxGTK.  Besides
71 #  controlling the wx-config wrapper this exports WX_CONFIG containing
72 #  the path to the config in case it needs to be passed to a build system.
73 #
74 #  In wxGTK-2.9 and later it also controls the level of debugging output
75 #  from the libraries.  In these versions debugging features are enabled
76 #  by default and need to be disabled at the package level.  Because this
77 #  causes many warning dialogs to pop up during runtime we add -DNDEBUG to
78 #  CPPFLAGS to disable debugging features (unless your ebuild has a debug
79 #  USE flag and it's enabled).  If you don't like this behavior you can set
80 #  WX_DISABLE_NDEBUG to override it.
81 #
82 #  See: http://docs.wxwidgets.org/trunk/overview_debugging.html
83
84 setup-wxwidgets() {
85         local wxtoolkit wxdebug wxconf
86
87         [[ -z ${WX_GTK_VER} ]] \
88                 && die "WX_GTK_VER must be set before calling $FUNCNAME."
89
90         case "${WX_GTK_VER}" in
91                 3.0-gtk3)
92                         wxtoolkit=gtk3
93                         if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
94                                 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
95                         fi
96                         ;;
97                 2.9|3.0)
98                         wxtoolkit=gtk2
99                         if [[ -z ${WX_DISABLE_NDEBUG} ]]; then
100                                 ( in_iuse debug && use debug ) || append-cppflags -DNDEBUG
101                         fi
102                         ;;
103                 2.8)
104                         wxtoolkit=gtk2
105                         wxdebug="release-"
106                         has_version x11-libs/wxGTK:${WX_GTK_VER}[debug] && wxdebug="debug-"
107                         ;;
108                 *)
109                         die "Invalid WX_GTK_VER: must be set to a valid wxGTK SLOT"
110                         ;;
111         esac
112
113         # toolkit overrides
114         if has_version "x11-libs/wxGTK:${WX_GTK_VER}[aqua]"; then
115                 wxtoolkit="mac"
116         elif ! has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then
117                 wxtoolkit="base"
118         fi
119
120         wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}"
121
122         [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]] \
123                 && die "Failed to find configuration ${wxconf}"
124
125         export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}"
126         export WX_ECLASS_CONFIG="${WX_CONFIG}"
127
128         echo
129         einfo "Requested wxWidgets:        ${WX_GTK_VER}"
130         einfo "Using wxWidgets:            ${wxconf}"
131         echo
132 }
133
134 # deprecated
135 need-wxwidgets() {
136         setup-wxwidgets
137 }
138
139 _WXWIDGETS_ECLASS=1
140 fi