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

Contents of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download)
Mon Mar 4 19:30:28 2013 UTC (16 months, 3 weeks ago) by mgorny
Branch: MAIN
Changes since 1.7: +21 -27 lines
Convert to use multibuild.eclass.

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.7 2013/03/02 18:18:13 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 multibuild multilib
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 # ${ABI} can be used to override the fallback (multilib-portage),
85 # ${DEFAULT_ABI} is the safe fallback.
86 local abi=${ABI:-${DEFAULT_ABI}}
87
88 debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}"
89 debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}"
90 echo ${abi}
91 fi
92 }
93
94 # @FUNCTION: _multilib_multibuild_wrapper
95 # @USAGE: <argv>...
96 # @INTERNAL
97 # @DESCRIPTION:
98 # Initialize the environment for ABI selected for multibuild.
99 _multilib_multibuild_wrapper() {
100 debug-print-function ${FUNCNAME} "${@}"
101
102 local ABI=${MULTIBUILD_VARIANT}
103 multilib_toolchain_setup "${ABI}"
104 "${@}"
105 }
106
107 # @FUNCTION: multilib_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.
113 #
114 # If multilib support is disabled, it just runs the commands. No setup
115 # is done.
116 multilib_foreach_abi() {
117 debug-print-function ${FUNCNAME} "${@}"
118
119 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
120 multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
121 }
122
123 # @FUNCTION: multilib_parallel_foreach_abi
124 # @USAGE: <argv>...
125 # @DESCRIPTION:
126 # If multilib support is enabled, sets the toolchain up for each
127 # supported ABI along with the ABI variable and correct BUILD_DIR,
128 # and runs the given commands with them. The commands are run
129 # in parallel with number of jobs being determined from MAKEOPTS.
130 #
131 # If multilib support is disabled, it just runs the commands. No setup
132 # is done.
133 #
134 # Useful for running configure scripts.
135 multilib_parallel_foreach_abi() {
136 debug-print-function ${FUNCNAME} "${@}"
137
138 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
139 multibuild_parallel_foreach_variant _multilib_multibuild_wrapper "${@}"
140 }
141
142 # @FUNCTION: multilib_check_headers
143 # @DESCRIPTION:
144 # Check whether the header files are consistent between ABIs.
145 #
146 # This function needs to be called after each ABI's installation phase.
147 # It obtains the header file checksums and compares them with previous
148 # runs (if any). Dies if header files differ.
149 multilib_check_headers() {
150 _multilib_header_cksum() {
151 [[ -d ${ED}usr/include ]] && \
152 find "${ED}"usr/include -type f \
153 -exec cksum {} + | sort -k2
154 }
155
156 local cksum=$(_multilib_header_cksum)
157 local cksum_file=${T}/.multilib_header_cksum
158
159 if [[ -f ${cksum_file} ]]; then
160 local cksum_prev=$(< "${cksum_file}")
161
162 if [[ ${cksum} != ${cksum_prev} ]]; then
163 echo "${cksum}" > "${cksum_file}.new"
164
165 eerror "Header files have changed between ABIs."
166
167 if type -p diff &>/dev/null; then
168 eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")"
169 else
170 eerror "Old checksums in: ${cksum_file}"
171 eerror "New checksums in: ${cksum_file}.new"
172 fi
173
174 die "Header checksum mismatch, aborting."
175 fi
176 else
177 echo "${cksum}" > "${cksum_file}"
178 fi
179 }
180
181 _MULTILIB_BUILD=1
182 fi

  ViewVC Help
Powered by ViewVC 1.1.20