1.1 --- a/scripts/crosstool.sh Sun May 20 13:48:26 2007 +0000
1.2 +++ b/scripts/crosstool.sh Tue May 22 20:46:07 2007 +0000
1.3 @@ -28,10 +28,10 @@
1.4 CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
1.5
1.6 # Log policy:
1.7 -# - what goes to the log file goes to fd #1 (stdout)
1.8 -# - what goes to the screen goes to fd #6
1.9 +# - first of all, save stdout so we can see the live logs: fd #6
1.10 +exec 6>&1
1.11 +# - then point stdout to the log file (temporary for now)
1.12 tmp_log_file="${CT_TOP_DIR}/$$.log"
1.13 -exec 6>&1
1.14 exec >>"${tmp_log_file}"
1.15
1.16 # Are we configured? We'll need that later...
1.17 @@ -54,6 +54,13 @@
1.18 # Some sanity checks in the environment and needed tools
1.19 CT_DoLog INFO "Checking environment sanity"
1.20
1.21 +# First of really first of really all, **must not** move lower than here!
1.22 +if [ -n "${CT_RESTART}" -a -z "${CT_DEBUG_CT_SAVE_STEPS}" ]; then
1.23 + CT_DoLog ERROR "You asked to restart a non-restartable build"
1.24 + CT_DoLog ERROR "This happened because you didn't set CT_DEBUG_CT_SAVE_STEPS in the config options"
1.25 + CT_Abort "I will stop here to avoid any carnage"
1.26 +fi
1.27 +
1.28 # Enable known ordering of files in directory listings:
1.29 CT_Test "Crosstool-NG might not work as expected with LANG=\"${LANG}\"" -n "${LANG}"
1.30 case "${LC_COLLATE},${LC_ALL}" in
1.31 @@ -108,6 +115,11 @@
1.32 CT_SRC_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/src"
1.33 CT_BUILD_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/build"
1.34 CT_DEBUG_INSTALL_DIR="${CT_INSTALL_DIR}/${CT_TARGET}/debug-root"
1.35 +# Note: we'll always install the core compiler in its own directory, so as to
1.36 +# not mix the two builds: core and final. Anyway, its generic, wether we use
1.37 +# a different compiler as core, or not.
1.38 +CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
1.39 +CT_STATE_DIR="${CT_TOP_DIR}/targets/${CT_TARGET}/state"
1.40
1.41 # Make all path absolute, it so much easier!
1.42 CT_LOCAL_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_LOCAL_TARBALLS_DIR}\"`"
1.43 @@ -140,47 +152,62 @@
1.44
1.45 CT_DoLog EXTRA "Preparing working directories"
1.46
1.47 -# Get rid of pre-existing installed toolchain and previous build directories.
1.48 -# We need to do that _before_ we can safely log, because the log file will
1.49 -# most probably be in the toolchain directory.
1.50 -if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
1.51 - mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
1.52 - chmod -R u+w "${CT_TARBALLS_DIR}.$$"
1.53 - nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
1.54 -fi
1.55 -if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
1.56 - mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
1.57 - chmod -R u+w "${CT_SRC_DIR}.$$"
1.58 - nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
1.59 -fi
1.60 +# Ah! The build directory shall be eradicated, even if we restart!
1.61 if [ -d "${CT_BUILD_DIR}" ]; then
1.62 mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
1.63 chmod -R u+w "${CT_BUILD_DIR}.$$"
1.64 nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
1.65 fi
1.66 -if [ -d "${CT_INSTALL_DIR}" ]; then
1.67 - mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
1.68 - chmod -R u+w "${CT_INSTALL_DIR}.$$"
1.69 - nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
1.70 -fi
1.71 -if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
1.72 - mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
1.73 - chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
1.74 - nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
1.75 +
1.76 +# Don't eradicate directories if we need to restart
1.77 +if [ -z "${CT_RESTART}" ]; then
1.78 + # Get rid of pre-existing installed toolchain and previous build directories.
1.79 + # We need to do that _before_ we can safely log, because the log file will
1.80 + # most probably be in the toolchain directory.
1.81 + if [ "${CT_FORCE_DOWNLOAD}" = "y" -a -d "${CT_TARBALLS_DIR}" ]; then
1.82 + mv "${CT_TARBALLS_DIR}" "${CT_TARBALLS_DIR}.$$"
1.83 + chmod -R u+w "${CT_TARBALLS_DIR}.$$"
1.84 + nohup rm -rf "${CT_TARBALLS_DIR}.$$" >/dev/null 2>&1 &
1.85 + fi
1.86 + if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
1.87 + mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
1.88 + chmod -R u+w "${CT_SRC_DIR}.$$"
1.89 + nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
1.90 + fi
1.91 + if [ -d "${CT_INSTALL_DIR}" ]; then
1.92 + mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
1.93 + chmod -R u+w "${CT_INSTALL_DIR}.$$"
1.94 + nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
1.95 + fi
1.96 + if [ -d "${CT_DEBUG_INSTALL_DIR}" ]; then
1.97 + mv "${CT_DEBUG_INSTALL_DIR}" "${CT_DEBUG_INSTALL_DIR}.$$"
1.98 + chmod -R u+w "${CT_DEBUG_INSTALL_DIR}.$$"
1.99 + nohup rm -rf "${CT_DEBUG_INSTALL_DIR}.$$" >/dev/null 2>&1 &
1.100 + fi
1.101 + # In case we start anew, get rid of the previously saved state directory
1.102 + if [ -d "${CT_STATE_DIR}" ]; then
1.103 + mv "${CT_STATE_DIR}" "${CT_STATE_DIR}.$$"
1.104 + chmod -R u+w "${CT_STATE_DIR}.$$"
1.105 + nohup rm -rf "${CT_STATE_DIR}.$$" >/dev/null 2>&1 &
1.106 + fi
1.107 fi
1.108
1.109 -# Note: we'll always install the core compiler in its own directory, so as to
1.110 -# not mix the two builds: core and final. Anyway, its generic, wether we use
1.111 -# a different compiler as core, or not.
1.112 -CT_CC_CORE_PREFIX_DIR="${CT_BUILD_DIR}/${CT_CC}-core"
1.113 -
1.114 -# Create the directories we'll use
1.115 +# Create the directories we'll use, even if restarting: it does no harm to
1.116 +# create already existent directories, and CT_BUILD_DIR needs to be created
1.117 +# anyway
1.118 mkdir -p "${CT_TARBALLS_DIR}"
1.119 mkdir -p "${CT_SRC_DIR}"
1.120 mkdir -p "${CT_BUILD_DIR}"
1.121 mkdir -p "${CT_INSTALL_DIR}"
1.122 +mkdir -p "${CT_PREFIX_DIR}"
1.123 mkdir -p "${CT_DEBUG_INSTALL_DIR}"
1.124 mkdir -p "${CT_CC_CORE_PREFIX_DIR}"
1.125 +mkdir -p "${CT_STATE_DIR}"
1.126 +
1.127 +# Kludge: CT_INSTALL_DIR and CT_PREFIX_DIR might have grown read-only if
1.128 +# the previous build was successfull. To ba able to move the logfile there,
1.129 +# switch them back to read/write
1.130 +chmod -R u+w "${CT_INSTALL_DIR}" "${CT_PREFIX_DIR}"
1.131
1.132 # Redirect log to the actual log file now we can
1.133 # It's quite understandable that the log file will be installed in the install
1.134 @@ -191,127 +218,134 @@
1.135 ,*) rm -f "${tmp_log_file}"
1.136 ;;
1.137 y,/*) mkdir -p "`dirname \"${CT_LOG_FILE}\"`"
1.138 - mv "${tmp_log_file}" "${CT_LOG_FILE}"
1.139 + cat "${tmp_log_file}" >>"${CT_LOG_FILE}"
1.140 + rm -f "${tmp_log_file}"
1.141 exec >>"${CT_LOG_FILE}"
1.142 ;;
1.143 y,*) mkdir -p "`pwd`/`dirname \"${CT_LOG_FILE}\"`"
1.144 - mv "${tmp_log_file}" "`pwd`/${CT_LOG_FILE}"
1.145 + cat "${tmp_log_file}" >>"`pwd`/${CT_LOG_FILE}"
1.146 + rm -f "${tmp_log_file}"
1.147 exec >>"${CT_LOG_FILE}"
1.148 ;;
1.149 esac
1.150
1.151 -# Determine build system if not set by the user
1.152 -CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
1.153 -CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
1.154 +# Setting up the rest of the environment only is not restarting
1.155 +if [ -z "${CT_RESTART}" ]; then
1.156 + # Determine build system if not set by the user
1.157 + CT_Test "You did not specify the build system. That's OK, I can guess..." -z "${CT_BUILD}"
1.158 + CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
1.159
1.160 -# Arrange paths depending on wether we use sys-root or not.
1.161 -if [ "${CT_USE_SYSROOT}" = "y" ]; then
1.162 - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
1.163 - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
1.164 - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.165 - CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.166 - CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.167 - LIBC_SYSROOT_ARG=""
1.168 - # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
1.169 - # confused when $sysroot/usr/include is not present.
1.170 - # Note: --prefix=/usr is magic!
1.171 - # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
1.172 -else
1.173 - # plain old way. All libraries in prefix/target/lib
1.174 - CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
1.175 - CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
1.176 - # hack! Always use --with-sysroot for binutils.
1.177 - # binutils 2.14 and later obey it, older binutils ignore it.
1.178 - # Lets you build a working 32->64 bit cross gcc
1.179 - BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.180 - # Use --with-headers, else final gcc will define disable_glibc while
1.181 - # building libgcc, and you'll have no profiling
1.182 - CC_CORE_SYSROOT_ARG="--without-headers"
1.183 - CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
1.184 - LIBC_SYSROOT_ARG="prefix="
1.185 + # Arrange paths depending on wether we use sys-root or not.
1.186 + if [ "${CT_USE_SYSROOT}" = "y" ]; then
1.187 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
1.188 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
1.189 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.190 + CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.191 + CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.192 + LIBC_SYSROOT_ARG=""
1.193 + # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
1.194 + # confused when $sysroot/usr/include is not present.
1.195 + # Note: --prefix=/usr is magic!
1.196 + # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
1.197 + else
1.198 + # plain old way. All libraries in prefix/target/lib
1.199 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
1.200 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
1.201 + # hack! Always use --with-sysroot for binutils.
1.202 + # binutils 2.14 and later obey it, older binutils ignore it.
1.203 + # Lets you build a working 32->64 bit cross gcc
1.204 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.205 + # Use --with-headers, else final gcc will define disable_glibc while
1.206 + # building libgcc, and you'll have no profiling
1.207 + CC_CORE_SYSROOT_ARG="--without-headers"
1.208 + CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
1.209 + LIBC_SYSROOT_ARG="prefix="
1.210 + fi
1.211 +
1.212 + # Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
1.213 + # 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
1.214 + # "ld: cannot open crti.o: No such file or directory"
1.215 + mkdir -p "${CT_SYSROOT_DIR}/lib"
1.216 + mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
1.217 +
1.218 + # Canadian-cross are really picky on the way they are built. Tweak the values.
1.219 + if [ "${CT_CANADIAN}" = "y" ]; then
1.220 + # Arrange so that gcc never, ever think that build system == host system
1.221 + CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
1.222 + # We shall have a compiler for this target!
1.223 + # Do test here...
1.224 + else
1.225 + CT_HOST="${CT_BUILD}"
1.226 + CT_CANADIAN_OPT=
1.227 + # Add the target toolchain in the path so that we can build the C library
1.228 + export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
1.229 + fi
1.230 +
1.231 + # Modify GCC_HOST to never be equal to $BUILD or $TARGET
1.232 + # This strange operation causes gcc to always generate a cross-compiler
1.233 + # even if the build machine is the same kind as the host.
1.234 + # This is why CC has to be set when doing a canadian cross; you can't find a
1.235 + # host compiler by appending -gcc to our whacky $GCC_HOST
1.236 + # Kludge: it is reported that the above causes canadian crosses with cygwin
1.237 + # hosts to fail, so avoid it just in that one case. It would be cleaner to
1.238 + # just move this into the non-canadian case above, but I'm afraid that might
1.239 + # cause some configure script somewhere to decide that since build==host, they
1.240 + # could run host binaries.
1.241 + # (Copied almost as-is from original crosstool):
1.242 + case "${CT_KERNEL},${CT_CANADIAN}" in
1.243 + cygwin,y) ;;
1.244 + *) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
1.245 + esac
1.246 +
1.247 + # Ah! Recent versions of binutils need some of the build and/or host system
1.248 + # (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
1.249 + # Do that:
1.250 + CT_DoLog EXTRA "Making build system tools available"
1.251 + mkdir -p "${CT_PREFIX_DIR}/bin"
1.252 + for tool in ar as dlltool gcc g++ gnatbind gnatmake ld nm ranlib strip windres objcopy objdump; do
1.253 + if [ -n "`which ${tool}`" ]; then
1.254 + ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
1.255 + case "${CT_TOOLCHAIN_TYPE}" in
1.256 + cross|native) ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
1.257 + esac
1.258 + fi
1.259 + done
1.260 +
1.261 + # Ha. cygwin host have an .exe suffix (extension) for executables.
1.262 + [ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
1.263 +
1.264 + # Transform the ARCH into a kernel-understandable ARCH
1.265 + case "${CT_ARCH}" in
1.266 + x86) CT_KERNEL_ARCH=i386;;
1.267 + ppc) CT_KERNEL_ARCH=powerpc;;
1.268 + *) CT_KERNEL_ARCH="${CT_ARCH}";;
1.269 + esac
1.270 +
1.271 + # Build up the TARGET_CFLAGS from user-provided options
1.272 + # Override with user-specified CFLAGS
1.273 + [ -n "${CT_ARCH_CPU}" ] && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
1.274 + [ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
1.275 + [ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
1.276 + [ -n "${CT_ARCH_FPU}" ] && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
1.277 +
1.278 + # Help gcc
1.279 + CT_CFLAGS_FOR_HOST=
1.280 + [ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
1.281 +
1.282 + # And help make go faster
1.283 + PARALLELMFLAGS=
1.284 + [ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
1.285 + [ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
1.286 +
1.287 + CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
1.288 + CT_DoLog EXTRA "Building a toolchain for:"
1.289 + CT_DoLog EXTRA " build = ${CT_BUILD}"
1.290 + CT_DoLog EXTRA " host = ${CT_HOST}"
1.291 + CT_DoLog EXTRA " target = ${CT_TARGET}"
1.292 + set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
1.293 + CT_EndStep
1.294 fi
1.295
1.296 -# Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
1.297 -# 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
1.298 -# "ld: cannot open crti.o: No such file or directory"
1.299 -mkdir -p "${CT_SYSROOT_DIR}/lib"
1.300 -mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
1.301 -
1.302 -# Canadian-cross are really picky on the way they are built. Tweak the values.
1.303 -if [ "${CT_CANADIAN}" = "y" ]; then
1.304 - # Arrange so that gcc never, ever think that build system == host system
1.305 - CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
1.306 - # We shall have a compiler for this target!
1.307 - # Do test here...
1.308 -else
1.309 - CT_HOST="${CT_BUILD}"
1.310 - CT_CANADIAN_OPT=
1.311 - # Add the target toolchain in the path so that we can build the C library
1.312 - export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
1.313 -fi
1.314 -
1.315 -# Modify GCC_HOST to never be equal to $BUILD or $TARGET
1.316 -# This strange operation causes gcc to always generate a cross-compiler
1.317 -# even if the build machine is the same kind as the host.
1.318 -# This is why CC has to be set when doing a canadian cross; you can't find a
1.319 -# host compiler by appending -gcc to our whacky $GCC_HOST
1.320 -# Kludge: it is reported that the above causes canadian crosses with cygwin
1.321 -# hosts to fail, so avoid it just in that one case. It would be cleaner to
1.322 -# just move this into the non-canadian case above, but I'm afraid that might
1.323 -# cause some configure script somewhere to decide that since build==host, they
1.324 -# could run host binaries.
1.325 -# (Copied almost as-is from original crosstool):
1.326 -case "${CT_KERNEL},${CT_CANADIAN}" in
1.327 - cygwin,y) ;;
1.328 - *) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
1.329 -esac
1.330 -
1.331 -# Ah! Recent versions of binutils need some of the build and/or host system
1.332 -# (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
1.333 -# Do that:
1.334 -CT_DoLog EXTRA "Making build system tools available"
1.335 -mkdir -p "${CT_PREFIX_DIR}/bin"
1.336 -for tool in ar gcc; do
1.337 - ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
1.338 - case "${CT_TOOLCHAIN_TYPE}" in
1.339 - cross|native) ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}";;
1.340 - esac
1.341 -done
1.342 -
1.343 -# Ha. cygwin host have an .exe suffix (extension) for executables.
1.344 -[ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
1.345 -
1.346 -# Transform the ARCH into a kernel-understandable ARCH
1.347 -case "${CT_ARCH}" in
1.348 - x86) CT_KERNEL_ARCH=i386;;
1.349 - ppc) CT_KERNEL_ARCH=powerpc;;
1.350 - *) CT_KERNEL_ARCH="${CT_ARCH}";;
1.351 -esac
1.352 -
1.353 -# Build up the TARGET_CFLAGS from user-provided options
1.354 -# Override with user-specified CFLAGS
1.355 -[ -n "${CT_ARCH_CPU}" ] && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
1.356 -[ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
1.357 -[ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
1.358 -[ -n "${CT_ARCH_FPU}" ] && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
1.359 -
1.360 -# Help gcc
1.361 -CT_CFLAGS_FOR_HOST=
1.362 -[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
1.363 -
1.364 -# And help make go faster
1.365 -PARALLELMFLAGS=
1.366 -[ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
1.367 -[ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
1.368 -
1.369 -CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
1.370 -CT_DoLog EXTRA "Building a toolchain for:"
1.371 -CT_DoLog EXTRA " build = ${CT_BUILD}"
1.372 -CT_DoLog EXTRA " host = ${CT_HOST}"
1.373 -CT_DoLog EXTRA " target = ${CT_TARGET}"
1.374 -set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
1.375 -CT_EndStep
1.376 -
1.377 # Include sub-scripts instead of calling them: that way, we do not have to
1.378 # export any variable, nor re-parse the configuration and functions files.
1.379 . "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
1.380 @@ -322,64 +356,84 @@
1.381 . "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
1.382 . "${CT_TOP_DIR}/scripts/build/debug.sh"
1.383
1.384 -# Now for the job by itself. Go have a coffee!
1.385 -CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
1.386 -do_kernel_get
1.387 -do_binutils_get
1.388 -do_cc_core_get
1.389 -do_libfloat_get
1.390 -do_libc_get
1.391 -do_cc_get
1.392 -do_debug_get
1.393 -CT_EndStep
1.394 -
1.395 -if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
1.396 - if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
1.397 - mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
1.398 - nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1
1.399 - fi
1.400 - CT_DoStep INFO "Extracting and patching toolchain components"
1.401 - do_kernel_extract
1.402 - do_binutils_extract
1.403 - do_cc_core_extract
1.404 - do_libfloat_extract
1.405 - do_libc_extract
1.406 - do_cc_extract
1.407 - do_debug_extract
1.408 +if [ -z "${CT_RESTART}" ]; then
1.409 + CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
1.410 + do_kernel_get
1.411 + do_binutils_get
1.412 + do_cc_core_get
1.413 + do_libfloat_get
1.414 + do_libc_get
1.415 + do_cc_get
1.416 + do_debug_get
1.417 CT_EndStep
1.418
1.419 - if [ "${CT_ONLY_EXTRACT}" != "y" ]; then
1.420 - do_libc_check_config
1.421 - do_kernel_check_config
1.422 - do_kernel_headers
1.423 - do_binutils
1.424 - do_libc_headers
1.425 - do_cc_core
1.426 - do_libfloat
1.427 - do_libc
1.428 - do_cc
1.429 - do_libc_finish
1.430 - do_debug
1.431 + if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
1.432 + if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
1.433 + mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
1.434 + nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1
1.435 + fi
1.436 + CT_DoStep INFO "Extracting and patching toolchain components"
1.437 + do_kernel_extract
1.438 + do_binutils_extract
1.439 + do_cc_core_extract
1.440 + do_libfloat_extract
1.441 + do_libc_extract
1.442 + do_cc_extract
1.443 + do_debug_extract
1.444 + CT_EndStep
1.445 + fi
1.446 +fi
1.447
1.448 - # Create the aliases to the target tools
1.449 - if [ -n "${CT_TARGET_ALIAS}" ]; then
1.450 - CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
1.451 - CT_Pushd "${CT_PREFIX_DIR}/bin"
1.452 - for t in "${CT_TARGET}-"*; do
1.453 - _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
1.454 - CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
1.455 - ln -s "${t}" "${_t}"
1.456 - done
1.457 - CT_Popd
1.458 +# Now for the job by itself. Go have a coffee!
1.459 +if [ "${CT_ONLY_DOWNLOAD}" != "y" -a "${CT_ONLY_EXTRACT}" != "y" ]; then
1.460 + # Because of CT_RESTART, this becomes quite complex
1.461 + [ -n "${CT_RESTART}" ] && do_it=0 || do_it=1
1.462 + for step in libc_check_config \
1.463 + kernel_check_config \
1.464 + kernel_headers \
1.465 + binutils \
1.466 + libc_headers \
1.467 + cc_core \
1.468 + libfloat \
1.469 + libc \
1.470 + cc \
1.471 + libc_finish \
1.472 + debug \
1.473 + ; do
1.474 + if [ ${do_it} -eq 0 ]; then
1.475 + if [ "${CT_RESTART}" = "${step}" ]; then
1.476 + CT_DoLoadState "${step}"
1.477 + do_it=1
1.478 + fi
1.479 + else
1.480 + CT_DoSaveState ${step}
1.481 fi
1.482 + if [ ${do_it} -eq 1 ]; then
1.483 + do_${step}
1.484 + if [ "${CTDEBUG_CT_PAUSE_STEPS}" = "y" ]; then
1.485 + CT_DoPause "Step \"${step}\" finished"
1.486 + fi
1.487 + fi
1.488 + done
1.489
1.490 - # Remove the generated documentation files
1.491 - if [ "${CT_REMOVE_DOCS}" = "y" ]; then
1.492 - CT_DoLog INFO "Removing installed documentation"
1.493 - rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info}
1.494 - rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
1.495 - rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
1.496 - fi
1.497 + # Create the aliases to the target tools
1.498 + if [ -n "${CT_TARGET_ALIAS}" ]; then
1.499 + CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
1.500 + CT_Pushd "${CT_PREFIX_DIR}/bin"
1.501 + for t in "${CT_TARGET}-"*; do
1.502 + _t="`echo \"$t\" |sed -r -e 's/^'\"${CT_TARGET}\"'-/'\"${CT_TARGET_ALIAS}\"'-/;'`"
1.503 + CT_DoLog DEBUG "Linking \"${_t}\" -> \"${t}\""
1.504 + ln -s "${t}" "${_t}"
1.505 + done
1.506 + CT_Popd
1.507 + fi
1.508 +
1.509 + # Remove the generated documentation files
1.510 + if [ "${CT_REMOVE_DOCS}" = "y" ]; then
1.511 + CT_DoLog INFO "Removing installed documentation"
1.512 + rm -rf "${CT_PREFIX_DIR}/"{,usr/}{man,info}
1.513 + rm -rf "${CT_SYSROOT_DIR}/"{,usr/}{man,info}
1.514 + rm -rf "${CT_DEBUG_INSTALL_DIR}/"{,usr/}{man,info}
1.515 fi
1.516 fi
1.517