Fix building D.U.M.A:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue Jun 17 22:26:44 2008 +0000 (2008-06-17)
changeset 5714f4bfcf02c4f
parent 570 301eb285ae7d
child 572 944e145f3890
Fix building D.U.M.A:
- some (presumably 'old') versions have libduma.so.0.0, while others (presumably 'newer') have libduma.so.0.0.0
- don't build the libraries multiple times, do it in one pass
- install a custom LD_PRELOAD wrapper

/trunk/scripts/build/debug/200-duma.sh | 54 33 21 0 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 33 insertions(+), 21 deletions(-)
scripts/build/debug/200-duma.sh
     1.1 --- a/scripts/build/debug/200-duma.sh	Tue Jun 17 21:37:27 2008 +0000
     1.2 +++ b/scripts/build/debug/200-duma.sh	Tue Jun 17 22:26:44 2008 +0000
     1.3 @@ -1,4 +1,4 @@
     1.4 -# Biuld script for D.U.M.A.
     1.5 +# Build script for D.U.M.A.
     1.6  
     1.7  is_enabled="${CT_DUMA}"
     1.8  
     1.9 @@ -34,31 +34,43 @@
    1.10      DUMA_CPP=
    1.11      [ "${CT_CC_LANG_CXX}" = "y" ] && DUMA_CPP=1
    1.12  
    1.13 +    # The shared library needs some love: some version have libduma.so.0.0,
    1.14 +    # while others have libduma.so.0.0.0
    1.15 +    duma_so=$(make -n -p 2>&1 |egrep '^libduma.so[^:]*:' |head -n 1 |cut -d : -f 1)
    1.16 +
    1.17      libs=
    1.18      [ "${CT_DUMA_A}" = "y" ] && libs="${libs} libduma.a"
    1.19 -    [ "${CT_DUMA_SO}" = "y" ] && libs="${libs} libduma.so.0.0"
    1.20 -    for lib in ${libs}; do
    1.21 -        CT_DoLog EXTRA "Building library '${lib}'"
    1.22 -        make HOSTCC="${CT_CC_NATIVE}"       \
    1.23 -             HOSTCXX="${CT_CC_NATIVE}"      \
    1.24 -             CC="${CT_TARGET}-${CT_CC}"     \
    1.25 -             CXX="${CT_TARGET}-${CT_CC}"    \
    1.26 -             DUMA_CPP="${DUMA_CPP}"         \
    1.27 -             ${libs}                        2>&1 |CT_DoLog ALL
    1.28 -        CT_DoLog EXTRA "Installing library '${lib}'"
    1.29 -        install -m 644 "${lib}" "${CT_SYSROOT_DIR}/usr/lib" 2>&1 |CT_DoLog ALL
    1.30 -    done
    1.31 +    [ "${CT_DUMA_SO}" = "y" ] && libs="${libs} ${duma_so}"
    1.32 +    libs="${libs# }"
    1.33 +    CT_DoLog EXTRA "Building libraries '${libs}'"
    1.34 +    make HOSTCC="${CT_CC_NATIVE}"       \
    1.35 +         HOSTCXX="${CT_CC_NATIVE}"      \
    1.36 +         CC="${CT_TARGET}-gcc"          \
    1.37 +         CXX="${CT_TARGET}-g++"         \
    1.38 +         RANLIB="${CT_TARGET}-ranlib"   \
    1.39 +         DUMA_CPP="${DUMA_CPP}"         \
    1.40 +         ${libs}                        2>&1 |CT_DoLog ALL
    1.41 +    CT_DoLog EXTRA "Installing libraries '${libs}'"
    1.42 +    install -m 644 ${libs} "${CT_SYSROOT_DIR}/usr/lib" 2>&1 |CT_DoLog ALL
    1.43      if [ "${CT_DUMA_SO}" = "y" ]; then
    1.44 -        CT_DoLog EXTRA "Installing shared library links"
    1.45 -        ln -vsf libduma.so.0.0 "${CT_SYSROOT_DIR}/usr/lib/libduma.so.0" 2>&1 |CT_DoLog ALL
    1.46 -        ln -vsf libduma.so.0.0 "${CT_SYSROOT_DIR}/usr/lib/libduma.so"   2>&1 |CT_DoLog ALL
    1.47 +        CT_DoLog EXTRA "Installing shared library link"
    1.48 +        ln -vsf ${duma_so} "${CT_SYSROOT_DIR}/usr/lib/libduma.so"   2>&1 |CT_DoLog ALL
    1.49 +        CT_DoLog EXTRA "Installing wrapper script"
    1.50 +        mkdir -p "${CT_DEBUG_INSTALL_DIR}/usr/bin"
    1.51 +        # Install a simpler, smaller, safer wrapper than the one provided by D.U.M.A.
    1.52 +        cat >"${CT_DEBUG_INSTALL_DIR}/usr/bin/duma" <<_EOF_
    1.53 +#!/bin/sh
    1.54 +if [ \$# -eq 0 ]; then
    1.55 +  echo "Usage: \$0 <executable [args]>"
    1.56 +  exit 1
    1.57 +fi
    1.58 +export LD_PRELOAD="${duma_so}"
    1.59 +exec "\$@"
    1.60 +_EOF_
    1.61 +        chmod 755 "${CT_DEBUG_INSTALL_DIR}/usr/bin/duma"
    1.62      fi
    1.63 -    CT_DoLog EXTRA "Installing LD_PRELOAD wrapper script"
    1.64 -    mkdir -p "${CT_DEBUG_INSTALL_DIR}/usr/bin"
    1.65 -    cp -v duma.sh                               \
    1.66 -       "${CT_DEBUG_INSTALL_DIR}/usr/bin/duma"   2>&1 |CT_DoLog ALL
    1.67  
    1.68 +    CT_Popd
    1.69      CT_EndStep
    1.70 -    CT_Popd
    1.71  }
    1.72