/[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.28
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.28 2014/03/29 03:00:44 vapier 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
41 abi_ppc_32:ppc
42 abi_ppc_64:ppc64
36) 43)
37 44
38# @ECLASS-VARIABLE: MULTILIB_USEDEP 45# @ECLASS-VARIABLE: MULTILIB_USEDEP
39# @DESCRIPTION: 46# @DESCRIPTION:
40# The USE-dependency to be used on dependencies (libraries) needing 47# The USE-dependency to be used on dependencies (libraries) needing
68 local abis=( $(get_all_abis) ) 75 local abis=( $(get_all_abis) )
69 76
70 local abi i found 77 local abi i found
71 for abi in "${abis[@]}"; do 78 for abi in "${abis[@]}"; do
72 for i in "${_MULTILIB_FLAGS[@]}"; do 79 for i in "${_MULTILIB_FLAGS[@]}"; do
73 local m_abi=${i#*:} 80 local m_abis=${i#*:} m_abi
74 local m_flag=${i%:*} 81 local m_flag=${i%:*}
75 82
83 # split on ,; we can't switch IFS for function scope because
84 # paludis is broken (bug #486592), and switching it locally
85 # for the split is more complex than cheating like this
86 for m_abi in ${m_abis//,/ }; do
76 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then 87 if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
77 echo "${abi}" 88 echo "${abi}"
78 found=1 89 found=1
90 break 2
79 fi 91 fi
92 done
80 done 93 done
81 done 94 done
82 95
83 if [[ ! ${found} ]]; then 96 if [[ ! ${found} ]]; then
84 # ${ABI} can be used to override the fallback (multilib-portage), 97 # ${ABI} can be used to override the fallback (multilib-portage),
224# MULTILIB_WRAPPED_HEADERS=( 237# MULTILIB_WRAPPED_HEADERS=(
225# /usr/include/foobar/config.h 238# /usr/include/foobar/config.h
226# ) 239# )
227# @CODE 240# @CODE
228 241
242# @ECLASS-VARIABLE: MULTILIB_CHOST_TOOLS
243# @DESCRIPTION:
244# A list of tool executables to preserve for each multilib ABI.
245# The listed executables will be renamed to ${CHOST}-${basename},
246# and the native variant will be symlinked to the generic name.
247#
248# This variable has to be a bash array. Paths shall be relative to
249# installation root (${ED}), and name regular files. Recursive wrapping
250# is not supported.
251#
252# Please note that tool wrapping is *discouraged*. It is preferred to
253# install pkg-config files for each ABI, and require reverse
254# dependencies to use that.
255#
256# Packages that search for tools properly (e.g. using AC_PATH_TOOL
257# macro) will find the wrapper executables automatically. Other packages
258# will need explicit override of tool paths.
259#
260# Example:
261# @CODE
262# MULTILIB_CHOST_TOOLS=(
263# /usr/bin/foo-config
264# )
265
266# @CODE
229# @FUNCTION: multilib_prepare_wrappers 267# @FUNCTION: multilib_prepare_wrappers
230# @USAGE: [<install-root>] 268# @USAGE: [<install-root>]
231# @DESCRIPTION: 269# @DESCRIPTION:
232# Perform the preparation of all kinds of wrappers for the current ABI. 270# Perform the preparation of all kinds of wrappers for the current ABI.
233# This function shall be called once per each ABI, after installing 271# This function shall be called once per each ABI, after installing
260 fi 298 fi
261 # and then usr/include 299 # and then usr/include
262 f=${f#usr/include} 300 f=${f#usr/include}
263 301
264 local dir=${f%/*} 302 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 303
270 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then 304 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
271 dodir "/tmp/multilib-include${dir}" 305 dodir "/tmp/multilib-include${dir}"
272 # a generic template 306 # a generic template
273 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ 307 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_
282# else /* 64-bit ABI */ 316# else /* 64-bit ABI */
283# error "abi_x86_64 not supported by the package." 317# error "abi_x86_64 not supported by the package."
284# endif 318# endif
285#elif defined(__i386__) /* plain x86 */ 319#elif defined(__i386__) /* plain x86 */
286# error "abi_x86_32 not supported by the package." 320# error "abi_x86_32 not supported by the package."
321#elif defined(__mips__)
322# if(_MIPS_SIM == _ABIN32) /* n32 */
323# error "abi_mips_n32 not supported by the package."
324# elif(_MIPS_SIM == _ABI64) /* n64 */
325# error "abi_mips_n64 not supported by the package."
326# elif(_MIPS_SIM == _ABIO32) /* o32 */
327# error "abi_mips_o32 not supported by the package."
328# endif
287#else 329#else
288# error "No ABI matched, please report a bug to bugs.gentoo.org" 330# error "No ABI matched, please report a bug to bugs.gentoo.org"
289#endif 331#endif
290_EOF_ 332_EOF_
291 fi 333 fi
292 334
335 # Some ABIs may have install less files than others.
336 if [[ -f ${root}/usr/include${f} ]]; then
337 # $CHOST shall be set by multilib_toolchain_setup
338 dodir "/tmp/multilib-include/${CHOST}${dir}"
339 mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
340
293 # XXX: get abi_* directly 341 # XXX: get abi_* directly
294 local abi_flag 342 local abi_flag
295 case "${ABI}" in 343 case "${ABI}" in
296 amd64) 344 amd64|amd64_fbsd)
297 abi_flag=abi_x86_64;; 345 abi_flag=abi_x86_64;;
298 x86) 346 x86|x86_fbsd)
299 abi_flag=abi_x86_32;; 347 abi_flag=abi_x86_32;;
300 x32) 348 x32)
301 abi_flag=abi_x86_x32;; 349 abi_flag=abi_x86_x32;;
350 n32)
351 abi_flag=abi_mips_n32;;
352 n64)
353 abi_flag=abi_mips_n64;;
354 o32)
355 abi_flag=abi_mips_o32;;
356 ppc)
357 abi_flag=abi_ppc_32;;
358 ppc64)
359 abi_flag=abi_ppc_64;;
302 *) 360 *)
303 die "Header wrapping for ${ABI} not supported yet";; 361 die "Header wrapping for ${ABI} not supported yet";;
304 esac 362 esac
305 363
306 # Note: match a space afterwards to avoid collision potential. 364 # Note: match a space afterwards to avoid collision potential.
307 sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \ 365 sed -e "/${abi_flag} /s&error.*&include <${CHOST}${f}>&" \
308 -i "${ED}/tmp/multilib-include${f}" || die 366 -i "${ED}/tmp/multilib-include${f}" || die
367 fi
368 done
369
370 for f in "${MULTILIB_CHOST_TOOLS[@]}"; do
371 # drop leading slash if it's there
372 f=${f#/}
373
374 local dir=${f%/*}
375 local fn=${f##*/}
376
377 mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die
378
379 # symlink the native one back
380 if multilib_build_binaries; then
381 ln -s "${CHOST}-${fn}" "${root}/${f}" || die
382 fi
309 done 383 done
310} 384}
311 385
312# @FUNCTION: multilib_install_wrappers 386# @FUNCTION: multilib_install_wrappers
313# @USAGE: [<install-root>] 387# @USAGE: [<install-root>]
336 # it can fail if something else uses /tmp 410 # it can fail if something else uses /tmp
337 rmdir "${ED}"/tmp &>/dev/null 411 rmdir "${ED}"/tmp &>/dev/null
338 fi 412 fi
339} 413}
340 414
415# @FUNCTION: multilib_is_native_abi
416# @DESCRIPTION:
417# Determine whether the currently built ABI is the profile native.
418# Return true status (0) if that is true, otherwise false (1).
419#
420# This function is not intended to be used directly. Please use
421# multilib_build_binaries instead.
422multilib_is_native_abi() {
423 debug-print-function ${FUNCNAME} "${@}"
424
425 [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments"
426
427 [[ ${ABI} == ${DEFAULT_ABI} ]]
428}
429
430# @FUNCTION: multilib_build_binaries
431# @DESCRIPTION:
432# Determine whether to build binaries for the currently built ABI.
433# Returns true status (0) if the currently built ABI is the profile
434# native or COMPLETE_MULTILIB variable is set to 'yes', otherwise
435# false (1).
436#
437# This is often useful for configure calls when some of the options are
438# supposed to be disabled for multilib ABIs (like those used for
439# executables only).
440multilib_build_binaries() {
441 debug-print-function ${FUNCNAME} "${@}"
442
443 [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments"
444
445 [[ ${COMPLETE_MULTILIB} == yes ]] || multilib_is_native_abi
446}
447
341_MULTILIB_BUILD=1 448_MULTILIB_BUILD=1
342fi 449fi

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

  ViewVC Help
Powered by ViewVC 1.1.20