arch/lkl: use archprepare rule to generate config.h

arch/lkl/include/generated/uapi/asm/config.h is generated at build time
with any of:
  #define LKL_CONFIG_64BIT 1
  #define LKL_CONFIG_CPU_BIG_ENDIAN 1
based on the build environment.
Generation is handled by Makefiles under tools/lkl, where it is then
copied to arch/lkl/include/generated/uapi/asm/config.h prior to kernel
compilation.
This change simplifies header generation by doing it directly in the
arch/lkl parent Makefile. It also improves rebuild times by only
rewriting config.h if its contents would change.

Signed-off-by: David Disseldorp <ddiss@suse.de>
This commit is contained in:
David Disseldorp
2025-05-29 19:28:02 +10:00
parent 277a9d2e48
commit 407010b7ca
5 changed files with 18 additions and 19 deletions

View File

@@ -65,6 +65,20 @@ core-y += arch/lkl/lib/
core-y += arch/lkl/mm/
core-y += arch/lkl/drivers/
configh-y = printf "/* this header is autogenerated */\n"
configh-$(CONFIG_64BIT) += && printf '\#define LKL_CONFIG_64BIT 1\n'
configh-$(CONFIG_CPU_BIG_ENDIAN) += && printf '\#define LKL_CONFIG_CPU_BIG_ENDIAN 1\n'
quiet_cmd_gen_configh = GEN $@
cmd_gen_configh = mkdir -p $(dir $@); ($(configh-y)) > $@
targets += arch/lkl/include/generated/uapi/asm/config.h
arch/lkl/include/generated/uapi/asm/config.h: FORCE
$(call if_changed,gen_configh)
archprepare: arch/lkl/include/generated/uapi/asm/config.h
all: lkl.o arch/lkl/include/generated/uapi/asm/syscall_defs.h
lkl.o: vmlinux

View File

@@ -33,3 +33,5 @@ generic-y += termios.h
generic-y += time.h
generic-y += user.h
generic-y += mman.h
generated-y += config.h

View File

@@ -13,7 +13,6 @@ tests/config
tests/test-dlmopen
Makefile.conf
include/lkl_autoconf.h
include/kernel_config.h
tests/autoconf.sh
*.pyc
bin/stat

View File

@@ -41,7 +41,7 @@ all:
conf: $(OUTPUT)Makefile.conf
$(OUTPUT)Makefile.conf $(OUTPUT)include/kernel_config.h $(OUTPUT)/kernel.config: Makefile.autoconf
$(OUTPUT)Makefile.conf $(OUTPUT)/kernel.config: Makefile.autoconf
$(call QUIET_AUTOCONF, headers)$(MAKE) -f Makefile.autoconf -s
include $(OUTPUT)Makefile.conf
@@ -72,8 +72,6 @@ else
$(Q)touch bin/stat
endif
ASM_UAPI_GENERATED:=$(OUTPUT)../../arch/lkl/include/generated/uapi/asm
ASM_CONFIG:=$(ASM_UAPI_GENERATED)/config.h
DOT_CONFIG:=$(OUTPUT)../../.config
$(DOT_CONFIG): $(OUTPUT)/kernel.config
@@ -82,13 +80,8 @@ $(DOT_CONFIG): $(OUTPUT)/kernel.config
$(Q)$(MAKE) -C ../.. ARCH=lkl $(KOPT) olddefconfig
$(Q)$(MAKE) -C ../.. ARCH=lkl $(KOPT) syncconfig
$(ASM_CONFIG): $(OUTPUT)include/kernel_config.h
$(Q)mkdir -p $$(dirname $@)
$(call QUIET_INSTALL, kernel_config.h)cp $< $@
# rule to build lkl.o
$(OUTPUT)lib/lkl.o: bin/stat $(ASM_CONFIG) $(DOT_CONFIG)
$(OUTPUT)lib/lkl.o: bin/stat $(DOT_CONFIG)
# this workaround is for arm32 linker (ld.gold)
$(Q)export PATH="$(srctree)/tools/lkl/bin/:${PATH}" ;\
$(MAKE) -C ../.. ARCH=lkl $(KOPT)
@@ -174,7 +167,6 @@ mrproper: clean
clean-conf: mrproper
$(call QUIET_CLEAN, Makefile.conf)$(RM) $(OUTPUT)/Makefile.conf
$(call QUIET_CLEAN, kernel_config.h)$(RM) $(OUTPUT)/include/kernel_config.h
$(call QUIET_CLEAN, kernel.config)$(RM) $(OUTPUT)/kernel.config
headers_install: $(TARGETS)

View File

@@ -9,11 +9,6 @@ define set_autoconf_var
export LKL_HOST_CONFIG_$(1)=$(2)
endef
define set_kernel_config_h
$(shell echo "#define $(1) $(2)" \
>> $(OUTPUT)/include/kernel_config.h)
endef
define set_kernel_config
$(shell echo "CONFIG_$(1)=$(2)" >> $(OUTPUT)/kernel.config)
endef
@@ -119,12 +114,10 @@ define nt_host
endef
define s390_host
$(call set_kernel_config_h,LKL_CONFIG_CPU_BIG_ENDIAN,1)
$(call set_kernel_config,CPU_BIG_ENDIAN,y)
endef
define 64bit_host
$(call set_kernel_config_h,LKL_CONFIG_64BIT,1)
$(call set_kernel_config,64BIT,y)
endef
@@ -310,7 +303,6 @@ $(OUTPUT)Makefile.conf: Makefile.autoconf
$(shell mkdir -p $(OUTPUT)/include)
$(shell mkdir -p $(OUTPUT)/tests)
$(shell echo -n "" > $(OUTPUT)/include/lkl_autoconf.h)
$(shell echo -n "" > $(OUTPUT)/include/kernel_config.h)
$(shell echo -n "" > $(OUTPUT)/kernel.config)
$(shell echo -n "" > $(OUTPUT)/tests/autoconf.sh)
@echo "$$do_autoconf" > $(OUTPUT)/Makefile.conf