/[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.40
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2014 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.40 2014/04/28 17:38:21 mgorny Exp $
4 4
5# @ECLASS: multilib-build.eclass 5# @ECLASS: multilib-build.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# gx86-multilib team <multilib@gentoo.org>
8# @AUTHOR:
7# Michał Górny <mgorny@gentoo.org> 9# Author: Michał Górny <mgorny@gentoo.org>
8# @BLURB: flags and utility functions for building multilib packages 10# @BLURB: flags and utility functions for building multilib packages
9# @DESCRIPTION: 11# @DESCRIPTION:
10# The multilib-build.eclass exports USE flags and utility functions 12# The multilib-build.eclass exports USE flags and utility functions
11# necessary to build packages for multilib in a clean and uniform 13# necessary to build packages for multilib in a clean and uniform
12# manner. 14# manner.
26inherit multibuild multilib 28inherit multibuild multilib
27 29
28# @ECLASS-VARIABLE: _MULTILIB_FLAGS 30# @ECLASS-VARIABLE: _MULTILIB_FLAGS
29# @INTERNAL 31# @INTERNAL
30# @DESCRIPTION: 32# @DESCRIPTION:
31# The list of multilib flags and corresponding ABI values. 33# The list of multilib flags and corresponding ABI values. If the same
34# flag is reused for multiple ABIs (e.g. x86 on Linux&FreeBSD), multiple
35# ABIs may be separated by commas.
36#
37# Please contact multilib before modifying this list. This way we can
38# ensure that every *preliminary* work is done and the multilib can be
39# extended safely.
32_MULTILIB_FLAGS=( 40_MULTILIB_FLAGS=(
33 abi_x86_32:x86 41 abi_x86_32:x86,x86_fbsd
34 abi_x86_64:amd64 42 abi_x86_64:amd64,amd64_fbsd
35 abi_x86_x32:x32 43 abi_x86_x32:x32
44 abi_mips_n32:n32
45 abi_mips_n64:n64
46 abi_mips_o32:o32
36) 47)
37 48
38# @ECLASS-VARIABLE: MULTILIB_USEDEP 49# @ECLASS-VARIABLE: MULTILIB_USEDEP
39# @DESCRIPTION: 50# @DESCRIPTION:
40# The USE-dependency to be used on dependencies (libraries) needing 51# The USE-dependency to be used on dependencies (libraries) needing
68 local abis=( $(get_all_abis) ) 79 local abis=( $(get_all_abis) )
69 80
70 local abi i found 81 local abi i found
71 for abi in "${abis[@]}"; do 82 for abi in "${abis[@]}"; do
72 for i in "${_MULTILIB_FLAGS[@]}"; do 83 for i in "${_MULTILIB_FLAGS[@]}"; do
73 local m_abi=${i#*:} 84 local m_abis=${i#*:} m_abi
74 local m_flag=${i%:*} 85 local m_flag=${i%:*}
75 86
87 # split on ,; we can't switch IFS for function scope because
88 # paludis is broken (bug #486592), and switching it locally
89 # for the split is more complex than cheating like this
90 for m_abi in ${m_abis//,/ }; do
76 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then 91 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
77 echo "${abi}" 92 echo "${abi}"
78 found=1 93 found=1
94 break 2
79 fi 95 fi
96 done
80 done 97 done
81 done 98 done
82 99
83 if [[ ! ${found} ]]; then 100 if [[ ! ${found} ]]; then
84 # ${ABI} can be used to override the fallback (multilib-portage), 101 # ${ABI} can be used to override the fallback (multilib-portage),
224# MULTILIB_WRAPPED_HEADERS=( 241# MULTILIB_WRAPPED_HEADERS=(
225# /usr/include/foobar/config.h 242# /usr/include/foobar/config.h
226# ) 243# )
227# @CODE 244# @CODE
228 245
246# @ECLASS-VARIABLE: MULTILIB_CHOST_TOOLS
247# @DESCRIPTION:
248# A list of tool executables to preserve for each multilib ABI.
249# The listed executables will be renamed to ${CHOST}-${basename},
250# and the native variant will be symlinked to the generic name.
251#
252# This variable has to be a bash array. Paths shall be relative to
253# installation root (${ED}), and name regular files or symbolic
254# links to regular files. Recursive wrapping is not supported.
255#
256# If symbolic link is passed, both symlink path and symlink target
257# will be changed. As a result, the symlink target is expected
258# to be wrapped as well (either by listing in MULTILIB_CHOST_TOOLS
259# or externally).
260#
261# Please note that tool wrapping is *discouraged*. It is preferred to
262# install pkg-config files for each ABI, and require reverse
263# dependencies to use that.
264#
265# Packages that search for tools properly (e.g. using AC_PATH_TOOL
266# macro) will find the wrapper executables automatically. Other packages
267# will need explicit override of tool paths.
268#
269# Example:
270# @CODE
271# MULTILIB_CHOST_TOOLS=(
272# /usr/bin/foo-config
273# )
274
275# @CODE
229# @FUNCTION: multilib_prepare_wrappers 276# @FUNCTION: multilib_prepare_wrappers
230# @USAGE: [<install-root>] 277# @USAGE: [<install-root>]
231# @DESCRIPTION: 278# @DESCRIPTION:
232# Perform the preparation of all kinds of wrappers for the current ABI. 279# Perform the preparation of all kinds of wrappers for the current ABI.
233# This function shall be called once per each ABI, after installing 280# This function shall be called once per each ABI, after installing
260 fi 307 fi
261 # and then usr/include 308 # and then usr/include
262 f=${f#usr/include} 309 f=${f#usr/include}
263 310
264 local dir=${f%/*} 311 local dir=${f%/*}
265
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 312
270 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then 313 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
271 dodir "/tmp/multilib-include${dir}" 314 dodir "/tmp/multilib-include${dir}"
272 # a generic template 315 # a generic template
273 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ 316 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_
282# else /* 64-bit ABI */ 325# else /* 64-bit ABI */
283# error "abi_x86_64 not supported by the package." 326# error "abi_x86_64 not supported by the package."
284# endif 327# endif
285#elif defined(__i386__) /* plain x86 */ 328#elif defined(__i386__) /* plain x86 */
286# error "abi_x86_32 not supported by the package." 329# error "abi_x86_32 not supported by the package."
330#elif defined(__mips__)
331# if(_MIPS_SIM == _ABIN32) /* n32 */
332# error "abi_mips_n32 not supported by the package."
333# elif(_MIPS_SIM == _ABI64) /* n64 */
334# error "abi_mips_n64 not supported by the package."
335# elif(_MIPS_SIM == _ABIO32) /* o32 */
336# error "abi_mips_o32 not supported by the package."
337# endif
287#else 338#else
288# error "No ABI matched, please report a bug to bugs.gentoo.org" 339# error "No ABI matched, please report a bug to bugs.gentoo.org"
289#endif 340#endif
290_EOF_ 341_EOF_
291 fi 342 fi
292 343
344 # Some ABIs may have install less files than others.
345 if [[ -f ${root}/usr/include${f} ]]; then
346 # $CHOST shall be set by multilib_toolchain_setup
347 dodir "/tmp/multilib-include/${CHOST}${dir}"
348 mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
349
293 # XXX: get abi_* directly 350 # XXX: get abi_* directly
294 local abi_flag 351 local abi_flag
295 case "${ABI}" in 352 case "${ABI}" in
296 amd64) 353 amd64|amd64_fbsd)
297 abi_flag=abi_x86_64;; 354 abi_flag=abi_x86_64;;
298 x86) 355 x86|x86_fbsd)
299 abi_flag=abi_x86_32;; 356 abi_flag=abi_x86_32;;
300 x32) 357 x32)
301 abi_flag=abi_x86_x32;; 358 abi_flag=abi_x86_x32;;
359 n32)
360 abi_flag=abi_mips_n32;;
361 n64)
362 abi_flag=abi_mips_n64;;
363 o32)
364 abi_flag=abi_mips_o32;;
302 *) 365 *)
303 die "Header wrapping for ${ABI} not supported yet";; 366 die "Header wrapping for ${ABI} not supported yet";;
304 esac 367 esac
305 368
306 # Note: match a space afterwards to avoid collision potential. 369 # Note: match a space afterwards to avoid collision potential.
307 sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \ 370 sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
308 -i "${ED}/tmp/multilib-include${f}" || die 371 -i "${ED}/tmp/multilib-include${f}" || die
372 fi
373 done
374
375 for f in "${MULTILIB_CHOST_TOOLS[@]}"; do
376 # drop leading slash if it's there
377 f=${f#/}
378
379 local dir=${f%/*}
380 local fn=${f##*/}
381
382 if [[ -L ${root}/${f} ]]; then
383 # rewrite the symlink target
384 local target=$(readlink "${root}/${f}")
385 local target_dir
386 local target_fn=${target##*/}
387
388 [[ ${target} == */* ]] && target_dir=${target%/*}
389
390 ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" \
391 "${root}/${f}" || die
392 fi
393
394 mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die
395
396 # symlink the native one back
397 if multilib_is_native_abi; then
398 ln -s "${CHOST}-${fn}" "${root}/${f}" || die
399 fi
309 done 400 done
310} 401}
311 402
312# @FUNCTION: multilib_install_wrappers 403# @FUNCTION: multilib_install_wrappers
313# @USAGE: [<install-root>] 404# @USAGE: [<install-root>]
336 # it can fail if something else uses /tmp 427 # it can fail if something else uses /tmp
337 rmdir "${ED}"/tmp &>/dev/null 428 rmdir "${ED}"/tmp &>/dev/null
338 fi 429 fi
339} 430}
340 431
432# @FUNCTION: multilib_is_native_abi
433# @DESCRIPTION:
434# Determine whether the currently built ABI is the profile native.
435# Return true status (0) if that is true, otherwise false (1).
436#
437# This function is not intended to be used directly. Please use
438# multilib_build_binaries instead.
439multilib_is_native_abi() {
440 debug-print-function ${FUNCNAME} "${@}"
441
442 [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments"
443
444 [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
445}
446
447# @FUNCTION: multilib_build_binaries
448# @DESCRIPTION:
449# Determine whether to build binaries for the currently built ABI.
450# Returns true status (0) if the currently built ABI is the profile
451# native or COMPLETE_MULTILIB variable is set to 'yes', otherwise
452# false (1).
453#
454# This is often useful for configure calls when some of the options are
455# supposed to be disabled for multilib ABIs (like those used for
456# executables only).
457multilib_build_binaries() {
458 debug-print-function ${FUNCNAME} "${@}"
459
460 eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent"
461 eqawarn "multilib_is_native_abi function instead."
462
463 multilib_is_native_abi "${@}"
464}
465
466# @FUNCTION: multilib_native_use_with
467# @USAGE: <flag> [<opt-name> [<opt-value>]]
468# @DESCRIPTION:
469# Output --with configure option alike use_with if USE <flag> is enabled
470# and executables are being built (multilib_is_native_abi is true).
471# Otherwise, outputs --without configure option. Arguments are the same
472# as for use_with in the EAPI.
473multilib_native_use_with() {
474 if multilib_is_native_abi; then
475 use_with "${@}"
476 else
477 echo "--without-${2:-${1}}"
478 fi
479}
480
481# @FUNCTION: multilib_native_use_enable
482# @USAGE: <flag> [<opt-name> [<opt-value>]]
483# @DESCRIPTION:
484# Output --enable configure option alike use_with if USE <flag>
485# is enabled and executables are being built (multilib_is_native_abi
486# is true). Otherwise, outputs --disable configure option. Arguments are
487# the same as for use_enable in the EAPI.
488multilib_native_use_enable() {
489 if multilib_is_native_abi; then
490 use_enable "${@}"
491 else
492 echo "--disable-${2:-${1}}"
493 fi
494}
495
496# @FUNCTION: multilib_native_usex
497# @USAGE: <flag> [<true1> [<false1> [<true2> [<false2>]]]]
498# @DESCRIPTION:
499# Output the concatenation of <true1> (or 'yes' if unspecified)
500# and <true2> if USE <flag> is enabled and executables are being built
501# (multilib_is_native_abi is true). Otherwise, output the concatenation
502# of <false1> (or 'no' if unspecified) and <false2>. Arguments
503# are the same as for usex in the EAPI.
504#
505# Note: in EAPI 4 you need to inherit eutils to use this function.
506multilib_native_usex() {
507 if multilib_is_native_abi; then
508 usex "${@}"
509 else
510 echo "${3-no}${5}"
511 fi
512}
513
341_MULTILIB_BUILD=1 514_MULTILIB_BUILD=1
342fi 515fi

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

  ViewVC Help
Powered by ViewVC 1.1.20