Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 104daea1 authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

kconfig: reference environment variables directly and remove 'option env='



To get access to environment variables, Kconfig needs to define a
symbol using "option env=" syntax.  It is tedious to add a symbol entry
for each environment variable given that we need to define much more
such as 'CC', 'AS', 'srctree' etc. to evaluate the compiler capability
in Kconfig.

Adding '$' for symbol references is grammatically inconsistent.
Looking at the code, the symbols prefixed with 'S' are expanded by:
 - conf_expand_value()
   This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list'
 - sym_expand_string_value()
   This is used to expand strings in 'source' and 'mainmenu'

All of them are fixed values independent of user configuration.  So,
they can be changed into the direct expansion instead of symbols.

This change makes the code much cleaner.  The bounce symbols 'SRCARCH',
'ARCH', 'SUBARCH', 'KERNELVERSION' are gone.

sym_init() hard-coding 'UNAME_RELEASE' is also gone.  'UNAME_RELEASE'
should be replaced with an environment variable.

ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced
without '$' prefix.

The new syntax is addicted by Make.  The variable reference needs
parentheses, like $(FOO), but you can omit them for single-letter
variables, like $F.  Yet, in Makefiles, people tend to use the
parenthetical form for consistency / clarification.

At this moment, only the environment variable is supported, but I will
extend the concept of 'variable' later on.

The variables are expanded in the lexer so we can simplify the token
handling on the parser side.

For example, the following code works.

[Example code]

  config MY_TOOLCHAIN_LIST
          string
          default "My tools: CC=$(CC), AS=$(AS), CPP=$(CPP)"

[Result]

  $ make -s alldefconfig && tail -n 1 .config
  CONFIG_MY_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E"

Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
parent f1089c92
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -198,14 +198,6 @@ applicable everywhere (see syntax).
    enables the third modular state for all config symbols.
    At most one symbol may have the "modules" option set.

  - "env"=<value>
    This imports the environment variable into Kconfig. It behaves like
    a default, except that the value comes from the environment, this
    also means that the behaviour when mixing it with normal defaults is
    undefined at this point. The symbol is currently not exported back
    to the build environment (if this is desired, it can be done via
    another symbol).

  - "allnoconfig_y"
    This declares the symbol as one that should have the value y when
    using "allnoconfig". Used for symbols that hide other symbols.
+2 −6
Original line number Diff line number Diff line
@@ -3,10 +3,6 @@
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/kconfig-language.txt.
#
mainmenu "Linux/$ARCH $KERNELVERSION Kernel Configuration"
mainmenu "Linux/$(ARCH) $(KERNELVERSION) Kernel Configuration"

config SRCARCH
	string
	option env="SRCARCH"

source "arch/$SRCARCH/Kconfig"
source "arch/$(SRCARCH)/Kconfig"
+2 −1
Original line number Diff line number Diff line
@@ -284,7 +284,8 @@ include scripts/Kbuild.include
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
UNAME_RELEASE := $(shell uname --release)
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION UNAME_RELEASE

# SUBARCH tells the usermode build what the underlying arch is.  That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
+2 −2
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ config SUPERH
	  <http://www.linux-sh.org/>.

config SUPERH32
	def_bool ARCH = "sh"
	def_bool "$(ARCH)" = "sh"
	select HAVE_KPROBES
	select HAVE_KRETPROBES
	select HAVE_IOREMAP_PROT if MMU && !X2TLB
@@ -77,7 +77,7 @@ config SUPERH32
	select HAVE_CC_STACKPROTECTOR

config SUPERH64
	def_bool ARCH = "sh64"
	def_bool "$(ARCH)" = "sh64"
	select HAVE_EXIT_THREAD
	select KALLSYMS

+2 −2
Original line number Diff line number Diff line
config 64BIT
	bool "64-bit kernel" if ARCH = "sparc"
	default ARCH = "sparc64"
	bool "64-bit kernel" if "$(ARCH)" = "sparc"
	default "$(ARCH)" = "sparc64"
	help
	  SPARC is a family of RISC microprocessors designed and marketed by
	  Sun Microsystems, incorporated.  They are very widely found in Sun
Loading