/[gentoo-x86]/eclass/autotools-multilib.eclass
Gentoo

Contents of /eclass/autotools-multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Mon Apr 1 11:05:27 2013 UTC (17 months, 3 weeks ago) by mgorny
Branch: MAIN
Changes since 1.13: +8 -8 lines
Fix path handling in header wrapping code.

1 mgorny 1.3 # Copyright 1999-2013 Gentoo Foundation
2 mgorny 1.1 # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.14 # $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.13 2013/04/01 09:18:57 mgorny Exp $
4 mgorny 1.1
5     # @ECLASS: autotools-multilib.eclass
6     # @MAINTAINER:
7     # Michał Górny <mgorny@gentoo.org>
8     # @BLURB: autotools-utils wrapper for multilib builds
9     # @DESCRIPTION:
10     # The autotools-multilib.eclass is an autotools-utils.eclass(5) wrapper
11     # introducing support for building for more than one ABI (multilib).
12     #
13 mgorny 1.11 # Inheriting this eclass sets the USE flags and exports autotools-utils
14 mgorny 1.1 # phase function wrappers which build the package for each supported ABI
15 mgorny 1.11 # when the relevant flag is enabled. Other than that, it works like
16     # regular autotools-utils.
17 mgorny 1.1 #
18     # Note that the multilib support requires out-of-source builds to be
19     # enabled. Thus, it is impossible to use AUTOTOOLS_IN_SOURCE_BUILD with
20     # it.
21    
22 mgorny 1.6 # EAPI=5 is required for meaningful MULTILIB_USEDEP.
23 mgorny 1.1 case ${EAPI:-0} in
24 mgorny 1.6 5) ;;
25 mgorny 1.1 *) die "EAPI=${EAPI} is not supported" ;;
26     esac
27    
28     if [[ ${AUTOTOOLS_IN_SOURCE_BUILD} ]]; then
29     die "${ECLASS}: multilib support requires out-of-source builds."
30     fi
31    
32 mgorny 1.8 inherit autotools-utils multilib-build
33 mgorny 1.1
34 mgorny 1.12 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
35    
36 mgorny 1.13 # @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS
37     # @DESCRIPTION:
38     # A list of headers to wrap for multilib support. The listed headers
39     # will be moved to a non-standard location and replace with a file
40     # including them conditionally to current ABI.
41     #
42     # This variable has to be a bash array. Paths shall be relative to
43     # installation root (${ED}), and name regular files. Recursive wrapping
44     # is not supported.
45     #
46     # Please note that header wrapping is *discouraged*. It is preferred to
47     # install all headers in a subdirectory of libdir and use pkg-config to
48     # locate the headers. Some C preprocessors will not work with wrapped
49     # headers.
50     #
51     # Example:
52     # @CODE
53     # MULTILIB_WRAPPED_HEADERS=(
54     # /usr/include/foobar/config.h
55     # )
56     # @CODE
57    
58 mgorny 1.12 autotools-multilib_src_prepare() {
59     autotools-utils_src_prepare "${@}"
60     }
61 mgorny 1.1
62     autotools-multilib_src_configure() {
63 mgorny 1.10 multilib_parallel_foreach_abi autotools-utils_src_configure "${@}"
64 mgorny 1.1 }
65    
66     autotools-multilib_src_compile() {
67 mgorny 1.10 multilib_foreach_abi autotools-utils_src_compile "${@}"
68 mgorny 1.1 }
69    
70     autotools-multilib_src_test() {
71 mgorny 1.10 multilib_foreach_abi autotools-utils_src_test "${@}"
72 mgorny 1.1 }
73    
74 mgorny 1.13 _autotools-multilib_wrap_headers() {
75     debug-print-function ${FUNCNAME} "$@"
76     local f
77    
78     for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
79     # drop leading slash if it's there
80     f=${f#/}
81    
82     if [[ ${f} != usr/include/* ]]; then
83     die "Wrapping headers outside of /usr/include is not supported at the moment."
84     fi
85     # and then usr/include
86 mgorny 1.14 f=${f#usr/include}
87 mgorny 1.13
88     local dir=${f%/*}
89    
90     # $CHOST shall be set by multilib_toolchain_setup
91 mgorny 1.14 dodir "/tmp/multilib-include/${CHOST}${dir}"
92     mv "${ED}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
93 mgorny 1.13
94 mgorny 1.14 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
95     dodir "/tmp/multilib-include${dir}"
96 mgorny 1.13 # a generic template
97 mgorny 1.14 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ || die
98 mgorny 1.13 /* This file is auto-generated by autotools-multilib.eclass
99     * as a multilib-friendly wrapper. For the original content,
100     * please see the files that are #included below.
101     */
102    
103     #if defined(__x86_64__) /* amd64 */
104     # if defined(__ILP32__) /* x32 ABI */
105     # error "abi_x86_x32 not supported by the package."
106     # else /* 64-bit ABI */
107     # error "abi_x86_64 not supported by the package."
108     # endif
109     #elif defined(__i386__) /* plain x86 */
110     # error "abi_x86_32 not supported by the package."
111     #else
112     # error "No ABI matched, please report a bug to bugs.gentoo.org"
113     #endif
114     _EOF_
115     fi
116    
117     # XXX: get abi_* directly
118     local abi_flag
119     case "${ABI}" in
120     amd64)
121     abi_flag=abi_x86_64;;
122     x86)
123     abi_flag=abi_x86_32;;
124     x32)
125     abi_flag=abi_x86_x32;;
126     *)
127     die "Header wrapping for ${ABI} not supported yet";;
128     esac
129    
130     # Note: match a space afterwards to avoid collision potential.
131     sed -e "/${abi_flag} /s&error.*&include <${CHOST}/${f}>&" \
132 mgorny 1.14 -i "${ED}/tmp/multilib-include${f}" || die
133 mgorny 1.13 done
134     }
135    
136 mgorny 1.1 autotools-multilib_src_install() {
137 mgorny 1.8 autotools-multilib_secure_install() {
138 mgorny 1.10 autotools-utils_src_install "${@}"
139 mgorny 1.8
140 mgorny 1.13 _autotools-multilib_wrap_headers
141 mgorny 1.8 # Make sure all headers are the same for each ABI.
142 mgorny 1.9 multilib_check_headers
143 mgorny 1.8 }
144    
145 mgorny 1.10 multilib_foreach_abi autotools-multilib_secure_install "${@}"
146 mgorny 1.13
147     # merge the wrapped headers
148     if [[ -d "${ED}"/tmp/multilib-include ]]; then
149     multibuild_merge_root \
150     "${ED}"/tmp/multilib-include "${ED}"/usr/include
151     # it can fail if something else uses /tmp
152     rmdir "${ED}"/tmp &>/dev/null
153     fi
154 mgorny 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20