1 |
mgorny 13/04/01 09:18:57 |
2 |
|
3 |
Modified: ChangeLog autotools-multilib.eclass |
4 |
Log: |
5 |
Support wrapping headers for multilib. |
6 |
|
7 |
Revision Changes Path |
8 |
1.763 eclass/ChangeLog |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.763&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.763&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.762&r2=1.763 |
13 |
|
14 |
Index: ChangeLog |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v |
17 |
retrieving revision 1.762 |
18 |
retrieving revision 1.763 |
19 |
diff -u -r1.762 -r1.763 |
20 |
--- ChangeLog 1 Apr 2013 09:17:53 -0000 1.762 |
21 |
+++ ChangeLog 1 Apr 2013 09:18:57 -0000 1.763 |
22 |
@@ -1,6 +1,9 @@ |
23 |
# ChangeLog for eclass directory |
24 |
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.762 2013/04/01 09:17:53 mgorny Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.763 2013/04/01 09:18:57 mgorny Exp $ |
27 |
+ |
28 |
+ 01 Apr 2013; Michał Górny <mgorny@g.o> autotools-multilib.eclass: |
29 |
+ Support wrapping headers for multilib. |
30 |
|
31 |
01 Apr 2013; Michał Górny <mgorny@g.o> distutils-r1.eclass, |
32 |
multibuild.eclass: |
33 |
|
34 |
|
35 |
|
36 |
1.13 eclass/autotools-multilib.eclass |
37 |
|
38 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/autotools-multilib.eclass?rev=1.13&view=markup |
39 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/autotools-multilib.eclass?rev=1.13&content-type=text/plain |
40 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/autotools-multilib.eclass?r1=1.12&r2=1.13 |
41 |
|
42 |
Index: autotools-multilib.eclass |
43 |
=================================================================== |
44 |
RCS file: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v |
45 |
retrieving revision 1.12 |
46 |
retrieving revision 1.13 |
47 |
diff -u -r1.12 -r1.13 |
48 |
--- autotools-multilib.eclass 27 Feb 2013 21:47:38 -0000 1.12 |
49 |
+++ autotools-multilib.eclass 1 Apr 2013 09:18:57 -0000 1.13 |
50 |
@@ -1,6 +1,6 @@ |
51 |
# Copyright 1999-2013 Gentoo Foundation |
52 |
# Distributed under the terms of the GNU General Public License v2 |
53 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.12 2013/02/27 21:47:38 mgorny Exp $ |
54 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.13 2013/04/01 09:18:57 mgorny Exp $ |
55 |
|
56 |
# @ECLASS: autotools-multilib.eclass |
57 |
# @MAINTAINER: |
58 |
@@ -33,6 +33,28 @@ |
59 |
|
60 |
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install |
61 |
|
62 |
+# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS |
63 |
+# @DESCRIPTION: |
64 |
+# A list of headers to wrap for multilib support. The listed headers |
65 |
+# will be moved to a non-standard location and replace with a file |
66 |
+# including them conditionally to current ABI. |
67 |
+# |
68 |
+# This variable has to be a bash array. Paths shall be relative to |
69 |
+# installation root (${ED}), and name regular files. Recursive wrapping |
70 |
+# is not supported. |
71 |
+# |
72 |
+# Please note that header wrapping is *discouraged*. It is preferred to |
73 |
+# install all headers in a subdirectory of libdir and use pkg-config to |
74 |
+# locate the headers. Some C preprocessors will not work with wrapped |
75 |
+# headers. |
76 |
+# |
77 |
+# Example: |
78 |
+# @CODE |
79 |
+# MULTILIB_WRAPPED_HEADERS=( |
80 |
+# /usr/include/foobar/config.h |
81 |
+# ) |
82 |
+# @CODE |
83 |
+ |
84 |
autotools-multilib_src_prepare() { |
85 |
autotools-utils_src_prepare "${@}" |
86 |
} |
87 |
@@ -49,13 +71,84 @@ |
88 |
multilib_foreach_abi autotools-utils_src_test "${@}" |
89 |
} |
90 |
|
91 |
+_autotools-multilib_wrap_headers() { |
92 |
+ debug-print-function ${FUNCNAME} "$@" |
93 |
+ local f |
94 |
+ |
95 |
+ for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do |
96 |
+ # drop leading slash if it's there |
97 |
+ f=${f#/} |
98 |
+ |
99 |
+ if [[ ${f} != usr/include/* ]]; then |
100 |
+ die "Wrapping headers outside of /usr/include is not supported at the moment." |
101 |
+ fi |
102 |
+ # and then usr/include |
103 |
+ f=${f#usr/include/} |
104 |
+ |
105 |
+ local dir=${f%/*} |
106 |
+ |
107 |
+ # $CHOST shall be set by multilib_toolchain_setup |
108 |
+ dodir "/tmp/multilib-include/${CHOST}/${dir}" |
109 |
+ mv "${ED}/usr/include/${f}" "${ED}/tmp/multilib-include/${CHOST}/${dir}/" || die |
110 |
+ |
111 |
+ if [[ ! -f ${ED}/tmp/multilib-include/${f} ]]; then |
112 |
+ dodir "/tmp/multilib-include/${dir}" |
113 |
+ # a generic template |
114 |
+ cat > "${ED}/tmp/multilib-include/${f}" <<_EOF_ || die |
115 |
+/* This file is auto-generated by autotools-multilib.eclass |
116 |
+ * as a multilib-friendly wrapper. For the original content, |
117 |
+ * please see the files that are #included below. |
118 |
+ */ |
119 |
+ |
120 |
+#if defined(__x86_64__) /* amd64 */ |
121 |
+# if defined(__ILP32__) /* x32 ABI */ |
122 |
+# error "abi_x86_x32 not supported by the package." |
123 |
+# else /* 64-bit ABI */ |
124 |
+# error "abi_x86_64 not supported by the package." |
125 |
+# endif |
126 |
+#elif defined(__i386__) /* plain x86 */ |
127 |
+# error "abi_x86_32 not supported by the package." |
128 |
+#else |
129 |
+# error "No ABI matched, please report a bug to bugs.gentoo.org" |
130 |
+#endif |
131 |
+_EOF_ |
132 |
+ fi |
133 |
+ |
134 |
+ # XXX: get abi_* directly |
135 |
+ local abi_flag |
136 |
+ case "${ABI}" in |
137 |
+ amd64) |
138 |
+ abi_flag=abi_x86_64;; |
139 |
+ x86) |
140 |
+ abi_flag=abi_x86_32;; |
141 |
+ x32) |
142 |
+ abi_flag=abi_x86_x32;; |
143 |
+ *) |
144 |
+ die "Header wrapping for ${ABI} not supported yet";; |
145 |
+ esac |
146 |
+ |
147 |
+ # Note: match a space afterwards to avoid collision potential. |
148 |
+ sed -e "/${abi_flag} /s&error.*&include <${CHOST}/${f}>&" \ |
149 |
+ -i "${ED}/tmp/multilib-include/${f}" || die |
150 |
+ done |
151 |
+} |
152 |
+ |
153 |
autotools-multilib_src_install() { |
154 |
autotools-multilib_secure_install() { |
155 |
autotools-utils_src_install "${@}" |
156 |
|
157 |
+ _autotools-multilib_wrap_headers |
158 |
# Make sure all headers are the same for each ABI. |
159 |
multilib_check_headers |
160 |
} |
161 |
|
162 |
multilib_foreach_abi autotools-multilib_secure_install "${@}" |
163 |
+ |
164 |
+ # merge the wrapped headers |
165 |
+ if [[ -d "${ED}"/tmp/multilib-include ]]; then |
166 |
+ multibuild_merge_root \ |
167 |
+ "${ED}"/tmp/multilib-include "${ED}"/usr/include |
168 |
+ # it can fail if something else uses /tmp |
169 |
+ rmdir "${ED}"/tmp &>/dev/null |
170 |
+ fi |
171 |
} |