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

Contents of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Feb 10 11:44:00 2013 UTC (22 months, 2 weeks ago) by mgorny
Branch: MAIN
Changes since 1.1: +39 -1 lines
Move header checking function into multilib-build for wider reuse.

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.1 2013/02/01 21:39:50 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 )
36
37 # @ECLASS-VARIABLE: MULTILIB_USEDEP
38 # @DESCRIPTION:
39 # The USE-dependency to be used on dependencies (libraries) needing
40 # to support multilib as well.
41 #
42 # Example use:
43 # @CODE
44 # RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}]
45 # net-libs/libbar[ssl,${MULTILIB_USEDEP}]"
46 # @CODE
47
48 _multilib_build_set_globals() {
49 local flags=( "${_MULTILIB_FLAGS[@]%:*}" )
50 local usedeps=${flags[@]/%/(-)?}
51
52 IUSE=${flags[*]}
53 MULTILIB_USEDEP=${usedeps// /,}
54 }
55 _multilib_build_set_globals
56
57 # @FUNCTION: multilib_get_enabled_abis
58 # @DESCRIPTION:
59 # Return the ordered list of enabled ABIs if multilib builds
60 # are enabled. The best (most preferred) ABI will come last.
61 #
62 # If multilib is disabled, the default ABI will be returned
63 # in order to enforce consistent testing with multilib code.
64 multilib_get_enabled_abis() {
65 debug-print-function ${FUNCNAME} "${@}"
66
67 local abis=( $(get_all_abis) )
68
69 local abi i found
70 for abi in "${abis[@]}"; do
71 for i in "${_MULTILIB_FLAGS[@]}"; do
72 local m_abi=${i#*:}
73 local m_flag=${i%:*}
74
75 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
76 echo "${abi}"
77 found=1
78 fi
79 done
80 done
81
82 if [[ ! ${found} ]]; then
83 debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${DEFAULT_ABI}"
84 echo ${DEFAULT_ABI}
85 fi
86 }
87
88 # @FUNCTION: multilib_foreach_abi
89 # @USAGE: <argv>...
90 # @DESCRIPTION:
91 # If multilib support is enabled, sets the toolchain up for each
92 # supported ABI along with the ABI variable and correct BUILD_DIR,
93 # and runs the given commands with them.
94 #
95 # If multilib support is disabled, it just runs the commands. No setup
96 # is done.
97 multilib_foreach_abi() {
98 local initial_dir=${BUILD_DIR:-${S}}
99
100 local ABI
101 for ABI in $(multilib_get_enabled_abis); do
102 multilib_toolchain_setup "${ABI}"
103 BUILD_DIR=${initial_dir%%/}-${ABI} "${@}"
104 done
105 }
106
107 # @FUNCTION: multilib_parallel_foreach_abi
108 # @USAGE: <argv>...
109 # @DESCRIPTION:
110 # If multilib support is enabled, sets the toolchain up for each
111 # supported ABI along with the ABI variable and correct BUILD_DIR,
112 # and runs the given commands with them. The commands are run
113 # in parallel with number of jobs being determined from MAKEOPTS.
114 #
115 # If multilib support is disabled, it just runs the commands. No setup
116 # is done.
117 #
118 # Useful for running configure scripts.
119 multilib_parallel_foreach_abi() {
120 local initial_dir=${BUILD_DIR:-${S}}
121
122 multijob_init
123
124 local ABI
125 for ABI in $(multilib_get_enabled_abis); do
126 (
127 multijob_child_init
128
129 multilib_toolchain_setup "${ABI}"
130 BUILD_DIR=${initial_dir%%/}-${ABI}
131 "${@}"
132 ) &
133
134 multijob_post_fork
135 done
136
137 multijob_finish
138 }
139
140 # @FUNCTION: multilib_check_headers
141 # @DESCRIPTION:
142 # Check whether the header files are consistent between ABIs.
143 #
144 # This function needs to be called after each ABI's installation phase.
145 # It obtains the header file checksums and compares them with previous
146 # runs (if any). Dies if header files differ.
147 multilib_check_headers() {
148 _multilib_header_cksum() {
149 find "${ED}"usr/include -type f \
150 -exec cksum {} + | sort -k2
151 }
152
153 local cksum=$(_multilib_header_cksum)
154 local cksum_file=${T}/.multilib_header_cksum
155
156 if [[ -f ${cksum_file} ]]; then
157 local cksum_prev=$(< "${cksum_file}")
158
159 if [[ ${cksum} != ${cksum_prev} ]]; then
160 echo "${cksum}" > "${cksum_file}.new"
161
162 eerror "Header files have changed between ABIs."
163
164 if type -p diff &>/dev/null; then
165 eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")"
166 else
167 eerror "Old checksums in: ${cksum_file}"
168 eerror "New checksums in: ${cksum_file}.new"
169 fi
170
171 die "Header checksum mismatch, aborting."
172 fi
173 else
174 echo "${cksum}" > "${cksum_file}"
175 fi
176 }
177
178 _MULTILIB_BUILD=1
179 fi

  ViewVC Help
Powered by ViewVC 1.1.20