scripts/build/companion_libs/100-gmp.sh
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Sun May 11 23:43:52 2014 +0200 (2014-05-11)
changeset 3320 78af1c99bc6d
parent 3115 1c68438f44f7
permissions -rw-r--r--
scripts/functions: add target_endian_le and target_endian_be

We currently define target_endian_el and target_endian_eb to be the
tuple extension depending on endianness, defined to be respectively
'el' or 'eb' according to the endianness.

Some architecture do not use 'el' or 'eb', but use 'le' or 'be'.

Provide that as well, as two new variables: target_endian_le and
target_endian_be.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Cody P Schafer <dev@codyps.com>
     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