/[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.8 Revision 1.14
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.8 2013/02/01 21:39:50 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.14 2013/04/01 11:05:27 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
9# @DESCRIPTION: 9# @DESCRIPTION:
10# The autotools-multilib.eclass is an autotools-utils.eclass(5) wrapper 10# The autotools-multilib.eclass is an autotools-utils.eclass(5) wrapper
11# introducing support for building for more than one ABI (multilib). 11# introducing support for building for more than one ABI (multilib).
12# 12#
13# Inheriting this eclass sets IUSE=multilib and exports autotools-utils 13# Inheriting this eclass sets the USE flags and exports autotools-utils
14# phase function wrappers which build the package for each supported ABI 14# phase function wrappers which build the package for each supported ABI
15# if the flag is enabled. Otherwise, it works like regular 15# when the relevant flag is enabled. Other than that, it works like
16# autotools-utils. 16# regular autotools-utils.
17# 17#
18# Note that the multilib support requires out-of-source builds to be 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 19# enabled. Thus, it is impossible to use AUTOTOOLS_IN_SOURCE_BUILD with
20# it. 20# it.
21 21
29 die "${ECLASS}: multilib support requires out-of-source builds." 29 die "${ECLASS}: multilib support requires out-of-source builds."
30fi 30fi
31 31
32inherit autotools-utils multilib-build 32inherit autotools-utils multilib-build
33 33
34EXPORT_FUNCTIONS src_configure src_compile src_test src_install 34EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
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
58autotools-multilib_src_prepare() {
59 autotools-utils_src_prepare "${@}"
60}
35 61
36autotools-multilib_src_configure() { 62autotools-multilib_src_configure() {
37 multilib_parallel_foreach_abi autotools-utils_src_configure 63 multilib_parallel_foreach_abi autotools-utils_src_configure "${@}"
38} 64}
39 65
40autotools-multilib_src_compile() { 66autotools-multilib_src_compile() {
41 multilib_foreach_abi autotools-utils_src_compile 67 multilib_foreach_abi autotools-utils_src_compile "${@}"
42} 68}
43 69
44autotools-multilib_src_test() { 70autotools-multilib_src_test() {
45 multilib_foreach_abi autotools-utils_src_test 71 multilib_foreach_abi autotools-utils_src_test "${@}"
72}
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
46} 134}
47 135
48autotools-multilib_src_install() { 136autotools-multilib_src_install() {
49 autotools-multilib_secure_install() { 137 autotools-multilib_secure_install() {
50 autotools-utils_src_install 138 autotools-utils_src_install "${@}"
51 139
140 _autotools-multilib_wrap_headers
52 # Make sure all headers are the same for each ABI. 141 # Make sure all headers are the same for each ABI.
53 autotools-multilib_cksum() { 142 multilib_check_headers
54 find "${ED}"usr/include -type f \
55 -exec cksum {} + | sort -k2
56 }
57
58 local cksum=$(autotools-multilib_cksum)
59 local cksum_file=${T}/.autotools-multilib_cksum
60
61 if [[ -f ${cksum_file} ]]; then
62 local cksum_prev=$(< "${cksum_file}")
63
64 if [[ ${cksum} != ${cksum_prev} ]]; then
65 echo "${cksum}" > "${cksum_file}.new"
66
67 eerror "Header files have changed between ABIs."
68
69 if type -p diff &>/dev/null; then
70 eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")"
71 else
72 eerror "Old checksums in: ${cksum_file}"
73 eerror "New checksums in: ${cksum_file}.new"
74 fi
75
76 die "Header checksum mismatch, aborting."
77 fi
78 else
79 echo "${cksum}" > "${cksum_file}"
80 fi
81 } 143 }
82 144
83 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
84} 154}

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.20