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

Contents of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations) (download)
Sat Mar 2 18:18:13 2013 UTC (18 months, 2 weeks ago) by mgorny
Branch: MAIN
Changes since 1.6: +12 -5 lines
Improve the no-multilib fallback to respect ${ABI} set by multilib-portage.

1 mgorny 1.1 # Copyright 1999-2013 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.7 # $Header: /var/cvsroot/gentoo-x86/eclass/multilib-build.eclass,v 1.6 2013/02/27 23:23:11 mgorny Exp $
4 mgorny 1.1
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 mgorny 1.6 abi_x86_x32:x32
36 mgorny 1.1 )
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 mgorny 1.7 # ${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 mgorny 1.1 fi
92     }
93    
94     # @FUNCTION: multilib_foreach_abi
95     # @USAGE: <argv>...
96     # @DESCRIPTION:
97     # If multilib support is enabled, sets the toolchain up for each
98     # supported ABI along with the ABI variable and correct BUILD_DIR,
99     # and runs the given commands with them.
100     #
101     # If multilib support is disabled, it just runs the commands. No setup
102     # is done.
103     multilib_foreach_abi() {
104     local initial_dir=${BUILD_DIR:-${S}}
105    
106 mgorny 1.7 local abis=( $(multilib_get_enabled_abis) )
107 mgorny 1.1 local ABI
108 mgorny 1.7 for ABI in "${abis[@]}"; do
109 mgorny 1.1 multilib_toolchain_setup "${ABI}"
110 mgorny 1.5 BUILD_DIR=${initial_dir%%/}-${ABI} "${@}"
111 mgorny 1.1 done
112     }
113    
114     # @FUNCTION: multilib_parallel_foreach_abi
115     # @USAGE: <argv>...
116     # @DESCRIPTION:
117     # If multilib support is enabled, sets the toolchain up for each
118     # supported ABI along with the ABI variable and correct BUILD_DIR,
119     # and runs the given commands with them. The commands are run
120     # in parallel with number of jobs being determined from MAKEOPTS.
121     #
122     # If multilib support is disabled, it just runs the commands. No setup
123     # is done.
124     #
125     # Useful for running configure scripts.
126     multilib_parallel_foreach_abi() {
127     local initial_dir=${BUILD_DIR:-${S}}
128    
129     multijob_init
130    
131 mgorny 1.7 local abis=( $(multilib_get_enabled_abis) )
132 mgorny 1.1 local ABI
133 mgorny 1.7 for ABI in "${abis[@]}"; do
134 mgorny 1.1 (
135     multijob_child_init
136    
137     multilib_toolchain_setup "${ABI}"
138 mgorny 1.5 BUILD_DIR=${initial_dir%%/}-${ABI}
139     "${@}"
140 mgorny 1.1 ) &
141    
142     multijob_post_fork
143     done
144    
145     multijob_finish
146     }
147    
148 mgorny 1.2 # @FUNCTION: multilib_check_headers
149     # @DESCRIPTION:
150     # Check whether the header files are consistent between ABIs.
151     #
152     # This function needs to be called after each ABI's installation phase.
153     # It obtains the header file checksums and compares them with previous
154     # runs (if any). Dies if header files differ.
155     multilib_check_headers() {
156     _multilib_header_cksum() {
157 mgorny 1.4 [[ -d ${ED}usr/include ]] && \
158 mgorny 1.2 find "${ED}"usr/include -type f \
159     -exec cksum {} + | sort -k2
160     }
161    
162     local cksum=$(_multilib_header_cksum)
163     local cksum_file=${T}/.multilib_header_cksum
164    
165     if [[ -f ${cksum_file} ]]; then
166     local cksum_prev=$(< "${cksum_file}")
167    
168     if [[ ${cksum} != ${cksum_prev} ]]; then
169     echo "${cksum}" > "${cksum_file}.new"
170    
171     eerror "Header files have changed between ABIs."
172    
173     if type -p diff &>/dev/null; then
174     eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")"
175     else
176     eerror "Old checksums in: ${cksum_file}"
177     eerror "New checksums in: ${cksum_file}.new"
178     fi
179    
180     die "Header checksum mismatch, aborting."
181     fi
182     else
183     echo "${cksum}" > "${cksum_file}"
184     fi
185     }
186    
187 mgorny 1.1 _MULTILIB_BUILD=1
188     fi

  ViewVC Help
Powered by ViewVC 1.1.20