scripts/build/debug/400-ltrace.sh
author Daniel Price <daniel.price@gmail.com>
Tue Nov 20 16:59:17 2012 -0800 (2012-11-20)
changeset 3126 333d3e40cbd1
parent 2345 7ac35671d133
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 # Build script for ltrace
     2 
     3 do_debug_ltrace_get() {
     4     CT_GetFile "ltrace_${CT_LTRACE_VERSION}.orig" .tar.gz               \
     5                {ftp,http}://ftp.de.debian.org/debian/pool/main/l/ltrace/
     6     # Create a link so that the following steps are easier to do:
     7     CT_Pushd "${CT_TARBALLS_DIR}"
     8     ltrace_ext=$(CT_GetFileExtension "ltrace_${CT_LTRACE_VERSION}.orig")
     9     ln -sf "ltrace_${CT_LTRACE_VERSION}.orig${ltrace_ext}"              \
    10            "ltrace-${CT_LTRACE_VERSION}${ltrace_ext}"
    11     CT_Popd
    12 }
    13 
    14 do_debug_ltrace_extract() {
    15     CT_Extract "ltrace-${CT_LTRACE_VERSION}"
    16     CT_Patch "ltrace" "${CT_LTRACE_VERSION}"
    17 }
    18 
    19 do_debug_ltrace_build() {
    20     local ltrace_host
    21 
    22     CT_DoStep INFO "Installing ltrace"
    23 
    24     CT_DoLog EXTRA "Copying sources to build dir"
    25     CT_DoExecLog ALL cp -av "${CT_SRC_DIR}/ltrace-${CT_LTRACE_VERSION}" \
    26                             "${CT_BUILD_DIR}/build-ltrace"
    27     CT_Pushd "${CT_BUILD_DIR}/build-ltrace"
    28 
    29     CT_DoLog EXTRA "Configuring ltrace"
    30     # ltrace-0.5.3, and later, don't use GNU Autotools configure script anymore
    31     if [ "${CT_LTRACE_0_5_3_or_later}" = "y" ]; then
    32         case "${CT_ARCH}:${CT_ARCH_BITNESS}" in
    33             x86:32)     ltrace_host="i386";;
    34             x86:64)     ltrace_host="x86_64";;
    35             powerpc:*)  ltrace_host="ppc";;
    36             mips:*)     ltrace_host="mipsel";;
    37             *)          ltrace_host="${CT_ARCH}";;
    38         esac
    39         CT_DoExecLog CFG                \
    40         CC="${CT_TARGET}-${CT_CC}"      \
    41         AR="${CT_TARGET}-ar"            \
    42         HOST="${ltrace_host}"           \
    43         HOST_OS="${CT_TARGET_KERNEL}"   \
    44         CFLAGS="${CT_TARGET_CFLAGS}"    \
    45         ./configure --prefix=/usr
    46     else
    47         CT_DoExecLog CFG        \
    48         ./configure             \
    49             --build=${CT_BUILD} \
    50             --host=${CT_TARGET} \
    51             --prefix=/usr
    52     fi
    53 
    54     CT_DoLog EXTRA "Building ltrace"
    55     CT_DoExecLog ALL make
    56 
    57     CT_DoLog EXTRA "Installing ltrace"
    58     CT_DoExecLog ALL make DESTDIR="${CT_DEBUGROOT_DIR}" install
    59 
    60     CT_Popd
    61     CT_EndStep
    62 }
    63