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

Diff of /eclass/multilib.eclass

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

Revision 1.65 Revision 1.86
1# Copyright 1999-2008 Gentoo Foundation 1# Copyright 1999-2011 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.eclass,v 1.65 2008/06/01 01:37:29 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.86 2011/03/18 19:12:08 vapier Exp $
4 4
5# @ECLASS: multilib.eclass 5# @ECLASS: multilib.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# amd64@gentoo.org 7# amd64@gentoo.org
8# toolchain@gentoo.org 8# toolchain@gentoo.org
10# @DESCRIPTION: 10# @DESCRIPTION:
11# This eclass is for all functions pertaining to handling multilib configurations. 11# This eclass is for all functions pertaining to handling multilib configurations.
12 12
13___ECLASS_RECUR_MULTILIB="yes" 13___ECLASS_RECUR_MULTILIB="yes"
14[[ -z ${___ECLASS_RECUR_TOOLCHAIN_FUNCS} ]] && inherit toolchain-funcs 14[[ -z ${___ECLASS_RECUR_TOOLCHAIN_FUNCS} ]] && inherit toolchain-funcs
15
16# is_final_abi:
17# Return true if ${ABI} is the final abi to be installed (and thus we are
18# on our last run through a src_* function.
19
20# number_abis:
21# echo the number of ABIs we will be installing for
22
23# get_install_abis:
24# Return a list of the ABIs we want to install for with
25# the last one in the list being the default.
26
27# get_all_abis:
28# Return a list of the ABIs supported by this profile.
29# the last one in the list being the default.
30
31# get_all_libdirs:
32# Returns a list of all the libdirs used by this profile. This includes
33# those that might not be touched by the current ebuild and always includes
34# "lib".
35
36# get_libdir:
37# Returns the libdir for the selected ABI. This is backwards compatible
38# and simply calls get_abi_LIBDIR() on newer profiles. You should use this
39# to determine where to install shared objects (ex: /usr/$(get_libdir))
40
41# get_abi_var <VAR> [<ABI>]:
42# returns the value of ${<VAR>_<ABI>} which should be set in make.defaults
43#
44# get_abi_CFLAGS:
45# get_abi_CDEFINE:
46# get_abi_LIBDIR:
47# Aliases for 'get_abi_var CFLAGS', etc.
48
49# get_ml_incdir [<include dir> [<ABI>]]
50# include dir defaults to /usr/include
51# ABI defaults to ${ABI} or ${DEFAULT_ABI}
52#
53# If a multilib include dir is associated with the passed include dir, then
54# we return it, otherwise, we just echo back the include dir. This is
55# neccessary when a built script greps header files rather than testing them
56# via #include (like perl) to figure out features.
57
58# prep_ml_includes:
59# Some includes (include/asm, glibc, etc) are ABI dependent. In this case,
60# We can install them in different locations for each ABI and create a common
61# header which includes the right one based on CDEFINE_${ABI}. If your
62# package installs ABI-specific headers, just add 'prep_ml_includes' to the
63# end of your src_install(). It takes a list of directories that include
64# files are installed in (default is /usr/include if none are passed).
65#
66# Example:
67# src_install() {
68# ...
69# prep_ml_includes /usr/qt/3/include
70# }
71
72# create_ml_includes <include dir> <symbol 1>:<dir 1> [<symbol 2>:<dir 2> ...]
73# If you need more control than prep_ml_includes can offer (like linux-headers
74# for the asm-* dirs, then use create_ml_includes. The firs argument is the
75# common dir. The remaining args are of the form <symbol>:<dir> where
76# <symbol> is what is put in the #ifdef for choosing that dir.
77#
78# Ideas for this code came from debian's sparc-linux headers package.
79#
80# Example:
81# create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64
82# create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64
83
84# get_libname [version]
85# returns libname with proper suffix {.so,.dylib} and optionally supplied version
86# for ELF/MACH-O shared objects
87#
88# Example:
89# get_libname libfoo ${PV}
90# Returns: libfoo.so.${PV} (ELF) || libfoo.${PV}.dylib (MACH)
91
92### END DOCUMENTATION ###
93 15
94# Defaults: 16# Defaults:
95export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} 17export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"}
96export DEFAULT_ABI=${DEFAULT_ABI:-"default"} 18export DEFAULT_ABI=${DEFAULT_ABI:-"default"}
97export CFLAGS_default 19export CFLAGS_default
313# @DESCRIPTION: 235# @DESCRIPTION:
314# Returns a list of all the libdirs used by this profile. This includes 236# Returns a list of all the libdirs used by this profile. This includes
315# those that might not be touched by the current ebuild and always includes 237# those that might not be touched by the current ebuild and always includes
316# "lib". 238# "lib".
317get_all_libdirs() { 239get_all_libdirs() {
318 local libdirs="lib" 240 local libdirs
319 local abi 241 local abi
320 local dir 242 local dir
321 243
322 for abi in ${MULTILIB_ABIS}; do 244 for abi in ${MULTILIB_ABIS}; do
323 [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})" 245 libdirs+=" $(get_abi_LIBDIR ${abi})"
324 done 246 done
247 [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib"
325 248
326 echo "${libdirs}" 249 echo "${libdirs}"
327} 250}
328 251
329# @FUNCTION: is_final_abi 252# @FUNCTION: is_final_abi
331# Return true if ${ABI} is the last ABI on our list (or if we're not 254# Return true if ${ABI} is the last ABI on our list (or if we're not
332# using the new multilib configuration. This can be used to determine 255# using the new multilib configuration. This can be used to determine
333# if we're in the last (or only) run through src_{unpack,compile,install} 256# if we're in the last (or only) run through src_{unpack,compile,install}
334is_final_abi() { 257is_final_abi() {
335 has_multilib_profile || return 0 258 has_multilib_profile || return 0
336 local ALL_ABIS=$(get_install_abis) 259 set -- $(get_install_abis)
337 local LAST_ABI=${ALL_ABIS/* /} 260 local LAST_ABI=$#
338 [[ ${LAST_ABI} == ${ABI} ]] 261 [[ ${!LAST_ABI} == ${ABI} ]]
339} 262}
340 263
341# @FUNCTION: number_abis 264# @FUNCTION: number_abis
342# @DESCRIPTION: 265# @DESCRIPTION:
343# echo the number of ABIs we will be installing for 266# echo the number of ABIs we will be installing for
415 done 338 done
416 339
417 if is_final_abi; then 340 if is_final_abi; then
418 base=${T}/gentoo-multilib 341 base=${T}/gentoo-multilib
419 pushd "${base}" 342 pushd "${base}"
420 find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C ${D} 343 find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C "${D}"
421 popd 344 popd
422 345
423 # This 'set' stuff is required by mips profiles to properly pass 346 # This 'set' stuff is required by mips profiles to properly pass
424 # CDEFINE's (which have spaces) to sub-functions 347 # CDEFINE's (which have spaces) to sub-functions
425 set -- 348 set --
553# Helper function for create_ml_includes 476# Helper function for create_ml_includes
554create_ml_includes-makedestdirs() { 477create_ml_includes-makedestdirs() {
555 local dest=$1 478 local dest=$1
556 shift 479 shift
557 local basedirs=$@ 480 local basedirs=$@
481 [[ -z ${ED} ]] && local ED=${D}
558 482
559 dodir ${dest} 483 dodir ${dest}
560 484
561 local basedir 485 local basedir
562 for basedir in ${basedirs}; do 486 for basedir in ${basedirs}; do
563 local dir 487 local dir
564 for dir in $(find ${D}/${basedir} -type d); do 488 for dir in $(find "${ED}"/${basedir} -type d); do
565 dodir ${dest}/${dir/${D}\/${basedir}/} 489 dodir ${dest}/${dir/${ED}\/${basedir}/}
566 done 490 done
567 done 491 done
568} 492}
569 493
570# Helper function for create_ml_includes 494# Helper function for create_ml_includes
571create_ml_includes-allfiles() { 495create_ml_includes-allfiles() {
496 [[ -z ${ED} ]] && local ED=${D}
572 local basedir file 497 local basedir file
573 for basedir in "$@" ; do 498 for basedir in "$@" ; do
574 for file in $(find "${D}"/${basedir} -type f); do 499 for file in $(find "${ED}"/${basedir} -type f); do
575 echo ${file/${D}\/${basedir}\//} 500 echo ${file/${ED}\/${basedir}\//}
576 done 501 done
577 done | sort | uniq 502 done | sort | uniq
578} 503}
579 504
580# Helper function for create_ml_includes 505# Helper function for create_ml_includes
594} 519}
595 520
596# @FUNCTION: get_libname 521# @FUNCTION: get_libname
597# @USAGE: [version] 522# @USAGE: [version]
598# @DESCRIPTION: 523# @DESCRIPTION:
599# Returns libname with proper suffix {.so,.dylib} and optionally supplied version 524# Returns libname with proper suffix {.so,.dylib,.dll,etc} and optionally
600# for ELF/MACH-O shared objects 525# supplied version for the current platform identified by CHOST.
601# 526#
602# Example: 527# Example:
603# get_libname libfoo ${PV} 528# get_libname ${PV}
604# Returns: libfoo.so.${PV} (ELF) || libfoo.${PV}.dylib (MACH) 529# Returns: .so.${PV} (ELF) || .${PV}.dylib (MACH) || ...
605get_libname() { 530get_libname() {
606 local libname 531 local libname
607 local ver=$1 532 local ver=$1
608 case ${CHOST} in 533 case ${CHOST} in
609 mingw*|*-mingw*) libname="dll";; 534 *-cygwin|mingw*|*-mingw*) libname="dll";;
610 *-darwin*) libname="dylib";; 535 *-darwin*) libname="dylib";;
536 *-mint*) libname="irrelevant";;
537 hppa*-hpux*) libname="sl";;
611 *) libname="so";; 538 *) libname="so";;
612 esac 539 esac
613 540
614 if [[ -z $* ]] ; then 541 if [[ -z $* ]] ; then
615 echo ".${libname}" 542 echo ".${libname}"
616 else 543 else
617 for ver in "$@" ; do 544 for ver in "$@" ; do
618 case ${CHOST} in 545 case ${CHOST} in
619 *-darwin*) echo ".${ver}.${libname}";; 546 *-darwin*) echo ".${ver}.${libname}";;
547 *-mint*) echo ".${libname}";;
620 *) echo ".${libname}.${ver}";; 548 *) echo ".${libname}.${ver}";;
621 esac 549 esac
622 done 550 done
623 fi 551 fi
552}
553
554# @FUNCTION: get_modname
555# @USAGE:
556# @DESCRIPTION:
557# Returns modulename with proper suffix {.so,.bundle,etc} for the current
558# platform identified by CHOST.
559#
560# Example:
561# libfoo$(get_modname)
562# Returns: libfoo.so (ELF) || libfoo.bundle (MACH) || ...
563get_modname() {
564 local modname
565 local ver=$1
566 case ${CHOST} in
567 *-darwin*) modname="bundle";;
568 *) modname="so";;
569 esac
570
571 echo ".${modname}"
624} 572}
625 573
626# This is for the toolchain to setup profile variables when pulling in 574# This is for the toolchain to setup profile variables when pulling in
627# a crosscompiler (and thus they aren't set in the profile) 575# a crosscompiler (and thus they aren't set in the profile)
628multilib_env() { 576multilib_env() {
632 x86_64*) 580 x86_64*)
633 export CFLAGS_x86=${CFLAGS_x86--m32} 581 export CFLAGS_x86=${CFLAGS_x86--m32}
634 export CHOST_x86=${CTARGET/x86_64/i686} 582 export CHOST_x86=${CTARGET/x86_64/i686}
635 export CTARGET_x86=${CHOST_x86} 583 export CTARGET_x86=${CHOST_x86}
636 export CDEFINE_x86="__i386__" 584 export CDEFINE_x86="__i386__"
585 if [[ ${SYMLINK_LIBDIR} == "yes" ]] ; then
586 export LIBDIR_x86="lib32"
587 else
637 export LIBDIR_x86="lib" 588 export LIBDIR_x86="lib"
589 fi
638 590
639 export CFLAGS_amd64=${CFLAGS_amd64--m64} 591 export CFLAGS_amd64=${CFLAGS_amd64--m64}
640 export CHOST_amd64=${CTARGET} 592 export CHOST_amd64=${CTARGET}
641 export CTARGET_amd64=${CHOST_amd64} 593 export CTARGET_amd64=${CHOST_amd64}
642 export CDEFINE_amd64="__x86_64__" 594 export CDEFINE_amd64="__x86_64__"
643 export LIBDIR_amd64="lib64" 595 export LIBDIR_amd64="lib64"
644 596
597 export CFLAGS_x32=${CFLAGS_x32--mx32}
598 export CHOST_x32=${CTARGET}
599 export CTARGET_x32=${CHOST_x32}
600 export CDEFINE_x32="__i386__"
601 export LIBDIR_x32="libx32"
602
645 export MULTILIB_ABIS="amd64 x86" 603 : ${MULTILIB_ABIS=amd64 x86}
646 export DEFAULT_ABI="amd64" 604 : ${DEFAULT_ABI=amd64}
647 ;; 605 ;;
648 mips64*) 606 mips64*)
649 export CFLAGS_o32=${CFLAGS_o32--mabi=32} 607 export CFLAGS_o32=${CFLAGS_o32--mabi=32}
650 export CHOST_o32=${CTARGET/mips64/mips} 608 export CHOST_o32=${CTARGET/mips64/mips}
651 export CTARGET_o32=${CHOST_o32} 609 export CTARGET_o32=${CHOST_o32}
662 export CHOST_n64=${CTARGET} 620 export CHOST_n64=${CTARGET}
663 export CTARGET_n64=${CHOST_n64} 621 export CTARGET_n64=${CHOST_n64}
664 export CDEFINE_n64="_MIPS_SIM == _ABI64" 622 export CDEFINE_n64="_MIPS_SIM == _ABI64"
665 export LIBDIR_n64="lib64" 623 export LIBDIR_n64="lib64"
666 624
667 export MULTILIB_ABIS="n64 n32 o32" 625 : ${MULTILIB_ABIS=n64 n32 o32}
668 export DEFAULT_ABI="n32" 626 : ${DEFAULT_ABI=n32}
669 ;; 627 ;;
670 powerpc64*) 628 powerpc64*)
671 export CFLAGS_ppc=${CFLAGS_ppc--m32} 629 export CFLAGS_ppc=${CFLAGS_ppc--m32}
672 export CHOST_ppc=${CTARGET/powerpc64/powerpc} 630 export CHOST_ppc=${CTARGET/powerpc64/powerpc}
673 export CTARGET_ppc=${CHOST_ppc} 631 export CTARGET_ppc=${CHOST_ppc}
678 export CHOST_ppc64=${CTARGET} 636 export CHOST_ppc64=${CTARGET}
679 export CTARGET_ppc64=${CHOST_ppc64} 637 export CTARGET_ppc64=${CHOST_ppc64}
680 export CDEFINE_ppc64="__powerpc64__" 638 export CDEFINE_ppc64="__powerpc64__"
681 export LIBDIR_ppc64="lib64" 639 export LIBDIR_ppc64="lib64"
682 640
683 export MULTILIB_ABIS="ppc64 ppc" 641 : ${MULTILIB_ABIS=ppc64 ppc}
684 export DEFAULT_ABI="ppc64" 642 : ${DEFAULT_ABI=ppc64}
685 ;; 643 ;;
686 s390x*) 644 s390x*)
687 export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo 645 export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo
688 export CHOST_s390=${CTARGET/s390x/s390} 646 export CHOST_s390=${CTARGET/s390x/s390}
689 export CTARGET_s390=${CHOST_s390} 647 export CTARGET_s390=${CHOST_s390}
694 export CHOST_s390x=${CTARGET} 652 export CHOST_s390x=${CTARGET}
695 export CTARGET_s390x=${CHOST_s390x} 653 export CTARGET_s390x=${CHOST_s390x}
696 export CDEFINE_s390x="__s390x__" 654 export CDEFINE_s390x="__s390x__"
697 export LIBDIR_s390x="lib64" 655 export LIBDIR_s390x="lib64"
698 656
699 export MULTILIB_ABIS="s390x s390" 657 : ${MULTILIB_ABIS=s390x s390}
700 export DEFAULT_ABI="s390x" 658 : ${DEFAULT_ABI=s390x}
701 ;; 659 ;;
702 sparc64*) 660 sparc*)
703 export CFLAGS_sparc32=${CFLAGS_sparc32--m32} 661 export CFLAGS_sparc32=${CFLAGS_sparc32}
704 export CHOST_sparc32=${CTARGET/sparc64/sparc} 662 export CHOST_sparc32=${CTARGET/sparc64/sparc}
705 export CTARGET_sparc32=${CHOST_sparc32} 663 export CTARGET_sparc32=${CHOST_sparc32}
706 export CDEFINE_sparc32="!__arch64__" 664 export CDEFINE_sparc32="!__arch64__"
707 export LIBDIR_sparc32="lib" 665 export LIBDIR_sparc32="lib"
708 666
710 export CHOST_sparc64=${CTARGET} 668 export CHOST_sparc64=${CTARGET}
711 export CTARGET_sparc64=${CHOST_sparc64} 669 export CTARGET_sparc64=${CHOST_sparc64}
712 export CDEFINE_sparc64="__arch64__" 670 export CDEFINE_sparc64="__arch64__"
713 export LIBDIR_sparc64="lib64" 671 export LIBDIR_sparc64="lib64"
714 672
715 export MULTILIB_ABIS="sparc64 sparc32" 673 : ${MULTILIB_ABIS=sparc64 sparc32}
716 export DEFAULT_ABI="sparc64" 674 : ${DEFAULT_ABI=sparc64}
717 ;; 675 ;;
718 *) 676 *)
719 export MULTILIB_ABIS="default" 677 : ${MULTILIB_ABIS=default}
720 export DEFAULT_ABI="default" 678 : ${DEFAULT_ABI=default}
721 ;; 679 ;;
722 esac 680 esac
681
682 export MULTILIB_ABIS DEFAULT_ABI
723} 683}
724 684
725# @FUNCTION: multilib_toolchain_setup 685# @FUNCTION: multilib_toolchain_setup
726# @DESCRIPTION: 686# @DESCRIPTION:
727# Hide multilib details here for packages which are forced to be compiled for a 687# Hide multilib details here for packages which are forced to be compiled for a
728# specific ABI when run on another ABI (like x86-specific packages on amd64) 688# specific ABI when run on another ABI (like x86-specific packages on amd64)
729multilib_toolchain_setup() { 689multilib_toolchain_setup() {
690 local v vv
691
730 export ABI=$1 692 export ABI=$1
731 693
732 if has_version app-admin/eselect-compiler ; then 694 # First restore any saved state we have laying around.
733 # Binutils doesn't have wrappers for ld and as (yet). Eventually it 695 if [[ ${__DEFAULT_ABI_SAVED} == "true" ]] ; then
734 # will, and all this can just be handled with CHOST. 696 for v in CHOST CBUILD AS CC CXX LD ; do
735 export LD="ld $(get_abi_LDFLAGS $1)" 697 vv="__abi_saved_${v}"
698 export ${v}="${!vv}"
699 unset ${vv}
700 done
701 unset __DEFAULT_ABI_SAVED
702 fi
703
704 # We want to avoid the behind-the-back magic of gcc-config as it
705 # screws up ccache and distcc. See #196243 for more info.
706 if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
707 # Back that multilib-ass up so we can restore it later
708 for v in CHOST CBUILD AS CC CXX LD ; do
709 export __abi_saved_${v}="${!v}"
710 done
711 export __DEFAULT_ABI_SAVED="true"
712
713 # Set the CHOST native first so that we pick up the native
714 # toolchain and not a cross-compiler by accident #202811.
715 export CHOST=$(get_abi_CHOST ${DEFAULT_ABI})
736 export AS="as $(get_abi_ASFLAGS $1)" 716 export AS="$(tc-getAS) $(get_abi_ASFLAGS)"
737 717 export CC="$(tc-getCC) $(get_abi_CFLAGS)"
718 export CXX="$(tc-getCXX) $(get_abi_CFLAGS)"
719 export LD="$(tc-getLD) $(get_abi_LDFLAGS)"
738 export CHOST=$(get_abi_CHOST $1) 720 export CHOST=$(get_abi_CHOST $1)
739 export CBUILD=$(get_abi_CHOST $1) 721 export CBUILD=$(get_abi_CHOST $1)
740 else
741 tc-export CC
742 fi 722 fi
743} 723}

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.86

  ViewVC Help
Powered by ViewVC 1.1.20