scripts/build/internals.sh
author Oron Peled <oron@actcom.co.il>
Mon Aug 03 00:49:25 2009 +0200 (2009-08-03)
changeset 1449 8ad2773e7ae3
parent 1413 084d38788c1d
child 1493 0dce3a3986a1
permissions -rw-r--r--
[complib:mpfr] Fix building MPFR in some weird cases

The tmul test uses a compiled-in input file in $(srcdir).
The problem is that the Makefile passes it unquoted. The C code
tries to stringify it using clever macros, which may *usually* work.

In my case the source directory was named:
.../toolchain-powerpc-e500v2-linux-gnuspe-1.0-2.fc10/.../tests
And guess what? During testing I found out the program fails because
it tries to open:
.../toolchain-powerpc-e500v2-1-gnuspe-1.0-2.fc10/.../tests

Yes, CPP tokenized the macro before stringifying it and not surprisingly
the 'linux' part was converted to 1.
[on Fedora-10: cpp (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)]

So the attached patch simplify the macros and pass the path as string
from the Makefile.
     1 # This file contains crosstool-NG internal steps
     2 
     3 # This step is called once all components were built, to remove
     4 # un-wanted files, to add tuple aliases, and to add the final
     5 # crosstool-NG-provided files.
     6 do_finish() {
     7     local _t
     8 
     9     CT_DoStep INFO "Cleaning-up the toolchain's directory"
    10 
    11     CT_DoLog EXTRA "Removing access to the build system tools"
    12     CT_DoExecLog DEBUG rm -rf "${CT_PREFIX_DIR}/buildtools"
    13 
    14     if [ "${CT_BARE_METAL}" != "y" ]; then
    15         CT_DoLog EXTRA "Installing the populate helper"
    16         sed -r -e 's|@@CT_TARGET@@|'"${CT_TARGET}"'|g;' \
    17                -e 's|@@CT_install@@|'"${install}"'|g;'  \
    18                -e 's|@@CT_bash@@|'"${bash}"'|g;'        \
    19                -e 's|@@CT_grep@@|'"${grep}"'|g;'        \
    20                -e 's|@@CT_make@@|'"${make}"'|g;'        \
    21                -e 's|@@CT_sed@@|'"${sed}"'|g;'          \
    22                "${CT_LIB_DIR}/scripts/populate.in"      \
    23                >"${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    24         CT_DoExecLog ALL chmod 755 "${CT_PREFIX_DIR}/bin/${CT_TARGET}-populate"
    25     fi
    26 
    27     # Create the aliases to the target tools
    28     CT_DoLog EXTRA "Creating toolchain aliases"
    29     CT_Pushd "${CT_PREFIX_DIR}/bin"
    30     for t in "${CT_TARGET}-"*; do
    31         if [ -n "${CT_TARGET_ALIAS}" ]; then
    32             _t=$(echo "$t" |sed -r -e 's/^'"${CT_TARGET}"'-/'"${CT_TARGET_ALIAS}"'-/;')
    33             CT_DoExecLog ALL ln -sv "${t}" "${_t}"
    34         fi
    35         if [ -n "${CT_TARGET_ALIAS_SED_EXPR}" ]; then
    36             _t=$(echo "$t" |sed -r -e "${CT_TARGET_ALIAS_SED_EXPR}")
    37             CT_DoExecLog ALL ln -sv "${t}" "${_t}"
    38         fi
    39     done
    40     CT_Popd
    41 
    42     # If using the companion libraries, we need a wrapper
    43     # that will set LD_LIBRARY_PATH approriately
    44     if [    "${CT_GMP_MPFR}" = "y"      \
    45          -o "${CT_PPL_CLOOG_MPC}" = "y" ]; then
    46         CT_DoLog EXTRA "Installing toolchain wrappers"
    47         CT_Pushd "${CT_PREFIX_DIR}/bin"
    48 
    49         # Copy the wrapper
    50         CT_DoExecLog DEBUG install -m 0755 "${CT_LIB_DIR}/scripts/wrapper.in"   \
    51                                            ".${CT_TARGET}-wrapper"
    52 
    53         # Replace every tools with the wrapper
    54         # Do it unconditionally, even for those tools that happen to be shell
    55         # scripts, we don't know if they would in the end spawn a binary...
    56         # Just skip symlinks
    57         for _t in "${CT_TARGET}-"*; do
    58             if [ "$( LANG=C stat -c '%F' "${_t}" )" != "symbolic link" ]; then
    59                 CT_DoExecLog ALL mv "${_t}" ".${_t}"
    60                 CT_DoExecLog ALL ln ".${CT_TARGET}-wrapper" "${_t}"
    61             fi
    62         done
    63 
    64         # Get rid of the wrapper, we're using hardlinks
    65         CT_DoExecLog DEBUG rm -f ".${CT_TARGET}-wrapper"
    66         CT_Popd
    67     fi
    68 
    69     # Remove the generated documentation files
    70     if [ "${CT_REMOVE_DOCS}" = "y" ]; then
    71         CT_DoLog EXTRA "Removing installed documentation"
    72         CT_DoForceRmdir "${CT_PREFIX_DIR}/"{,usr/}{man,info}
    73         CT_DoForceRmdir "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
    74         CT_DoForceRmdir "${CT_DEBUGROOT_DIR}/"{,usr/}{man,info}
    75     fi
    76 
    77     CT_EndStep
    78 }