scripts/crosstool.sh
changeset 85 ac2845835b13
parent 83 286b5a6938ac
child 88 f67b52e42fd1
     1.1 --- a/scripts/crosstool.sh	Wed May 09 18:55:35 2007 +0000
     1.2 +++ b/scripts/crosstool.sh	Thu May 10 21:33:35 2007 +0000
     1.3 @@ -118,16 +118,56 @@
     1.4  # then rescan the options file now:
     1.5  . "${CT_TOP_DIR}/.config"
     1.6  
     1.7 +# Where will we work?
     1.8 +CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
     1.9 +CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
    1.10 +CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
    1.11 +
    1.12 +# Make all path absolute, it so much easier!
    1.13 +CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
    1.14 +
    1.15  # Some more sanity checks now that we have all paths set up
    1.16  case "${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
    1.17      *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
    1.18  esac
    1.19  
    1.20 +# Check now if we can write to the destination directory:
    1.21 +if [ -d "${CT_INSTALL_DIR}" ]; then
    1.22 +    CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
    1.23 +fi
    1.24 +
    1.25 +# Get rid of pre-existing installed toolchain and previous build directories.
    1.26 +# We need to do that _before_ we can safely log, because the log file will
    1.27 +# most probably be in the toolchain directory.
    1.28 +if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
    1.29 +    mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
    1.30 +    nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
    1.31 +fi
    1.32 +if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
    1.33 +    mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
    1.34 +    nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
    1.35 +fi
    1.36 +if [ -d "${CT_BUILD_DIR}" ]; then
    1.37 +    mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
    1.38 +    nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
    1.39 +fi
    1.40 +if [ -d "${CT_INSTALL_DIR}" ]; then
    1.41 +    mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
    1.42 +    nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
    1.43 +fi
    1.44 +
    1.45  # Note: we'll always install the core compiler in its own directory, so as to
    1.46  # not mix the two builds: core and final. Anyway, its generic, wether we use
    1.47  # a different compiler as core, or not.
    1.48  CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
    1.49  
    1.50 +# Create the directories we'll use
    1.51 +mkdir -p "${CT_TARBALLS_DIR}"
    1.52 +mkdir -p "${CT_SRC_DIR}"
    1.53 +mkdir -p "${CT_BUILD_DIR}"
    1.54 +mkdir -p "${CT_INSTALL_DIR}"
    1.55 +mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
    1.56 +
    1.57  # Good, now grab a bit of informations on the system we're being run,
    1.58  # just in case something goes awok, and it's not our fault:
    1.59  CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
    1.60 @@ -144,36 +184,6 @@
    1.61  CT_SYS_GCC=`gcc -dumpversion`
    1.62  CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_SYS_DATE} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME} for ${CT_TARGET}"
    1.63  
    1.64 -# Check now if we can write to the destination directory:
    1.65 -if [ -d "${CT_INSTALL_DIR}" ]; then
    1.66 -    CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
    1.67 -fi
    1.68 -
    1.69 -# Get rid of pre-existing installed toolchain and previous build directories.
    1.70 -# We need to do that _before_ we can safely log, because the log file will
    1.71 -# most probably be in the toolchain directory.
    1.72 -if [ -d "${CT_INSTALL_DIR}" ]; then
    1.73 -    mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
    1.74 -    nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
    1.75 -fi
    1.76 -if [ -d "${CT_BUILD_DIR}" ]; then
    1.77 -    mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
    1.78 -    nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
    1.79 -fi
    1.80 -if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
    1.81 -    mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
    1.82 -    nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
    1.83 -fi
    1.84 -mkdir -p "${CT_INSTALL_DIR}"
    1.85 -mkdir -p "${CT_BUILD_DIR}"
    1.86 -mkdir -p "${CT_TARBALLS_DIR}"
    1.87 -mkdir -p "${CT_SRC_DIR}"
    1.88 -
    1.89 -# Make all path absolute, it so much easier!
    1.90 -# Now we have had the directories created, we even will get rid of embedded .. in paths:
    1.91 -CT_SRC_DIR="`CT_MakeAbsolutePath \"${CT_SRC_DIR}\"`"
    1.92 -CT_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_TARBALLS_DIR}\"`"
    1.93 -
    1.94  # Redirect log to the actual log file now we can
    1.95  # It's quite understandable that the log file will be installed in the install
    1.96  # directory, so we must first ensure it exists and is writeable (above) before
    1.97 @@ -312,16 +322,14 @@
    1.98  . "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
    1.99  
   1.100  # Now for the job by itself. Go have a coffee!
   1.101 -if [ "${CT_NO_DOWNLOAD}" != "y" ]; then
   1.102 -	CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
   1.103 -    do_kernel_get
   1.104 -    do_binutils_get
   1.105 -    do_cc_core_get
   1.106 -    do_libfloat_get
   1.107 -    do_libc_get
   1.108 -    do_cc_get
   1.109 -    CT_EndStep
   1.110 -fi
   1.111 +CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
   1.112 +do_kernel_get
   1.113 +do_binutils_get
   1.114 +do_cc_core_get
   1.115 +do_libfloat_get
   1.116 +do_libc_get
   1.117 +do_cc_get
   1.118 +CT_EndStep
   1.119  
   1.120  if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
   1.121      if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
   1.122 @@ -348,25 +356,27 @@
   1.123          do_libc
   1.124          do_cc
   1.125          do_libc_finish
   1.126 +
   1.127 +        # Create the aliases to the target tools
   1.128 +        if [ -n "${CT_TARGET_ALIAS}" ]; then
   1.129 +            CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
   1.130 +            CT_Pushd "${CT_PREFIX_DIR}/bin"
   1.131 +            for t in "${CT_TARGET}-"*; do
   1.132 +                _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
   1.133 +                CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
   1.134 +                ln -s "${t}" "${_t}"
   1.135 +            done
   1.136 +            CT_Popd
   1.137 +        fi
   1.138 +
   1.139 +        # Remove the generated documentation files
   1.140 +        if [ "${CT_REMOVE_DOCS}" = "y" ]; then
   1.141 +        	CT_DoLog INFO "Removing installed documentation"
   1.142 +            rm -rf "${CT_PREFIX_DIR}/"{man,info}
   1.143 +        fi
   1.144      fi
   1.145  fi
   1.146  
   1.147 -if [ -n "${CT_TARGET_ALIAS}" ]; then
   1.148 -    CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
   1.149 -    CT_Pushd "${CT_PREFIX_DIR}/bin"
   1.150 -    for t in "${CT_TARGET}-"*; do
   1.151 -        _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
   1.152 -        CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
   1.153 -        ln -s "${t}" "${_t}"
   1.154 -    done
   1.155 -    CT_Popd
   1.156 -fi
   1.157 -
   1.158 -if [ "${CT_REMOVE_DOCS}" = "y" ]; then
   1.159 -	CT_DoLog INFO "Removing installed documentation"
   1.160 -    rm -rf "${CT_PREFIX_DIR}/"{man,info}
   1.161 -fi
   1.162 -
   1.163  CT_STOP_DATE=`CT_DoDate +%s%N`
   1.164  CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
   1.165  CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"