1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scripts/buildToolchain.sh Tue Apr 10 15:04:33 2007 +0000
1.3 @@ -0,0 +1,123 @@
1.4 +# This scripts calls each component's build script.
1.5 +# Copyright 2007 Yann E. MORIN
1.6 +# Licensed under the GPL v2. See COPYING in the root of this package
1.7 +
1.8 +# Parse all build files to have the needed functions.
1.9 +. "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
1.10 +. "${CT_TOP_DIR}/scripts/build/binutils.sh"
1.11 +. "${CT_TOP_DIR}/scripts/build/libc_libfloat.sh"
1.12 +. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh"
1.13 +. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh"
1.14 +. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
1.15 +
1.16 +# Arrange paths depending on wether we use sys-root or not.
1.17 +if [ "${CT_USE_SYSROOT}" = "y" ]; then
1.18 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
1.19 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
1.20 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.21 + CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.22 + CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.23 + LIBC_SYSROOT_ARG=""
1.24 + # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
1.25 + # confused when $sysroot/usr/include is not present.
1.26 + # Note: --prefix=/usr is magic!
1.27 + # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
1.28 +else
1.29 + # plain old way. All libraries in prefix/target/lib
1.30 + CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
1.31 + CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
1.32 + # hack! Always use --with-sysroot for binutils.
1.33 + # binutils 2.14 and later obey it, older binutils ignore it.
1.34 + # Lets you build a working 32->64 bit cross gcc
1.35 + BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
1.36 + # Use --with-headers, else final gcc will define disable_glibc while
1.37 + # building libgcc, and you'll have no profiling
1.38 + CC_CORE_SYSROOT_ARG="--without-headers"
1.39 + CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
1.40 + LIBC_SYSROOT_ARG="prefix="
1.41 +fi
1.42 +
1.43 +# Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
1.44 +# 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
1.45 +# "ld: cannot open crti.o: No such file or directory"
1.46 +mkdir -p "${CT_SYSROOT_DIR}/lib"
1.47 +mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
1.48 +
1.49 +# Canadian-cross are really picky on the way they are built. Tweak the values.
1.50 +if [ "${CT_CANADIAN}" = "y" ]; then
1.51 + # Arrange so that gcc never, ever think that build system == host system
1.52 + CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
1.53 + # We shall have a compiler for this target!
1.54 + # Do test here...
1.55 +else
1.56 + CT_HOST="${CT_BUILD}"
1.57 + CT_CANADIAN_OPT=
1.58 + # Add the target toolchain in the path so that we can build the C library
1.59 + export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
1.60 +fi
1.61 +
1.62 +# Modify GCC_HOST to never be equal to $BUILD or $TARGET
1.63 +# This strange operation causes gcc to always generate a cross-compiler
1.64 +# even if the build machine is the same kind as the host.
1.65 +# This is why CC has to be set when doing a canadian cross; you can't find a
1.66 +# host compiler by appending -gcc to our whacky $GCC_HOST
1.67 +# Kludge: it is reported that the above causes canadian crosses with cygwin
1.68 +# hosts to fail, so avoid it just in that one case. It would be cleaner to
1.69 +# just move this into the non-canadian case above, but I'm afraid that might
1.70 +# cause some configure script somewhere to decide that since build==host, they
1.71 +# could run host binaries.
1.72 +# (Copied almost as-is from original crosstool):
1.73 +case "${CT_KERNEL},${CT_CANADIAN}" in
1.74 + cygwin,y) ;;
1.75 + *) CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
1.76 +esac
1.77 +
1.78 +# Ha. cygwin host have an .exe suffix (extension) for executables.
1.79 +[ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
1.80 +
1.81 +# Transform the ARCH into a kernel-understandable ARCH
1.82 +case "${CT_ARCH}" in
1.83 + x86) CT_KERNEL_ARCH=i386;;
1.84 + ppc) CT_KERNL_ARCH=powerpc;;
1.85 + *) CT_KERNEL_ARCH="${CT_ARCH}";;
1.86 +esac
1.87 +
1.88 +# Build up the TARGET_CFLAGS from user-provided options
1.89 +tmp_target_CFLAGS=
1.90 +[ -n "${CT_ARCH_CPU}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mcpu=${CT_ARCH_CPU}"
1.91 +[ -n "${CT_ARCH_TUNE}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mtune=${CT_ARCH_TUNE}"
1.92 +[ -n "${CT_ARCH_ARCH}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -march=${CT_ARCH_ARCH}"
1.93 +[ -n "${CT_ARCH_FPU}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mfpu=${CT_ARCH_FPU}"
1.94 +# Override with user-specified CFLAGS
1.95 +CT_TARGET_CFLAGS="${tmp_target_CFLAGS} ${CT_TARGET_CFLAGS}"
1.96 +
1.97 +# Help gcc
1.98 +CT_CFLAGS_FOR_HOST=
1.99 +[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
1.100 +
1.101 +# And help make go faster
1.102 +PARALLELMFLAGS=
1.103 +[ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
1.104 +[ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
1.105 +
1.106 +CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
1.107 +CT_DoLog EXTRA "Building a toolchain for :"
1.108 +CT_DoLog EXTRA " build = ${CT_BUILD}"
1.109 +CT_DoLog EXTRA " host = ${CT_HOST}"
1.110 +CT_DoLog EXTRA " target = ${CT_TARGET}"
1.111 +set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
1.112 +CT_EndStep
1.113 +
1.114 +# Now for the job by itself.
1.115 +# Check the C library config ASAP, before the user gets bored, and is
1.116 +# gone having his/her coffee
1.117 +do_libc_check_config
1.118 +do_kernel_check_config
1.119 +do_kernel_headers
1.120 +do_binutils
1.121 +do_libc_headers
1.122 +do_cc_core
1.123 +do_libfloat
1.124 +do_libc
1.125 +do_cc
1.126 +do_libc_finish