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