xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 13 Mar 2021 12:23:41 +0000 (21:23 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Sun, 4 Apr 2021 22:39:02 +0000 (15:39 -0700)
Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place
for CONFIG options.

I slightly simplified the test code. You can use the -P option to suppress
linemarker generation. The grep command is unneeded.

  $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -
  # 1 "<stdin>"
  # 1 "<built-in>"
  # 1 "<command-line>"
  # 1 "<stdin>"
  1

  $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P -
  1

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Message-Id: <20210313122342.69995-1-masahiroy@kernel.org>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/Kconfig
arch/xtensa/Makefile
arch/xtensa/boot/Makefile
arch/xtensa/boot/boot-elf/Makefile
arch/xtensa/boot/boot-redboot/Makefile

index a99dc39..d637b39 100644 (file)
@@ -84,6 +84,12 @@ config KASAN_SHADOW_OFFSET
        hex
        default 0x6e400000
 
+config CPU_BIG_ENDIAN
+       def_bool $(success,test "$(shell,echo __XTENSA_EB__ | $(CC) -E -P -)" = 1)
+
+config CPU_LITTLE_ENDIAN
+       def_bool !CPU_BIG_ENDIAN
+
 menu "Processor type and features"
 
 choice
index cf09407..ba9fee7 100644 (file)
@@ -52,14 +52,7 @@ ifneq ($(CONFIG_LD_NO_RELAX),)
 KBUILD_LDFLAGS := --no-relax
 endif
 
-ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
-CHECKFLAGS += -D__XTENSA_EB__
-KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN
-endif
-ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
-CHECKFLAGS += -D__XTENSA_EL__
-KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN
-endif
+CHECKFLAGS += -D$(if $(CONFIG_CPU_BIG_ENDIAN),__XTENSA_EB__,__XTENSA_EL__)
 
 vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y))
 plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y))
index f6bb352..a65b7a9 100644 (file)
 KBUILD_CFLAGS  += -fno-builtin -Iarch/$(ARCH)/boot/include
 HOSTFLAGS      += -Iarch/$(ARCH)/boot/include
 
-BIG_ENDIAN     := $(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
-
-export BIG_ENDIAN
-
 subdir-y       := lib
 targets                += vmlinux.bin vmlinux.bin.gz
 targets                += uImage xipImage
index f7c775d..47b9063 100644 (file)
@@ -4,11 +4,7 @@
 # for more details.
 #
 
-ifeq ($(BIG_ENDIAN),1)
-OBJCOPY_ARGS    := -O elf32-xtensa-be
-else
-OBJCOPY_ARGS    := -O elf32-xtensa-le
-endif
+OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
 
 export OBJCOPY_ARGS
 export CPPFLAGS_boot.lds += -P -C
index 07cb24a..1d1d462 100644 (file)
@@ -4,11 +4,7 @@
 # for more details.
 #
 
-ifeq ($(BIG_ENDIAN),1)
-OBJCOPY_ARGS   := -O elf32-xtensa-be
-else
-OBJCOPY_ARGS   := -O elf32-xtensa-le
-endif
+OBJCOPY_ARGS := -O $(if $(CONFIG_CPU_BIG_ENDIAN),elf32-xtensa-be,elf32-xtensa-le)
 
 LD_ARGS        = -T $(srctree)/$(obj)/boot.ld