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

Diff of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.14 Revision 1.21
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/multilib-build.eclass,v 1.14 2013/06/28 02:37:52 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multilib-build.eclass,v 1.21 2013/09/30 07:27:06 mgorny Exp $
4 4
5# @ECLASS: multilib-build.eclass 5# @ECLASS: multilib-build.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Michał Górny <mgorny@gentoo.org> 7# Michał Górny <mgorny@gentoo.org>
8# @BLURB: flags and utility functions for building multilib packages 8# @BLURB: flags and utility functions for building multilib packages
26inherit multibuild multilib 26inherit multibuild multilib
27 27
28# @ECLASS-VARIABLE: _MULTILIB_FLAGS 28# @ECLASS-VARIABLE: _MULTILIB_FLAGS
29# @INTERNAL 29# @INTERNAL
30# @DESCRIPTION: 30# @DESCRIPTION:
31# The list of multilib flags and corresponding ABI values. 31# The list of multilib flags and corresponding ABI values. If the same
32# flag is reused for multiple ABIs (e.g. x86 on Linux&FreeBSD), multiple
33# ABIs may be separated by commas.
32_MULTILIB_FLAGS=( 34_MULTILIB_FLAGS=(
33 abi_x86_32:x86 35 abi_x86_32:x86,x86_fbsd
34 abi_x86_64:amd64 36 abi_x86_64:amd64,amd64_fbsd
35 abi_x86_x32:x32 37 abi_x86_x32:x32
38 abi_mips_n32:n32
39 abi_mips_n64:n64
40 abi_mips_o32:o32
36) 41)
37 42
38# @ECLASS-VARIABLE: MULTILIB_USEDEP 43# @ECLASS-VARIABLE: MULTILIB_USEDEP
39# @DESCRIPTION: 44# @DESCRIPTION:
40# The USE-dependency to be used on dependencies (libraries) needing 45# The USE-dependency to be used on dependencies (libraries) needing
65multilib_get_enabled_abis() { 70multilib_get_enabled_abis() {
66 debug-print-function ${FUNCNAME} "${@}" 71 debug-print-function ${FUNCNAME} "${@}"
67 72
68 local abis=( $(get_all_abis) ) 73 local abis=( $(get_all_abis) )
69 74
75 local IFS=,
70 local abi i found 76 local abi i found
71 for abi in "${abis[@]}"; do 77 for abi in "${abis[@]}"; do
72 for i in "${_MULTILIB_FLAGS[@]}"; do 78 for i in "${_MULTILIB_FLAGS[@]}"; do
73 local m_abi=${i#*:} 79 local m_abis=${i#*:} m_abi
74 local m_flag=${i%:*} 80 local m_flag=${i%:*}
75 81
82 for m_abi in ${m_abis}; do
76 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then 83 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
77 echo "${abi}" 84 echo "${abi}"
78 found=1 85 found=1
86 break 2
79 fi 87 fi
88 done
80 done 89 done
81 done 90 done
82 91
83 if [[ ! ${found} ]]; then 92 if [[ ! ${found} ]]; then
84 # ${ABI} can be used to override the fallback (multilib-portage), 93 # ${ABI} can be used to override the fallback (multilib-portage),
261 # and then usr/include 270 # and then usr/include
262 f=${f#usr/include} 271 f=${f#usr/include}
263 272
264 local dir=${f%/*} 273 local dir=${f%/*}
265 274
266 # $CHOST shall be set by multilib_toolchain_setup
267 dodir "/tmp/multilib-include/${CHOST}${dir}"
268 mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
269
270 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then 275 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
271 dodir "/tmp/multilib-include${dir}" 276 dodir "/tmp/multilib-include${dir}"
272 # a generic template 277 # a generic template
273 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ 278 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_
274/* This file is auto-generated by multilib-build.eclass 279/* This file is auto-generated by multilib-build.eclass
282# else /* 64-bit ABI */ 287# else /* 64-bit ABI */
283# error "abi_x86_64 not supported by the package." 288# error "abi_x86_64 not supported by the package."
284# endif 289# endif
285#elif defined(__i386__) /* plain x86 */ 290#elif defined(__i386__) /* plain x86 */
286# error "abi_x86_32 not supported by the package." 291# error "abi_x86_32 not supported by the package."
292#elif defined(__mips__)
293# if(_MIPS_SIM == _ABIN32) /* n32 */
294# error "abi_mips_n32 not supported by the package."
295# elif(_MIPS_SIM == _ABI64) /* n64 */
296# error "abi_mips_n64 not supported by the package."
297# elif(_MIPS_SIM == _ABIO32) /* o32 */
298# error "abi_mips_o32 not supported by the package."
299# endif
287#else 300#else
288# error "No ABI matched, please report a bug to bugs.gentoo.org" 301# error "No ABI matched, please report a bug to bugs.gentoo.org"
289#endif 302#endif
290_EOF_ 303_EOF_
291 fi 304 fi
292 305
306 # Some ABIs may have install less files than others.
307 if [[ -f ${root}/usr/include${f} ]]; then
308 # $CHOST shall be set by multilib_toolchain_setup
309 dodir "/tmp/multilib-include/${CHOST}${dir}"
310 mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
311
293 # XXX: get abi_* directly 312 # XXX: get abi_* directly
294 local abi_flag 313 local abi_flag
295 case "${ABI}" in 314 case "${ABI}" in
296 amd64) 315 amd64|amd64_fbsd)
297 abi_flag=abi_x86_64;; 316 abi_flag=abi_x86_64;;
298 x86) 317 x86|x86_fbsd)
299 abi_flag=abi_x86_32;; 318 abi_flag=abi_x86_32;;
300 x32) 319 x32)
301 abi_flag=abi_x86_x32;; 320 abi_flag=abi_x86_x32;;
321 n32)
322 abi_flag=abi_mips_n32;;
323 n64)
324 abi_flag=abi_mips_n64;;
325 o32)
326 abi_flag=abi_mips_o32;;
302 *) 327 *)
303 die "Header wrapping for ${ABI} not supported yet";; 328 die "Header wrapping for ${ABI} not supported yet";;
304 esac 329 esac
305 330
306 # Note: match a space afterwards to avoid collision potential. 331 # Note: match a space afterwards to avoid collision potential.
307 sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \ 332 sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
308 -i "${ED}/tmp/multilib-include${f}" || die 333 -i "${ED}/tmp/multilib-include${f}" || die
334 fi
309 done 335 done
310} 336}
311 337
312# @FUNCTION: multilib_install_wrappers 338# @FUNCTION: multilib_install_wrappers
313# @USAGE: [<install-root>] 339# @USAGE: [<install-root>]
336 # it can fail if something else uses /tmp 362 # it can fail if something else uses /tmp
337 rmdir "${ED}"/tmp &>/dev/null 363 rmdir "${ED}"/tmp &>/dev/null
338 fi 364 fi
339} 365}
340 366
367# @FUNCTION: multilib_is_native_abi
368# @DESCRIPTION:
369# Determine whether the currently built ABI is the profile native.
370# Return true status (0) if that is true, otherwise false (1).
371#
372# This is often useful for configure calls when some of the options are
373# supposed to be disabled for multilib ABIs (like those used for
374# executables only).
375multilib_is_native_abi() {
376 debug-print-function ${FUNCNAME} "${@}"
377
378 [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments"
379
380 [[ ${ABI} == ${DEFAULT_ABI} ]]
381}
382
383# @FUNCTION: multilib_build_binaries
384# @DESCRIPTION:
385# Determine wheter to build binaries for the current build ABI.
386# Returns true status (0) if the current built ABI is the profile
387# native or COMPLETE_MULTILIB variable is set to yes, otherwise
388# false (1).
389#
390# The COMPLETE_MULTILIB variable can be set by users or profiles
391# when they want to build binaries for none-default ABI so e.g.
392# 32bit binaries on amd64.
393multilib_build_binaries() {
394 debug-print-function ${FUNCNAME} "${@}"
395
396 [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments"
397
398 [[ ${COMPLETE_MULTILIB} == yes ]] || multilib_is_native_abi
399}
400
341_MULTILIB_BUILD=1 401_MULTILIB_BUILD=1
342fi 402fi

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

  ViewVC Help
Powered by ViewVC 1.1.20