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

Contents of /eclass/multilib-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.60 - (hide annotations) (download)
Thu Jul 3 07:48:49 2014 UTC (3 years, 2 months ago) by mgorny
Branch: MAIN
Changes since 1.59: +3 -1 lines
Re-enable multilib flags for s390.

1 mgorny 1.26 # Copyright 1999-2014 Gentoo Foundation
2 mgorny 1.1 # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.60 # $Header: /var/cvsroot/gentoo-x86/eclass/multilib-build.eclass,v 1.59 2014/06/29 08:32:46 mgorny Exp $
4 mgorny 1.1
5     # @ECLASS: multilib-build.eclass
6     # @MAINTAINER:
7 mgorny 1.34 # gx86-multilib team <multilib@gentoo.org>
8     # @AUTHOR:
9     # Author: Michał Górny <mgorny@gentoo.org>
10 mgorny 1.1 # @BLURB: flags and utility functions for building multilib packages
11     # @DESCRIPTION:
12     # The multilib-build.eclass exports USE flags and utility functions
13     # necessary to build packages for multilib in a clean and uniform
14     # manner.
15     #
16     # Please note that dependency specifications for multilib-capable
17     # dependencies shall use the USE dependency string in ${MULTILIB_USEDEP}
18     # to properly request multilib enabled.
19    
20     if [[ ! ${_MULTILIB_BUILD} ]]; then
21    
22 mgorny 1.12 # EAPI=4 is required for meaningful MULTILIB_USEDEP.
23 mgorny 1.1 case ${EAPI:-0} in
24 mgorny 1.12 4|5) ;;
25 mgorny 1.1 *) die "EAPI=${EAPI} is not supported" ;;
26     esac
27    
28 mgorny 1.8 inherit multibuild multilib
29 mgorny 1.1
30     # @ECLASS-VARIABLE: _MULTILIB_FLAGS
31     # @INTERNAL
32     # @DESCRIPTION:
33 mgorny 1.21 # The list of multilib flags and corresponding ABI values. If the same
34     # flag is reused for multiple ABIs (e.g. x86 on Linux&FreeBSD), multiple
35     # ABIs may be separated by commas.
36 mgorny 1.33 #
37     # Please contact multilib before modifying this list. This way we can
38     # ensure that every *preliminary* work is done and the multilib can be
39     # extended safely.
40 mgorny 1.1 _MULTILIB_FLAGS=(
41 mgorny 1.21 abi_x86_32:x86,x86_fbsd
42     abi_x86_64:amd64,amd64_fbsd
43 mgorny 1.6 abi_x86_x32:x32
44 mattst88 1.17 abi_mips_n32:n32
45     abi_mips_n64:n64
46     abi_mips_o32:o32
47 mgorny 1.57 abi_ppc_32:ppc
48     abi_ppc_64:ppc64
49 mgorny 1.60 abi_s390_32:s390
50     abi_s390_64:s390x
51 mgorny 1.1 )
52    
53 mgorny 1.46 # @ECLASS-VARIABLE: MULTILIB_COMPAT
54     # @DEFAULT_UNSET
55     # @DESCRIPTION:
56     # List of multilib ABIs supported by the ebuild. If unset, defaults to
57     # all ABIs supported by the eclass.
58     #
59     # This variable is intended for use in prebuilt multilib packages that
60     # can provide binaries only for a limited set of ABIs. If ABIs need to
61     # be limited due to a bug in source code, package.use.mask is
62     # recommended instead.
63     #
64     # Example use:
65     # @CODE
66     # # Upstream provides binaries for x86 & amd64 only
67     # MULTILIB_COMPAT=( abi_x86_{32,64} )
68     # @CODE
69    
70 mgorny 1.1 # @ECLASS-VARIABLE: MULTILIB_USEDEP
71     # @DESCRIPTION:
72     # The USE-dependency to be used on dependencies (libraries) needing
73     # to support multilib as well.
74     #
75     # Example use:
76     # @CODE
77     # RDEPEND="dev-libs/libfoo[${MULTILIB_USEDEP}]
78     # net-libs/libbar[ssl,${MULTILIB_USEDEP}]"
79     # @CODE
80    
81 mgorny 1.50 # @ECLASS-VARIABLE: MULTILIB_ABI_FLAG
82     # @DEFAULT_UNSET
83     # @DESCRIPTION:
84     # The complete ABI name. Resembles the USE flag name.
85     #
86     # This is set within multilib_foreach_abi(),
87     # multilib_parallel_foreach_abi() and multilib-minimal sub-phase
88     # functions.
89     #
90     # It may be null (empty) when the build is done on ABI not controlled
91     # by a USE flag (e.g. on non-multilib arch or when using multilib
92     # portage). The build will always be done for a single ABI then.
93     #
94     # Example value:
95     # @CODE
96     # abi_x86_64
97     # @CODE
98    
99 mgorny 1.1 _multilib_build_set_globals() {
100     local flags=( "${_MULTILIB_FLAGS[@]%:*}" )
101 mgorny 1.46
102     if [[ ${MULTILIB_COMPAT[@]} ]]; then
103     # Validate MULTILIB_COMPAT and filter out the flags.
104     local f
105     for f in "${MULTILIB_COMPAT[@]}"; do
106     if ! has "${f}" "${flags[@]}"; then
107     die "Invalid value in MULTILIB_COMPAT: ${f}"
108     fi
109     done
110    
111     flags=( "${MULTILIB_COMPAT[@]}" )
112     fi
113    
114 mgorny 1.1 local usedeps=${flags[@]/%/(-)?}
115    
116     IUSE=${flags[*]}
117     MULTILIB_USEDEP=${usedeps// /,}
118     }
119     _multilib_build_set_globals
120    
121     # @FUNCTION: multilib_get_enabled_abis
122     # @DESCRIPTION:
123     # Return the ordered list of enabled ABIs if multilib builds
124     # are enabled. The best (most preferred) ABI will come last.
125     #
126     # If multilib is disabled, the default ABI will be returned
127     # in order to enforce consistent testing with multilib code.
128     multilib_get_enabled_abis() {
129     debug-print-function ${FUNCNAME} "${@}"
130    
131 mgorny 1.49 local pairs=( $(multilib_get_enabled_abi_pairs) )
132 mgorny 1.55 echo "${pairs[@]#*.}"
133 mgorny 1.49 }
134    
135     # @FUNCTION: multilib_get_enabled_abi_pairs
136     # @DESCRIPTION:
137 mgorny 1.54 # Return the ordered list of enabled <use-flag>.<ABI> pairs
138 mgorny 1.49 # if multilib builds are enabled. The best (most preferred)
139     # ABI will come last.
140     #
141     # If multilib is disabled, the default ABI will be returned
142     # along with empty <use-flag>.
143     multilib_get_enabled_abi_pairs() {
144     debug-print-function ${FUNCNAME} "${@}"
145    
146 mgorny 1.1 local abis=( $(get_all_abis) )
147    
148     local abi i found
149     for abi in "${abis[@]}"; do
150     for i in "${_MULTILIB_FLAGS[@]}"; do
151 mgorny 1.21 local m_abis=${i#*:} m_abi
152 mgorny 1.1 local m_flag=${i%:*}
153    
154 mgorny 1.22 # split on ,; we can't switch IFS for function scope because
155     # paludis is broken (bug #486592), and switching it locally
156 mgorny 1.23 # for the split is more complex than cheating like this
157     for m_abi in ${m_abis//,/ }; do
158 mgorny 1.58 if [[ ${m_abi} == ${abi} ]] \
159 mgorny 1.59 && { [[ ! "${MULTILIB_COMPAT[@]}" ]] || has "${m_flag}" "${MULTILIB_COMPAT[@]}"; } \
160 mgorny 1.58 && use "${m_flag}"
161     then
162 mgorny 1.54 echo "${m_flag}.${abi}"
163 mgorny 1.21 found=1
164     break 2
165     fi
166     done
167 mgorny 1.1 done
168     done
169    
170     if [[ ! ${found} ]]; then
171 mgorny 1.7 # ${ABI} can be used to override the fallback (multilib-portage),
172     # ${DEFAULT_ABI} is the safe fallback.
173     local abi=${ABI:-${DEFAULT_ABI}}
174    
175     debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}"
176     debug-print "${FUNCNAME}: ABI=${ABI}, DEFAULT_ABI=${DEFAULT_ABI}"
177 mgorny 1.54 echo ".${abi}"
178 mgorny 1.1 fi
179     }
180    
181 mgorny 1.8 # @FUNCTION: _multilib_multibuild_wrapper
182     # @USAGE: <argv>...
183     # @INTERNAL
184     # @DESCRIPTION:
185     # Initialize the environment for ABI selected for multibuild.
186     _multilib_multibuild_wrapper() {
187     debug-print-function ${FUNCNAME} "${@}"
188    
189 mgorny 1.54 local ABI=${MULTIBUILD_VARIANT#*.}
190     local MULTILIB_ABI_FLAG=${MULTIBUILD_VARIANT%.*}
191 mgorny 1.50
192 mgorny 1.8 multilib_toolchain_setup "${ABI}"
193     "${@}"
194     }
195    
196 mgorny 1.1 # @FUNCTION: multilib_foreach_abi
197     # @USAGE: <argv>...
198     # @DESCRIPTION:
199     # If multilib support is enabled, sets the toolchain up for each
200     # supported ABI along with the ABI variable and correct BUILD_DIR,
201     # and runs the given commands with them.
202     #
203     # If multilib support is disabled, it just runs the commands. No setup
204     # is done.
205     multilib_foreach_abi() {
206 mgorny 1.8 debug-print-function ${FUNCNAME} "${@}"
207 mgorny 1.1
208 mgorny 1.50 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) )
209 mgorny 1.8 multibuild_foreach_variant _multilib_multibuild_wrapper "${@}"
210 mgorny 1.1 }
211    
212     # @FUNCTION: multilib_parallel_foreach_abi
213     # @USAGE: <argv>...
214     # @DESCRIPTION:
215     # If multilib support is enabled, sets the toolchain up for each
216     # supported ABI along with the ABI variable and correct BUILD_DIR,
217     # and runs the given commands with them. The commands are run
218     # in parallel with number of jobs being determined from MAKEOPTS.
219     #
220     # If multilib support is disabled, it just runs the commands. No setup
221     # is done.
222     #
223     # Useful for running configure scripts.
224     multilib_parallel_foreach_abi() {
225 mgorny 1.8 debug-print-function ${FUNCNAME} "${@}"
226 mgorny 1.1
227 mgorny 1.50 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) )
228 mgorny 1.8 multibuild_parallel_foreach_variant _multilib_multibuild_wrapper "${@}"
229 mgorny 1.1 }
230    
231 mgorny 1.9 # @FUNCTION: multilib_for_best_abi
232     # @USAGE: <argv>...
233     # @DESCRIPTION:
234     # Runs the given command with setup for the 'best' (usually native) ABI.
235     multilib_for_best_abi() {
236     debug-print-function ${FUNCNAME} "${@}"
237    
238 mgorny 1.51 eqawarn "QA warning: multilib_for_best_abi() function is deprecated and should"
239     eqawarn "not be used. The multilib_is_native_abi() check may be used instead."
240    
241 mgorny 1.50 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) )
242 mgorny 1.9
243     multibuild_for_best_variant _multilib_multibuild_wrapper "${@}"
244     }
245    
246 mgorny 1.2 # @FUNCTION: multilib_check_headers
247     # @DESCRIPTION:
248     # Check whether the header files are consistent between ABIs.
249     #
250     # This function needs to be called after each ABI's installation phase.
251     # It obtains the header file checksums and compares them with previous
252     # runs (if any). Dies if header files differ.
253     multilib_check_headers() {
254     _multilib_header_cksum() {
255 mgorny 1.4 [[ -d ${ED}usr/include ]] && \
256 mgorny 1.2 find "${ED}"usr/include -type f \
257     -exec cksum {} + | sort -k2
258     }
259    
260     local cksum=$(_multilib_header_cksum)
261     local cksum_file=${T}/.multilib_header_cksum
262    
263     if [[ -f ${cksum_file} ]]; then
264     local cksum_prev=$(< "${cksum_file}")
265    
266     if [[ ${cksum} != ${cksum_prev} ]]; then
267     echo "${cksum}" > "${cksum_file}.new"
268    
269     eerror "Header files have changed between ABIs."
270    
271     if type -p diff &>/dev/null; then
272     eerror "$(diff -du "${cksum_file}" "${cksum_file}.new")"
273     else
274     eerror "Old checksums in: ${cksum_file}"
275     eerror "New checksums in: ${cksum_file}.new"
276     fi
277    
278     die "Header checksum mismatch, aborting."
279     fi
280     else
281     echo "${cksum}" > "${cksum_file}"
282     fi
283     }
284    
285 mgorny 1.10 # @FUNCTION: multilib_copy_sources
286     # @DESCRIPTION:
287     # Create a single copy of the package sources for each enabled ABI.
288     #
289     # The sources are always copied from initial BUILD_DIR (or S if unset)
290     # to ABI-specific build directory matching BUILD_DIR used by
291     # multilib_foreach_abi().
292     multilib_copy_sources() {
293     debug-print-function ${FUNCNAME} "${@}"
294    
295 mgorny 1.50 local MULTIBUILD_VARIANTS=( $(multilib_get_enabled_abi_pairs) )
296 mgorny 1.10 multibuild_copy_sources
297     }
298    
299 mgorny 1.11 # @ECLASS-VARIABLE: MULTILIB_WRAPPED_HEADERS
300     # @DESCRIPTION:
301     # A list of headers to wrap for multilib support. The listed headers
302     # will be moved to a non-standard location and replaced with a file
303     # including them conditionally to current ABI.
304     #
305     # This variable has to be a bash array. Paths shall be relative to
306     # installation root (${ED}), and name regular files. Recursive wrapping
307     # is not supported.
308     #
309     # Please note that header wrapping is *discouraged*. It is preferred to
310     # install all headers in a subdirectory of libdir and use pkg-config to
311     # locate the headers. Some C preprocessors will not work with wrapped
312     # headers.
313     #
314     # Example:
315     # @CODE
316     # MULTILIB_WRAPPED_HEADERS=(
317     # /usr/include/foobar/config.h
318     # )
319     # @CODE
320    
321 mgorny 1.26 # @ECLASS-VARIABLE: MULTILIB_CHOST_TOOLS
322     # @DESCRIPTION:
323     # A list of tool executables to preserve for each multilib ABI.
324     # The listed executables will be renamed to ${CHOST}-${basename},
325     # and the native variant will be symlinked to the generic name.
326     #
327     # This variable has to be a bash array. Paths shall be relative to
328 mgorny 1.29 # installation root (${ED}), and name regular files or symbolic
329     # links to regular files. Recursive wrapping is not supported.
330     #
331     # If symbolic link is passed, both symlink path and symlink target
332     # will be changed. As a result, the symlink target is expected
333     # to be wrapped as well (either by listing in MULTILIB_CHOST_TOOLS
334     # or externally).
335 mgorny 1.26 #
336     # Please note that tool wrapping is *discouraged*. It is preferred to
337     # install pkg-config files for each ABI, and require reverse
338     # dependencies to use that.
339     #
340     # Packages that search for tools properly (e.g. using AC_PATH_TOOL
341     # macro) will find the wrapper executables automatically. Other packages
342     # will need explicit override of tool paths.
343     #
344     # Example:
345     # @CODE
346     # MULTILIB_CHOST_TOOLS=(
347     # /usr/bin/foo-config
348     # )
349    
350     # @CODE
351 mgorny 1.11 # @FUNCTION: multilib_prepare_wrappers
352     # @USAGE: [<install-root>]
353     # @DESCRIPTION:
354     # Perform the preparation of all kinds of wrappers for the current ABI.
355     # This function shall be called once per each ABI, after installing
356     # the files to be wrapped.
357     #
358     # Takes an optional custom <install-root> from which files will be
359     # used. If no root is specified, uses ${ED}.
360     #
361     # The files to be wrapped are specified using separate variables,
362     # e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed
363     # between the successive calls to multilib_prepare_wrappers
364     # and multilib_install_wrappers.
365     #
366     # After all wrappers are prepared, multilib_install_wrappers shall
367     # be called to commit them to the installation tree.
368     multilib_prepare_wrappers() {
369     debug-print-function ${FUNCNAME} "${@}"
370    
371     [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments"
372    
373     local root=${1:-${ED}}
374     local f
375    
376 mgorny 1.43 if [[ ${COMPLETE_MULTILIB} == yes ]]; then
377     # symlink '${CHOST}-foo -> foo' to support abi-wrapper while
378     # keeping ${CHOST}-foo calls correct.
379    
380     for f in "${MULTILIB_CHOST_TOOLS[@]}"; do
381     # drop leading slash if it's there
382     f=${f#/}
383    
384     local dir=${f%/*}
385     local fn=${f##*/}
386    
387     ln -s "${fn}" "${root}/${dir}/${CHOST}-${fn}" || die
388     done
389    
390     return
391     fi
392    
393 mgorny 1.44 for f in "${MULTILIB_CHOST_TOOLS[@]}"; do
394     # drop leading slash if it's there
395     f=${f#/}
396    
397     local dir=${f%/*}
398     local fn=${f##*/}
399    
400     if [[ -L ${root}/${f} ]]; then
401     # rewrite the symlink target
402     local target=$(readlink "${root}/${f}")
403     local target_dir
404     local target_fn=${target##*/}
405    
406     [[ ${target} == */* ]] && target_dir=${target%/*}
407    
408     ln -f -s "${target_dir+${target_dir}/}${CHOST}-${target_fn}" \
409     "${root}/${f}" || die
410     fi
411    
412     mv "${root}/${f}" "${root}/${dir}/${CHOST}-${fn}" || die
413    
414     # symlink the native one back
415     if multilib_is_native_abi; then
416     ln -s "${CHOST}-${fn}" "${root}/${f}" || die
417     fi
418     done
419    
420 mgorny 1.45 if [[ ${MULTILIB_WRAPPED_HEADERS[@]} ]]; then
421 mgorny 1.52 # If abi_flag is unset, then header wrapping is unsupported on
422     # this ABI. This means the arch doesn't support multilib at all
423     # -- in this case, the headers are not wrapped and everything
424     # works as expected.
425 mgorny 1.45
426 mgorny 1.52 if [[ ${MULTILIB_ABI_FLAG} ]]; then
427 mgorny 1.45 for f in "${MULTILIB_WRAPPED_HEADERS[@]}"; do
428     # drop leading slash if it's there
429     f=${f#/}
430 mgorny 1.11
431 mgorny 1.45 if [[ ${f} != usr/include/* ]]; then
432     die "Wrapping headers outside of /usr/include is not supported at the moment."
433     fi
434     # and then usr/include
435     f=${f#usr/include}
436 mgorny 1.11
437 mgorny 1.45 local dir=${f%/*}
438 mgorny 1.11
439 mgorny 1.48 # Some ABIs may have install less files than others.
440     if [[ -f ${root}/usr/include${f} ]]; then
441 mgorny 1.52 local wrapper=${ED}/tmp/multilib-include${f}
442    
443 mgorny 1.48 if [[ ! -f ${ED}/tmp/multilib-include${f} ]]; then
444     dodir "/tmp/multilib-include${dir}"
445     # a generic template
446 mgorny 1.52 cat > "${wrapper}" <<_EOF_
447 mgorny 1.11 /* This file is auto-generated by multilib-build.eclass
448     * as a multilib-friendly wrapper. For the original content,
449     * please see the files that are #included below.
450     */
451    
452     #if defined(__x86_64__) /* amd64 */
453     # if defined(__ILP32__) /* x32 ABI */
454     # error "abi_x86_x32 not supported by the package."
455     # else /* 64-bit ABI */
456     # error "abi_x86_64 not supported by the package."
457     # endif
458     #elif defined(__i386__) /* plain x86 */
459     # error "abi_x86_32 not supported by the package."
460 mattst88 1.17 #elif defined(__mips__)
461     # if(_MIPS_SIM == _ABIN32) /* n32 */
462     # error "abi_mips_n32 not supported by the package."
463     # elif(_MIPS_SIM == _ABI64) /* n64 */
464     # error "abi_mips_n64 not supported by the package."
465     # elif(_MIPS_SIM == _ABIO32) /* o32 */
466     # error "abi_mips_o32 not supported by the package."
467     # endif
468 mgorny 1.53 #elif defined(__sparc__)
469     # if defined(__arch64__)
470     # error "abi_sparc_64 not supported by the package."
471     # else
472     # error "abi_sparc_32 not supported by the package."
473     # endif
474     #elif defined(__s390__)
475     # if defined(__s390x__)
476     # error "abi_s390_64 not supported by the package."
477     # else
478     # error "abi_s390_32 not supported by the package."
479     # endif
480     #elif defined(__powerpc__)
481     # if defined(__powerpc64__)
482     # error "abi_ppc_64 not supported by the package."
483     # else
484     # error "abi_ppc_32 not supported by the package."
485     # endif
486 mgorny 1.56 #elif defined(SWIG) /* https://sourceforge.net/p/swig/bugs/799/ */
487     # error "Native ABI not supported by the package."
488 mgorny 1.11 #else
489     # error "No ABI matched, please report a bug to bugs.gentoo.org"
490     #endif
491     _EOF_
492 mgorny 1.48 fi
493 mgorny 1.11
494 mgorny 1.52 if ! grep -q "${MULTILIB_ABI_FLAG} " "${wrapper}"
495     then
496     die "Flag ${MULTILIB_ABI_FLAG} not listed in wrapper template. Please report a bug to https://bugs.gentoo.org."
497     fi
498    
499 mgorny 1.45 # $CHOST shall be set by multilib_toolchain_setup
500     dodir "/tmp/multilib-include/${CHOST}${dir}"
501     mv "${root}/usr/include${f}" "${ED}/tmp/multilib-include/${CHOST}${dir}/" || die
502    
503     # Note: match a space afterwards to avoid collision potential.
504 mgorny 1.52 sed -e "/${MULTILIB_ABI_FLAG} /s&error.*&include <${CHOST}${f}>&" \
505     -i "${wrapper}" || die
506 mgorny 1.47
507     # Hack for emul-linux-x86 compatibility.
508     # It assumes amd64 will come after x86, and will use amd64
509     # headers if no specific x86 headers were installed.
510     if [[ ${ABI} == amd64 ]]; then
511     sed -e "/abi_x86_32 /s&error.*&include <${CHOST}${f}>&" \
512 mgorny 1.52 -i "${wrapper}" || die
513 mgorny 1.47 fi
514 mgorny 1.56
515     # Needed for swig.
516     if multilib_is_native_abi; then
517     sed -e "/Native ABI/s&error.*&include <${CHOST}${f}>&" \
518     -i "${wrapper}" || die
519     fi
520 mgorny 1.45 fi
521     done
522 mgorny 1.18 fi
523 mgorny 1.45 fi
524 mgorny 1.11 }
525    
526     # @FUNCTION: multilib_install_wrappers
527     # @USAGE: [<install-root>]
528     # @DESCRIPTION:
529     # Install the previously-prepared wrappers. This function shall
530     # be called once, after all wrappers were prepared.
531     #
532     # Takes an optional custom <install-root> to which the wrappers will be
533     # installed. If no root is specified, uses ${ED}. There is no need to
534     # use the same root as when preparing the wrappers.
535     #
536     # The files to be wrapped are specified using separate variables,
537     # e.g. MULTILIB_WRAPPED_HEADERS. Those variables shall not be changed
538     # between the calls to multilib_prepare_wrappers
539     # and multilib_install_wrappers.
540     multilib_install_wrappers() {
541     debug-print-function ${FUNCNAME} "${@}"
542    
543     [[ ${#} -le 1 ]] || die "${FUNCNAME}: too many arguments"
544    
545 mgorny 1.42 [[ ${COMPLETE_MULTILIB} == yes ]] && return
546 mgorny 1.41
547 mgorny 1.11 local root=${1:-${ED}}
548    
549     if [[ -d "${ED}"/tmp/multilib-include ]]; then
550     multibuild_merge_root \
551     "${ED}"/tmp/multilib-include "${root}"/usr/include
552     # it can fail if something else uses /tmp
553     rmdir "${ED}"/tmp &>/dev/null
554     fi
555     }
556    
557 mgorny 1.15 # @FUNCTION: multilib_is_native_abi
558     # @DESCRIPTION:
559     # Determine whether the currently built ABI is the profile native.
560     # Return true status (0) if that is true, otherwise false (1).
561     #
562 mgorny 1.25 # This function is not intended to be used directly. Please use
563     # multilib_build_binaries instead.
564 mgorny 1.15 multilib_is_native_abi() {
565     debug-print-function ${FUNCNAME} "${@}"
566    
567 mgorny 1.40 [[ ${#} -eq 0 ]] || die "${FUNCNAME}: too many arguments"
568    
569     [[ ${COMPLETE_MULTILIB} == yes || ${ABI} == ${DEFAULT_ABI} ]]
570 mgorny 1.15 }
571    
572 tommy 1.20 # @FUNCTION: multilib_build_binaries
573     # @DESCRIPTION:
574 mgorny 1.27 # Determine whether to build binaries for the currently built ABI.
575 mgorny 1.25 # Returns true status (0) if the currently built ABI is the profile
576     # native or COMPLETE_MULTILIB variable is set to 'yes', otherwise
577 tommy 1.20 # false (1).
578     #
579 mgorny 1.25 # This is often useful for configure calls when some of the options are
580     # supposed to be disabled for multilib ABIs (like those used for
581     # executables only).
582 tommy 1.19 multilib_build_binaries() {
583     debug-print-function ${FUNCNAME} "${@}"
584    
585 mgorny 1.40 eqawarn "QA warning: multilib_build_binaries is deprecated. Please use the equivalent"
586     eqawarn "multilib_is_native_abi function instead."
587 tommy 1.19
588 mgorny 1.40 multilib_is_native_abi "${@}"
589 tommy 1.19 }
590 tommy 1.20
591 mgorny 1.35 # @FUNCTION: multilib_native_use_with
592     # @USAGE: <flag> [<opt-name> [<opt-value>]]
593     # @DESCRIPTION:
594     # Output --with configure option alike use_with if USE <flag> is enabled
595 mgorny 1.40 # and executables are being built (multilib_is_native_abi is true).
596 mgorny 1.35 # Otherwise, outputs --without configure option. Arguments are the same
597     # as for use_with in the EAPI.
598     multilib_native_use_with() {
599 mgorny 1.40 if multilib_is_native_abi; then
600 mgorny 1.35 use_with "${@}"
601     else
602     echo "--without-${2:-${1}}"
603     fi
604     }
605    
606     # @FUNCTION: multilib_native_use_enable
607     # @USAGE: <flag> [<opt-name> [<opt-value>]]
608     # @DESCRIPTION:
609     # Output --enable configure option alike use_with if USE <flag>
610 mgorny 1.40 # is enabled and executables are being built (multilib_is_native_abi
611 mgorny 1.35 # is true). Otherwise, outputs --disable configure option. Arguments are
612     # the same as for use_enable in the EAPI.
613     multilib_native_use_enable() {
614 mgorny 1.40 if multilib_is_native_abi; then
615 mgorny 1.35 use_enable "${@}"
616     else
617     echo "--disable-${2:-${1}}"
618     fi
619     }
620    
621     # @FUNCTION: multilib_native_usex
622     # @USAGE: <flag> [<true1> [<false1> [<true2> [<false2>]]]]
623     # @DESCRIPTION:
624     # Output the concatenation of <true1> (or 'yes' if unspecified)
625     # and <true2> if USE <flag> is enabled and executables are being built
626 mgorny 1.40 # (multilib_is_native_abi is true). Otherwise, output the concatenation
627 mgorny 1.35 # of <false1> (or 'no' if unspecified) and <false2>. Arguments
628     # are the same as for usex in the EAPI.
629     #
630     # Note: in EAPI 4 you need to inherit eutils to use this function.
631     multilib_native_usex() {
632 mgorny 1.40 if multilib_is_native_abi; then
633 mgorny 1.35 usex "${@}"
634     else
635     echo "${3-no}${5}"
636     fi
637     }
638    
639 mgorny 1.1 _MULTILIB_BUILD=1
640     fi

  ViewVC Help
Powered by ViewVC 1.1.20