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

Contents of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Wed Feb 27 23:23:11 2013 UTC (16 months, 2 weeks ago) by mgorny
Branch: MAIN
Changes since 1.5: +2 -1 lines
Enable x32 ABI support.

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/multilib-build.eclass,v 1.5 2013/02/27 21:02:59 mgorny Exp $
4
5 # @ECLASS: multilib-build.eclass
6 # @MAINTAINER:
7 # Michał Górny <mgorny@gentoo.org>
8 # @BLURB: flags and utility functions for building multilib packages
9 # @DESCRIPTION:
10 # The multilib-build.eclass exports USE flags and utility functions
11 # necessary to build packages for multilib in a clean and uniform
12 # manner.
13 #
14 # Please note that dependency specifications for multilib-capable
15 # dependencies shall use the USE dependency string in ${MULTILIB_USEDEP}
16 # to properly request multilib enabled.
17
18 if [[ ! ${_MULTILIB_BUILD} ]]; then
19
20 # EAPI=5 is required for meaningful MULTILIB_USEDEP.
21 case ${EAPI:-0} in
22 5) ;;
23 *) die "EAPI=${EAPI} is not supported" ;;
24 esac
25
26 inherit multilib multiprocessing
27
28 # @ECLASS-VARIABLE: _MULTILIB_FLAGS
29 # @INTERNAL
30 # @DESCRIPTION:
31 # The list of multilib flags and corresponding ABI values.
32 _MULTILIB_FLAGS=(
33 abi_x86_32:x86
34 abi_x86_64:amd64
35 abi_x86_x32:x32
36 )
37
38 # @ECLASS-VARIABLE: MULTILIB_USEDEP
39 # @DESCRIPTION:
40 # The USE-dependency to be used on dependencies (libraries) needing
41 # to support multilib as well.
42 #
43 # Example use:
44 # @CODE
45 # RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}]
46 # net-libs/libbar[ssl,${MULTILIB_USEDEP}]"
47 # @CODE
48
49 _multilib_build_set_globals() {
50 local flags=( "${_MULTILIB_FLAGS[@]%:*}" )
51 local usedeps=${flags[@]/%/(-)?}
52
53 IUSE=${flags[*]}
54 MULTILIB_USEDEP=${usedeps// /,}
55 }
56 _multilib_build_set_globals
57
58 # @FUNCTION: multilib_get_enabled_abis
59 # @DESCRIPTION:
60 # Return the ordered list of enabled ABIs if multilib builds
61 # are enabled. The best (most preferred) ABI will come last.
62 #
63 # If multilib is disabled, the default ABI will be returned
64 # in order to enforce consistent testing with multilib code.
65 multilib_get_enabled_abis() {
66 debug-print-function ${FUNCNAME} "${@}"
67
68 local abis=( $(get_all_abis) )
69
70 local abi i found
71 for abi in "${abis[@]}"; do
72 for i in "${_MULTILIB_FLAGS[@]}"; do
73 local m_abi=${i#*:}
74 local m_flag=${i%:*}
75
76 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
77 echo "${abi}"
78 found=1
79 fi
80 done
81 done
82
83 if [[ ! ${found} ]]; then
84 debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${DEFAULT_ABI}"
85 echo ${DEFAULT_ABI}
86 fi
87 }
88
89 # @FUNCTION: multilib_foreach_abi
90 # @USAGE: <argv>...
91 # @DESCRIPTION:
92 # If multilib support is enabled, sets the toolchain up for each
93 # supported ABI along with the ABI variable and correct BUILD_DIR,
94 # and runs the given commands with them.
95 #
96 # If multilib support is disabled, it just runs the commands. No setup
97 # is done.
98 multilib_foreach_abi() {
99 local initial_dir=${BUILD_DIR:-${S}}
100
101 local ABI
102 for ABI in $(multilib_get_enabled_abis); do
103 multilib_toolchain_setup "${ABI}"
104 BUILD_DIR=${initial_dir%%/}-${ABI} "${@}"
105 done
106 }
107
108 # @FUNCTION: multilib_parallel_foreach_abi
109 # @USAGE: <argv>...
110 # @DESCRIPTION:
111 # If multilib support is enabled, sets the toolchain up for each
112 # supported ABI along with the ABI variable and correct BUILD_DIR,
113 # and runs the given commands with them. The commands are run
114 # in parallel with number of jobs being determined from MAKEOPTS.
115 #
116 # If multilib support is disabled, it just runs the commands. No setup
117 # is done.
118 #
119 # Useful for running configure scripts.
120 multilib_parallel_foreach_abi() {
121 local initial_dir=${BUILD_DIR:-${S}}
122
123 multijob_init
124
125 local ABI
126 for ABI in $(multilib_get_enabled_abis); do
127 (
128 multijob_child_init
129
130 multilib_toolchain_setup "${ABI}"
131 BUILD_DIR=${initial_dir%%/}-${ABI}
132 "${@}"
133 ) &
134
135 multijob_post_fork
136 done
137
138 multijob_finish
139 }
140
141 # @FUNCTION: multilib_check_headers
142 # @DESCRIPTION:
143 # Check whether the header files are consistent between ABIs.
144 #
145 # This function needs to be called after each ABI's installation phase.
146 # It obtains the header file checksums and compares them with previous
147 # runs (if any). Dies if header files differ.
148 multilib_check_headers() {
149 _multilib_header_cksum() {
150 [[ -d ${ED}usr/include ]] && \
151 find "${ED}"usr/include -type f \
152 -exec cksum {} + | sort -k2
153 }
154
155 local cksum=$(_multilib_header_cksum)
156 local cksum_file=${T}/.multilib_header_cksum
157
158 if [[ -f ${cksum_file} ]]; then
159 local cksum_prev=$(< "${cksum_file}")
160
161 if [[ ${cksum} != ${cksum_prev} ]]; then
162 echo "${cksum}" > "${cksum_file}.new"
163
164 eerror "Header files have changed between ABIs."
165
166 if type -p diff &>/dev/null; then
167 eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")"
168 else
169 eerror "Old checksums in: ${cksum_file}"
170 eerror "New checksums in: ${cksum_file}.new"
171 fi
172
173 die "Header checksum mismatch, aborting."
174 fi
175 else
176 echo "${cksum}" > "${cksum_file}"
177 fi
178 }
179
180 _MULTILIB_BUILD=1
181 fi

  ViewVC Help
Powered by ViewVC 1.1.20