1 |
On Sat, 23 Mar 2013 17:26:38 +0100 |
2 |
Michał Górny <mgorny@g.o> wrote: |
3 |
|
4 |
> --- |
5 |
> gx86/eclass/autotools-multilib.eclass | 82 |
6 |
> +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) |
7 |
> |
8 |
> diff --git a/gx86/eclass/autotools-multilib.eclass |
9 |
> b/gx86/eclass/autotools-multilib.eclass index d7372b0..c65c777 100644 |
10 |
> --- a/gx86/eclass/autotools-multilib.eclass |
11 |
> +++ b/gx86/eclass/autotools-multilib.eclass |
12 |
|
13 |
|
14 |
why not multilib-build ? |
15 |
|
16 |
|
17 |
> @@ -33,6 +33,28 @@ inherit autotools-utils multilib-build |
18 |
> |
19 |
> EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test |
20 |
> src_install |
21 |
> +# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS |
22 |
> +# @DESCRIPTION: |
23 |
> +# A list of headers to wrap for multilib support. The listed headers |
24 |
> +# will be moved to a non-standard location and replace with a file |
25 |
> +# including them conditionally to current ABI. |
26 |
> +# |
27 |
> +# This variable has to be a bash array. Paths shall be relative to |
28 |
> +# installation root (${D}), and name regular files. Recursive |
29 |
> wrapping +# is not supported. |
30 |
> +# |
31 |
> +# Please note that header wrapping is *discouraged*. It is preferred |
32 |
> to +# install all headers in a subdirectory of libdir and use |
33 |
> pkg-config to +# locate the headers. Some C preprocessors will not |
34 |
> work with wrapped +# headers. |
35 |
> +# |
36 |
> +# Example: |
37 |
> +# @CODE |
38 |
> +# MULTILIB_WRAPPED_HEADERS=( |
39 |
> +# /usr/include/foobar/config.h |
40 |
> +# ) |
41 |
> +# @CODE |
42 |
> + |
43 |
> autotools-multilib_src_prepare() { |
44 |
> autotools-utils_src_prepare "${@}" |
45 |
> } |
46 |
> @@ -49,13 +71,73 @@ autotools-multilib_src_test() { |
47 |
> multilib_foreach_abi autotools-utils_src_test "${@}" |
48 |
> } |
49 |
> |
50 |
> +_autotools-multilib_wrap_headers() { |
51 |
> + debug-print-function ${FUNCNAME} "$@" |
52 |
> + local f |
53 |
> + |
54 |
> + for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do |
55 |
> + # drop leading slash if it's there |
56 |
> + f=${f#/} |
57 |
> + |
58 |
> + if [[ ${f} != usr/include/* ]]; then |
59 |
> + die "Wrapping headers outside |
60 |
> of /usr/include is not supported at the moment." |
61 |
> + fi |
62 |
|
63 |
Do you really want to support this at some point? Why? |
64 |
I'd just go for paths relative to $EPREFIX/usr/include (or |
65 |
$ED/usr/include) for MULTILIB_WRAPPED_HEADERS. That would simplify the |
66 |
code. |
67 |
|
68 |
|
69 |
> + # and then usr/include |
70 |
> + f=${f#usr/include/} |
71 |
> + |
72 |
> + local dir=${f%/*} |
73 |
> + |
74 |
> + # $CHOST shall be set by multilib_toolchain_setup |
75 |
> + dodir "/tmp/multilib-include/${CHOST}/${dir}" |
76 |
> + mv "${ED}/usr/include/${f}" |
77 |
> "${ED}/tmp/multilib-include/${CHOST}/${dir}/" || die + |
78 |
|
79 |
why not use $T rather than $ED/tmp ? |
80 |
|
81 |
> + if [[ ! -f ${ED}/tmp/multilib-include/${f} ]]; then |
82 |
> + dodir "/tmp/multilib-include/${dir}" |
83 |
> + cat > "${ED}/tmp/multilib-include/${f}" |
84 |
> <<_EOF_ || die +/* This file is auto-generated by |
85 |
> autotools-multilib.eclass |
86 |
> + * as a multilib-friendly wrapper to /${f}. For the original content, |
87 |
> + * please see the files that are #included below. |
88 |
> + */ |
89 |
> +_EOF_ |
90 |
> + fi |
91 |
> + |
92 |
> + local defs |
93 |
> + case "${ABI}" in |
94 |
|
95 |
didn't you say $ABI may have name collisions? |
96 |
considering the code below, it seems much safer to match on $CHOST |
97 |
|
98 |
[...] |
99 |
|
100 |
It'd be nice to have an attempt to support all the ABIs gentoo supports |
101 |
in that file: I'd prefer to spot possible problems with this solution |
102 |
vs. sedding a template for example to be seen before having to rewrite |
103 |
it. |
104 |
For example, IIRC, ppc64 defines both __powerpc__ and __powerpc64__, |
105 |
the natural way would be: |
106 |
#if defined(__powerpc64__) |
107 |
ppc64 stuff |
108 |
#elif defined(__powerpc__) |
109 |
ppc stuff |
110 |
#endif |
111 |
|
112 |
with your approach that'd be: |
113 |
#if defined(__powerpc__) && !defined(__powerpc64__) |
114 |
ppc stuff |
115 |
#elif defined(__powerpc64__) |
116 |
ppc64 stuff |
117 |
#endif |
118 |
|
119 |
|
120 |
doing with a template has its disadvantages but allows more flexibility |
121 |
in how the #ifery is written; I don't want to realize your approach |
122 |
cannot deal with some weird arches after it has been deployed. |
123 |
|
124 |
|
125 |
thanks for working on this, |
126 |
|
127 |
Alexis. |