| 1 | # Copyright 1999-2012 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/autotools-multilib.eclass,v 1.1 2012/10/08 18:44:30 mgorny Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.7 2013/01/26 11:39:41 mgorny Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: autotools-multilib.eclass |
5 | # @ECLASS: autotools-multilib.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # Michał Górny <mgorny@gentoo.org> |
7 | # Michał Górny <mgorny@gentoo.org> |
| 8 | # @BLURB: autotools-utils wrapper for multilib builds |
8 | # @BLURB: autotools-utils wrapper for multilib builds |
| … | |
… | |
| 17 | # |
17 | # |
| 18 | # Note that the multilib support requires out-of-source builds to be |
18 | # Note that the multilib support requires out-of-source builds to be |
| 19 | # enabled. Thus, it is impossible to use AUTOTOOLS_IN_SOURCE_BUILD with |
19 | # enabled. Thus, it is impossible to use AUTOTOOLS_IN_SOURCE_BUILD with |
| 20 | # it. |
20 | # it. |
| 21 | |
21 | |
|
|
22 | # EAPI=5 is required for meaningful MULTILIB_USEDEP. |
| 22 | case ${EAPI:-0} in |
23 | case ${EAPI:-0} in |
| 23 | 2|3|4) ;; |
24 | 5) ;; |
| 24 | *) die "EAPI=${EAPI} is not supported" ;; |
25 | *) die "EAPI=${EAPI} is not supported" ;; |
| 25 | esac |
26 | esac |
| 26 | |
27 | |
| 27 | if [[ ${AUTOTOOLS_IN_SOURCE_BUILD} ]]; then |
28 | if [[ ${AUTOTOOLS_IN_SOURCE_BUILD} ]]; then |
| 28 | die "${ECLASS}: multilib support requires out-of-source builds." |
29 | die "${ECLASS}: multilib support requires out-of-source builds." |
| 29 | fi |
30 | fi |
| 30 | |
31 | |
| 31 | inherit autotools-utils multilib |
32 | inherit autotools-utils multilib multiprocessing |
| 32 | |
33 | |
| 33 | EXPORT_FUNCTIONS src_configure src_compile src_test src_install |
34 | EXPORT_FUNCTIONS src_configure src_compile src_test src_install |
| 34 | |
35 | |
| 35 | IUSE=multilib |
36 | IUSE=multilib |
| 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 | MULTILIB_USEDEP='multilib(-)?' |
|
|
49 | |
| 37 | # @FUNCTION: autotools-multilib_foreach_abi |
50 | # @FUNCTION: autotools-multilib_foreach_abi |
| 38 | # @USAGE: argv... |
51 | # @USAGE: argv... |
| 39 | # @DESCRIPTION: |
52 | # @DESCRIPTION: |
| 40 | # If multilib support is enabled, sets the toolchain up for each |
53 | # If multilib support is enabled, sets the toolchain up for each |
| 41 | # supported ABI along with the ABI variable and correct |
54 | # supported ABI along with the ABI variable and correct BUILD_DIR, |
| 42 | # AUTOTOOLS_BUILD_DIR, and runs the given commands with them. |
55 | # and runs the given commands with them. |
| 43 | # |
56 | # |
| 44 | # If multilib support is disabled, it just runs the commands. No setup |
57 | # If multilib support is disabled, it just runs the commands. No setup |
| 45 | # is done. |
58 | # is done. |
| 46 | autotools-multilib_foreach_abi() { |
59 | autotools-multilib_foreach_abi() { |
|
|
60 | local initial_dir=${BUILD_DIR:-${S}} |
|
|
61 | |
| 47 | if use multilib; then |
62 | if use multilib; then |
| 48 | local ABI |
63 | local ABI |
| 49 | for ABI in $(get_all_abis); do |
64 | for ABI in $(get_all_abis); do |
| 50 | multilib_toolchain_setup "${ABI}" |
65 | multilib_toolchain_setup "${ABI}" |
| 51 | AUTOTOOLS_BUILD_DIR=${S%%/}-${ABI} "${@}" |
66 | BUILD_DIR=${initial_dir%%/}-${ABI} "${@}" |
| 52 | done |
67 | done |
| 53 | else |
68 | else |
| 54 | "${@}" |
69 | "${@}" |
| 55 | fi |
70 | fi |
| 56 | } |
71 | } |
| 57 | |
72 | |
|
|
73 | # @FUNCTION: autotools-multilib_parallel_foreach_abi |
|
|
74 | # @USAGE: argv... |
|
|
75 | # @DESCRIPTION: |
|
|
76 | # If multilib support is enabled, sets the toolchain up for each |
|
|
77 | # supported ABI along with the ABI variable and correct BUILD_DIR, |
|
|
78 | # and runs the given commands with them. The commands are run |
|
|
79 | # in parallel with number of jobs being determined from MAKEOPTS. |
|
|
80 | # |
|
|
81 | # If multilib support is disabled, it just runs the commands. No setup |
|
|
82 | # is done. |
|
|
83 | # |
|
|
84 | # Useful for running configure scripts. |
|
|
85 | autotools-multilib_parallel_foreach_abi() { |
|
|
86 | local initial_dir=${BUILD_DIR:-${S}} |
|
|
87 | |
|
|
88 | if use multilib; then |
|
|
89 | multijob_init |
|
|
90 | |
|
|
91 | local ABI |
|
|
92 | for ABI in $(get_all_abis); do |
|
|
93 | ( |
|
|
94 | multijob_child_init |
|
|
95 | |
|
|
96 | multilib_toolchain_setup "${ABI}" |
|
|
97 | BUILD_DIR=${initial_dir%%/}-${ABI} |
|
|
98 | "${@}" |
|
|
99 | ) & |
|
|
100 | |
|
|
101 | multijob_post_fork |
|
|
102 | done |
|
|
103 | |
|
|
104 | multijob_finish |
|
|
105 | else |
|
|
106 | "${@}" |
|
|
107 | fi |
|
|
108 | } |
|
|
109 | |
| 58 | autotools-multilib_src_configure() { |
110 | autotools-multilib_src_configure() { |
| 59 | autotools-multilib_foreach_abi autotools-utils_src_configure |
111 | autotools-multilib_parallel_foreach_abi autotools-utils_src_configure |
| 60 | } |
112 | } |
| 61 | |
113 | |
| 62 | autotools-multilib_src_compile() { |
114 | autotools-multilib_src_compile() { |
| 63 | autotools-multilib_foreach_abi autotools-utils_src_compile |
115 | autotools-multilib_foreach_abi autotools-utils_src_compile |
| 64 | } |
116 | } |