# HG changeset patch # User Yann Diorcet # Date 1353320491 -3600 # Node ID 6a5946fbc7289868ab73447412ef97e83abe6f2a # Parent 23fbfabd8a0fb740db98285a96ab50784be82fca binutils: introduce the infrastructure to support binutils alternatives Rework binutils in order to provide soon binutils alternative. Signed-off-by: Yann Diorcet [yann.morin.1998@free.fr: split up original patch for self-contained changes] Signed-off-by: "Yann E. MORIN" Message-Id: Patchwork-Id: 199971 diff -r 23fbfabd8a0f -r 6a5946fbc728 config/binutils.in --- a/config/binutils.in Mon Nov 19 23:24:49 2012 +0100 +++ b/config/binutils.in Mon Nov 19 11:21:31 2012 +0100 @@ -33,7 +33,10 @@ endchoice -source "config/binutils/binutils.in" -source "config/binutils/elf2flt.in" +config BINUTILS + string + +source "config.gen/binutils.in" +source "config.gen/binutils.in.2" endmenu diff -r 23fbfabd8a0f -r 6a5946fbc728 config/binutils/binutils.in.2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/binutils/binutils.in.2 Mon Nov 19 11:21:31 2012 +0100 @@ -0,0 +1,56 @@ +# elf2flt options + +if ARCH_BINFMT_FLAT + +comment "elf2flt" + +choice + bool + prompt "elf2flt version" +# Don't remove next line +# CT_INSERT_VERSION_BELOW + +config ELF2FLT_CVSHEAD + bool + prompt "CVS Head" + help + Grab the latest version of elf2flt from the CVS repository + +config ELF2FLT_CUSTOM + bool + prompt "Custom elf2flt" + depends on EXPERIMENTAL + +endchoice + +if ELF2FLT_CUSTOM + +config ELF2FLT_CUSTOM_LOCATION + string + prompt "Full path to custom elf2flt source" + default "" + help + Enter the path to the directory (or tarball) of your source for elf2flt, + or leave blank to use default CT_CUSTOM_LOCATION_ROOT_DIR/elf2flt + +endif # ELF2FLT_CUSTOM + +config ELF2FLT_VERSION + string + default "cvs" if ELF2FLT_CVSHEAD + default "custom" if ELF2FLT_CUSTOM +# Don't remove next line +# CT_INSERT_VERSION_STRING_BELOW + +config ELF2FLT_EXTRA_CONFIG_ARRAY + string + prompt "elf2flt extra config" + default "" + help + Extra flags passed onto ./configure when configuring + + You can enter multiple arguments here, and arguments can contain spaces + if they are properly quoted (or escaped, but prefer quotes). Eg.: + --with-foo="1st arg with 4 spaces" --with-bar=2nd-arg-without-space + +endif diff -r 23fbfabd8a0f -r 6a5946fbc728 config/binutils/elf2flt.in --- a/config/binutils/elf2flt.in Mon Nov 19 23:24:49 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -# elf2flt options - -if ARCH_BINFMT_FLAT - -comment "elf2flt" - -choice - bool - prompt "elf2flt version" -# Don't remove next line -# CT_INSERT_VERSION_BELOW - -config ELF2FLT_CVSHEAD - bool - prompt "CVS Head" - help - Grab the latest version of elf2flt from the CVS repository - -config ELF2FLT_CUSTOM - bool - prompt "Custom elf2flt" - depends on EXPERIMENTAL - -endchoice - -if ELF2FLT_CUSTOM - -config ELF2FLT_CUSTOM_LOCATION - string - prompt "Full path to custom elf2flt source" - default "" - help - Enter the path to the directory (or tarball) of your source for elf2flt, - or leave blank to use default CT_CUSTOM_LOCATION_ROOT_DIR/elf2flt - -endif # ELF2FLT_CUSTOM - -config ELF2FLT_VERSION - string - default "cvs" if ELF2FLT_CVSHEAD - default "custom" if ELF2FLT_CUSTOM -# Don't remove next line -# CT_INSERT_VERSION_STRING_BELOW - -config ELF2FLT_EXTRA_CONFIG_ARRAY - string - prompt "elf2flt extra config" - default "" - help - Extra flags passed onto ./configure when configuring - - You can enter multiple arguments here, and arguments can contain spaces - if they are properly quoted (or escaped, but prefer quotes). Eg.: - --with-foo="1st arg with 4 spaces" --with-bar=2nd-arg-without-space - -endif diff -r 23fbfabd8a0f -r 6a5946fbc728 config/config.mk --- a/config/config.mk Mon Nov 19 23:24:49 2012 +0100 +++ b/config/config.mk Mon Nov 19 11:21:31 2012 +0100 @@ -21,6 +21,8 @@ KERNEL_CONFIG_FILES_2 = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/kernel/*.in.2)) CC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in)) CC_CONFIG_FILES_2 = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/cc/*.in.2)) +BINUTILS_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/binutils/*.in)) +BINUTILS_CONFIG_FILES_2 = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/binutils/*.in.2)) LIBC_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in)) LIBC_CONFIG_FILES_2 = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/libc/*.in.2)) DEBUG_CONFIG_FILES = $(patsubst $(CT_LIB_DIR)/%,%,$(wildcard $(CT_LIB_DIR)/config/debug/*.in)) @@ -29,6 +31,7 @@ GEN_CONFIG_FILES = config.gen/arch.in \ config.gen/kernel.in \ config.gen/cc.in \ + config.gen/binutils.in \ config.gen/libc.in \ config.gen/debug.in # ... and how to access them: @@ -61,6 +64,7 @@ ARCHS = $(patsubst config/arch/%.in,%,$(ARCH_CONFIG_FILES)) KERNELS = $(patsubst config/kernel/%.in,%,$(KERNEL_CONFIG_FILES)) CCS = $(patsubst config/cc/%.in,%,$(CC_CONFIG_FILES)) +BINUTILSS = $(patsubst config/binutils/%.in,%,$(BINUTILS_CONFIG_FILES)) LIBCS = $(patsubst config/libc/%.in,%,$(LIBC_CONFIG_FILES)) DEBUGS = $(patsubst config/debug/%.in,%,$(DEBUG_CONFIG_FILES)) @@ -81,6 +85,10 @@ @$(ECHO) ' IN $(@)' $(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C compiler" "CC" "config/cc" "N" $(CCS) +config.gen/binutils.in: $(CC_BINUTILS_FILES) $(CC_BINUTILS_FILES_2) + @$(ECHO) ' IN $(@)' + $(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "Binutils" "BINUTILS" "config/binutils" "N" $(BINUTILSS) + config.gen/libc.in: $(LIBC_CONFIG_FILES) $(LIBC_CONFIG_FILES_2) @$(ECHO) ' IN $(@)' $(SILENT)$(CT_LIB_DIR)/scripts/gen_in_frags.sh choice "$@" "C library" "LIBC" "config/libc" "Y" $(LIBCS) diff -r 23fbfabd8a0f -r 6a5946fbc728 scripts/build/binutils/binutils.sh --- a/scripts/build/binutils/binutils.sh Mon Nov 19 23:24:49 2012 +0100 +++ b/scripts/build/binutils/binutils.sh Mon Nov 19 11:21:31 2012 +0100 @@ -12,6 +12,14 @@ {ftp,http}://{ftp.gnu.org/gnu,ftp.kernel.org/pub/linux/devel}/binutils \ ftp://gcc.gnu.org/pub/binutils/{releases,snapshots} fi + + if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then + CT_GetCVS "elf2flt-${CT_ELF2FLT_VERSION}" \ + ":pserver:anonymous@cvs.uclinux.org:/var/cvs" \ + "elf2flt" \ + "" \ + "elf2flt-${CT_ELF2FLT_VERSION}" + fi } # Extract binutils @@ -24,6 +32,11 @@ CT_Extract "binutils-${CT_BINUTILS_VERSION}" CT_Patch "binutils" "${CT_BINUTILS_VERSION}" + + if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then + CT_Extract "elf2flt-${CT_ELF2FLT_VERSION}" + CT_Patch "elf2flt" "${CT_ELF2FLT_VERSION}" + fi } # Build binutils for build -> target @@ -45,6 +58,19 @@ do_binutils_backend "${binutils_opts[@]}" CT_Popd + + if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then + # We re-use binutils' options, plus our owns + binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" ) + binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_BUILD}" ) + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-build-${CT_BUILD}" + + do_elf2flt_backend "${binutils_opts[@]}" + + CT_Popd + fi + CT_EndStep } @@ -65,6 +91,20 @@ do_binutils_backend "${binutils_opts[@]}" + CT_Popd + + if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then + # We re-use binutils' options, plus our owns + binutils_opts+=( "binutils_src=${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" ) + binutils_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" ) + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}" + + do_elf2flt_backend "${binutils_opts[@]}" + + CT_Popd + fi + # Make those new tools available to the core C compilers to come. # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as # well. Create that. @@ -73,6 +113,9 @@ case "${CT_TOOLCHAIN_TYPE}" in cross|native) binutils_tools=( ar as ld strip ) + if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then + binutils_tools+=( elf2flt flthdr ) + fi case "${CT_BINUTILS_LINKERS_LIST}" in ld) binutils_tools+=( ld.bfd ) ;; gold) binutils_tools+=( ld.gold ) ;; @@ -93,7 +136,6 @@ *) ;; esac - CT_Popd CT_EndStep } @@ -218,6 +260,54 @@ fi } +# Build elf2flt for X -> target +# Parameter : description : type : default +# host : machine to run on : tuple : (none) +# prefix : prefix to install into : dir : (none) +# static_build : build statcially : bool : no +# cflags : cflags to use : string : (empty) +# ldflags : ldflags to use : string : (empty) +# binutils_src : source dir of binutils : dir : (none) +# binutils_bld : build dir of binutils : dir : (none) +# build_manuals : whether to build manuals : bool : no +do_elf2flt_backend() { + local host + local prefix + local static_build + local cflags + local ldflags + local binutils_bld + local binutils_src + local build_manuals + local arg + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Configuring elf2flt" + CT_DoExecLog CFG \ + CFLAGS="${cflags}" \ + LDFLAGS="${ldflags}" \ + "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure" \ + --build=${CT_BUILD} \ + --host=${host} \ + --target=${CT_TARGET} \ + --prefix=${prefix} \ + --with-bfd-include-dir=${binutils_bld}/bfd \ + --with-binutils-include-dir=${binutils_src}/include \ + --with-libbfd=${binutils_bld}/bfd/libbfd.a \ + --with-libiberty=${binutils_bld}/libiberty/libiberty.a \ + ${elf2flt_opts} \ + "${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}" + + CT_DoLog EXTRA "Building elf2flt" + CT_DoExecLog ALL make ${JOBSFLAGS} + + CT_DoLog EXTRA "Installing elf2flt" + CT_DoExecLog ALL make install +} + # Now on for the target libraries do_binutils_for_target() { local -a extra_config diff -r 23fbfabd8a0f -r 6a5946fbc728 scripts/build/binutils/elf2flt.sh --- a/scripts/build/binutils/elf2flt.sh Mon Nov 19 23:24:49 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,149 +0,0 @@ -# This file adds functions to build elf2flt -# Copyright 2009 John Williams -# Copyright 2007 Yann E. MORIN -# Licensed under the GPL v2. See COPYING in the root of this package - -# Default: do nothing -do_elf2flt_get() { :; } -do_elf2flt_extract() { :; } -do_elf2flt_for_build() { :; } -do_elf2flt_for_host() { :; } - -if [ -n "${CT_ARCH_BINFMT_FLAT}" ]; then - -# Download elf2flt -do_elf2flt_get() { - if [ "${CT_ELF2FLT_CUSTOM}" = "y" ]; then - CT_GetCustom "elf2flt" "${ELF2FLT_VERSION}" \ - "${CT_ELF2FLT_CUSTOM_LOCATION}" - else - CT_GetCVS "elf2flt-${CT_ELF2FLT_VERSION}" \ - ":pserver:anonymous@cvs.uclinux.org:/var/cvs" \ - "elf2flt" \ - "" \ - "elf2flt-${CT_ELF2FLT_VERSION}" - fi -} - -# Extract elf2flt -do_elf2flt_extract() { - # If using custom directory location, nothing to do - if [ "${CT_ELF2FLT_CUSTOM}" = "y" \ - -a -d "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}" ]; then - return 0 - fi - CT_Extract "elf2flt-${CT_ELF2FLT_VERSION}" - CT_Patch "elf2flt" "${CT_ELF2FLT_VERSION}" -} - -# Build elf2flt for build -> target -do_elf2flt_for_build() { - local -a elf2flt_opts - - case "${CT_TOOLCHAIN_TYPE}" in - native|cross) return 0;; - esac - - CT_DoStep INFO "Installing elf2flt for build" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-build-${CT_BUILD}" - - elf2flt_opts+=( "host=${CT_BUILD}" ) - elf2flt_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) - elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) - elf2flt_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) - elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-build-${CT_HOST}" ) - - do_elf2flt_backend "${elf2flt_opts[@]}" - - CT_Popd - CT_EndStep -} - -# Build elf2flt for host -> target -do_elf2flt_for_host() { - local -a elf2flt_opts - - CT_DoStep INFO "Installing elf2flt for host" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-elf2flt-host-${CT_HOST}" - - elf2flt_opts+=( "host=${CT_HOST}" ) - elf2flt_opts+=( "prefix=${CT_PREFIX_DIR}" ) - elf2flt_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" ) - elf2flt_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) - elf2flt_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) - elf2flt_opts+=( "binutils_bld=${CT_BUILD_DIR}/build-binutils-host-${CT_HOST}" ) - - do_elf2flt_backend "${elf2flt_opts[@]}" - - # Make those new tools available to the core C compilers to come. - # Note: some components want the ${TARGET}-{ar,as,ld,strip} commands as - # well. Create that. - # Don't do it for canadian or cross-native, because the binutils - # are not executable on the build machine. - case "${CT_TOOLCHAIN_TYPE}" in - cross|native) - mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin" - mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin" - for t in elf2flt flthdr; do - CT_DoExecLog ALL ln -sv \ - "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \ - "${CT_BUILDTOOLS_PREFIX_DIR}/${CT_TARGET}/bin/${t}" - CT_DoExecLog ALL ln -sv \ - "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${t}" \ - "${CT_BUILDTOOLS_PREFIX_DIR}/bin/${CT_TARGET}-${t}" - done - ;; - *) ;; - esac - - CT_Popd - CT_EndStep -} - -# Build elf2flt for X -> target -# Parameter : description : type : default -# host : machine to run on : tuple : (none) -# prefix : prefix to install into : dir : (none) -# static_build : build statcially : bool : no -# cflags : cflags to use : string : (empty) -# ldflags : ldflags to use : string : (empty) -do_elf2flt_backend() { - local host - local prefix - local static_build - local cflags - local ldflags - local binutils_bld - local binutils_src - local arg - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - binutils_src="${CT_SRC_DIR}/binutils-${CT_BINUTILS_VERSION}" - - CT_DoLog EXTRA "Configuring elf2flt" - CT_DoExecLog CFG \ - CFLAGS="${cflags}" \ - LDFLAGS="${ldflags}" \ - "${CT_SRC_DIR}/elf2flt-${CT_ELF2FLT_VERSION}/configure" \ - --build=${CT_BUILD} \ - --host=${host} \ - --target=${CT_TARGET} \ - --prefix=${prefix} \ - --with-bfd-include-dir=${binutils_bld}/bfd \ - --with-binutils-include-dir=${binutils_src}/include \ - --with-libbfd=${binutils_bld}/bfd/libbfd.a \ - --with-libiberty=${binutils_bld}/libiberty/libiberty.a \ - ${elf2flt_opts} \ - "${CT_ELF2FLT_EXTRA_CONFIG_ARRAY[@]}" - - CT_DoLog EXTRA "Building elf2flt" - CT_DoExecLog ALL make ${JOBSFLAGS} - - CT_DoLog EXTRA "Installing elf2flt" - CT_DoExecLog ALL make install -} - -fi # CT_ARCH_BINFMT_FLAT diff -r 23fbfabd8a0f -r 6a5946fbc728 scripts/crosstool-NG.sh.in --- a/scripts/crosstool-NG.sh.in Mon Nov 19 23:24:49 2012 +0100 +++ b/scripts/crosstool-NG.sh.in Mon Nov 19 11:21:31 2012 +0100 @@ -127,8 +127,7 @@ . "${CT_LIB_DIR}/scripts/build/companion_tools.sh" . "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" . "${CT_LIB_DIR}/scripts/build/companion_libs.sh" -. "${CT_LIB_DIR}/scripts/build/binutils/binutils.sh" -. "${CT_LIB_DIR}/scripts/build/binutils/elf2flt.sh" +. "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh" . "${CT_LIB_DIR}/scripts/build/libc/${CT_LIBC}.sh" . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" . "${CT_LIB_DIR}/scripts/build/debug.sh" @@ -545,7 +544,6 @@ do_kernel_get do_companion_libs_get do_binutils_get - do_elf2flt_get do_cc_get do_libc_get do_debug_get @@ -569,7 +567,6 @@ do_kernel_extract do_companion_libs_extract do_binutils_extract - do_elf2flt_extract do_cc_extract do_libc_extract do_debug_extract diff -r 23fbfabd8a0f -r 6a5946fbc728 steps.mk --- a/steps.mk Mon Nov 19 23:24:49 2012 +0100 +++ b/steps.mk Mon Nov 19 11:21:31 2012 +0100 @@ -21,10 +21,8 @@ CT_STEPS := libc_check_config \ companion_libs_for_build \ binutils_for_build \ - elf2flt_for_build \ companion_libs_for_host \ binutils_for_host \ - elf2flt_for_host \ cc_core_pass_1 \ kernel_headers \ libc_start_files \