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

Diff of /eclass/autotools-multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.12 Revision 1.13
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.12 2013/02/27 21:47:38 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.13 2013/04/01 09:18:57 mgorny Exp $
4 4
5# @ECLASS: autotools-multilib.eclass 5# @ECLASS: autotools-multilib.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Michał Górny <mgorny@gentoo.org> 7# Michał Górny <mgorny@gentoo.org>
8# @BLURB: autotools-utils wrapper for multilib builds 8# @BLURB: autotools-utils wrapper for multilib builds
31 31
32inherit autotools-utils multilib-build 32inherit autotools-utils multilib-build
33 33
34EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install 34EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
35 35
36# @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
36autotools-multilib_src_prepare() { 58autotools-multilib_src_prepare() {
37 autotools-utils_src_prepare "${@}" 59 autotools-utils_src_prepare "${@}"
38} 60}
39 61
40autotools-multilib_src_configure() { 62autotools-multilib_src_configure() {
47 69
48autotools-multilib_src_test() { 70autotools-multilib_src_test() {
49 multilib_foreach_abi autotools-utils_src_test "${@}" 71 multilib_foreach_abi autotools-utils_src_test "${@}"
50} 72}
51 73
74_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 f=${f#usr/include/}
87
88 local dir=${f%/*}
89
90 # $CHOST shall be set by multilib_toolchain_setup
91 dodir "/tmp/multilib-include/${CHOST}/${dir}"
92 mv "${ED}/usr/include/${f}" "${ED}/tmp/multilib-include/${CHOST}/${dir}/" || die
93
94 if [[ ! -f ${ED}/tmp/multilib-include/${f} ]]; then
95 dodir "/tmp/multilib-include/${dir}"
96 # a generic template
97 cat > "${ED}/tmp/multilib-include/${f}" <<_EOF_ || die
98/* 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 -i "${ED}/tmp/multilib-include/${f}" || die
133 done
134}
135
52autotools-multilib_src_install() { 136autotools-multilib_src_install() {
53 autotools-multilib_secure_install() { 137 autotools-multilib_secure_install() {
54 autotools-utils_src_install "${@}" 138 autotools-utils_src_install "${@}"
55 139
140 _autotools-multilib_wrap_headers
56 # Make sure all headers are the same for each ABI. 141 # Make sure all headers are the same for each ABI.
57 multilib_check_headers 142 multilib_check_headers
58 } 143 }
59 144
60 multilib_foreach_abi autotools-multilib_secure_install "${@}" 145 multilib_foreach_abi autotools-multilib_secure_install "${@}"
146
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
61} 154}

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20