Skip to content

Commit

Permalink
Add config flags for omitting 'arch' and 'vendor'
Browse files Browse the repository at this point in the history
... 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 <stilor@att.net>
  • Loading branch information
stilor committed Dec 10, 2018
1 parent afb1724 commit 5cf859d
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 74 deletions.
4 changes: 4 additions & 0 deletions config/libc/avr-libc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions config/target.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion config/toolchain.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
46 changes: 28 additions & 18 deletions scripts/build/arch.sh
Original file line number Diff line number Diff line change
@@ -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 <variable-name> <CFLAGS>
CT_DoArchMultilibTarget() {
:;
CT_DoArchMultilibTarget()
{
:
}

# Multilib: Adjust target tuple for GLIBC
# Usage: CT_DoArchGlibcAdjustTuple <variable-name>
CT_DoArchGlibcAdjustTuple() {
:;
CT_DoArchGlibcAdjustTuple()
{
:
}

# Multilib: Adjust configure arguments for GLIBC
# Usage: CT_DoArchGlibcAdjustConfigure <configure-args-array-name> <cflags>
CT_DoArchGlibcAdjustConfigure() {
:;
CT_DoArchGlibcAdjustConfigure()
{
:
}

# Helper for uClibc configurators: select the architecture
Expand All @@ -41,14 +46,16 @@ CT_DoArchUClibcSelectArch() {

# uClibc: Adjust configuration file according to the CT-NG configuration
# Usage: CT_DoArchUClibcConfig <config-file>
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 <config-file> <cflags>
CT_DoArchUClibcCflags() {
CT_DoArchUClibcCflags()
{
local cfg="${1}"
local cflags="${2}"

Expand All @@ -63,21 +70,24 @@ CT_DoArchUClibcCflags() {

# Multilib/uClibc: Adjust header installation path for given CFLAGS
# Usage: CT_DoArchUClibcHeaderDir <path-variable> <cflags>
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 <path-variable> <cflags>
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.
Expand Down
15 changes: 6 additions & 9 deletions scripts/build/arch/arc.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 0 additions & 7 deletions scripts/build/arch/avr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 4 additions & 7 deletions scripts/build/arch/xtensa.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
12 changes: 8 additions & 4 deletions scripts/build/kernel/bare-metal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
:
}
13 changes: 7 additions & 6 deletions scripts/build/kernel/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -18,7 +17,8 @@ CT_DoKernelTupleValues() {
}

# Download the kernel
do_kernel_get() {
do_kernel_get()
{
CT_Fetch LINUX
}

Expand All @@ -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

Expand Down
12 changes: 8 additions & 4 deletions scripts/build/kernel/windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
:
}
50 changes: 32 additions & 18 deletions scripts/functions
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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=""
Expand All @@ -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
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 5cf859d

Please sign in to comment.