1.1 --- a/scripts/crosstool.sh Sun May 13 21:12:56 2007 +0000
1.2 +++ b/scripts/crosstool.sh Thu May 17 16:22:51 2007 +0000
1.3 @@ -10,14 +10,14 @@
1.4
1.5 # What this file does is prepare the environment, based upon the user-choosen
1.6 # options. It also checks the existing environment for un-friendly variables,
1.7 -# and checks for needed tools. It eventually calls the main build script.
1.8 +# and builds the tools.
1.9
1.10 -# User must set CT_TOP_DIR in is environment!
1.11 -# Once we can build out-of-tree, then this will have to go.
1.12 +# CT_TOP_DIR is set by the makefile. If we don't have it, something's gone horribly wrong...
1.13 if [ -z "${CT_TOP_DIR}" -o ! -d "${CT_TOP_DIR}" ]; then
1.14 # We don't have the functions right now, because we don't have CT_TOP_DIR.
1.15 # Do the print stuff by hand:
1.16 - echo "CT_TOP_DIR not set. You must set CT_TOP_DIR to the top directory where crosstool is installed."
1.17 + echo "CT_TOP_DIR not set, or not a directory. Something's gone horribly wrong."
1.18 + echo "Please send a bug report (see README)"
1.19 exit 1
1.20 fi
1.21
1.22 @@ -30,34 +30,22 @@
1.23 # Log to a temporary file until we have built our environment
1.24 CT_ACTUAL_LOG_FILE="${CT_TOP_DIR}/$$.log"
1.25
1.26 +# Are we configured? We'll need that later...
1.27 +CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
1.28 +
1.29 # Parse the configuration file
1.30 -CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
1.31 +# It has some info about the logging facility, so include it early
1.32 . "${CT_TOP_DIR}/.config"
1.33
1.34 -# Override the color scheme if needed
1.35 -if [ "${CT_LOG_USE_COLORS}" = "y" ]; then
1.36 - CT_ERROR_COLOR="${_A_NOR}${_A_BRI}${_F_RED}"
1.37 - CT_WARN_COLOR="${_A_NOR}${_A_BRI}${_F_YEL}"
1.38 - CT_INFO_COLOR="${_A_NOR}${_A_BRI}${_F_GRN}"
1.39 - CT_EXTRA_COLOR="${_A_NOR}${_A_DIM}${_F_GRN}"
1.40 - CT_DEBUG_COLOR="${_A_NOR}${_A_BRI}${_F_BLU}"
1.41 - CT_ALL_COLOR="${_A_NOR}${_A_DIM}${_F_WHI}"
1.42 - CT_NORMAL_COLOR="${_A_NOR}"
1.43 -else
1.44 - CT_ERROR_COLOR=
1.45 - CT_WARN_COLOR=
1.46 - CT_INFO_COLOR=
1.47 - CT_EXTRA_COLOR=
1.48 - CT_DEBUG_COLOR=
1.49 - CT_ALL_COLOR=
1.50 - CT_NORMAL_COLOR=
1.51 -fi
1.52 +# renice oursleves
1.53 +renice ${CT_NICE} $$ |CT_DoLog DEBUG
1.54
1.55 # Yes! We can do full logging from now on!
1.56 CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
1.57
1.58 -# renice oursleves
1.59 -renice ${CT_NICE} $$ |CT_DoLog DEBUG
1.60 +CT_DoStep DEBUG "Dumping crosstool-NG configuration"
1.61 +cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG
1.62 +CT_EndStep
1.63
1.64 # Some sanity checks in the environment and needed tools
1.65 CT_DoLog INFO "Checking environment sanity"
1.66 @@ -89,15 +77,15 @@
1.67 CT_HasOrAbort bison
1.68 CT_HasOrAbort flex
1.69
1.70 -CT_DoStep DEBUG "Dumping crosstool-NG configuration"
1.71 -cat ${CT_TOP_DIR}/.config |egrep '^(# |)CT_' |CT_DoLog DEBUG
1.72 -CT_EndStep
1.73 -
1.74 CT_DoLog INFO "Building environment variables"
1.75
1.76 # Target triplet: CT_TARGET needs a little love:
1.77 CT_DoBuildTargetTriplet
1.78
1.79 +# Kludge: If any of the configured options needs CT_TARGET,
1.80 +# then rescan the options file now:
1.81 +. "${CT_TOP_DIR}/.config"
1.82 +
1.83 # Now, build up the variables from the user-configured options.
1.84 CT_KERNEL_FILE="${CT_KERNEL}-${CT_KERNEL_VERSION}"
1.85 CT_BINUTILS_FILE="binutils-${CT_BINUTILS_VERSION}"
1.86 @@ -111,14 +99,11 @@
1.87 CT_LIBC_FILE="${CT_LIBC}-${CT_LIBC_VERSION}"
1.88 [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] && CT_LIBFLOAT_FILE="libfloat-990616"
1.89
1.90 -# Kludge: If any of the configured options needs CT_TARGET,
1.91 -# then rescan the options file now:
1.92 -. "${CT_TOP_DIR}/.config"
1.93 -
1.94 # Where will we work?
1.95 CT_TARBALLS_DIR="${CT_TOP_DIR}/targets/tarballs"
1.96 CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
1.97 CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
1.98 +CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
1.99
1.100 # Make all path absolute, it so much easier!
1.101 CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
1.102 @@ -133,25 +118,52 @@
1.103 CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
1.104 fi
1.105
1.106 +# Good, now grab a bit of informations on the system we're being run on,
1.107 +# just in case something goes awok, and it's not our fault:
1.108 +CT_SYS_USER="`id -un`"
1.109 +CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
1.110 +# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
1.111 +CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-`uname -n`}"
1.112 +CT_SYS_KERNEL=`uname -s`
1.113 +CT_SYS_REVISION=`uname -r`
1.114 +# MacOS X lacks '-o' :
1.115 +CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"`
1.116 +CT_SYS_MACHINE=`uname -m`
1.117 +CT_SYS_PROCESSOR=`uname -p`
1.118 +CT_SYS_GCC=`gcc -dumpversion`
1.119 +CT_SYS_TARGET=`${CT_TOP_DIR}/tools/config.guess`
1.120 +CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_STAR_DATE_HUMAN} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
1.121 +
1.122 +CT_DoLog EXTRA "Preparing working directories"
1.123 +
1.124 # Get rid of pre-existing installed toolchain and previous build directories.
1.125 # We need to do that _before_ we can safely log, because the log file will
1.126 # most probably be in the toolchain directory.
1.127 if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
1.128 mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
1.129 + chmod -R u+w "${CT_TARBALLS_DIR}.$$"
1.130 nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
1.131 fi
1.132 if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
1.133 mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
1.134 + chmod -R u+w "${CT_SRC_DIR}.$$"
1.135 nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
1.136 fi
1.137 if [ -d "${CT_BUILD_DIR}" ]; then
1.138 mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
1.139 + chmod -R u+w "${CT_BUILD_DIR}.$$"
1.140 nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
1.141 fi
1.142 if [ -d "${CT_INSTALL_DIR}" ]; then
1.143 mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
1.144 + chmod -R u+w "${CT_INSTALL_DIR}.$$"
1.145 nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
1.146 fi
1.147 +if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
1.148 + mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
1.149 + chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
1.150 + nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
1.151 +fi
1.152
1.153 # Note: we'll always install the core compiler in its own directory, so as to
1.154 # not mix the two builds: core and final. Anyway, its generic, wether we use
1.155 @@ -163,24 +175,9 @@
1.156 mkdir -p "${CT_SRC_DIR}"
1.157 mkdir -p "${CT_BUILD_DIR}"
1.158 mkdir -p "${CT_INSTALL_DIR}"
1.159 +mkdir -p "${CT_DEBUG_INSTALL_DIR}"
1.160 mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
1.161
1.162 -# Good, now grab a bit of informations on the system we're being run,
1.163 -# just in case something goes awok, and it's not our fault:
1.164 -CT_SYS_HOSTNAME=`hostname -f 2>/dev/null || true`
1.165 -# Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name.
1.166 -CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-`uname -n`}"
1.167 -CT_SYS_KERNEL=`uname -s`
1.168 -CT_SYS_REVISION=`uname -r`
1.169 -# MacOS X lacks '-o' :
1.170 -CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"`
1.171 -CT_SYS_MACHINE=`uname -m`
1.172 -CT_SYS_PROCESSOR=`uname -p`
1.173 -CT_SYS_USER="`id -un`"
1.174 -CT_SYS_DATE=`CT_DoDate +%Y%m%d.%H%M%S`
1.175 -CT_SYS_GCC=`gcc -dumpversion`
1.176 -CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_SYS_DATE} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME}"
1.177 -
1.178 # Redirect log to the actual log file now we can
1.179 # It's quite understandable that the log file will be installed in the install
1.180 # directory, so we must first ensure it exists and is writeable (above) before
1.181 @@ -270,9 +267,11 @@
1.182 # Do that:
1.183 CT_DoLog EXTRA "Making build system tools available"
1.184 mkdir -p "${CT_PREFIX_DIR}/bin"
1.185 -for tool in ar; do
1.186 +for tool in ar gcc; do
1.187 ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
1.188 - ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
1.189 + case "${CT_TOOLCHAIN_TYPE}" in
1.190 + cross|native) ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
1.191 + esac
1.192 done
1.193
1.194 # Ha. cygwin host have an .exe suffix (extension) for executables.
1.195 @@ -317,6 +316,7 @@
1.196 . "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh"
1.197 . "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh"
1.198 . "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
1.199 +. "${CT_TOP_DIR}/scripts/build/debug.sh"
1.200
1.201 # Now for the job by itself. Go have a coffee!
1.202 CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
1.203 @@ -326,6 +326,7 @@
1.204 do_libfloat_get
1.205 do_libc_get
1.206 do_cc_get
1.207 +do_debug_get
1.208 CT_EndStep
1.209
1.210 if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
1.211 @@ -336,10 +337,11 @@
1.212 CT_DoStep INFO "Extracting and patching toolchain components"
1.213 do_kernel_extract
1.214 do_binutils_extract
1.215 + do_cc_core_extract
1.216 + do_libfloat_extract
1.217 do_libc_extract
1.218 - do_libfloat_extract
1.219 - do_cc_core_extract
1.220 do_cc_extract
1.221 + do_debug_extract
1.222 CT_EndStep
1.223
1.224 if [ "${CT_ONLY_EXTRACT}" != "y" ]; then
1.225 @@ -353,6 +355,7 @@
1.226 do_libc
1.227 do_cc
1.228 do_libc_finish
1.229 + do_debug
1.230
1.231 # Create the aliases to the target tools
1.232 if [ -n "${CT_TARGET_ALIAS}" ]; then
1.233 @@ -370,18 +373,22 @@
1.234 if [ "${CT_REMOVE_DOCS}" = "y" ]; then
1.235 CT_DoLog INFO "Removing installed documentation"
1.236 rm -rf "${CT_PREFIX_DIR}/"{man,info}
1.237 + rm -rf "${CT_DEBUG_INSTALL_DIR}/usr/"{man,info}
1.238 fi
1.239 fi
1.240 fi
1.241
1.242 -CT_STOP_DATE=`CT_DoDate +%s%N`
1.243 -CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
1.244 -CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"
1.245 -elapsed=$((CT_STOP_DATE-CT_STAR_DATE))
1.246 -elapsed_min=$((elapsed/(60*1000*1000*1000)))
1.247 -elapsed_sec=`printf "%02d" $(((elapsed%(60*1000*1000*1000))/(1000*1000*1000)))`
1.248 -elapsed_csec=`printf "%02d" $(((elapsed%(1000*1000*1000))/(10*1000*1000)))`
1.249 -CT_DoLog INFO "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
1.250 +# OK, now we're done, set the toolchain read-only
1.251 +# Don't log, the log file may become read-only any moment...
1.252 +chmod -R a-w "${CT_INSTALL_DIR}"
1.253 +
1.254 +# We stil have some small bits to log
1.255 +chmod u+w "${CT_LOG_FILE}"
1.256 +
1.257 +CT_DoEnd INFO
1.258 +
1.259 +# All files should now be read-only, log-file included
1.260 +chmod a-w "${CT_LOG_FILE}"
1.261
1.262 # Restore a 'normal' color setting
1.263 echo -en "${CT_NORMAL_COLOR}"