/[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.10 Revision 1.11
1# Copyright 1999-2013 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/multilib-build.eclass,v 1.10 2013/03/09 13:52:05 mgorny Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multilib-build.eclass,v 1.11 2013/04/07 16:56:14 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
202 202
203 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) ) 203 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abis) )
204 multibuild_copy_sources 204 multibuild_copy_sources
205} 205}
206 206
207# @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS
208# @DESCRIPTION:
209# A list of headers to wrap for multilib support. The listed headers
210# will be moved to a non-standard location and replaced with a file
211# including them conditionally to current ABI.
212#
213# This variable has to be a bash array. Paths shall be relative to
214# installation root (${ED}), and name regular files. Recursive wrapping
215# is not supported.
216#
217# Please note that header wrapping is *discouraged*. It is preferred to
218# install all headers in a subdirectory of libdir and use pkg-config to
219# locate the headers. Some C preprocessors will not work with wrapped
220# headers.
221#
222# Example:
223# @CODE
224# MULTILIB_WRAPPED_HEADERS=(
225# /usr/include/foobar/config.h
226# )
227# @CODE
228
229# @FUNCTION: multilib_prepare_wrappers
230# @USAGE: [<install-root>]
231# @DESCRIPTION:
232# Perform the preparation of all kinds of wrappers for the current ABI.
233# This function shall be called once per each ABI, after installing
234# the files to be wrapped.
235#
236# Takes an optional custom <install-root> from which files will be
237# used. If no root is specified, uses ${ED}.
238#
239# The files to be wrapped are specified using separate variables,
240# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed
241# between the successive calls to multilib_prepare_wrappers
242# and multilib_install_wrappers.
243#
244# After all wrappers are prepared, multilib_install_wrappers shall
245# be called to commit them to the installation tree.
246multilib_prepare_wrappers() {
247 debug-print-function ${FUNCNAME} "${@}"
248
249 [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments"
250
251 local root=${1:-${ED}}
252 local f
253
254 for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
255 # drop leading slash if it's there
256 f=${f#/}
257
258 if [[ ${f} != usr/include/* ]]; then
259 die "Wrapping headers outside of /usr/include is not supported at the moment."
260 fi
261 # and then usr/include
262 f=${f#usr/include}
263
264 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
270 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
271 dodir "/tmp/multilib-include${dir}"
272 # a generic template
273 cat > "${ED}/tmp/multilib-include${f}" <<_EOF_ || die
274/* This file is auto-generated by multilib-build.eclass
275 * as a multilib-friendly wrapper. For the original content,
276 * please see the files that are #included below.
277 */
278
279#if defined(__x86_64__) /* amd64 */
280# if defined(__ILP32__) /* x32 ABI */
281# error "abi_x86_x32 not supported by the package."
282# else /* 64-bit ABI */
283# error "abi_x86_64 not supported by the package."
284# endif
285#elif defined(__i386__) /* plain x86 */
286# error "abi_x86_32 not supported by the package."
287#else
288# error "No ABI matched, please report a bug to bugs.gentoo.org"
289#endif
290_EOF_
291 fi
292
293 # XXX: get abi_* directly
294 local abi_flag
295 case "${ABI}" in
296 amd64)
297 abi_flag=abi_x86_64;;
298 x86)
299 abi_flag=abi_x86_32;;
300 x32)
301 abi_flag=abi_x86_x32;;
302 *)
303 die "Header wrapping for ${ABI} not supported yet";;
304 esac
305
306 # Note: match a space afterwards to avoid collision potential.
307 sed -e "/${abi_flag} /s&error.*&include <${CHOST}/${f}>&" \
308 -i "${ED}/tmp/multilib-include${f}" || die
309 done
310}
311
312# @FUNCTION: multilib_install_wrappers
313# @USAGE: [<install-root>]
314# @DESCRIPTION:
315# Install the previously-prepared wrappers. This function shall
316# be called once, after all wrappers were prepared.
317#
318# Takes an optional custom <install-root> to which the wrappers will be
319# installed. If no root is specified, uses ${ED}. There is no need to
320# use the same root as when preparing the wrappers.
321#
322# The files to be wrapped are specified using separate variables,
323# e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed
324# between the calls to multilib_prepare_wrappers
325# and multilib_install_wrappers.
326multilib_install_wrappers() {
327 debug-print-function ${FUNCNAME} "${@}"
328
329 [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments"
330
331 local root=${1:-${ED}}
332
333 if [[ -d "${ED}"/tmp/multilib-include ]]; then
334 multibuild_merge_root \
335 "${ED}"/tmp/multilib-include "${root}"/usr/include
336 # it can fail if something else uses /tmp
337 rmdir "${ED}"/tmp &>/dev/null
338 fi
339}
340
207_MULTILIB_BUILD=1 341_MULTILIB_BUILD=1
208fi 342fi

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.20