scripts/build/companion_libs/140-mpc.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 MPC library
     2 # Copyright 2009 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 do_mpc_get() { :; }
     6 do_mpc_extract() { :; }
     7 do_mpc_for_build() { :; }
     8 do_mpc_for_host() { :; }
     9 
    10 # Overide functions depending on configuration
    11 if [ "${CT_MPC}" = "y" ]; then
    12 
    13 # Download MPC
    14 do_mpc_get() {
    15     CT_GetFile "mpc-${CT_MPC_VERSION}" .tar.gz      \
    16         http://www.multiprecision.org/mpc/download
    17 }
    18 
    19 # Extract MPC
    20 do_mpc_extract() {
    21     CT_Extract "mpc-${CT_MPC_VERSION}"
    22     CT_Patch "mpc" "${CT_MPC_VERSION}"
    23 }
    24 
    25 # Build MPC for running on build
    26 # - always build statically
    27 # - we do not have build-specific CFLAGS
    28 # - install in build-tools prefix
    29 do_mpc_for_build() {
    30     local -a mpc_opts
    31 
    32     case "${CT_TOOLCHAIN_TYPE}" in
    33         native|cross)   return 0;;
    34     esac
    35 
    36     CT_DoStep INFO "Installing MPC for build"
    37     CT_mkdir_pushd "${CT_BUILD_DIR}/build-mpc-build-${CT_BUILD}"
    38 
    39     mpc_opts+=( "host=${CT_BUILD}" )
    40     mpc_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    41     mpc_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
    42     mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
    43     do_mpc_backend "${mpc_opts[@]}"
    44 
    45     CT_Popd
    46     CT_EndStep
    47 }
    48 
    49 # Build MPC for running on host
    50 do_mpc_for_host() {
    51     local -a mpc_opts
    52 
    53     CT_DoStep INFO "Installing MPC for host"
    54     CT_mkdir_pushd "${CT_BUILD_DIR}/build-mpc-host-${CT_HOST}"
    55 
    56     mpc_opts+=( "host=${CT_HOST}" )
    57     mpc_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    58     mpc_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    59     mpc_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    60     do_mpc_backend "${mpc_opts[@]}"
    61 
    62     CT_Popd
    63     CT_EndStep
    64 }
    65 
    66 # Build MPC
    67 #     Parameter     : description               : type      : default
    68 #     host          : machine to run on         : tuple     : (none)
    69 #     prefix        : prefix to install into    : dir       : (none)
    70 #     cflags        : cflags to use             : string    : (empty)
    71 #     ldflags       : ldflags to use            : string    : (empty)
    72 do_mpc_backend() {
    73     local host
    74     local prefix
    75     local cflags
    76     local ldflags
    77     local arg
    78 
    79     for arg in "$@"; do
    80         eval "${arg// /\\ }"
    81     done
    82 
    83     CT_DoLog EXTRA "Configuring MPC"
    84 
    85     CT_DoExecLog CFG                                \
    86     CFLAGS="${cflags}"                              \
    87     LDFLAGS="${ldflags}"                            \
    88     "${CT_SRC_DIR}/mpc-${CT_MPC_VERSION}/configure" \
    89         --build=${CT_BUILD}                         \
    90         --host=${host}                              \
    91         --prefix="${prefix}"                        \
    92         --with-gmp="${prefix}"                      \
    93         --with-mpfr="${prefix}"                     \
    94         --disable-shared                            \
    95         --enable-static
    96 
    97     CT_DoLog EXTRA "Building MPC"
    98     CT_DoExecLog ALL make ${JOBSFLAGS}
    99 
   100     if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
   101         CT_DoLog EXTRA "Checking MPC"
   102         CT_DoExecLog ALL make ${JOBSFLAGS} -s check
   103     fi
   104 
   105     CT_DoLog EXTRA "Installing MPC"
   106     CT_DoExecLog ALL make install
   107 }
   108 
   109 fi # CT_MPC