scripts/build/companion_libs/120-ppl.sh
author Daniel Price <daniel.price@gmail.com>
Tue Nov 20 16:59:17 2012 -0800 (2012-11-20)
changeset 3126 333d3e40cbd1
parent 3115 1c68438f44f7
child 3135 3829050af02a
permissions -rw-r--r--
scripts: refine static linking check to better guide the user

The current mechanism to check if static linking is possible, and the mesage
displayed on failure, can be puzzling to the unsuspecting user.

Also, the current implementation is not using the existing infrastructure,
and is thus difficult to enhance with new tests.

So, switch to using the standard CT_DoExecLog infra, and use four tests to
check for the host compiler:
- check we can run it
- check it can build a trivial program
- check it can statically link that program
- check if it statically link with libstdc++

That should cover most of the problems. Hopefully.

(At the same time, fix a typo in a comment)

Signed-off-by: Daniel Price <daniel.price@gmail.com>
[yann.morin.1998@free.fr: split original patch for self-contained changes]
[yann.morin.1998@free.fr: use steps to better see gcc's output]
[yann.morin.1998@free.fr: commit log]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <163f86b5216fc08c672a.1353459722@nipigon.dssd.com>
Patchwork-Id: 200536
     1 # This file adds the functions to build the PPL library
     2 # Copyright 2009 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 do_ppl_get() { :; }
     6 do_ppl_extract() { :; }
     7 do_ppl_for_build() { :; }
     8 do_ppl_for_host() { :; }
     9 
    10 # Overide functions depending on configuration
    11 if [ "${CT_PPL}" = "y" ]; then
    12 
    13 # Download PPL
    14 do_ppl_get() {
    15     CT_GetFile "ppl-${CT_PPL_VERSION}"                                      \
    16         http://www.cs.unipr.it/ppl/Download/ftp/releases/${CT_PPL_VERSION}  \
    17         ftp://ftp.cs.unipr.it/pub/ppl/releases/${CT_PPL_VERSION}            \
    18         ftp://gcc.gnu.org/pub/gcc/infrastructure
    19 }
    20 
    21 # Extract PPL
    22 do_ppl_extract() {
    23     CT_Extract "ppl-${CT_PPL_VERSION}"
    24     CT_Patch "ppl" "${CT_PPL_VERSION}"
    25 }
    26 
    27 # Build PPL for running on build
    28 # - always build statically
    29 # - we do not have build-specific CFLAGS
    30 # - install in build-tools prefix
    31 do_ppl_for_build() {
    32     local -a ppl_opts
    33 
    34     case "${CT_TOOLCHAIN_TYPE}" in
    35         native|cross)   return 0;;
    36     esac
    37 
    38     CT_DoStep INFO "Installing PPL for build"
    39     CT_mkdir_pushd "${CT_BUILD_DIR}/build-ppl-build-${CT_BUILD}"
    40 
    41     ppl_opts+=( "host=${CT_BUILD}" )
    42     ppl_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    43     ppl_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
    44     ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
    45     do_ppl_backend "${ppl_opts[@]}"
    46 
    47     CT_Popd
    48     CT_EndStep
    49 }
    50 
    51 # Build PPL for running on host
    52 do_ppl_for_host() {
    53     local -a ppl_opts
    54 
    55     CT_DoStep INFO "Installing PPL for host"
    56     CT_mkdir_pushd "${CT_BUILD_DIR}/build-ppl-host-${CT_HOST}"
    57 
    58     ppl_opts+=( "host=${CT_HOST}" )
    59     ppl_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    60     ppl_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    61     ppl_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    62     do_ppl_backend "${ppl_opts[@]}"
    63 
    64     CT_Popd
    65     CT_EndStep
    66 }
    67 
    68 # Build PPL
    69 #     Parameter     : description               : type      : default
    70 #     host          : machine to run on         : tuple     : (none)
    71 #     prefix        : prefix to install into    : dir       : (none)
    72 #     cflags        : cflags to use             : string    : (empty)
    73 #     ldflags       : ldflags to use            : string    : (empty)
    74 do_ppl_backend() {
    75     local host
    76     local prefix
    77     local cflags
    78     local ldflags
    79     local arg
    80 
    81     for arg in "$@"; do
    82         eval "${arg// /\\ }"
    83     done
    84 
    85     CT_DoLog EXTRA "Configuring PPL"
    86 
    87     CT_DoExecLog CFG                                \
    88     CFLAGS="${cflags}"                              \
    89     CXXFLAGS="${cflags}"                            \
    90     LDFLAGS="${ldflags}"                            \
    91     "${CT_SRC_DIR}/ppl-${CT_PPL_VERSION}/configure" \
    92         --build=${CT_BUILD}                         \
    93         --host=${host}                              \
    94         --prefix="${prefix}"                        \
    95         --with-libgmp-prefix="${prefix}"            \
    96         --with-libgmpxx-prefix="${prefix}"          \
    97         --with-gmp-prefix="${prefix}"               \
    98         --enable-watchdog                           \
    99         --disable-debugging                         \
   100         --disable-assertions                        \
   101         --disable-ppl_lcdd                          \
   102         --disable-ppl_lpsol                         \
   103         --disable-shared                            \
   104         --enable-interfaces='c c++'                 \
   105         --enable-static
   106 
   107     # Maybe-options:
   108     # --enable-optimization=speed  or sspeed (yes, with 2 's')
   109 
   110     CT_DoLog EXTRA "Building PPL"
   111     CT_DoExecLog ALL make ${JOBSFLAGS}
   112 
   113     if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
   114         CT_DoLog EXTRA "Checking PPL"
   115         CT_DoExecLog ALL make ${JOBSFLAGS} -s check
   116     fi
   117 
   118     CT_DoLog EXTRA "Installing PPL"
   119     CT_DoExecLog ALL make install
   120 
   121     # Remove spuriously installed file
   122     CT_DoExecLog ALL rm -f "${prefix}/bin/ppl-config"
   123 }
   124 
   125 fi # CT_PPL