From 5cf859d9d9308e341c58caff45d54a910480ad24 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Mon, 10 Dec 2018 01:10:01 -0800 Subject: [PATCH] Add config flags for omitting 'arch' and 'vendor' ... parts of the config tuple. While here, remove parts that are setting portions of the target tuple to a value that's already the default. Signed-off-by: Alexey Neyman --- config/libc/avr-libc.in | 4 +++ config/target.in | 15 +++++++++ config/toolchain.in | 2 +- scripts/build/arch.sh | 46 ++++++++++++++++----------- scripts/build/arch/arc.sh | 15 ++++----- scripts/build/arch/avr.sh | 7 ----- scripts/build/arch/xtensa.sh | 11 +++---- scripts/build/kernel/bare-metal.sh | 12 ++++--- scripts/build/kernel/linux.sh | 13 ++++---- scripts/build/kernel/windows.sh | 12 ++++--- scripts/functions | 50 +++++++++++++++++++----------- 11 files changed, 113 insertions(+), 74 deletions(-) diff --git a/config/libc/avr-libc.in b/config/libc/avr-libc.in index ade44540..ac037b71 100644 --- a/config/libc/avr-libc.in +++ b/config/libc/avr-libc.in @@ -1,9 +1,13 @@ # avr-libc options +# Do not canonicalize the target tuple: avr-libc requires a non-canonical "avr" target. +# ## depends on ARCH_AVR ## depends on BARE_METAL ## ## select LIBC_SUPPORT_THREADS_NONE +## select OMIT_TARGET_VENDOR +## select TARGET_SKIP_CONFIG_SUB ## ## help The AVR Libc package provides a subset of the standard C library for ## help Atmel AVR 8-bit RISC microcontrollers. In addition, the library diff --git a/config/target.in b/config/target.in index c0054f21..8549c5b8 100644 --- a/config/target.in +++ b/config/target.in @@ -19,6 +19,21 @@ config ARCH_SUFFIX If you are not sure about what this is, leave it blank. +config OMIT_TARGET_ARCH + bool + help + Do not include architecture into the target tuple. + +config OMIT_TARGET_VENDOR + bool "Omit vendor part of the target tuple" + help + Do not include vendor into the target tuple. + +config TARGET_SKIP_CONFIG_SUB + bool + help + Skip canonicalization of the target tuple. + #-------------------------------------- comment "Generic target options" diff --git a/config/toolchain.in b/config/toolchain.in index 0599592e..36a4782e 100644 --- a/config/toolchain.in +++ b/config/toolchain.in @@ -121,7 +121,7 @@ comment "Tuple completion and aliasing" config TARGET_VENDOR string prompt "Tuple's vendor string" - depends on !LIBC_AVR_LIBC + depends on !OMIT_TARGET_VENDOR default "unknown" help Vendor part of the target tuple. diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh index de3e3c91..e7a2efe4 100644 --- a/scripts/build/arch.sh +++ b/scripts/build/arch.sh @@ -1,31 +1,36 @@ # This file provides the default implementations of arch-specific functions. # Set up the target tuple -CT_DoArchTupleValues() { - :; +CT_DoArchTupleValues() +{ + : } # Adjust the list of multilibs for the target -CT_DoArchMultilibList() { - :; +CT_DoArchMultilibList() +{ + : } # Multilib: change the target triplet according to CFLAGS # Usage: CT_DoArchGlibcAdjustTuple -CT_DoArchMultilibTarget() { - :; +CT_DoArchMultilibTarget() +{ + : } # Multilib: Adjust target tuple for GLIBC # Usage: CT_DoArchGlibcAdjustTuple -CT_DoArchGlibcAdjustTuple() { - :; +CT_DoArchGlibcAdjustTuple() +{ + : } # Multilib: Adjust configure arguments for GLIBC # Usage: CT_DoArchGlibcAdjustConfigure -CT_DoArchGlibcAdjustConfigure() { - :; +CT_DoArchGlibcAdjustConfigure() +{ + : } # Helper for uClibc configurators: select the architecture @@ -41,14 +46,16 @@ CT_DoArchUClibcSelectArch() { # uClibc: Adjust configuration file according to the CT-NG configuration # Usage: CT_DoArchUClibcConfig -CT_DoArchUClibcConfig() { +CT_DoArchUClibcConfig() +{ CT_DoLog WARN "Support for '${CT_ARCH}' is not implemented in uClibc config tweaker." CT_DoLog WARN "Exact configuration file must be provided." } # Multilib/uClibc: Adjust configuration file for given CFLAGS # Usage: CT_DoArchUClibcCflags -CT_DoArchUClibcCflags() { +CT_DoArchUClibcCflags() +{ local cfg="${1}" local cflags="${2}" @@ -63,21 +70,24 @@ CT_DoArchUClibcCflags() { # Multilib/uClibc: Adjust header installation path for given CFLAGS # Usage: CT_DoArchUClibcHeaderDir -CT_DoArchUClibcHeaderDir() { +CT_DoArchUClibcHeaderDir() +{ # Only needed if a given architecture may select different uClibc architectures. - :; + : } # Multilib/MUSL: Adjust header installation path for given CFLAGS # Usage: CT_DoArchMUSLHeaderDir -CT_DoArchMUSLHeaderDir() { +CT_DoArchMUSLHeaderDir() +{ # Only needed if a given architecture may select different MUSL architectures. - :; + : } # MUSL: Perform any final adjustments on the installed libc/headers -CT_DoArchMUSLPostInstall() { - :; +CT_DoArchMUSLPostInstall() +{ + : } # Override from the actual arch implementation as needed. diff --git a/scripts/build/arch/arc.sh b/scripts/build/arch/arc.sh index 2b48e4ba..b13ef0eb 100644 --- a/scripts/build/arch/arc.sh +++ b/scripts/build/arch/arc.sh @@ -1,23 +1,20 @@ # Compute ARC-specific values -CT_DoArchTupleValues() { +CT_DoArchTupleValues() +{ # The architecture part of the tuple: CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX:-${target_endian_eb}}" - - # The system part of the tuple: - case "${CT_LIBC}" in - glibc) CT_TARGET_SYS=gnu;; - uClibc) CT_TARGET_SYS=uclibc;; - esac } -CT_DoArchUClibcConfig() { +CT_DoArchUClibcConfig() +{ local cfg="${1}" CT_DoArchUClibcSelectArch "${cfg}" "arc" } -CT_DoArchUClibcCflags() { +CT_DoArchUClibcCflags() +{ local cfg="${1}" local cflags="${2}" local f diff --git a/scripts/build/arch/avr.sh b/scripts/build/arch/avr.sh index fd8c8edd..501b020b 100644 --- a/scripts/build/arch/avr.sh +++ b/scripts/build/arch/avr.sh @@ -2,11 +2,4 @@ CT_DoArchTupleValues() { CT_TARGET_ARCH="${CT_ARCH}" - case "${CT_LIBC}" in - avr-libc) - # avr-libc only seems to work with the non-canonical "avr" target. - CT_TARGET_SKIP_CONFIG_SUB=y - CT_TARGET_SYS= # CT_TARGET_SYS must be empty - ;; - esac } diff --git a/scripts/build/arch/xtensa.sh b/scripts/build/arch/xtensa.sh index 744bbb2d..d0ba6f58 100644 --- a/scripts/build/arch/xtensa.sh +++ b/scripts/build/arch/xtensa.sh @@ -1,18 +1,15 @@ # Compute Xtensa-specific values -CT_DoArchTupleValues() { +CT_DoArchTupleValues() +{ # The architecture part of the tuple: CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX}" CT_ARCH_ENDIAN_CFLAG="" CT_ARCH_ENDIAN_LDFLAG="" - # The system part of the tuple: - case "${CT_LIBC}" in - *glibc) CT_TARGET_SYS=gnu;; - uClibc) CT_TARGET_SYS=uclibc;; - esac } -CT_DoArchUClibcConfig() { +CT_DoArchUClibcConfig() +{ local cfg="${1}" CT_DoArchUClibcSelectArch "${cfg}" "xtensa" diff --git a/scripts/build/kernel/bare-metal.sh b/scripts/build/kernel/bare-metal.sh index 629f63fa..79c43454 100644 --- a/scripts/build/kernel/bare-metal.sh +++ b/scripts/build/kernel/bare-metal.sh @@ -2,19 +2,23 @@ # Copyright 2008 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -CT_DoKernelTupleValues() { +CT_DoKernelTupleValues() +{ # For bare-metal, there is no kernel part in the tuple CT_TARGET_KERNEL= } -do_kernel_get() { +do_kernel_get() +{ : } -do_kernel_extract() { +do_kernel_extract() +{ : } -do_kernel_headers() { +do_kernel_headers() +{ : } diff --git a/scripts/build/kernel/linux.sh b/scripts/build/kernel/linux.sh index 5ab49182..f0987653 100644 --- a/scripts/build/kernel/linux.sh +++ b/scripts/build/kernel/linux.sh @@ -2,10 +2,9 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -CT_DoKernelTupleValues() { - if [ "${CT_ARCH_USE_MMU}" = "y" ]; then - CT_TARGET_KERNEL="linux" - else +CT_DoKernelTupleValues() +{ + if [ -z "${CT_ARCH_USE_MMU}" ]; then # Some no-mmu linux targets requires a -uclinux tuple (like m68k/cf), # while others must have a -linux tuple. Other targets # should be added here when someone starts to care about them. @@ -18,7 +17,8 @@ CT_DoKernelTupleValues() { } # Download the kernel -do_kernel_get() { +do_kernel_get() +{ CT_Fetch LINUX } @@ -42,7 +42,8 @@ do_kernel_extract() } # Install kernel headers using headers_install from kernel sources. -do_kernel_headers() { +do_kernel_headers() +{ local kernel_path local kernel_arch diff --git a/scripts/build/kernel/windows.sh b/scripts/build/kernel/windows.sh index 7d6266c1..37bc1d78 100644 --- a/scripts/build/kernel/windows.sh +++ b/scripts/build/kernel/windows.sh @@ -2,20 +2,24 @@ # Copyright 2012 Yann Diorcet # Licensed under the GPL v2. See COPYING in the root of this package -CT_DoKernelTupleValues() { +CT_DoKernelTupleValues() +{ # Even we compile for x86_64 target architecture, the target OS have to # bet mingw32 (require by gcc and mingw-w64) CT_TARGET_KERNEL="mingw32" } -do_kernel_get() { +do_kernel_get() +{ : } -do_kernel_extract() { +do_kernel_extract() +{ : } -do_kernel_headers() { +do_kernel_headers() +{ : } diff --git a/scripts/functions b/scripts/functions index affb10a5..764477b9 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1094,18 +1094,18 @@ CT_DoBuildTargetTuple() { # Build the default architecture tuple part CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX}" - # Set defaults for the system part of the tuple. Can be overriden - # by architecture-specific values. + # Set defaults for the system part of the tuple; only C libraries that + # support multiple architectures. Can be overriden by architecture-specific + # values. case "${CT_LIBC}" in - glibc) CT_TARGET_SYS=gnu;; - uClibc) CT_TARGET_SYS=uclibc;; - musl) CT_TARGET_SYS=musl;; - bionic) CT_TARGET_SYS=android;; - none|newlib) - CT_TARGET_SYS=elf - ;; + glibc) CT_TARGET_SYS=gnu;; + uClibc) CT_TARGET_SYS=uclibc;; + musl) CT_TARGET_SYS=musl;; + bionic) CT_TARGET_SYS=android;; + none|newlib) CT_TARGET_SYS=elf;; *) - CT_TARGET_SYS= # Keep empty for the libraries like mingw + # Keep empty for the libraries like mingw or avr-libc + CT_TARGET_SYS= ;; esac @@ -1145,10 +1145,18 @@ CT_DoBuildTargetTuple() { CT_DoKernelTupleValues # Finish the target tuple construction - CT_TARGET="${CT_TARGET_ARCH}" - CT_TARGET="${CT_TARGET}${CT_TARGET_VENDOR:+-${CT_TARGET_VENDOR}}" - CT_TARGET="${CT_TARGET}${CT_TARGET_KERNEL:+-${CT_TARGET_KERNEL}}" - CT_TARGET="${CT_TARGET}${CT_TARGET_SYS:+-${CT_TARGET_SYS}}" + if [ -z "${CT_OMIT_TARGET_ARCH}" ]; then + CT_TARGET="${CT_TARGET_ARCH}" + fi + if [ -z "${CT_OMIT_TARGET_VENDOR}" -a -n "${CT_TARGET_VENDOR}" ]; then + CT_TARGET="${CT_TARGET:+${CT_TARGET}-}${CT_TARGET_VENDOR}" + fi + if [ -n "${CT_TARGET_KERNEL}" ]; then + CT_TARGET="${CT_TARGET:+${CT_TARGET}-}${CT_TARGET_KERNEL}" + fi + if [ -n "${CT_TARGET_SYS}" ]; then + CT_TARGET="${CT_TARGET:+${CT_TARGET}-}${CT_TARGET_SYS}" + fi # Sanity checks __sed_alias="" @@ -1165,6 +1173,12 @@ CT_DoBuildTargetTuple() { # Canonicalise it if [ "${CT_TARGET_SKIP_CONFIG_SUB}" != "y" ]; then CT_TARGET=$(CT_DoConfigSub "${CT_TARGET}") + + if [ -n "${CT_OMIT_TARGET_VENDOR}" ]; then + # config.sub always returns a 3- or 4-part tuple, with vendor + # always being the 2nd part. + CT_TARGET="${CT_TARGET%%-*}-${CT_TARGET#*-*-}" + fi fi # Prepare the target CFLAGS @@ -1316,7 +1330,7 @@ CT_DoSaveState() { done | ${sed} 's/^declare /declare -g /' echo "builtin unset ${CT_ENVVAR_UNSET}" } >"${state_dir}/env.sh" - + # Save .config to check it hasn't changed when resuming. CT_DoExecLog STATE cp ".config" "${state_dir}/config" @@ -1804,7 +1818,7 @@ CT_Download_cvs() fi } -# Find the most recent version from Subversion. +# Find the most recent version from Subversion. CT_GetVersion_svn() { devel_branch="${devel_branch:-/trunk}" @@ -1857,7 +1871,7 @@ CT_Download_hg() fi if [ "${devel_revision}" = "to.be.determined" ]; then # Report what we found out (as common message lacks the revision) - devel_revision=`hg identify -i` + devel_revision=`hg identify -i` unique_id="${devel_revision}" CT_DoLog EXTRA "Retrieved revision ${devel_revision}" else @@ -2246,7 +2260,7 @@ CT_DoExtractPatch() done fi done - + # TBD create meta-package for config.sub/config.guess with replacement script if [ "${CT_OVERRIDE_CONFIG_GUESS_SUB}" = "y" ]; then CT_DoLog ALL "Overiding config.guess and config.sub"