Merge the save-sample branch to trunk:
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon May 07 09:04:02 2007 +0000 (2007-05-07)
changeset 6389b41dbffe8d
parent 62 651912c5477c
child 64 7dab8d1a2426
Merge the save-sample branch to trunk:
- reorder most of the environment setup,
- geting, extracting and patching are now components' sub-actions,
- save the current config as a sample to be used as a pre-configured target.
Makefile
config/global.in
kconfig/Makefile
samples/Makefile
scripts/build/binutils.sh
scripts/build/cc_core_gcc.sh
scripts/build/cc_gcc.sh
scripts/build/kernel_linux.sh
scripts/build/libc_glibc.sh
scripts/build/libc_libfloat.sh
scripts/build/libc_uClibc.sh
scripts/buildToolchain.sh
scripts/crosstool.sh
scripts/functions
scripts/getExtractPatch.sh
scripts/saveSample.sh
tools/Makefile
     1.1 --- a/Makefile	Sun May 06 21:47:29 2007 +0000
     1.2 +++ b/Makefile	Mon May 07 09:04:02 2007 +0000
     1.3 @@ -13,10 +13,11 @@
     1.4  HOST_CC = gcc -funsigned-char
     1.5  
     1.6  help::
     1.7 -	@echo  'Available make targets (*: default target):'
     1.8 +	@echo  'Available make targets:'
     1.9  	@echo
    1.10  
    1.11  include $(CT_TOP_DIR)/kconfig/Makefile
    1.12 +include $(CT_TOP_DIR)/samples/Makefile
    1.13  
    1.14  help::
    1.15  	@echo  'Build targets:'
    1.16 @@ -26,6 +27,9 @@
    1.17  
    1.18  include $(CT_TOP_DIR)/tools/Makefile
    1.19  
    1.20 +help::
    1.21 +	@echo  'Execute "make" or "make all" to build all targets marked with [*]'
    1.22 +
    1.23  .config: $(shell find $(CT_TOP_DIR)/config -type f -name '*.in')
    1.24  	@make menuconfig
    1.25  	@# Because exiting menuconfig without saving is not an error to menuconfig
     2.1 --- a/config/global.in	Sun May 06 21:47:29 2007 +0000
     2.2 +++ b/config/global.in	Mon May 07 09:04:02 2007 +0000
     2.3 @@ -162,33 +162,28 @@
     2.4        Remove the installed documentation (man and info pages).
     2.5        Gains around 8MiB for a uClibc-based, C and C++ compiler.
     2.6  
     2.7 -comment "Downloading and extracting"
     2.8 +comment "Downloading"
     2.9  
    2.10 -config NO_DOWNLOAD
    2.11 +config FORCE_DOWNLOAD
    2.12      bool
    2.13 -    prompt "Avoid downloads"
    2.14 +    prompt "Force downloads"
    2.15      default n
    2.16      help
    2.17 -      Avoid downloading anything. Bail out if a tarball is missing.
    2.18 +      Force downloading tarballs, even if one already exists.
    2.19 +      
    2.20 +      Usefull if you suspect a tarball to be damaged.
    2.21  
    2.22  config ONLY_DOWNLOAD
    2.23      bool
    2.24 -    prompt "Only download tarballs"
    2.25 +    prompt "Stop after downloading tarballs"
    2.26      default n
    2.27 -    depends on ! NO_DOWNLOAD
    2.28      help
    2.29        Only download the tarballs. Exit once it done.
    2.30        
    2.31        Usefull to pre-retrieve the tarballs before going off-line.
    2.32  
    2.33 -config FORCE_DOWNLOAD
    2.34 -    bool
    2.35 -    prompt "Force downloads"
    2.36 -    default n
    2.37 -    depends on ! NO_DOWNLOAD
    2.38 -    help
    2.39 -      Force downloading tarballs, even if one already exists.
    2.40 -      Usefull if you suspect a tarball to be damaged.
    2.41 +comment "Extracting"
    2.42 +    depends on ! ONLY_DOWNLOAD
    2.43  
    2.44  config FORCE_EXTRACT
    2.45      bool
    2.46 @@ -201,6 +196,16 @@
    2.47        Usefull if you suspect a previous extract did not complete (eg. broken
    2.48        tarball), or you added a new set of patches for this component.
    2.49  
    2.50 +config ONLY_EXTRACT
    2.51 +    bool
    2.52 +    prompt "Stop after extracting tarballs"
    2.53 +    depends on ! ONLY_DOWNLOAD
    2.54 +    default n
    2.55 +    help
    2.56 +      Exit after unpacking and patching tarballs.
    2.57 +      
    2.58 +      Usefull to look at the code before doing the build itself.
    2.59 +
    2.60  comment "Logging"
    2.61  
    2.62  choice
     3.1 --- a/kconfig/Makefile	Sun May 06 21:47:29 2007 +0000
     3.2 +++ b/kconfig/Makefile	Mon May 07 09:04:02 2007 +0000
     3.3 @@ -25,24 +25,14 @@
     3.4  oldconfig: $(obj)/conf
     3.5  	@$< -s $(KCONFIG_TOP)
     3.6  
     3.7 -# Build a list of all available samples
     3.8 -SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%,%,$(filter-out %Makefile,$(wildcard $(CT_TOP_DIR)/samples/*)))
     3.9 -.PHONY: $(SAMPLES)
    3.10 -$(SAMPLES):
    3.11 -	@cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config"
    3.12 -	@$(MAKE) oldconfig
    3.13 -
    3.14  # Help text used by make help
    3.15  help::
    3.16  	@echo  'General purpose configuration targets:'
    3.17  	@echo  '  config         - Update current config using a line-oriented program'
    3.18  	@echo  '  menuconfig     - Update current config using a menu based program'
    3.19  	@echo  '  oldconfig      - Update current config using a provided .config as base'
    3.20 -	@echo
    3.21 -	@echo  'Preconfigured targets:'
    3.22 -	@for s in $(SAMPLES); do   \
    3.23 -	    echo  "  $${s}"; \
    3.24 -	 done
    3.25 +	@# saveconfig is listed here for homogeneity, but implemented in samples/Makefile
    3.26 +	@echo  '  saveconfig     - Save current config as a preconfigured target'
    3.27  	@echo  ''
    3.28  
    3.29  # Cheesy build
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/samples/Makefile	Mon May 07 09:04:02 2007 +0000
     4.3 @@ -0,0 +1,17 @@
     4.4 +# Build a list of all available samples
     4.5 +
     4.6 +SAMPLES = $(patsubst $(CT_TOP_DIR)/samples/%,%,$(filter-out %Makefile,$(wildcard $(CT_TOP_DIR)/samples/*)))
     4.7 +.PHONY: $(SAMPLES)
     4.8 +$(SAMPLES):
     4.9 +	@cp "$(CT_TOP_DIR)/samples/$(@)/crosstool.config" "$(CT_TOP_DIR)/.config"
    4.10 +	@$(MAKE) oldconfig
    4.11 +
    4.12 +help::
    4.13 +	@echo  'Preconfigured targets:'
    4.14 +	@for s in $(SAMPLES); do   \
    4.15 +	    echo  "  $${s}"; \
    4.16 +	 done
    4.17 +	@echo  ''
    4.18 +
    4.19 +saveconfig:
    4.20 +	@$(CT_TOP_DIR)/scripts/saveSample.sh
     5.1 --- a/scripts/build/binutils.sh	Sun May 06 21:47:29 2007 +0000
     5.2 +++ b/scripts/build/binutils.sh	Mon May 07 09:04:02 2007 +0000
     5.3 @@ -2,6 +2,19 @@
     5.4  # Copyright 2007 Yann E. MORIN
     5.5  # Licensed under the GPL v2. See COPYING in the root of this package
     5.6  
     5.7 +# Download binutils
     5.8 +do_binutils_get() {
     5.9 +    CT_GetFile "${CT_BINUTILS_FILE}"                            \
    5.10 +               ftp://ftp.gnu.org/gnu/binutils                   \
    5.11 +               ftp://ftp.kernel.org/pub/linux/devel/binutils
    5.12 +}
    5.13 +
    5.14 +# Extract binutils
    5.15 +do_binutils_extract() {
    5.16 +    CT_ExtractAndPatch "${CT_BINUTILS_FILE}"
    5.17 +}
    5.18 +
    5.19 +# Build binutils
    5.20  do_binutils() {
    5.21      mkdir -p "${CT_BUILD_DIR}/build-binutils"
    5.22      cd "${CT_BUILD_DIR}/build-binutils"
     6.1 --- a/scripts/build/cc_core_gcc.sh	Sun May 06 21:47:29 2007 +0000
     6.2 +++ b/scripts/build/cc_core_gcc.sh	Mon May 07 09:04:02 2007 +0000
     6.3 @@ -2,6 +2,26 @@
     6.4  # Copyright 2007 Yann E. MORIN
     6.5  # Licensed under the GPL v2. See COPYING in the root of this package
     6.6  
     6.7 +# Download core gcc
     6.8 +do_cc_core_get() {
     6.9 +    # Ah! gcc folks are kind of 'different': they store the tarballs in
    6.10 +    # subdirectories of the same name! That's because gcc is such /crap/ that
    6.11 +    # it is such /big/ that it needs being splitted for distribution! Sad. :-(
    6.12 +    # Arrgghh! Some of those versions does not follow this convention:
    6.13 +    # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
    6.14 +    # subdirectory! You bastard!
    6.15 +    CT_GetFile "${CT_CC_CORE_FILE}"                                    \
    6.16 +               ftp://ftp.gnu.org/gnu/gcc/${CT_CC_CORE_FILE}            \
    6.17 +               ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_CORE_FILE}   \
    6.18 +               ftp://ftp.gnu.org/gnu/gcc
    6.19 +}
    6.20 +
    6.21 +# Extract core gcc
    6.22 +do_cc_core_extract() {
    6.23 +    CT_ExtractAndPatch "${CT_CC_CORE_FILE}"
    6.24 +}
    6.25 +
    6.26 +# Build core gcc
    6.27  do_cc_core() {
    6.28      mkdir -p "${CT_BUILD_DIR}/build-cc-core"
    6.29      cd "${CT_BUILD_DIR}/build-cc-core"
     7.1 --- a/scripts/build/cc_gcc.sh	Sun May 06 21:47:29 2007 +0000
     7.2 +++ b/scripts/build/cc_gcc.sh	Mon May 07 09:04:02 2007 +0000
     7.3 @@ -2,6 +2,26 @@
     7.4  # Copyright 2007 Yann E. MORIN
     7.5  # Licensed under the GPL v2. See COPYING in the root of this package
     7.6  
     7.7 +# Download final gcc
     7.8 +do_cc_get() {
     7.9 +    # Ah! gcc folks are kind of 'different': they store the tarballs in
    7.10 +    # subdirectories of the same name! That's because gcc is such /crap/ that
    7.11 +    # it is such /big/ that it needs being splitted for distribution! Sad. :-(
    7.12 +    # Arrgghh! Some of those versions does not follow this convention:
    7.13 +    # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
    7.14 +    # subdirectory! You bastard!
    7.15 +    CT_GetFile "${CT_CC_FILE}"                                  \
    7.16 +               ftp://ftp.gnu.org/gnu/gcc/${CT_CC_FILE}          \
    7.17 +               ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_FILE} \
    7.18 +               ftp://ftp.gnu.org/gnu/gcc
    7.19 +}
    7.20 +
    7.21 +# Extract final gcc
    7.22 +do_cc_extract() {
    7.23 +    CT_ExtractAndPatch "${CT_CC_FILE}"
    7.24 +}
    7.25 +
    7.26 +# Build final gcc
    7.27  do_cc() {
    7.28      CT_DoStep INFO "Installing final compiler"
    7.29  
     8.1 --- a/scripts/build/kernel_linux.sh	Sun May 06 21:47:29 2007 +0000
     8.2 +++ b/scripts/build/kernel_linux.sh	Mon May 07 09:04:02 2007 +0000
     8.3 @@ -2,6 +2,27 @@
     8.4  # Copyright 2007 Yann E. MORIN
     8.5  # Licensed under the GPL v2. See COPYING in the root of this package
     8.6  
     8.7 +# Download the kernel
     8.8 +do_kernel_get() {
     8.9 +    if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" != "y" ]; then
    8.10 +        CT_GetFile "${CT_KERNEL_FILE}"                                  \
    8.11 +                   ftp://ftp.kernel.org/pub/linux/kernel/v2.6           \
    8.12 +                   ftp://ftp.kernel.org/pub/linux/kernel/v2.4           \
    8.13 +                   ftp://ftp.kernel.org/pub/linux/kernel/v2.2           \
    8.14 +                   ftp://ftp.kernel.org/pub/linux/kernel/v2.6/testing   \
    8.15 +                   http://ep09.pld-linux.org/~mmazur/linux-libc-headers
    8.16 +    fi
    8.17 +    return 0
    8.18 +}
    8.19 +
    8.20 +# Extract kernel
    8.21 +do_kernel_extract() {
    8.22 +    if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" != "y" ]; then
    8.23 +        CT_ExtractAndPatch "${CT_KERNEL_FILE}"
    8.24 +    fi
    8.25 +    return 0
    8.26 +}
    8.27 +
    8.28  # Check kernel configuration
    8.29  do_kernel_check_config() {
    8.30      CT_DoStep INFO "Checking kernel configuration"
     9.1 --- a/scripts/build/libc_glibc.sh	Sun May 06 21:47:29 2007 +0000
     9.2 +++ b/scripts/build/libc_glibc.sh	Mon May 07 09:04:02 2007 +0000
     9.3 @@ -2,6 +2,33 @@
     9.4  # Copyright 2007 Yann E. MORIN
     9.5  # Licensed under the GPL v2. See COPYING in the root of this package
     9.6  
     9.7 +# Download glibc
     9.8 +do_libc_download() {
     9.9 +    # Ah! Not all GNU folks seem stupid. All glibc releases are in the same
    9.10 +    # directory. Good. Alas, there is no snapshot there. I'll deal with them
    9.11 +    # later on... :-/
    9.12 +    CT_GetFile "${CT_LIBC_FILE}" ftp://ftp.gnu.org/gnu/glibc
    9.13 +
    9.14 +    # C library addons
    9.15 +    addons_list=`echo "${CT_LIBC_ADDONS}" |sed -r -e 's/,/ /g; s/ $//g;'`
    9.16 +    for addon in ${addons_list}; do
    9.17 +        CT_GetFile "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ftp://ftp.gnu.org/gnu/glibc
    9.18 +    done
    9.19 +    [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_GetFile "${CT_LIBC}-ports-${CT_LIBC_VERSION}" ftp://ftp.gnu.org/gnu/glibc
    9.20 +}
    9.21 +
    9.22 +# Extract glibc
    9.23 +do_libc_extract() {
    9.24 +    CT_ExtractAndPatch "${CT_LIBC_FILE}"
    9.25 +
    9.26 +    # C library addons
    9.27 +    addons_list=`echo "${CT_LIBC_ADDONS}" |sed -r -e 's/,/ /g; s/ $//g;'`
    9.28 +    for addon in ${addons_list}; do
    9.29 +        CT_ExtractAndPatch "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
    9.30 +    done
    9.31 +    [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_ExtractAndPatch "${CT_LIBC}-ports-${CT_LIBC_VERSION}"
    9.32 +}
    9.33 +
    9.34  # There is nothing to do for glibc check config
    9.35  do_libc_check_config() {
    9.36      CT_DoStep INFO "Checking C library configuration"
    9.37 @@ -44,7 +71,8 @@
    9.38          --host="${CT_TARGET}"                   \
    9.39          --prefix=/usr                           \
    9.40          --with-headers="${CT_HEADERS_DIR}"      \
    9.41 -        --without-cvs --disable-sanity-checks   \
    9.42 +        --without-cvs                           \
    9.43 +        --disable-sanity-checks                 \
    9.44          --enable-hacker-mode                    \
    9.45          --enable-add-ons=""                     \
    9.46          --without-nptl                          2>&1 |CT_DoLog DEBUG
    9.47 @@ -142,7 +170,7 @@
    9.48      CT_DoLog DEBUG "Extra config args passed: \"${extra_config}\""
    9.49  
    9.50      # Add some default CC args
    9.51 -    extra_cc_args=
    9.52 +    extra_cc_args="${CT_CFLAGS_FOR_HOST}"
    9.53      case "${CT_LIBC_EXTRA_CC_ARGS}" in
    9.54          *-mbig-endian*) ;;
    9.55          *-mlittle-endian*) ;;
    10.1 --- a/scripts/build/libc_libfloat.sh	Sun May 06 21:47:29 2007 +0000
    10.2 +++ b/scripts/build/libc_libfloat.sh	Mon May 07 09:04:02 2007 +0000
    10.3 @@ -2,6 +2,34 @@
    10.4  # Copyright 2007 Yann E. MORIN
    10.5  # Licensed under the GPL v2. See COPYING in the root of this package
    10.6  
    10.7 +# Define libfloat functions depending on wether it is selected or not
    10.8 +if [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ]; then
    10.9 +
   10.10 +# Download libfloat
   10.11 +do_libfloat_get() {
   10.12 +    # Please note: because the file we download, and the file we store on the
   10.13 +    # file system don't have the same name, CT_GetFile will always try to
   10.14 +    # download the file over and over.
   10.15 +    # To avoid this, we check that the file we want already exists in the
   10.16 +    # tarball directory first. This is an ugly hack that overrides the standard
   10.17 +    # CT_GetFile behavior... Sight...
   10.18 +    lib_float_url="ftp://ftp.de.debian.org/debian/pool/main/libf/libfloat/"
   10.19 +    ext=`CT_GetFileExtension "${CT_LIBFLOAT_FILE}"`
   10.20 +    if [ -z "${ext}" ]; then
   10.21 +        CT_GetFile libfloat_990616.orig "${lib_float_url}"
   10.22 +        ext=`CT_GetFileExtension "libfloat_990616.orig"`
   10.23 +        # Hack: remove the .orig extension, and change _ to -
   10.24 +        mv -v "${CT_TARBALLS_DIR}/libfloat_990616.orig${ext}" \
   10.25 +              "${CT_TARBALLS_DIR}/libfloat-990616${ext}"      2>&1 |CT_DoLog DEBUG
   10.26 +    fi
   10.27 +}
   10.28 +
   10.29 +# Extract libfloat
   10.30 +do_libfloat_extract() {
   10.31 +    [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] && CT_ExtractAndPatch "${CT_LIBFLOAT_FILE}"
   10.32 +}
   10.33 +
   10.34 +# Build libfloat
   10.35  do_libfloat() {
   10.36      # Here we build and install libfloat for the target, so that the C library
   10.37      # builds OK with those versions of gcc that have severed softfloat support
   10.38 @@ -29,3 +57,17 @@
   10.39  
   10.40      CT_EndStep
   10.41  }
   10.42 +
   10.43 +else # "${CT_ARCH_FLOAT_SW_LIBFLOAT}" != "y"
   10.44 +
   10.45 +do_libfloat_get() {
   10.46 +    true
   10.47 +}
   10.48 +do_libfloat_extract() {
   10.49 +    true
   10.50 +}
   10.51 +do_libfloat() {
   10.52 +    true
   10.53 +}
   10.54 +
   10.55 +fi
    11.1 --- a/scripts/build/libc_uClibc.sh	Sun May 06 21:47:29 2007 +0000
    11.2 +++ b/scripts/build/libc_uClibc.sh	Mon May 07 09:04:02 2007 +0000
    11.3 @@ -2,6 +2,25 @@
    11.4  # Copyright 2007 Yann E. MORIN
    11.5  # Licensed under the GPL v2. See COPYING in the root of this package
    11.6  
    11.7 +# Download uClibc
    11.8 +do_libc_get() {
    11.9 +	libc_src="http://www.uclibc.org/downloads
   11.10 +              http://www.uclibc.org/downloads/snapshots
   11.11 +              http://www.uclibc.org/downloads/old-releases"
   11.12 +    # For uClibc, we have almost every thing: releases, and snapshots
   11.13 +    # for the last month or so. We'll have to deal with svn revisions
   11.14 +    # later...
   11.15 +    CT_GetFile "${CT_LIBC_FILE}" ${libc_src}
   11.16 +    # uClibc locales
   11.17 +    [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] && CT_GetFile "uClibc-locale-030818" ${libc_src}
   11.18 +}
   11.19 +
   11.20 +# Extract uClibc
   11.21 +do_libc_extract() {
   11.22 +    CT_ExtractAndPatch "${CT_LIBC_FILE}"
   11.23 +    # uClibc locales
   11.24 +    [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] && CT_ExtractAndPatch "uClibc-locale-030818"
   11.25 +}
   11.26  
   11.27  # Check that uClibc has been previously configured
   11.28  do_libc_check_config() {
    12.1 --- a/scripts/buildToolchain.sh	Sun May 06 21:47:29 2007 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,133 +0,0 @@
    12.4 -# This scripts calls each component's build script.
    12.5 -# Copyright 2007 Yann E. MORIN
    12.6 -# Licensed under the GPL v2. See COPYING in the root of this package
    12.7 -
    12.8 -# Parse all build files to have the needed functions.
    12.9 -. "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
   12.10 -. "${CT_TOP_DIR}/scripts/build/binutils.sh"
   12.11 -. "${CT_TOP_DIR}/scripts/build/libc_libfloat.sh"
   12.12 -. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh"
   12.13 -. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh"
   12.14 -. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
   12.15 -
   12.16 -# Arrange paths depending on wether we use sys-root or not.
   12.17 -if [ "${CT_USE_SYSROOT}" = "y" ]; then
   12.18 -    CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
   12.19 -    CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
   12.20 -    BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   12.21 -    CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   12.22 -    CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   12.23 -    LIBC_SYSROOT_ARG=""
   12.24 -    # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
   12.25 -    # confused when $sysroot/usr/include is not present.
   12.26 -    # Note: --prefix=/usr is magic!
   12.27 -    # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
   12.28 -else
   12.29 -    # plain old way. All libraries in prefix/target/lib
   12.30 -    CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
   12.31 -    CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
   12.32 -    # hack!  Always use --with-sysroot for binutils.
   12.33 -    # binutils 2.14 and later obey it, older binutils ignore it.
   12.34 -    # Lets you build a working 32->64 bit cross gcc
   12.35 -    BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
   12.36 -    # Use --with-headers, else final gcc will define disable_glibc while
   12.37 -    # building libgcc, and you'll have no profiling
   12.38 -    CC_CORE_SYSROOT_ARG="--without-headers"
   12.39 -    CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
   12.40 -    LIBC_SYSROOT_ARG="prefix="
   12.41 -fi
   12.42 -
   12.43 -# Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
   12.44 -# 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
   12.45 -#  "ld: cannot open crti.o: No such file or directory"
   12.46 -mkdir -p "${CT_SYSROOT_DIR}/lib"
   12.47 -mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
   12.48 -
   12.49 -# Canadian-cross are really picky on the way they are built. Tweak the values.
   12.50 -if [ "${CT_CANADIAN}" = "y" ]; then
   12.51 -    # Arrange so that gcc never, ever think that build system == host system
   12.52 -    CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
   12.53 -    # We shall have a compiler for this target!
   12.54 -    # Do test here...
   12.55 -else
   12.56 -    CT_HOST="${CT_BUILD}"
   12.57 -    CT_CANADIAN_OPT=
   12.58 -    # Add the target toolchain in the path so that we can build the C library
   12.59 -    export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
   12.60 -fi
   12.61 -
   12.62 -# Modify GCC_HOST to never be equal to $BUILD or $TARGET
   12.63 -# This strange operation causes gcc to always generate a cross-compiler
   12.64 -# even if the build machine is the same kind as the host.
   12.65 -# This is why CC has to be set when doing a canadian cross; you can't find a
   12.66 -# host compiler by appending -gcc to our whacky $GCC_HOST
   12.67 -# Kludge: it is reported that the above causes canadian crosses with cygwin
   12.68 -# hosts to fail, so avoid it just in that one case.  It would be cleaner to
   12.69 -# just move this into the non-canadian case above, but I'm afraid that might
   12.70 -# cause some configure script somewhere to decide that since build==host, they
   12.71 -# could run host binaries.
   12.72 -# (Copied almost as-is from original crosstool):
   12.73 -case "${CT_KERNEL},${CT_CANADIAN}" in
   12.74 -    cygwin,y) ;;
   12.75 -    *)        CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
   12.76 -esac
   12.77 -
   12.78 -# Ah! Recent versions of binutils need some of the build and/or host system
   12.79 -# (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
   12.80 -# Do that:
   12.81 -CT_DoLog EXTRA "Making build system tools available"
   12.82 -mkdir -p "${CT_PREFIX_DIR}/bin"
   12.83 -for tool in ar; do
   12.84 -    ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
   12.85 -    ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
   12.86 -done
   12.87 -
   12.88 -# Ha. cygwin host have an .exe suffix (extension) for executables.
   12.89 -[ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
   12.90 -
   12.91 -# Transform the ARCH into a kernel-understandable ARCH
   12.92 -case "${CT_ARCH}" in
   12.93 -    x86) CT_KERNEL_ARCH=i386;;
   12.94 -    ppc) CT_KERNEL_ARCH=powerpc;;
   12.95 -    *)   CT_KERNEL_ARCH="${CT_ARCH}";;
   12.96 -esac
   12.97 -
   12.98 -# Build up the TARGET_CFLAGS from user-provided options
   12.99 -tmp_target_CFLAGS=
  12.100 -[ -n "${CT_ARCH_CPU}" ]  && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mcpu=${CT_ARCH_CPU}"
  12.101 -[ -n "${CT_ARCH_TUNE}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mtune=${CT_ARCH_TUNE}"
  12.102 -[ -n "${CT_ARCH_ARCH}" ] && tmp_target_CFLAGS="${tmp_target_CFLAGS} -march=${CT_ARCH_ARCH}"
  12.103 -[ -n "${CT_ARCH_FPU}" ]  && tmp_target_CFLAGS="${tmp_target_CFLAGS} -mfpu=${CT_ARCH_FPU}"
  12.104 -# Override with user-specified CFLAGS
  12.105 -CT_TARGET_CFLAGS="${tmp_target_CFLAGS} ${CT_TARGET_CFLAGS}"
  12.106 -
  12.107 -# Help gcc
  12.108 -CT_CFLAGS_FOR_HOST=
  12.109 -[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
  12.110 -
  12.111 -# And help make go faster
  12.112 -PARALLELMFLAGS=
  12.113 -[ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
  12.114 -[ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
  12.115 -
  12.116 -CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
  12.117 -CT_DoLog EXTRA "Building a toolchain for:"
  12.118 -CT_DoLog EXTRA "  build  = ${CT_BUILD}"
  12.119 -CT_DoLog EXTRA "  host   = ${CT_HOST}"
  12.120 -CT_DoLog EXTRA "  target = ${CT_TARGET}"
  12.121 -set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
  12.122 -CT_EndStep
  12.123 -
  12.124 -# Now for the job by itself.
  12.125 -# Check the C library config ASAP, before the user gets bored, and is
  12.126 -# gone having his/her coffee
  12.127 -do_libc_check_config
  12.128 -do_kernel_check_config
  12.129 -do_kernel_headers
  12.130 -do_binutils
  12.131 -do_libc_headers
  12.132 -do_cc_core
  12.133 -do_libfloat
  12.134 -do_libc
  12.135 -do_cc
  12.136 -do_libc_finish
    13.1 --- a/scripts/crosstool.sh	Sun May 06 21:47:29 2007 +0000
    13.2 +++ b/scripts/crosstool.sh	Mon May 07 09:04:02 2007 +0000
    13.3 @@ -28,7 +28,7 @@
    13.4  CT_STAR_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
    13.5  
    13.6  # Log to a temporary file until we have built our environment
    13.7 -CT_ACTUAL_LOG_FILE="`pwd`/$$.log"
    13.8 +CT_ACTUAL_LOG_FILE="${CT_TOP_DIR}/$$.log"
    13.9  
   13.10  # CT_TOP_DIR should be an absolute path.
   13.11  CT_TOP_DIR="`CT_MakeAbsolutePath \"${CT_TOP_DIR}\"`"
   13.12 @@ -73,6 +73,9 @@
   13.13  # Yes! We can do full logging from now on!
   13.14  CT_DoLog INFO "Build started ${CT_STAR_DATE_HUMAN}"
   13.15  
   13.16 +# renice oursleves
   13.17 +renice ${CT_NICE} $$ |CT_DoLog DEBUG
   13.18 +
   13.19  # Some sanity checks in the environment and needed tools
   13.20  CT_DoLog INFO "Checking environment sanity"
   13.21  
   13.22 @@ -109,50 +112,8 @@
   13.23  
   13.24  CT_DoLog INFO "Building environment variables"
   13.25  
   13.26 -# This should go in buildToolchain.sh, but we might need it because it could
   13.27 -# be used by the user in his/her paths definitions.
   13.28  # Target triplet: CT_TARGET needs a little love:
   13.29 -case "${CT_ARCH_BE},${CT_ARCH_LE}" in
   13.30 -    y,) target_endian_eb=eb; target_endian_el=;;
   13.31 -    ,y) target_endian_eb=; target_endian_el=el;;
   13.32 -esac
   13.33 -case "${CT_ARCH}" in
   13.34 -    arm)  CT_TARGET="${CT_ARCH}${target_endian_eb}";;
   13.35 -    mips) CT_TARGET="${CT_ARCH}${target_endian_el}";;
   13.36 -    x86*) # Much love for this one :-(
   13.37 -          # Ultimately, we should use config.sub to output the correct
   13.38 -          # procesor name. Work for later...
   13.39 -          arch="${CT_ARCH_ARCH}"
   13.40 -          [ -z "${arch}" ] && arch="${CT_ARCH_TUNE}"
   13.41 -          case "${CT_ARCH}" in
   13.42 -              x86_64)      CT_TARGET=x86_64;;
   13.43 -          	  *)  case "${arch}" in
   13.44 -                      "")                                       CT_TARGET=i386;;
   13.45 -                      i386|i486|i586|i686)                      CT_TARGET="${arch}";;
   13.46 -                      winchip*)                                 CT_TARGET=i486;;
   13.47 -                      pentium|pentium-mmx|c3*)                  CT_TARGET=i586;;
   13.48 -                      nocona|athlon*64|k8|athlon-fx|opteron)    CT_TARGET=x86_64;;
   13.49 -                      pentiumpro|pentium*|athlon*)              CT_TARGET=i686;;
   13.50 -                      *)                                        CT_TARGET=i586;;
   13.51 -                  esac;;
   13.52 -          esac;;
   13.53 -esac
   13.54 -case "${CT_TARGET_VENDOR}" in
   13.55 -    "") CT_TARGET="${CT_TARGET}-unknown";;
   13.56 -    *)  CT_TARGET="${CT_TARGET}-${CT_TARGET_VENDOR}";;
   13.57 -esac
   13.58 -case "${CT_KERNEL}" in
   13.59 -    linux*)  CT_TARGET="${CT_TARGET}-linux";;
   13.60 -    cygwin*) CT_TARGET="${CT_TARGET}-cygwin";;
   13.61 -esac
   13.62 -case "${CT_LIBC}" in
   13.63 -    glibc)  CT_TARGET="${CT_TARGET}-gnu";;
   13.64 -    uClibc) CT_TARGET="${CT_TARGET}-uclibc";;
   13.65 -esac
   13.66 -case "${CT_ARCH_ABI}" in
   13.67 -    eabi)   CT_TARGET="${CT_TARGET}eabi";;
   13.68 -esac
   13.69 -CT_TARGET="`${CT_TOP_DIR}/tools/config.sub ${CT_TARGET}`"
   13.70 +CT_DoBuildTargetTriplet
   13.71  
   13.72  # Now, build up the variables from the user-configured options.
   13.73  CT_KERNEL_FILE="${CT_KERNEL}-${CT_KERNEL_VERSION}"
   13.74 @@ -171,50 +132,6 @@
   13.75  # then rescan the options file now:
   13.76  . "${CT_TOP_DIR}/.config"
   13.77  
   13.78 -# Determine build system if not set by the user
   13.79 -CT_Test "You did not specify the build system. Guessing." -z "${CT_BUILD}"
   13.80 -CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
   13.81 -
   13.82 -# Get rid of pre-existing installed toolchain and previous build directories.
   13.83 -# We need to do that _before_ we can safely log, because the log file will
   13.84 -# most probably be in the toolchain directory.
   13.85 -if [ -d "${CT_PREFIX_DIR}" ]; then
   13.86 -    mv "${CT_PREFIX_DIR}" "${CT_PREFIX_DIR}.$$"
   13.87 -    nohup rm -rf "${CT_PREFIX_DIR}.$$" >/dev/null 2>&1 &
   13.88 -fi
   13.89 -mkdir -p "${CT_PREFIX_DIR}"
   13.90 -if [ -d "${CT_BUILD_DIR}" ]; then
   13.91 -    mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
   13.92 -    nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
   13.93 -fi
   13.94 -mkdir -p "${CT_BUILD_DIR}"
   13.95 -
   13.96 -# Check now if we can write to the destination directory:
   13.97 -if [ -d "${CT_PREFIX_DIR}" ]; then
   13.98 -    CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not writeable" ! -w "${CT_PREFIX_DIR}"
   13.99 -else
  13.100 -    mkdir -p "${CT_PREFIX_DIR}" || CT_Abort "Could not create destination directory \"${CT_PREFIX_DIR}\""
  13.101 -fi
  13.102 -
  13.103 -# Redirect log to the actual log file now we can
  13.104 -# It's quite understandable that the log file will be installed in the
  13.105 -# install directory, so we must first ensure it exists and is writeable (above)
  13.106 -# before we can log there
  13.107 -t="${CT_ACTUAL_LOG_FILE}"
  13.108 -case "${CT_LOG_TO_FILE},${CT_LOG_FILE}" in
  13.109 -    ,*)   CT_ACTUAL_LOG_FILE=/dev/null
  13.110 -          rm -f "${t}"
  13.111 -          ;;
  13.112 -    y,/*) mkdir -p "`dirname \"${CT_LOG_FILE}\"`"
  13.113 -          CT_ACTUAL_LOG_FILE="${CT_LOG_FILE}"
  13.114 -          mv "${t}" "${CT_ACTUAL_LOG_FILE}"
  13.115 -          ;;
  13.116 -    y,*)  mkdir -p "`pwd`/`dirname \"${CT_LOG_FILE}\"`"
  13.117 -          CT_ACTUAL_LOG_FILE="`pwd`/${CT_LOG_FILE}"
  13.118 -          mv "${t}" "${CT_ACTUAL_LOG_FILE}"
  13.119 -          ;;
  13.120 -esac
  13.121 -
  13.122  # Some more sanity checks now that we have all paths set up
  13.123  case "${CT_TARBALLS_DIR},${CT_SRC_DIR},${CT_BUILD_DIR},${CT_PREFIX_DIR},${CT_INSTALL_DIR}" in
  13.124      *" "*) CT_Abort "Don't use spaces in paths, it breaks things.";;
  13.125 @@ -233,7 +150,7 @@
  13.126  CT_SYS_KERNEL=`uname -s`
  13.127  CT_SYS_REVISION=`uname -r`
  13.128  # MacOS X lacks '-o' :
  13.129 -CT_SYS_OS=`uname -o || echo Unkown`
  13.130 +CT_SYS_OS=`uname -o || echo "Unknown (maybe MacOS-X)"`
  13.131  CT_SYS_MACHINE=`uname -m`
  13.132  CT_SYS_PROCESSOR=`uname -p`
  13.133  CT_SYS_USER="`id -un`"
  13.134 @@ -241,14 +158,212 @@
  13.135  CT_SYS_GCC=`gcc -dumpversion`
  13.136  CT_TOOLCHAIN_ID="crosstool-${CT_VERSION} build ${CT_SYS_DATE} by ${CT_SYS_USER}@${CT_SYS_HOSTNAME} for ${CT_TARGET}"
  13.137  
  13.138 -# renice oursleves
  13.139 -renice ${CT_NICE} $$ |CT_DoLog DEBUG
  13.140 +# Check now if we can write to the destination directory:
  13.141 +if [ -d "${CT_INSTALL_DIR}" ]; then
  13.142 +    CT_TestAndAbort "Destination directory \"${CT_INSTALL_DIR}\" is not removable" ! -w `dirname "${CT_INSTALL_DIR}"`
  13.143 +fi
  13.144 +
  13.145 +# Get rid of pre-existing installed toolchain and previous build directories.
  13.146 +# We need to do that _before_ we can safely log, because the log file will
  13.147 +# most probably be in the toolchain directory.
  13.148 +if [ -d "${CT_INSTALL_DIR}" ]; then
  13.149 +    mv "${CT_INSTALL_DIR}" "${CT_INSTALL_DIR}.$$"
  13.150 +    nohup rm -rf "${CT_INSTALL_DIR}.$$" >/dev/null 2>&1 &
  13.151 +fi
  13.152 +if [ -d "${CT_BUILD_DIR}" ]; then
  13.153 +    mv "${CT_BUILD_DIR}" "${CT_BUILD_DIR}.$$"
  13.154 +    nohup rm -rf "${CT_BUILD_DIR}.$$" >/dev/null 2>&1 &
  13.155 +fi
  13.156 +if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
  13.157 +    mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
  13.158 +    nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
  13.159 +fi
  13.160 +mkdir -p "${CT_INSTALL_DIR}"
  13.161 +mkdir -p "${CT_BUILD_DIR}"
  13.162 +mkdir -p "${CT_TARBALLS_DIR}"
  13.163 +mkdir -p "${CT_SRC_DIR}"
  13.164 +
  13.165 +# Make all path absolute, it so much easier!
  13.166 +# Now we have had the directories created, we even will get rid of embedded .. in paths:
  13.167 +CT_SRC_DIR="`CT_MakeAbsolutePath \"${CT_SRC_DIR}\"`"
  13.168 +CT_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_TARBALLS_DIR}\"`"
  13.169 +
  13.170 +# Redirect log to the actual log file now we can
  13.171 +# It's quite understandable that the log file will be installed in the install
  13.172 +# directory, so we must first ensure it exists and is writeable (above) before
  13.173 +# we can log there
  13.174 +case "${CT_LOG_TO_FILE},${CT_LOG_FILE}" in
  13.175 +    ,*)   rm -f "${CT_ACTUAL_LOG_FILE}"
  13.176 +          CT_ACTUAL_LOG_FILE=/dev/null
  13.177 +          ;;
  13.178 +    y,/*) mkdir -p "`dirname \"${CT_LOG_FILE}\"`"
  13.179 +          mv "${CT_ACTUAL_LOG_FILE}" "${CT_LOG_FILE}"
  13.180 +          CT_ACTUAL_LOG_FILE="${CT_LOG_FILE}"
  13.181 +          ;;
  13.182 +    y,*)  mkdir -p "`pwd`/`dirname \"${CT_LOG_FILE}\"`"
  13.183 +          mv "${CT_ACTUAL_LOG_FILE}" "`pwd`/${CT_LOG_FILE}"
  13.184 +          CT_ACTUAL_LOG_FILE="`pwd`/${CT_LOG_FILE}"
  13.185 +          ;;
  13.186 +esac
  13.187 +
  13.188 +# Determine build system if not set by the user
  13.189 +CT_Test "You did not specify the build system. Guessing." -z "${CT_BUILD}"
  13.190 +CT_BUILD="`${CT_TOP_DIR}/tools/config.sub \"${CT_BUILD:-\`${CT_TOP_DIR}/tools/config.guess\`}\"`"
  13.191 +
  13.192 +# Arrange paths depending on wether we use sys-root or not.
  13.193 +if [ "${CT_USE_SYSROOT}" = "y" ]; then
  13.194 +    CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}/sys-root"
  13.195 +    CT_HEADERS_DIR="${CT_SYSROOT_DIR}/usr/include"
  13.196 +    BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
  13.197 +    CC_CORE_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
  13.198 +    CC_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
  13.199 +    LIBC_SYSROOT_ARG=""
  13.200 +    # glibc's prefix must be exactly /usr, else --with-sysroot'd gcc will get
  13.201 +    # confused when $sysroot/usr/include is not present.
  13.202 +    # Note: --prefix=/usr is magic!
  13.203 +    # See http://www.gnu.org/software/libc/FAQ.html#s-2.2
  13.204 +else
  13.205 +    # plain old way. All libraries in prefix/target/lib
  13.206 +    CT_SYSROOT_DIR="${CT_PREFIX_DIR}/${CT_TARGET}"
  13.207 +    CT_HEADERS_DIR="${CT_SYSROOT_DIR}/include"
  13.208 +    # hack!  Always use --with-sysroot for binutils.
  13.209 +    # binutils 2.14 and later obey it, older binutils ignore it.
  13.210 +    # Lets you build a working 32->64 bit cross gcc
  13.211 +    BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}"
  13.212 +    # Use --with-headers, else final gcc will define disable_glibc while
  13.213 +    # building libgcc, and you'll have no profiling
  13.214 +    CC_CORE_SYSROOT_ARG="--without-headers"
  13.215 +    CC_SYSROOT_ARG="--with-headers=${CT_HEADERS_DIR}"
  13.216 +    LIBC_SYSROOT_ARG="prefix="
  13.217 +fi
  13.218 +
  13.219 +# Prepare the 'lib' directories in sysroot, else the ../lib64 hack used by
  13.220 +# 32 -> 64 bit crosscompilers won't work, and build of final gcc will fail with
  13.221 +#  "ld: cannot open crti.o: No such file or directory"
  13.222 +mkdir -p "${CT_SYSROOT_DIR}/lib"
  13.223 +mkdir -p "${CT_SYSROOT_DIR}/usr/lib"
  13.224 +
  13.225 +# Canadian-cross are really picky on the way they are built. Tweak the values.
  13.226 +if [ "${CT_CANADIAN}" = "y" ]; then
  13.227 +    # Arrange so that gcc never, ever think that build system == host system
  13.228 +    CT_CANADIAN_OPT="--build=`echo \"${CT_BUILD}\" |sed -r -e 's/-/-build_/'`"
  13.229 +    # We shall have a compiler for this target!
  13.230 +    # Do test here...
  13.231 +else
  13.232 +    CT_HOST="${CT_BUILD}"
  13.233 +    CT_CANADIAN_OPT=
  13.234 +    # Add the target toolchain in the path so that we can build the C library
  13.235 +    export PATH="${CT_PREFIX_DIR}/bin:${CT_CC_CORE_PREFIX_DIR}/bin:${PATH}"
  13.236 +fi
  13.237 +
  13.238 +# Modify GCC_HOST to never be equal to $BUILD or $TARGET
  13.239 +# This strange operation causes gcc to always generate a cross-compiler
  13.240 +# even if the build machine is the same kind as the host.
  13.241 +# This is why CC has to be set when doing a canadian cross; you can't find a
  13.242 +# host compiler by appending -gcc to our whacky $GCC_HOST
  13.243 +# Kludge: it is reported that the above causes canadian crosses with cygwin
  13.244 +# hosts to fail, so avoid it just in that one case.  It would be cleaner to
  13.245 +# just move this into the non-canadian case above, but I'm afraid that might
  13.246 +# cause some configure script somewhere to decide that since build==host, they
  13.247 +# could run host binaries.
  13.248 +# (Copied almost as-is from original crosstool):
  13.249 +case "${CT_KERNEL},${CT_CANADIAN}" in
  13.250 +    cygwin,y) ;;
  13.251 +    *)        CT_HOST="`echo \"${CT_HOST}\" |sed -r -e 's/-/-host_/;'`";;
  13.252 +esac
  13.253 +
  13.254 +# Ah! Recent versions of binutils need some of the build and/or host system
  13.255 +# (read CT_BUILD and CT_HOST) tools to be accessible (ar is but an example).
  13.256 +# Do that:
  13.257 +CT_DoLog EXTRA "Making build system tools available"
  13.258 +mkdir -p "${CT_PREFIX_DIR}/bin"
  13.259 +for tool in ar; do
  13.260 +    ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_BUILD}-${tool}"
  13.261 +    ln -s "`which ${tool}`" "${CT_PREFIX_DIR}/bin/${CT_HOST}-${tool}"
  13.262 +done
  13.263 +
  13.264 +# Ha. cygwin host have an .exe suffix (extension) for executables.
  13.265 +[ "${CT_KERNEL}" = "cygwin" ] && EXEEXT=".exe" || EXEEXT=""
  13.266 +
  13.267 +# Transform the ARCH into a kernel-understandable ARCH
  13.268 +case "${CT_ARCH}" in
  13.269 +    x86) CT_KERNEL_ARCH=i386;;
  13.270 +    ppc) CT_KERNEL_ARCH=powerpc;;
  13.271 +    *)   CT_KERNEL_ARCH="${CT_ARCH}";;
  13.272 +esac
  13.273 +
  13.274 +# Build up the TARGET_CFLAGS from user-provided options
  13.275 +# Override with user-specified CFLAGS
  13.276 +[ -n "${CT_ARCH_CPU}" ]  && CT_TARGET_CFLAGS="-mcpu=${CT_ARCH_CPU} ${CT_TARGET_CFLAGS}"
  13.277 +[ -n "${CT_ARCH_TUNE}" ] && CT_TARGET_CFLAGS="-mtune=${CT_ARCH_TUNE} ${CT_TARGET_CFLAGS}"
  13.278 +[ -n "${CT_ARCH_ARCH}" ] && CT_TARGET_CFLAGS="-march=${CT_ARCH_ARCH} ${CT_TARGET_CFLAGS}"
  13.279 +[ -n "${CT_ARCH_FPU}" ]  && CT_TARGET_CFLAGS="-mfpu=${CT_ARCH_FPU} ${CT_TARGET_CFLAGS}"
  13.280 +
  13.281 +# Help gcc
  13.282 +CT_CFLAGS_FOR_HOST=
  13.283 +[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST="${CT_CFLAGS_FOR_HOST} -pipe"
  13.284 +
  13.285 +# And help make go faster
  13.286 +PARALLELMFLAGS=
  13.287 +[ ${CT_PARALLEL_JOBS} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -j${CT_PARALLEL_JOBS}"
  13.288 +[ ${CT_LOAD} -ne 0 ] && PARALLELMFLAGS="${PARALLELMFLAGS} -l${CT_LOAD}"
  13.289 +
  13.290 +CT_DoStep EXTRA "Dumping internal crosstool-NG configuration"
  13.291 +CT_DoLog EXTRA "Building a toolchain for:"
  13.292 +CT_DoLog EXTRA "  build  = ${CT_BUILD}"
  13.293 +CT_DoLog EXTRA "  host   = ${CT_HOST}"
  13.294 +CT_DoLog EXTRA "  target = ${CT_TARGET}"
  13.295 +set |egrep '^CT_.+=' |sort |CT_DoLog DEBUG
  13.296 +CT_EndStep
  13.297  
  13.298  # Include sub-scripts instead of calling them: that way, we do not have to
  13.299  # export any variable, nor re-parse the configuration and functions files.
  13.300 -. "${CT_TOP_DIR}/scripts/getExtractPatch.sh"
  13.301 -. "${CT_TOP_DIR}/scripts/buildToolchain.sh"
  13.302 -#. "${CT_TOP_DIR}/scripts/testToolchain.sh"
  13.303 +. "${CT_TOP_DIR}/scripts/build/kernel_${CT_KERNEL}.sh"
  13.304 +. "${CT_TOP_DIR}/scripts/build/binutils.sh"
  13.305 +. "${CT_TOP_DIR}/scripts/build/libc_libfloat.sh"
  13.306 +. "${CT_TOP_DIR}/scripts/build/libc_${CT_LIBC}.sh"
  13.307 +. "${CT_TOP_DIR}/scripts/build/cc_core_${CT_CC_CORE}.sh"
  13.308 +. "${CT_TOP_DIR}/scripts/build/cc_${CT_CC}.sh"
  13.309 +
  13.310 +# Now for the job by itself. Go have a coffee!
  13.311 +if [ "${CT_NO_DOWNLOAD}" != "y" ]; then
  13.312 +	CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
  13.313 +    do_kernel_get
  13.314 +    do_binutils_get
  13.315 +    do_libc_get
  13.316 +    do_libfloat_get
  13.317 +    do_cc_core_get
  13.318 +    do_cc_get
  13.319 +    CT_EndStep
  13.320 +fi
  13.321 +
  13.322 +if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
  13.323 +    if [ "${CT_FORCE_EXTRACT}" = "y" ]; then
  13.324 +        mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
  13.325 +        nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1
  13.326 +    fi
  13.327 +    CT_DoStep INFO "Extracting and patching toolchain components"
  13.328 +    do_kernel_extract
  13.329 +    do_binutils_extract
  13.330 +    do_libc_extract
  13.331 +    do_libfloat_extract
  13.332 +    do_cc_core_extract
  13.333 +    do_cc_extract
  13.334 +    CT_EndStep
  13.335 +
  13.336 +    if [ "${CT_ONLY_EXTRACT}" != "y" ]; then
  13.337 +        do_libc_check_config
  13.338 +        do_kernel_check_config
  13.339 +        do_kernel_headers
  13.340 +        do_binutils
  13.341 +        do_libc_headers
  13.342 +        do_cc_core
  13.343 +        do_libfloat
  13.344 +        do_libc
  13.345 +        do_cc
  13.346 +        do_libc_finish
  13.347 +    fi
  13.348 +fi
  13.349  
  13.350  if [ -n "${CT_TARGET_ALIAS}" ]; then
  13.351      CT_DoLog EXTRA "Creating symlinks from \"${CT_TARGET}-*\" to \"${CT_TARGET_ALIAS}-*\""
    14.1 --- a/scripts/functions	Sun May 06 21:47:29 2007 +0000
    14.2 +++ b/scripts/functions	Mon May 07 09:04:02 2007 +0000
    14.3 @@ -218,3 +218,234 @@
    14.4  CT_DoYes() {
    14.5      yes "$1" || true
    14.6  }
    14.7 +
    14.8 +# Download an URL using wget
    14.9 +# Usage: CT_DoGetFileWget <URL>
   14.10 +CT_DoGetFileWget() {
   14.11 +    # Need to return true because it is legitimate to not find the tarball at
   14.12 +    # some of the provided URLs (think about snapshots, different layouts for
   14.13 +    # different gcc versions, etc...)
   14.14 +    # Some (very old!) FTP server might not support the passive mode, thus
   14.15 +    # retry without
   14.16 +    # With automated download as we are doing, it can be very dangerous to use
   14.17 +    # -c to continue the downloads. It's far better to simply overwrite the
   14.18 +    # destination file
   14.19 +    wget -nc --progress=dot:binary --tries=3 --passive-ftp "$1" || wget -nc --progress=dot:binary --tries=3 "$1" || true
   14.20 +}
   14.21 +
   14.22 +# Download an URL using curl
   14.23 +# Usage: CT_DoGetFileCurl <URL>
   14.24 +CT_DoGetFileCurl() {
   14.25 +	# Note: comments about wget method are also valid here
   14.26 +	# Plus: no good progreess indicator is available with curl,
   14.27 +	#       so output is consigned to oblivion
   14.28 +	curl --ftp-pasv -O --retry 3 "$1" >/dev/null || curl -O --retry 3 "$1" >/dev/null || true
   14.29 +}
   14.30 +
   14.31 +# Wrapper function to call one of curl or wget
   14.32 +# Usage: CT_DoGetFile <URL>
   14.33 +CT_DoGetFile() {
   14.34 +    local _wget=`which wget`
   14.35 +    local _curl=`which curl`
   14.36 +    case "${_wget},${_curl}" in
   14.37 +        ,)  CT_DoError "Could find neither wget nor curl";;
   14.38 +        ,*) CT_DoGetFileCurl "$1";;
   14.39 +        *)  CT_DoGetFileWget "$1";;
   14.40 +    esac
   14.41 +}
   14.42 +
   14.43 +# Download the file from one of the URLs passed as argument
   14.44 +# Usage: CT_GetFile <filename> <url> [<url> ...]
   14.45 +CT_GetFile() {
   14.46 +    local got_it
   14.47 +    local ext
   14.48 +    local url
   14.49 +    local file="$1"
   14.50 +    shift
   14.51 +
   14.52 +    # Do we already have it?
   14.53 +    ext=`CT_GetFileExtension "${file}"`
   14.54 +    if [ -n "${ext}" ]; then
   14.55 +        if [ "${CT_FORCE_DOWNLOAD}" = "y" ]; then
   14.56 +            rm -f "${CT_TARBALLS_DIR}/${file}${ext}"
   14.57 +        else
   14.58 +            return 0
   14.59 +        fi
   14.60 +    fi
   14.61 +
   14.62 +    CT_DoLog EXTRA "Retrieving \"${file}\""
   14.63 +    CT_Pushd "${CT_TARBALLS_DIR}"
   14.64 +    # File not yet downloaded, try to get it
   14.65 +    got_it=0
   14.66 +    if [ "${got_it}" != "y" ]; then
   14.67 +        # We'd rather have a bzip2'ed tarball, then gzipped, and finally plain tar.
   14.68 +        for ext in .tar.bz2 .tar.gz .tgz .tar; do
   14.69 +            # Try all urls in turn
   14.70 +            for url in "$@"; do
   14.71 +                case "${url}" in
   14.72 +                    *)  CT_DoLog EXTRA "Trying \"${url}/${file}${ext}\""
   14.73 +                        CT_DoGetFile "${url}/${file}${ext}" 2>&1 |CT_DoLog DEBUG
   14.74 +                        ;;
   14.75 +                esac
   14.76 +                [ -f "${file}${ext}" ] && got_it=1 && break 2 || true
   14.77 +            done
   14.78 +        done
   14.79 +    fi
   14.80 +    CT_Popd
   14.81 +
   14.82 +    CT_TestAndAbort "Could not download \"${file}\", and not present in \"${CT_TARBALLS_DIR}\"" ${got_it} -eq 0
   14.83 +}
   14.84 +
   14.85 +# Get the file name extension of a component
   14.86 +# Usage: CT_GetFileExtension <component_name-component_version>
   14.87 +# If found, echoes the extension to stdout
   14.88 +# If not found, echoes nothing on stdout.
   14.89 +CT_GetFileExtension() {
   14.90 +    local ext
   14.91 +    local file="$1"
   14.92 +    local got_it=1
   14.93 +
   14.94 +    CT_Pushd "${CT_TARBALLS_DIR}"
   14.95 +    for ext in .tar.gz .tar.bz2 .tgz .tar; do
   14.96 +        if [ -f "${file}${ext}" ]; then
   14.97 +            echo "${ext}"
   14.98 +            got_it=0
   14.99 +            break
  14.100 +        fi
  14.101 +    done
  14.102 +    CT_Popd
  14.103 +
  14.104 +    return 0
  14.105 +}
  14.106 +
  14.107 +# Extract a tarball and patch the resulting sources if necessary.
  14.108 +# Some tarballs need to be extracted in specific places. Eg.: glibc addons
  14.109 +# must be extracted in the glibc directory; uCLibc locales must be extracted
  14.110 +# in the extra/locale sub-directory of uClibc.
  14.111 +CT_ExtractAndPatch() {
  14.112 +    local file="$1"
  14.113 +    local base_file=`echo "${file}" |cut -d - -f 1`
  14.114 +    local ver_file=`echo "${file}" |cut -d - -f 2-`
  14.115 +    local official_patch_dir
  14.116 +    local custom_patch_dir
  14.117 +    local libc_addon
  14.118 +    local ext=`CT_GetFileExtension "${file}"`
  14.119 +    CT_TestAndAbort "\"${file}\" not found in \"${CT_TARBALLS_DIR}\"" -z "${ext}"
  14.120 +    local full_file="${CT_TARBALLS_DIR}/${file}${ext}"
  14.121 +
  14.122 +    CT_Pushd "${CT_SRC_DIR}"
  14.123 +
  14.124 +    # Add-ons need a little love, really.
  14.125 +    case "${file}" in
  14.126 +        glibc-[a-z]*-*)
  14.127 +            CT_TestAndAbort "Trying to extract the C-library addon/locales \"${file}\" when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
  14.128 +            cd "${CT_LIBC_FILE}"
  14.129 +            libc_addon=y
  14.130 +            [ -f ".${file}.extracted" ] && return 0
  14.131 +            touch ".${file}.extracted"
  14.132 +            ;;
  14.133 +        uClibc-locale-*)
  14.134 +            CT_TestAndAbort "Trying to extract the C-library addon/locales \"${file}\" when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
  14.135 +            cd "${CT_LIBC_FILE}/extra/locale"
  14.136 +            libc_addon=y
  14.137 +            [ -f ".${file}.extracted" ] && return 0
  14.138 +            touch ".${file}.extracted"
  14.139 +            ;;
  14.140 +    esac
  14.141 +
  14.142 +    # If the directory exists, then consider extraction and patching done
  14.143 +    [ -d "${file}" ] && return 0
  14.144 +
  14.145 +    CT_DoLog EXTRA "Extracting \"${file}\""
  14.146 +    case "${ext}" in
  14.147 +        .tar.bz2)     tar xvjf "${full_file}" |CT_DoLog DEBUG;;
  14.148 +        .tar.gz|.tgz) tar xvzf "${full_file}" |CT_DoLog DEBUG;;
  14.149 +        .tar)         tar xvf  "${full_file}" |CT_DoLog DEBUG;;
  14.150 +        *)            CT_Abort "Don't know how to handle \"${file}\": unknown extension" ;;
  14.151 +    esac
  14.152 +
  14.153 +    # Snapshots might not have the version number in the extracted directory
  14.154 +    # name. This is also the case for some (old) packages, such as libfloat.
  14.155 +    # Overcome this issue by symlink'ing the directory.
  14.156 +    if [ ! -d "${file}" -a "${libc_addon}" != "y" ]; then
  14.157 +        case "${ext}" in
  14.158 +            .tar.bz2)     base=`tar tjf "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
  14.159 +            .tar.gz|.tgz) base=`tar tzf "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
  14.160 +            .tar)         base=`tar tf  "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
  14.161 +        esac
  14.162 +        CT_TestOrAbort "There was a problem when extracting \"${file}\"" -d "${base}" -o "${base}" != "${file}"
  14.163 +        ln -s "${base}" "${file}"
  14.164 +    fi
  14.165 +
  14.166 +    # Kludge: outside this function, we wouldn't know if we had just extracted
  14.167 +    # a libc addon, or a plain package. Apply patches now.
  14.168 +    CT_DoLog EXTRA "Patching \"${file}\""
  14.169 +
  14.170 +    # If libc addon, we're already in the correct place.
  14.171 +    [ -z "${libc_addon}" ] && cd "${file}"
  14.172 +
  14.173 +    [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_TOP_DIR}/patches/${base_file}/${ver_file}"
  14.174 +    [ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}"
  14.175 +    for patch_dir in "${official_patch_dir}" "${custom_patch_dir}"; do
  14.176 +        if [ -n "${patch_dir}" -a -d "${patch_dir}" ]; then
  14.177 +            for p in "${patch_dir}"/*.patch; do
  14.178 +                if [ -f "${p}" ]; then
  14.179 +                    CT_DoLog DEBUG "Applying patch \"${p}\""
  14.180 +                    patch -g0 -F1 -p1 -f <"${p}" |CT_DoLog DEBUG
  14.181 +                    CT_TestAndAbort "Failed while applying patch file \"${p}\"" ${PIPESTATUS[0]} -ne 0
  14.182 +                fi
  14.183 +            done
  14.184 +        fi
  14.185 +    done
  14.186 +
  14.187 +    CT_Popd
  14.188 +}
  14.189 +
  14.190 +# Compute the target triplet from what is provided by the user
  14.191 +# Usage: CT_DoBuildTargetTriplet
  14.192 +# In fact this function takes the environment variables to build the target
  14.193 +# triplet. It is needed both by the normal build sequence, as well as the
  14.194 +# sample saving sequence.
  14.195 +CT_DoBuildTargetTriplet() {
  14.196 +    case "${CT_ARCH_BE},${CT_ARCH_LE}" in
  14.197 +        y,) target_endian_eb=eb; target_endian_el=;;
  14.198 +        ,y) target_endian_eb=; target_endian_el=el;;
  14.199 +    esac
  14.200 +    case "${CT_ARCH}" in
  14.201 +        arm)  CT_TARGET="${CT_ARCH}${target_endian_eb}";;
  14.202 +        mips) CT_TARGET="${CT_ARCH}${target_endian_el}";;
  14.203 +        x86*) # Much love for this one :-(
  14.204 +              # Ultimately, we should use config.sub to output the correct
  14.205 +              # procesor name. Work for later...
  14.206 +              arch="${CT_ARCH_ARCH}"
  14.207 +              [ -z "${arch}" ] && arch="${CT_ARCH_TUNE}"
  14.208 +              case "${CT_ARCH}" in
  14.209 +                  x86_64)      CT_TARGET=x86_64;;
  14.210 +              	  *)  case "${arch}" in
  14.211 +                          "")                                       CT_TARGET=i386;;
  14.212 +                          i386|i486|i586|i686)                      CT_TARGET="${arch}";;
  14.213 +                          winchip*)                                 CT_TARGET=i486;;
  14.214 +                          pentium|pentium-mmx|c3*)                  CT_TARGET=i586;;
  14.215 +                          nocona|athlon*64|k8|athlon-fx|opteron)    CT_TARGET=x86_64;;
  14.216 +                          pentiumpro|pentium*|athlon*)              CT_TARGET=i686;;
  14.217 +                          *)                                        CT_TARGET=i586;;
  14.218 +                      esac;;
  14.219 +              esac;;
  14.220 +    esac
  14.221 +    case "${CT_TARGET_VENDOR}" in
  14.222 +        "") CT_TARGET="${CT_TARGET}-unknown";;
  14.223 +        *)  CT_TARGET="${CT_TARGET}-${CT_TARGET_VENDOR}";;
  14.224 +    esac
  14.225 +    case "${CT_KERNEL}" in
  14.226 +        linux*)  CT_TARGET="${CT_TARGET}-linux";;
  14.227 +        cygwin*) CT_TARGET="${CT_TARGET}-cygwin";;
  14.228 +    esac
  14.229 +    case "${CT_LIBC}" in
  14.230 +        glibc)  CT_TARGET="${CT_TARGET}-gnu";;
  14.231 +        uClibc) CT_TARGET="${CT_TARGET}-uclibc";;
  14.232 +    esac
  14.233 +    case "${CT_ARCH_ABI}" in
  14.234 +        eabi)   CT_TARGET="${CT_TARGET}eabi";;
  14.235 +    esac
  14.236 +    CT_TARGET="`${CT_TOP_DIR}/tools/config.sub ${CT_TARGET}`"
  14.237 +}
    15.1 --- a/scripts/getExtractPatch.sh	Sun May 06 21:47:29 2007 +0000
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,334 +0,0 @@
    15.4 -# This script will download tarballs, extract them and patch the source.
    15.5 -# Copyright 2007 Yann E. MORIN
    15.6 -# Licensed under the GPL v2. See COPYING in the root of this package
    15.7 -
    15.8 -# Download tarballs in sequence. Once we have everything, start extracting
    15.9 -# and patching the tarballs.
   15.10 -
   15.11 -#-----------------------------------------------------------------------------
   15.12 -
   15.13 -_wget=`which wget || true`
   15.14 -_curl=`which curl || true`
   15.15 -#_svn=`which svn ||true`
   15.16 -#_cvs=`which cvs || true`
   15.17 -
   15.18 -case "${_wget},${_curl}" in
   15.19 -    ,)  CT_Abort "Found neither curl nor wget. Please install one.";;
   15.20 -    ,*) CT_DoLog DEBUG "Using curl to retrieve tarballs"; CT_DoGetFile=CT_DoGetFileCurl;;
   15.21 -    *)  CT_DoLog DEBUG "Using wget to retrieve tarballs"; CT_DoGetFile=CT_DoGetFileWget;;
   15.22 -esac
   15.23 -
   15.24 -CT_DoGetFileWget() {
   15.25 -    # Need to return true because it is legitimate to not find the tarball at
   15.26 -    # some of the provided URLs (think about snapshots, different layouts for
   15.27 -    # different gcc versions, etc...)
   15.28 -    # Some (very old!) FTP server might not support the passive mode, thus
   15.29 -    # retry without
   15.30 -    # With automated download as we are doing, it can be very dangerous to use
   15.31 -    # -c to continue the downloads. It's far better to simply overwrite the
   15.32 -    # destination file
   15.33 -    wget -nc --progress=dot:binary --tries=3 --passive-ftp "$1" || wget -nc --progress=dot:binary --tries=3 "$1" || true
   15.34 -}
   15.35 -
   15.36 -CT_DoGetFileCurl() {
   15.37 -	# Note: comments about wget method are also valid here
   15.38 -	# Plus: no good progreess indicator is available with curl,
   15.39 -	#       so output is consigned to oblivion
   15.40 -	curl --ftp-pasv -O --retry 3 "$1" >/dev/null || curl -O --retry 3 "$1" >/dev/null || true
   15.41 -}
   15.42 -
   15.43 -# For those wanting bleading edge, or to retrieve old uClibc snapshots
   15.44 -# Usage: CT_GetFileSVN basename url
   15.45 -#CT_DoGetFileSVN() {
   15.46 -#    local basename="$1"
   15.47 -#    local url="`echo \"$2\" |cut -d : -f 2-`"
   15.48 -#    local tmp_dir
   15.49 -#
   15.50 -#    CT_TestOrAbort "You don't have subversion" -n "${_svn}"
   15.51 -#    CT_MktempDir tmp_dir
   15.52 -#    CT_Pushd "${tmp_dir}"
   15.53 -#    svn export --force "${url}" "${basename}"
   15.54 -#    tar cfj "${CT_TARBALLS_DIR}/${basename}.tar.bz2" "${basename}"
   15.55 -#    CT_Popd
   15.56 -#    rm -rf "${tmp_dir}"
   15.57 -#}
   15.58 -#
   15.59 -#CT_DoGetFileCVS() {
   15.60 -#    :
   15.61 -#}
   15.62 -
   15.63 -# Download the file from one of the URLs passed as argument
   15.64 -# Usage: CT_GetFile <filename> <url> [<url> ...]
   15.65 -CT_GetFile() {
   15.66 -    local got_it
   15.67 -    local ext
   15.68 -    local url
   15.69 -    local file="$1"
   15.70 -    shift
   15.71 -
   15.72 -    # Do we already have it?
   15.73 -    ext=`CT_GetFileExtension "${file}"`
   15.74 -    if [ -n "${ext}" ]; then
   15.75 -        if [ "${CT_FORCE_DOWNLOAD}" = "y" ]; then
   15.76 -            rm -f "${CT_TARBALLS_DIR}/${file}${ext}"
   15.77 -        else
   15.78 -            return 0
   15.79 -        fi
   15.80 -    fi
   15.81 -
   15.82 -    CT_DoLog EXTRA "Retrieving \"${file}\""
   15.83 -    CT_Pushd "${CT_TARBALLS_DIR}"
   15.84 -    # File not yet downloaded, try to get it
   15.85 -    got_it=0
   15.86 -    if [ "${got_it}" != "y" ]; then
   15.87 -        # We'd rather have a bzip2'ed tarball, then gzipped, and finally plain tar.
   15.88 -        for ext in .tar.bz2 .tar.gz .tgz .tar; do
   15.89 -            # Try all urls in turn
   15.90 -            for url in "$@"; do
   15.91 -                case "${url}" in
   15.92 -#                    svn://*)    CT_DoGetFileSVN "${file}" ${url}";;
   15.93 -#                    cvs://*)    CT_DoGetFileCVS "${file}" ${url}";;
   15.94 -                    *)  CT_DoLog EXTRA "Trying \"${url}/${file}${ext}\""
   15.95 -                        ${CT_DoGetFile} "${url}/${file}${ext}" 2>&1 |CT_DoLog DEBUG
   15.96 -                        ;;
   15.97 -                esac
   15.98 -                [ -f "${file}${ext}" ] && got_it=1 && break 2 || true
   15.99 -            done
  15.100 -        done
  15.101 -    fi
  15.102 -    CT_Popd
  15.103 -
  15.104 -    CT_TestAndAbort "Could not download \"${file}\", and not present in \"${CT_TARBALLS_DIR}\"" ${got_it} -eq 0
  15.105 -}
  15.106 -
  15.107 -#-----------------------------------------------------------------------------
  15.108 -
  15.109 -# Extract a tarball and patch.
  15.110 -# Some tarballs need to be extracted in specific places. Eg.: glibc addons
  15.111 -# must be extracted in the glibc directory; uCLibc locales must be extracted
  15.112 -# in the extra/locale sub-directory of uClibc.
  15.113 -CT_ExtractAndPatch() {
  15.114 -    local file="$1"
  15.115 -    local base_file=`echo "${file}" |cut -d - -f 1`
  15.116 -    local ver_file=`echo "${file}" |cut -d - -f 2-`
  15.117 -    local official_patch_dir
  15.118 -    local custom_patch_dir
  15.119 -    local libc_addon
  15.120 -    local ext=`CT_GetFileExtension "${file}"`
  15.121 -    CT_TestAndAbort "\"${file}\" not found in \"${CT_TARBALLS_DIR}\"" -z "${ext}"
  15.122 -    local full_file="${CT_TARBALLS_DIR}/${file}${ext}"
  15.123 -
  15.124 -    CT_Pushd "${CT_SRC_DIR}"
  15.125 -
  15.126 -    # Add-ons need a little love, really.
  15.127 -    case "${file}" in
  15.128 -        glibc-[a-z]*-*)
  15.129 -            CT_TestAndAbort "Trying to extract the C-library addon/locales \"${file}\" when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
  15.130 -            cd "${CT_LIBC_FILE}"
  15.131 -            libc_addon=y
  15.132 -            [ -f ".${file}.extracted" ] && return 0
  15.133 -            touch ".${file}.extracted"
  15.134 -            ;;
  15.135 -        uClibc-locale-*)
  15.136 -            CT_TestAndAbort "Trying to extract the C-library addon/locales \"${file}\" when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
  15.137 -            cd "${CT_LIBC_FILE}/extra/locale"
  15.138 -            libc_addon=y
  15.139 -            [ -f ".${file}.extracted" ] && return 0
  15.140 -            touch ".${file}.extracted"
  15.141 -            ;;
  15.142 -    esac
  15.143 -
  15.144 -    # If the directory exists, then consider extraction and patching done
  15.145 -    [ -d "${file}" ] && return 0
  15.146 -
  15.147 -    CT_DoLog EXTRA "Extracting \"${file}\""
  15.148 -    case "${ext}" in
  15.149 -        .tar.bz2)     tar xvjf "${full_file}" |CT_DoLog DEBUG;;
  15.150 -        .tar.gz|.tgz) tar xvzf "${full_file}" |CT_DoLog DEBUG;;
  15.151 -        .tar)         tar xvf  "${full_file}" |CT_DoLog DEBUG;;
  15.152 -        *)            CT_Abort "Don't know how to handle \"${file}\": unknown extension" ;;
  15.153 -    esac
  15.154 -
  15.155 -    # Snapshots might not have the version number in the extracted directory
  15.156 -    # name. This is also the case for some (old) packages, such as libfloat.
  15.157 -    # Overcome this issue by symlink'ing the directory.
  15.158 -    if [ ! -d "${file}" -a "${libc_addon}" != "y" ]; then
  15.159 -        case "${ext}" in
  15.160 -            .tar.bz2)     base=`tar tjf "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
  15.161 -            .tar.gz|.tgz) base=`tar tzf "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
  15.162 -            .tar)         base=`tar tf  "${full_file}" |head -n 1 |cut -d / -f 1 || true`;;
  15.163 -        esac
  15.164 -        CT_TestOrAbort "There was a problem when extracting \"${file}\"" -d "${base}" -o "${base}" != "${file}"
  15.165 -        ln -s "${base}" "${file}"
  15.166 -    fi
  15.167 -
  15.168 -    # Kludge: outside this function, we wouldn't know if we had just extracted
  15.169 -    # a libc addon, or a plain package. Apply patches now.
  15.170 -    CT_DoLog EXTRA "Patching \"${file}\""
  15.171 -
  15.172 -    # If libc addon, we're already in the correct place.
  15.173 -    [ -z "${libc_addon}" ] && cd "${file}"
  15.174 -
  15.175 -    [ "${CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_TOP_DIR}/patches/${base_file}/${ver_file}"
  15.176 -    [ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}"
  15.177 -    for patch_dir in "${official_patch_dir}" "${custom_patch_dir}"; do
  15.178 -        if [ -n "${patch_dir}" -a -d "${patch_dir}" ]; then
  15.179 -            for p in "${patch_dir}"/*.patch; do
  15.180 -                if [ -f "${p}" ]; then
  15.181 -                    CT_DoLog DEBUG "Applying patch \"${p}\""
  15.182 -                    patch -g0 -F1 -p1 -f <"${p}" |CT_DoLog DEBUG
  15.183 -                    CT_TestAndAbort "Failed while applying patch file \"${p}\"" ${PIPESTATUS[0]} -ne 0
  15.184 -                fi
  15.185 -            done
  15.186 -        fi
  15.187 -    done
  15.188 -
  15.189 -    CT_Popd
  15.190 -}
  15.191 -
  15.192 -#-----------------------------------------------------------------------------
  15.193 -
  15.194 -# Get the file name extension of a component
  15.195 -# Usage: CT_GetFileExtension <component-version>
  15.196 -# If found, echoes the extension to stdout
  15.197 -# If not found, echoes nothing on stdout.
  15.198 -CT_GetFileExtension() {
  15.199 -    local ext
  15.200 -    local file="$1"
  15.201 -    local got_it=1
  15.202 -
  15.203 -    CT_Pushd "${CT_TARBALLS_DIR}"
  15.204 -    for ext in .tar.gz .tar.bz2 .tgz .tar; do
  15.205 -        if [ -f "${file}${ext}" ]; then
  15.206 -            echo "${ext}"
  15.207 -            got_it=0
  15.208 -            break
  15.209 -        fi
  15.210 -    done
  15.211 -    CT_Popd
  15.212 -
  15.213 -    return 0
  15.214 -}
  15.215 -
  15.216 -#-----------------------------------------------------------------------------
  15.217 -
  15.218 -# Create needed directories, remove old ones
  15.219 -mkdir -p "${CT_TARBALLS_DIR}"
  15.220 -if [ "${CT_FORCE_EXTRACT}" = "y" -a -d "${CT_SRC_DIR}" ]; then
  15.221 -    mv "${CT_SRC_DIR}" "${CT_SRC_DIR}.$$"
  15.222 -    nohup rm -rf "${CT_SRC_DIR}.$$" >/dev/null 2>&1 &
  15.223 -fi
  15.224 -mkdir -p "${CT_SRC_DIR}"
  15.225 -
  15.226 -# Make all path absolute, it so much easier!
  15.227 -# Now we have had the directories created, we even will get rid of embedded .. in paths:
  15.228 -CT_SRC_DIR="`CT_MakeAbsolutePath \"${CT_SRC_DIR}\"`"
  15.229 -CT_TARBALLS_DIR="`CT_MakeAbsolutePath \"${CT_TARBALLS_DIR}\"`"
  15.230 -
  15.231 -# Prepare the addons list to be parsable:
  15.232 -addons_list="`echo \"${CT_LIBC_ADDONS_LIST}\" |sed -r -e 's/,/ /g; s/ $//g;'`"
  15.233 -
  15.234 -if [ "${CT_NO_DOWNLOAD}" != "y" ]; then
  15.235 -    CT_DoStep INFO "Retrieving needed toolchain components' tarballs"
  15.236 -
  15.237 -    # Kernel: for now, I don't care about cygwin.
  15.238 -    if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" != "y" ]; then
  15.239 -        CT_GetFile "${CT_KERNEL_FILE}"                                  \
  15.240 -                   ftp://ftp.kernel.org/pub/linux/kernel/v2.6           \
  15.241 -                   ftp://ftp.kernel.org/pub/linux/kernel/v2.4           \
  15.242 -                   ftp://ftp.kernel.org/pub/linux/kernel/v2.2           \
  15.243 -                   ftp://ftp.kernel.org/pub/linux/kernel/v2.6/testing   \
  15.244 -                   http://ep09.pld-linux.org/~mmazur/linux-libc-headers
  15.245 -    fi
  15.246 -
  15.247 -    # binutils
  15.248 -    CT_GetFile "${CT_BINUTILS_FILE}"                            \
  15.249 -               ftp://ftp.gnu.org/gnu/binutils                   \
  15.250 -               ftp://ftp.kernel.org/pub/linux/devel/binutils
  15.251 -
  15.252 -    # Core and final gcc
  15.253 -    # Ah! gcc folks are kind of 'different': they store the tarballs in
  15.254 -    # subdirectories of the same name! That's because gcc is such /crap/ that
  15.255 -    # it is such /big/ that it needs being splitted for distribution! Sad. :-(
  15.256 -    # Arrgghh! Some of those versions does not follow this convention:
  15.257 -    # gcc-3.3.3 lives in releases/gcc-3.3.3, while gcc-2.95.* isn't in a
  15.258 -    # subdirectory! You bastard!
  15.259 -    CT_GetFile "${CT_CC_CORE_FILE}"                                    \
  15.260 -               ftp://ftp.gnu.org/gnu/gcc/${CT_CC_CORE_FILE}            \
  15.261 -               ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_CORE_FILE}   \
  15.262 -               ftp://ftp.gnu.org/gnu/gcc
  15.263 -    CT_GetFile "${CT_CC_FILE}"                                  \
  15.264 -               ftp://ftp.gnu.org/gnu/gcc/${CT_CC_FILE}          \
  15.265 -               ftp://ftp.gnu.org/gnu/gcc/releases/${CT_CC_FILE} \
  15.266 -               ftp://ftp.gnu.org/gnu/gcc
  15.267 -
  15.268 -    # C library
  15.269 -    case "${CT_LIBC}" in
  15.270 -        glibc)
  15.271 -            # Ah! Not all GNU folks seem stupid. All glibc releases are in the same
  15.272 -            # directory. Good. Alas, there is no snapshot there. I'll deal with them
  15.273 -            # later on... :-/
  15.274 -            libc_src="ftp://ftp.gnu.org/gnu/glibc"
  15.275 -            ;;
  15.276 -        uClibc)
  15.277 -            # For uClibc, we have almost every thing: releases, and snapshots
  15.278 -            # for the last month or so. We'll have to deal with svn revisions
  15.279 -            # later...
  15.280 -            libc_src="http://www.uclibc.org/downloads
  15.281 -                      http://www.uclibc.org/downloads/snapshots
  15.282 -                      http://www.uclibc.org/downloads/old-releases"
  15.283 -            ;;
  15.284 -    esac
  15.285 -    CT_GetFile "${CT_LIBC_FILE}" ${libc_src}
  15.286 -
  15.287 -    # C library addons
  15.288 -    addons_list=`echo "${CT_LIBC_ADDONS}" |sed -r -e 's/,/ /g; s/ $//g;'`
  15.289 -    for addon in ${addons_list}; do
  15.290 -        CT_GetFile "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}" ${libc_src}
  15.291 -    done
  15.292 -    [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_GetFile "${CT_LIBC}-ports-${CT_LIBC_VERSION}" ${libc_src}
  15.293 -    [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] && CT_GetFile "uClibc-locale-030818" ${libc_src}
  15.294 -
  15.295 -    # libfloat if asked for
  15.296 -    if [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ]; then
  15.297 -        lib_float_url="ftp://ftp.de.debian.org/debian/pool/main/libf/libfloat/"
  15.298 -
  15.299 -        # Please note: because the file we download, and the file we store on the
  15.300 -        # file system don't have the same name, CT_GetFile will always try to
  15.301 -        # download the file over and over.
  15.302 -        # To avoid this, we check that the file we want already exists in the
  15.303 -        # tarball directory first. This is an ugly hack that overrides the standard
  15.304 -        # CT_GetFile behavior... Sight...
  15.305 -        ext=`CT_GetFileExtension "${CT_LIBFLOAT_FILE}"`
  15.306 -        if [ -z "${ext}" ]; then
  15.307 -            CT_GetFile libfloat_990616.orig "${lib_float_url}"
  15.308 -            ext=`CT_GetFileExtension "libfloat_990616.orig"`
  15.309 -            # Hack: remove the .orig extension, and change _ to -
  15.310 -            mv -v "${CT_TARBALLS_DIR}/libfloat_990616.orig${ext}" \
  15.311 -                  "${CT_TARBALLS_DIR}/libfloat-990616${ext}"      2>&1 |CT_DoLog DEBUG
  15.312 -        fi
  15.313 -    fi
  15.314 -    
  15.315 -    CT_EndStep
  15.316 -fi # CT_NO_DOWNLOAD
  15.317 -
  15.318 -if [ "${CT_ONLY_DOWNLOAD}" != "y" ]; then
  15.319 -    CT_DoStep INFO "Extracting and patching toolchain components"
  15.320 -
  15.321 -    if [ "${CT_KERNEL_LINUX_HEADERS_USE_CUSTOM_DIR}" != "y" ]; then
  15.322 -        CT_ExtractAndPatch "${CT_KERNEL_FILE}"
  15.323 -    fi
  15.324 -    CT_ExtractAndPatch "${CT_BINUTILS_FILE}"
  15.325 -    CT_ExtractAndPatch "${CT_CC_CORE_FILE}"
  15.326 -    CT_ExtractAndPatch "${CT_CC_FILE}"
  15.327 -    CT_ExtractAndPatch "${CT_LIBC_FILE}"
  15.328 -    for addon in ${addons_list}; do
  15.329 -        CT_ExtractAndPatch "${CT_LIBC}-${addon}-${CT_LIBC_VERSION}"
  15.330 -    done
  15.331 -    [ "${CT_LIBC_GLIBC_USE_PORTS}" = "y" ] && CT_ExtractAndPatch "${CT_LIBC}-ports-${CT_LIBC_VERSION}"
  15.332 -    [ "${CT_LIBC_UCLIBC_LOCALES}" = "y" ] && CT_ExtractAndPatch "uClibc-locale-030818"
  15.333 -
  15.334 -    [ "${CT_ARCH_FLOAT_SW_LIBFLOAT}" = "y" ] && CT_ExtractAndPatch "${CT_LIBFLOAT_FILE}"
  15.335 -
  15.336 -    CT_EndStep
  15.337 -fi
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/scripts/saveSample.sh	Mon May 07 09:04:02 2007 +0000
    16.3 @@ -0,0 +1,70 @@
    16.4 +#!/bin/bash
    16.5 +
    16.6 +# This script is responsible for saving the current configuration into a
    16.7 +# sample to be used later on as a pre-configured target.
    16.8 +
    16.9 +# What we need to save:
   16.10 +#  - the .config file
   16.11 +#  - the kernel .config file if specified
   16.12 +#  - the uClibc .config file if uClibc selected
   16.13 +
   16.14 +. "${CT_TOP_DIR}/scripts/functions"
   16.15 +
   16.16 +# Log to a temporary file until we have built our environment
   16.17 +CT_ACTUAL_LOG_FILE="${CT_TOP_DIR}/$$.log"
   16.18 +CT_LOG_INFO=y
   16.19 +CT_LOG_LEVEL_MAX="INFO"
   16.20 +
   16.21 +# Parse the configuration file
   16.22 +CT_TestOrAbort "Configuration file not found. Please create one." -f "${CT_TOP_DIR}/.config"
   16.23 +. "${CT_TOP_DIR}/.config"
   16.24 +
   16.25 +# Override log level
   16.26 +unset CT_LOG_ERROR CT_LOG_WARN CT_LOG_EXTRA CT_LOG_DEBUG 
   16.27 +CT_LOG_INFO=y
   16.28 +CT_LOG_LEVEL_MAX="INFO"
   16.29 +
   16.30 +# Target triplet: CT_TARGET needs a little love:
   16.31 +CT_DoBuildTargetTriplet
   16.32 +
   16.33 +# Create the sample directory
   16.34 +[ -d "${CT_TOP_DIR}/samples/${CT_TARGET}" ] || svn mkdir "${CT_TOP_DIR}/samples/${CT_TARGET}" >/dev/null 2>&1
   16.35 +
   16.36 +# Save the crosstool-NG config file
   16.37 +cp "${CT_TOP_DIR}/.config" "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
   16.38 +
   16.39 +# Save the kernel .config file
   16.40 +if [ -n "${CT_KERNEL_LINUX_CONFIG_FILE}" ]; then
   16.41 +    # We save the file, and then point the saved sample to this file
   16.42 +    cp "${CT_KERNEL_LINUX_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"
   16.43 +    svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config" >/dev/null 2>&1
   16.44 +    sed -r -i -e 's|^(CT_KERNEL_LINUX_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-${CT_KERNEL_VERSION}.config"|;' \
   16.45 +        "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
   16.46 +else
   16.47 +    # remove any dangling files
   16.48 +    for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_KERNEL}-"*.config; do
   16.49 +        if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi
   16.50 +    done
   16.51 +fi
   16.52 +
   16.53 +# Save the uClibc .config file
   16.54 +if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then
   16.55 +    # We save the file, and then point the saved sample to this file
   16.56 +    cp "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"
   16.57 +    svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config" >/dev/null 2>&1
   16.58 +    sed -r -i -e 's|^(CT_LIBC_UCLIBC_CONFIG_FILE=).+$|\1"${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-${CT_LIBC_VERSION}.config"|;' \
   16.59 +        "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config"
   16.60 +else
   16.61 +    # remove any dangling files
   16.62 +    for f in "${CT_TOP_DIR}/samples/${CT_TARGET}/${CT_LIBC}-"*.config; do
   16.63 +        if [ -f "${f}" ]; then svn rm --force "${f}" >/dev/null 2>&1; fi
   16.64 +    done
   16.65 +fi
   16.66 +
   16.67 +# We could svn add earlier, but it's better to
   16.68 +# add a frozen file than modifying it later
   16.69 +svn add "${CT_TOP_DIR}/samples/${CT_TARGET}/crosstool.config" >/dev/null 2>&1
   16.70 +
   16.71 +svn stat "${CT_TOP_DIR}/samples/${CT_TARGET}" 2>/dev/null |CT_DoLog INFO
   16.72 +
   16.73 +rm -f "${CT_ACTUAL_LOG_FILE}"
    17.1 --- a/tools/Makefile	Sun May 06 21:47:29 2007 +0000
    17.2 +++ b/tools/Makefile	Mon May 07 09:04:02 2007 +0000
    17.3 @@ -9,3 +9,4 @@
    17.4  
    17.5  help::
    17.6  	@echo  '  updatetools    - Update the config tools'
    17.7 +	@echo  ''