scripts/build/companion_libs/130-cloog.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 3218 3709e61ad85b
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 CLooG library
     2 # Copyright 2009 Yann E. MORIN
     3 # Licensed under the GPL v2. See COPYING in the root of this package
     4 
     5 do_cloog_get() { :; }
     6 do_cloog_extract() { :; }
     7 do_cloog_for_build() { :; }
     8 do_cloog_for_host() { :; }
     9 
    10 # Overide functions depending on configuration
    11 if [ "${CT_CLOOG}" = "y" ]; then
    12 
    13 # Download CLooG
    14 do_cloog_get() {
    15     CT_GetFile "cloog-ppl-${CT_CLOOG_VERSION}"  \
    16         ftp://gcc.gnu.org/pub/gcc/infrastructure
    17 }
    18 
    19 # Extract CLooG
    20 do_cloog_extract() {
    21     local _t
    22 
    23     # Version 0.15.3 has a dirname 'cloog-ppl' (with no version in it!)
    24     # while versions 0.15.4 onward do have the version in the dirname.
    25     # But, because the infrastructure properly creates the extracted
    26     # directories (with tar's --strip-components), we can live safely...
    27     CT_Extract "cloog-ppl-${CT_CLOOG_VERSION}"
    28     CT_Patch "cloog-ppl" "${CT_CLOOG_VERSION}"
    29 
    30     # Help the autostuff in case it thinks there are things to regenerate...
    31     CT_DoExecLog DEBUG mkdir -p "${CT_SRC_DIR}/cloog-ppl-${CT_CLOOG_VERSION}/m4"
    32 
    33     if [ "${CT_CLOOG_NEEDS_AUTORECONF}" = "y" ]; then
    34         CT_Pushd "${CT_SRC_DIR}/cloog-ppl-${CT_CLOOG_VERSION}"
    35         CT_DoExecLog CFG ./autogen.sh
    36         CT_Popd
    37     fi
    38 }
    39 
    40 # Build CLooG/PPL for running on build
    41 # - always build statically
    42 # - we do not have build-specific CFLAGS
    43 # - install in build-tools prefix
    44 do_cloog_for_build() {
    45     local -a cloog_opts
    46 
    47     case "${CT_TOOLCHAIN_TYPE}" in
    48         native|cross)   return 0;;
    49     esac
    50 
    51     CT_DoStep INFO "Installing CLooG/PPL for build"
    52     CT_mkdir_pushd "${CT_BUILD_DIR}/build-cloog-ppl-build-${CT_BUILD}"
    53 
    54     cloog_opts+=( "host=${CT_BUILD}" )
    55     cloog_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
    56     cloog_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
    57     cloog_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
    58     do_cloog_backend "${cloog_opts[@]}"
    59 
    60     CT_Popd
    61     CT_EndStep
    62 }
    63 
    64 # Build CLooG/PPL for running on host
    65 do_cloog_for_host() {
    66     local -a cloog_opts
    67 
    68     CT_DoStep INFO "Installing CLooG/PPL for host"
    69     CT_mkdir_pushd "${CT_BUILD_DIR}/build-cloog-ppl-host-${CT_HOST}"
    70 
    71     cloog_opts+=( "host=${CT_HOST}" )
    72     cloog_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
    73     cloog_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
    74     cloog_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
    75     do_cloog_backend "${cloog_opts[@]}"
    76 
    77     CT_Popd
    78     CT_EndStep
    79 }
    80 
    81 # Build ClooG/PPL
    82 #     Parameter     : description               : type      : default
    83 #     host          : machine to run on         : tuple     : (none)
    84 #     prefix        : prefix to install into    : dir       : (none)
    85 #     cflags        : cflags to use             : string    : (empty)
    86 #     ldflags       : ldflags to use            : string    : (empty)
    87 do_cloog_backend() {
    88     local host
    89     local prefix
    90     local cflags
    91     local ldflags
    92     local cloog_src_dir="${CT_SRC_DIR}/cloog-ppl-${CT_CLOOG_VERSION}"
    93     local arg
    94 
    95     for arg in "$@"; do
    96         eval "${arg// /\\ }"
    97     done
    98 
    99     CT_DoLog EXTRA "Configuring CLooG/ppl"
   100 
   101     CT_DoExecLog CFG                            \
   102     CFLAGS="${cflags}"                          \
   103     LDFLAGS="${ldflags}"                        \
   104     LIBS="-lm"                                  \
   105     "${cloog_src_dir}/configure"                \
   106         --build=${CT_BUILD}                     \
   107         --host=${host}                          \
   108         --prefix="${prefix}"                    \
   109         --with-gmp="${prefix}"                  \
   110         --with-ppl="${prefix}"                  \
   111         --with-bits=gmp                         \
   112         --with-host-libstdcxx='-lstdc++'        \
   113         --disable-shared                        \
   114         --enable-static
   115 
   116     CT_DoLog EXTRA "Building CLooG/ppl"
   117     CT_DoExecLog ALL make ${JOBSFLAGS} libcloog.la
   118 
   119     if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then
   120         CT_DoLog EXTRA "Checking CLooG/ppl"
   121         CT_DoExecLog ALL make ${JOBSFLAGS} -s check
   122     fi
   123 
   124     CT_DoLog EXTRA "Installing CLooG/ppl"
   125     CT_DoExecLog ALL make install-libLTLIBRARIES install-pkgincludeHEADERS
   126 }
   127 
   128 fi # CT_CLOOG