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

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

  ViewVC Help
Powered by ViewVC 1.1.20