1 |
# Copyright 1999-2013 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/wxwidgets.eclass,v 1.36 2013/11/16 10:25:39 dirtyepic Exp $ |
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 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. |
13 |
# |
14 |
# There are two ways to do it: |
15 |
# |
16 |
# - set WX_GTK_VER before inheriting the eclass |
17 |
# - set WX_GTK_VER and call need-wxwidgets from a phase function |
18 |
# |
19 |
# (where WX_GTK_VER is the SLOT you want) |
20 |
# |
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. |
24 |
# |
25 |
# @CODE |
26 |
# inherit wxwidgets |
27 |
# |
28 |
# IUSE="X wxwidgets" |
29 |
# DEPEND="wxwidgets? ( x11-libs/wxGTK:2.8[X?] )" |
30 |
# |
31 |
# src_configure() { |
32 |
# if use wxwidgets; then |
33 |
# WX_GTK_VER="2.8" |
34 |
# if use X; then |
35 |
# need-wxwidgets unicode |
36 |
# else |
37 |
# need-wxwidgets base-unicode |
38 |
# fi |
39 |
# fi |
40 |
# econf --with-wx-config="${WX_CONFIG}" |
41 |
# } |
42 |
# @CODE |
43 |
# |
44 |
# That's about as complicated as it gets. 99% of ebuilds can get away with: |
45 |
# |
46 |
# @CODE |
47 |
# inherit wxwidgets |
48 |
# DEPEND="wxwidgets? ( x11-libs/wxGTK:2.8[X] ) |
49 |
# ... |
50 |
# WX_GTK_VER=2.8 need-wxwidgets unicode |
51 |
# @CODE |
52 |
# |
53 |
# Note: unless you know your package works with wxbase (which is very |
54 |
# doubtful), always depend on wxGTK[X]. |
55 |
|
56 |
inherit eutils multilib |
57 |
|
58 |
# We do this in global scope so ebuilds can get sane defaults just by |
59 |
# inheriting. |
60 |
if [[ -z ${WX_CONFIG} ]]; then |
61 |
if [[ -n ${WX_GTK_VER} ]]; then |
62 |
for wxtoolkit in gtk2 base; do |
63 |
# newer versions don't have a seperate debug profile |
64 |
for wxdebug in xxx release- debug-; do |
65 |
wxconf="${wxtoolkit}-unicode-${wxdebug/xxx/}${WX_GTK_VER}" |
66 |
|
67 |
[[ -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]] || continue |
68 |
|
69 |
WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}" |
70 |
WX_ECLASS_CONFIG="${WX_CONFIG}" |
71 |
break |
72 |
done |
73 |
[[ -n ${WX_CONFIG} ]] && break |
74 |
done |
75 |
[[ -n ${WX_CONFIG} ]] && export WX_CONFIG WX_ECLASS_CONFIG |
76 |
fi |
77 |
fi |
78 |
|
79 |
# @FUNCTION: need-wxwidgets |
80 |
# @USAGE: <profile> |
81 |
# @DESCRIPTION: |
82 |
# |
83 |
# Available configurations are: |
84 |
# |
85 |
# unicode (USE="X") |
86 |
# base-unicode (USE="-X") |
87 |
|
88 |
need-wxwidgets() { |
89 |
local wxtoolkit wxdebug wxconf |
90 |
|
91 |
if [[ -z ${WX_GTK_VER} ]]; then |
92 |
eerror "WX_GTK_VER must be set before calling $FUNCNAME." |
93 |
echo |
94 |
die |
95 |
fi |
96 |
|
97 |
if [[ ${WX_GTK_VER} != 2.8 && ${WX_GTK_VER} != 2.9 ]]; then |
98 |
eerror "Invalid WX_GTK_VER: ${WX_GTK_VER} - must be set to a valid wxGTK SLOT." |
99 |
echo |
100 |
die |
101 |
fi |
102 |
|
103 |
case $1 in |
104 |
unicode|base-unicode) ;; |
105 |
*) eerror "Invalid $FUNCNAME profile: $1" |
106 |
echo |
107 |
die |
108 |
;; |
109 |
esac |
110 |
|
111 |
# wxbase is provided by both gtk2 and base installations |
112 |
if has_version "x11-libs/wxGTK:${WX_GTK_VER}[X]"; then |
113 |
wxtoolkit="gtk2" |
114 |
else |
115 |
wxtoolkit="base" |
116 |
fi |
117 |
|
118 |
# 2.8 has a separate debug tuple |
119 |
if [[ ${WX_GTK_VER} == 2.8 ]]; then |
120 |
if has_version "x11-libs/wxGTK:${WX_GTK_VER}[debug]"; then |
121 |
wxdebug="debug-" |
122 |
else |
123 |
wxdebug="release-" |
124 |
fi |
125 |
fi |
126 |
|
127 |
wxconf="${wxtoolkit}-unicode-${wxdebug}${WX_GTK_VER}" |
128 |
|
129 |
if [[ ! -f ${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf} ]]; then |
130 |
echo |
131 |
eerror "Failed to find configuration ${wxconf}" |
132 |
echo |
133 |
die |
134 |
fi |
135 |
|
136 |
export WX_CONFIG="${EPREFIX}/usr/$(get_libdir)/wx/config/${wxconf}" |
137 |
export WX_ECLASS_CONFIG="${WX_CONFIG}" |
138 |
|
139 |
echo |
140 |
einfo "Requested wxWidgets: ${1} ${WX_GTK_VER}" |
141 |
einfo "Using wxWidgets: ${wxconf}" |
142 |
echo |
143 |
} |