1 |
--- |
2 |
gx86/eclass/autotools-multilib.eclass | 82 +---------------------- |
3 |
gx86/eclass/multilib-build.eclass | 121 ++++++++++++++++++++++++++++++++++ |
4 |
2 files changed, 124 insertions(+), 79 deletions(-) |
5 |
|
6 |
diff --git a/gx86/eclass/autotools-multilib.eclass b/gx86/eclass/autotools-multilib.eclass |
7 |
index 55d32d7..6b0960f 100644 |
8 |
--- a/gx86/eclass/autotools-multilib.eclass |
9 |
+++ b/gx86/eclass/autotools-multilib.eclass |
10 |
@@ -33,28 +33,6 @@ inherit autotools-utils multilib-build |
11 |
|
12 |
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install |
13 |
|
14 |
-# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS |
15 |
-# @DESCRIPTION: |
16 |
-# A list of headers to wrap for multilib support. The listed headers |
17 |
-# will be moved to a non-standard location and replace with a file |
18 |
-# including them conditionally to current ABI. |
19 |
-# |
20 |
-# This variable has to be a bash array. Paths shall be relative to |
21 |
-# installation root (${ED}), and name regular files. Recursive wrapping |
22 |
-# is not supported. |
23 |
-# |
24 |
-# Please note that header wrapping is *discouraged*. It is preferred to |
25 |
-# install all headers in a subdirectory of libdir and use pkg-config to |
26 |
-# locate the headers. Some C preprocessors will not work with wrapped |
27 |
-# headers. |
28 |
-# |
29 |
-# Example: |
30 |
-# @CODE |
31 |
-# MULTILIB_WRAPPED_HEADERS=( |
32 |
-# /usr/include/foobar/config.h |
33 |
-# ) |
34 |
-# @CODE |
35 |
- |
36 |
autotools-multilib_src_prepare() { |
37 |
autotools-utils_src_prepare "${@}" |
38 |
} |
39 |
@@ -71,71 +49,17 @@ autotools-multilib_src_test() { |
40 |
multilib_foreach_abi autotools-utils_src_test "${@}" |
41 |
} |
42 |
|
43 |
-_autotools-multilib_wrap_headers() { |
44 |
- debug-print-function ${FUNCNAME} "$@" |
45 |
- local f |
46 |
- |
47 |
- for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do |
48 |
- # drop leading slash if it's there |
49 |
- f=${f#/} |
50 |
- |
51 |
- if [[ ${f} != usr/include/* ]]; then |
52 |
- die "Wrapping headers outside of /usr/include is not supported at the moment." |
53 |
- fi |
54 |
- # and then usr/include |
55 |
- f=${f#usr/include} |
56 |
- |
57 |
- local dir=${f%/*} |
58 |
- |
59 |
- # $CHOST shall be set by multilib_toolchain_setup |
60 |
- dodir "/tmp/multilib-include/${CHOST}${dir}" |
61 |
- mv "${ED}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die |
62 |
- |
63 |
- if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then |
64 |
- dodir "/tmp/multilib-include${dir}" |
65 |
- # a generic template |
66 |
- cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ || die |
67 |
-/* This file is auto-generated by autotools-multilib.eclass |
68 |
- * as a multilib-friendly wrapper. For the original content, |
69 |
- * please see the files that are #included below. |
70 |
- */ |
71 |
- |
72 |
-#if defined(__x86_64__) /* amd64 */ |
73 |
-# if defined(__ILP32__) /* x32 ABI */ |
74 |
-# error "x86_x32 not supported by the package." |
75 |
-# else /* 64-bit ABI */ |
76 |
-# error "x86_64 not supported by the package." |
77 |
-# endif |
78 |
-#elif defined(__i386__) /* plain x86 */ |
79 |
-# error "x86_32 not supported by the package." |
80 |
-#else |
81 |
-# error "No ABI matched, please report a bug to bugs.gentoo.org" |
82 |
-#endif |
83 |
-_EOF_ |
84 |
- fi |
85 |
- |
86 |
- # Note: match a space afterwards to avoid collision potential. |
87 |
- sed -e "/${MULTILIB_ABI} /s&error.*&include <${CHOST}/${f}>&" \ |
88 |
- -i "${ED}/tmp/multilib-include${f}" || die |
89 |
- done |
90 |
-} |
91 |
- |
92 |
autotools-multilib_src_install() { |
93 |
autotools-multilib_secure_install() { |
94 |
autotools-utils_src_install "${@}" |
95 |
|
96 |
- _autotools-multilib_wrap_headers |
97 |
+ multilib_prepare_wrappers |
98 |
# Make sure all headers are the same for each ABI. |
99 |
multilib_check_headers |
100 |
} |
101 |
|
102 |
multilib_foreach_abi autotools-multilib_secure_install "${@}" |
103 |
|
104 |
- # merge the wrapped headers |
105 |
- if [[ -d "${ED}"/tmp/multilib-include ]]; then |
106 |
- multibuild_merge_root \ |
107 |
- "${ED}"/tmp/multilib-include "${ED}"/usr/include |
108 |
- # it can fail if something else uses /tmp |
109 |
- rmdir "${ED}"/tmp &>/dev/null |
110 |
- fi |
111 |
+ # merge the wrappers |
112 |
+ multilib_install_wrappers |
113 |
} |
114 |
diff --git a/gx86/eclass/multilib-build.eclass b/gx86/eclass/multilib-build.eclass |
115 |
index fdaed6b..f0c433b 100644 |
116 |
--- a/gx86/eclass/multilib-build.eclass |
117 |
+++ b/gx86/eclass/multilib-build.eclass |
118 |
@@ -235,5 +235,126 @@ multilib_copy_sources() { |
119 |
multibuild_copy_sources |
120 |
} |
121 |
|
122 |
+# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS |
123 |
+# @DESCRIPTION: |
124 |
+# A list of headers to wrap for multilib support. The listed headers |
125 |
+# will be moved to a non-standard location and replaced with a file |
126 |
+# including them conditionally to current ABI. |
127 |
+# |
128 |
+# This variable has to be a bash array. Paths shall be relative to |
129 |
+# installation root (${ED}), and name regular files. Recursive wrapping |
130 |
+# is not supported. |
131 |
+# |
132 |
+# Please note that header wrapping is *discouraged*. It is preferred to |
133 |
+# install all headers in a subdirectory of libdir and use pkg-config to |
134 |
+# locate the headers. Some C preprocessors will not work with wrapped |
135 |
+# headers. |
136 |
+# |
137 |
+# Example: |
138 |
+# @CODE |
139 |
+# MULTILIB_WRAPPED_HEADERS=( |
140 |
+# /usr/include/foobar/config.h |
141 |
+# ) |
142 |
+# @CODE |
143 |
+ |
144 |
+# @FUNCTION: multilib_prepare_wrappers |
145 |
+# @USAGE: [<install-root>] |
146 |
+# @DESCRIPTION: |
147 |
+# Perform the preparation of all kinds of wrappers for the current ABI. |
148 |
+# This function shall be called once per each ABI, after installing |
149 |
+# the files to be wrapped. |
150 |
+# |
151 |
+# Takes an optional custom <install-root> from which files will be |
152 |
+# used. If no root is specified, uses ${ED}. |
153 |
+# |
154 |
+# The files to be wrapped are specified using separate variables, |
155 |
+# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed |
156 |
+# between the successive calls to multilib_prepare_wrappers |
157 |
+# and multilib_install_wrappers. |
158 |
+# |
159 |
+# After all wrappers are prepared, multilib_install_wrappers shall |
160 |
+# be called to commit them to the installation tree. |
161 |
+multilib_prepare_wrappers() { |
162 |
+ debug-print-function ${FUNCNAME} "${@}" |
163 |
+ |
164 |
+ [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" |
165 |
+ |
166 |
+ local root=${1:-${ED}} |
167 |
+ local f |
168 |
+ |
169 |
+ for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do |
170 |
+ # drop leading slash if it's there |
171 |
+ f=${f#/} |
172 |
+ |
173 |
+ if [[ ${f} != usr/include/* ]]; then |
174 |
+ die "Wrapping headers outside of /usr/include is not supported at the moment." |
175 |
+ fi |
176 |
+ # and then usr/include |
177 |
+ f=${f#usr/include} |
178 |
+ |
179 |
+ local dir=${f%/*} |
180 |
+ |
181 |
+ # $CHOST shall be set by multilib_toolchain_setup |
182 |
+ dodir "/tmp/multilib-include/${CHOST}${dir}" |
183 |
+ mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die |
184 |
+ |
185 |
+ if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then |
186 |
+ dodir "/tmp/multilib-include${dir}" |
187 |
+ # a generic template |
188 |
+ cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ || die |
189 |
+/* This file is auto-generated by multilib-build.eclass |
190 |
+ * as a multilib-friendly wrapper. For the original content, |
191 |
+ * please see the files that are #included below. |
192 |
+ */ |
193 |
+ |
194 |
+#if defined(__x86_64__) /* amd64 */ |
195 |
+# if defined(__ILP32__) /* x32 ABI */ |
196 |
+# error "x86_x32 not supported by the package." |
197 |
+# else /* 64-bit ABI */ |
198 |
+# error "x86_64 not supported by the package." |
199 |
+# endif |
200 |
+#elif defined(__i386__) /* plain x86 */ |
201 |
+# error "x86_32 not supported by the package." |
202 |
+#else |
203 |
+# error "No ABI matched, please report a bug to bugs.gentoo.org" |
204 |
+#endif |
205 |
+_EOF_ |
206 |
+ fi |
207 |
+ |
208 |
+ # Note: match a space afterwards to avoid collision potential. |
209 |
+ sed -e "/${MULTILIB_ABI} /s&error.*&include <${CHOST}/${f}>&" \ |
210 |
+ -i "${ED}/tmp/multilib-include${f}" || die |
211 |
+ done |
212 |
+} |
213 |
+ |
214 |
+# @FUNCTION: multilib_install_wrappers |
215 |
+# @USAGE: [<install-root>] |
216 |
+# @DESCRIPTION: |
217 |
+# Install the previously-prepared wrappers. This function shall |
218 |
+# be called once, after all wrappers were prepared. |
219 |
+# |
220 |
+# Takes an optional custom <install-root> to which the wrappers will be |
221 |
+# installed. If no root is specified, uses ${ED}. There is no need to |
222 |
+# use the same root as when preparing the wrappers. |
223 |
+# |
224 |
+# The files to be wrapped are specified using separate variables, |
225 |
+# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed |
226 |
+# between the calls to multilib_prepare_wrappers |
227 |
+# and multilib_install_wrappers. |
228 |
+multilib_install_wrappers() { |
229 |
+ debug-print-function ${FUNCNAME} "${@}" |
230 |
+ |
231 |
+ [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments" |
232 |
+ |
233 |
+ local root=${1:-${ED}} |
234 |
+ |
235 |
+ if [[ -d "${ED}"/tmp/multilib-include ]]; then |
236 |
+ multibuild_merge_root \ |
237 |
+ "${ED}"/tmp/multilib-include "${root}"/usr/include |
238 |
+ # it can fail if something else uses /tmp |
239 |
+ rmdir "${ED}"/tmp &>/dev/null |
240 |
+ fi |
241 |
+} |
242 |
+ |
243 |
_MULTILIB_BUILD=1 |
244 |
fi |
245 |
-- |
246 |
1.8.1.5 |