scripts/build/companion_libs/100-gmp.sh
author Cody Schafer <dev@codyps.com>
Fri May 09 19:13:49 2014 -0700 (2014-05-09)
changeset 3312 4876ff97e039
parent 3115 1c68438f44f7
permissions -rw-r--r--
cc/gcc: allow CC_EXTRA_CONFIG_ARRAY on baremetal

The final bare-metal compiler is built using the core backend.
Currently the core uses the CC_CORE_EXTRA_CONFIG_ARRAY variable.

While this works as supposed to, this can leave the user puzzled
in the menuconfig, since all he can see is the core options, not
the final options.

Only show the core options if any of the core passes are needed,
and use the final options in the core-backend if we're issuing
the bare-metal compiler.

Signed-off-by: Cody P Schafer <dev@codyps.com>
[yann.morin.1998@free.fr: hide core options if no core pass needed;
use final option in core backend if issuing the bare-metal compiler]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <22181e546ba746202489.1399688067@localhost>
Patchwork-Id: 347586
     1 # This file adds the functions to build the GMP library
     2 # Copyright 2008 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 do_gmp_get() { :; }
     6 do_gmp_extract() { :; }
     7 do_gmp_for_build() { :; }
     8 do_gmp_for_host() { :; }
     9 
    10 # Overide functions depending on configuration
    11 if [ "${CT_GMP}" = "y" ]; then
    12 
    13 # Download GMP
    14 do_gmp_get() {
    15     CT_GetFile "gmp-${CT_GMP_VERSION}" {ftp,http}://{ftp.sunet.se/pub,ftp.gnu.org}/gnu/gmp
    16 }
    17 
    18 # Extract GMP
    19 do_gmp_extract() {
    20     CT_Extract "gmp-${CT_GMP_VERSION}"
    21     CT_Patch "gmp" "${CT_GMP_VERSION}"
    22 }
    23 
    24 # Build GMP for running on build
    25 # - always build statically
    26 # - we do not have build-specific CFLAGS
    27 # - install in build-tools prefix
    28 do_gmp_for_build() {
    29     local -a gmp_opts
    30 
    31     case "${CT_TOOLCHAIN_TYPE}" in
    32         native|cross)   return 0;;
    33     esac
    34 
    35     CT_DoStep INFO "Installing GMP for build"
    36     CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-build-${CT_BUILD}"
    37 
    38     gmp_opts+=( "host=${CT_BUILD}" )
    39     gmp_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    40     gmp_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
    41     gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
    42     do_gmp_backend "${gmp_opts[@]}"
    43 
    44     CT_Popd
    45     CT_EndStep
    46 }
    47 
    48 # Build GMP for running on host
    49 do_gmp_for_host() {
    50     local -a gmp_opts
    51 
    52     CT_DoStep INFO "Installing GMP for host"
    53     CT_mkdir_pushd "${CT_BUILD_DIR}/build-gmp-host-${CT_HOST}"
    54 
    55     gmp_opts+=( "host=${CT_HOST}" )
    56     gmp_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    57     gmp_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    58     gmp_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    59     do_gmp_backend "${gmp_opts[@]}"
    60 
    61     CT_Popd
    62     CT_EndStep
    63 }
    64 
    65 # Build GMP
    66 #     Parameter     : description               : type      : default
    67 #     host          : machine to run on         : tuple     : (none)
    68 #     prefix        : prefix to install into    : dir       : (none)
    69 #     cflags        : cflags to use             : string    : (empty)
    70 #     ldflags       : ldflags to use            : string    : (empty)
    71 do_gmp_backend() {
    72     local host
    73     local prefix
    74     local cflags
    75     local ldflags
    76     local arg
    77 
    78     for arg in "$@"; do
    79         eval "${arg// /\\ }"
    80     done
    81 
    82     CT_DoLog EXTRA "Configuring GMP"
    83 
    84     CT_DoExecLog CFG                                \
    85     CFLAGS="${cflags} -fexceptions"                 \
    86     LDFLAGS="${ldflags}"                            \
    87     "${CT_SRC_DIR}/gmp-${CT_GMP_VERSION}/configure" \
    88         --build=${CT_BUILD}                         \
    89         --host=${host}                              \
    90         --prefix="${prefix}"                        \
    91         --enable-fft                                \
    92         --enable-mpbsd                              \
    93         --enable-cxx                                \
    94         --disable-shared                            \
    95         --enable-static
    96 
    97     CT_DoLog EXTRA "Building GMP"
    98     CT_DoExecLog ALL make ${JOBSFLAGS}
    99 
   100     if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
   101         CT_DoLog EXTRA "Checking GMP"
   102         CT_DoExecLog ALL make ${JOBSFLAGS} -s check
   103     fi
   104 
   105     CT_DoLog EXTRA "Installing GMP"
   106     CT_DoExecLog ALL make install
   107 }
   108 
   109 fi # CT_GMP