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

Contents of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Tue Feb 26 21:05:39 2013 UTC (13 months, 3 weeks ago) by mgorny
Branch: MAIN
Changes since 1.3: +2 -1 lines
Run header checksumming function only if /usr/include exists (IOW: silence the warning).

1 mgorny 1.1 # Copyright 1999-2013 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.4 # $Header: /var/cvsroot/gentoo-x86/eclass/multilib-build.eclass,v 1.3 2013/02/26 14:42:24 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     )
36    
37     # @ECLASS-VARIABLE: MULTILIB_USEDEP
38     # @DESCRIPTION:
39     # The USE-dependency to be used on dependencies (libraries) needing
40     # to support multilib as well.
41     #
42     # Example use:
43     # @CODE
44     # RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}]
45     # net-libs/libbar[ssl,${MULTILIB_USEDEP}]"
46     # @CODE
47    
48     _multilib_build_set_globals() {
49     local flags=( "${_MULTILIB_FLAGS[@]%:*}" )
50     local usedeps=${flags[@]/%/(-)?}
51    
52     IUSE=${flags[*]}
53     MULTILIB_USEDEP=${usedeps// /,}
54     }
55     _multilib_build_set_globals
56    
57     # @FUNCTION: multilib_get_enabled_abis
58     # @DESCRIPTION:
59     # Return the ordered list of enabled ABIs if multilib builds
60     # are enabled. The best (most preferred) ABI will come last.
61     #
62     # If multilib is disabled, the default ABI will be returned
63     # in order to enforce consistent testing with multilib code.
64     multilib_get_enabled_abis() {
65     debug-print-function ${FUNCNAME} "${@}"
66    
67     local abis=( $(get_all_abis) )
68    
69     local abi i found
70     for abi in "${abis[@]}"; do
71     for i in "${_MULTILIB_FLAGS[@]}"; do
72     local m_abi=${i#*:}
73     local m_flag=${i%:*}
74    
75     if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
76     echo "${abi}"
77     found=1
78     fi
79     done
80     done
81    
82     if [[ ! ${found} ]]; then
83     debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${DEFAULT_ABI}"
84     echo ${DEFAULT_ABI}
85     fi
86     }
87    
88     # @FUNCTION: multilib_foreach_abi
89     # @USAGE: <argv>...
90     # @DESCRIPTION:
91     # If multilib support is enabled, sets the toolchain up for each
92     # supported ABI along with the ABI variable and correct BUILD_DIR,
93     # and runs the given commands with them.
94     #
95     # If multilib support is disabled, it just runs the commands. No setup
96     # is done.
97     multilib_foreach_abi() {
98     local initial_dir=${BUILD_DIR:-${S}}
99    
100     local ABI
101     for ABI in $(multilib_get_enabled_abis); do
102     multilib_toolchain_setup "${ABI}"
103 mgorny 1.3 local BUILD_DIR=${initial_dir%%/}-${ABI}
104     "${@}" | tee -a "${T}/build-${ABI}.log"
105 mgorny 1.1 done
106     }
107    
108     # @FUNCTION: multilib_parallel_foreach_abi
109     # @USAGE: <argv>...
110     # @DESCRIPTION:
111     # If multilib support is enabled, sets the toolchain up for each
112     # supported ABI along with the ABI variable and correct BUILD_DIR,
113     # and runs the given commands with them. The commands are run
114     # in parallel with number of jobs being determined from MAKEOPTS.
115     #
116     # If multilib support is disabled, it just runs the commands. No setup
117     # is done.
118     #
119     # Useful for running configure scripts.
120     multilib_parallel_foreach_abi() {
121     local initial_dir=${BUILD_DIR:-${S}}
122    
123     multijob_init
124    
125     local ABI
126     for ABI in $(multilib_get_enabled_abis); do
127     (
128     multijob_child_init
129    
130     multilib_toolchain_setup "${ABI}"
131 mgorny 1.3 local BUILD_DIR=${initial_dir%%/}-${ABI}
132     "${@}" 2>&1 | tee -a "${T}/build-${ABI}.log"
133 mgorny 1.1 ) &
134    
135     multijob_post_fork
136     done
137    
138     multijob_finish
139     }
140    
141 mgorny 1.2 # @FUNCTION: multilib_check_headers
142     # @DESCRIPTION:
143     # Check whether the header files are consistent between ABIs.
144     #
145     # This function needs to be called after each ABI's installation phase.
146     # It obtains the header file checksums and compares them with previous
147     # runs (if any). Dies if header files differ.
148     multilib_check_headers() {
149     _multilib_header_cksum() {
150 mgorny 1.4 [[ -d ${ED}usr/include ]] && \
151 mgorny 1.2 find "${ED}"usr/include -type f \
152     -exec cksum {} + | sort -k2
153     }
154    
155     local cksum=$(_multilib_header_cksum)
156     local cksum_file=${T}/.multilib_header_cksum
157    
158     if [[ -f ${cksum_file} ]]; then
159     local cksum_prev=$(< "${cksum_file}")
160    
161     if [[ ${cksum} != ${cksum_prev} ]]; then
162     echo "${cksum}" > "${cksum_file}.new"
163    
164     eerror "Header files have changed between ABIs."
165    
166     if type -p diff &>/dev/null; then
167     eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")"
168     else
169     eerror "Old checksums in: ${cksum_file}"
170     eerror "New checksums in: ${cksum_file}.new"
171     fi
172    
173     die "Header checksum mismatch, aborting."
174     fi
175     else
176     echo "${cksum}" > "${cksum_file}"
177     fi
178     }
179    
180 mgorny 1.1 _MULTILIB_BUILD=1
181     fi

  ViewVC Help
Powered by ViewVC 1.1.20