diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-07-16 12:09:03 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-07-16 12:09:03 -0700 |
commit | d80f2996b8502779c39221a9e7c9ea7e361c0ae4 (patch) | |
tree | 339db3f28a684bb7c674d32d62fc2c0f14f935f4 /scripts/Makefile.asm-headers | |
parent | a5db8e4544a4dc7143f30a1438686a4d5fa6d775 (diff) | |
parent | 1a7b7326d587c9a5e8ff067e70d6aaf0333f4bb3 (diff) |
Merge tag 'asm-generic-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
Pull asm-generic updates from Arnd Bergmann:
"Most of this is part of my ongoing work to clean up the system call
tables. In this bit, all of the newer architectures are converted to
use the machine readable syscall.tbl format instead in place of
complex macros in include/uapi/asm-generic/unistd.h.
This follows an earlier series that fixed various API mismatches and
in turn is used as the base for planned simplifications.
The other two patches are dead code removal and a warning fix"
* tag 'asm-generic-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
vmlinux.lds.h: catch .bss..L* sections into BSS")
fixmap: Remove unused set_fixmap_offset_io()
riscv: convert to generic syscall table
openrisc: convert to generic syscall table
nios2: convert to generic syscall table
loongarch: convert to generic syscall table
hexagon: use new system call table
csky: convert to generic syscall table
arm64: rework compat syscall macros
arm64: generate 64-bit syscall.tbl
arm64: convert unistd_32.h to syscall.tbl format
arc: convert to generic syscall table
clone3: drop __ARCH_WANT_SYS_CLONE3 macro
kbuild: add syscall table generation to scripts/Makefile.asm-headers
kbuild: verify asm-generic header list
loongarch: avoid generating extra header files
um: don't generate asm/bpf_perf_event.h
csky: drop asm/gpio.h wrapper
syscalls: add generic scripts/syscall.tbl
Diffstat (limited to 'scripts/Makefile.asm-headers')
-rw-r--r-- | scripts/Makefile.asm-headers | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/scripts/Makefile.asm-headers b/scripts/Makefile.asm-headers new file mode 100644 index 000000000000..6b8e8318e810 --- /dev/null +++ b/scripts/Makefile.asm-headers @@ -0,0 +1,98 @@ +# SPDX-License-Identifier: GPL-2.0 +# include/asm-generic contains a lot of files that are used +# verbatim by several architectures. +# +# This Makefile generates arch/$(SRCARCH)/include/generated/(uapi/)/asm +# headers from multiple sources: +# - a small wrapper to include the corresponding asm-generic/*.h +# is generated for each file listed as generic-y +# - uapi/asm/unistd_*.h files listed as syscalls-y are generated from +# syscall.tbl with the __NR_* macros +# - Corresponding asm/syscall_table_*.h are generated from the same input + +PHONY := all +all: + +src := $(srctree)/$(subst /generated,,$(obj)) + +syscall_abis_32 += common,32 +syscall_abis_64 += common,64 +syscalltbl := $(srctree)/scripts/syscall.tbl +syshdr-args := --emit-nr + +# let architectures override $(syscall_abis_%) and $(syscalltbl) +-include $(srctree)/arch/$(SRCARCH)/kernel/Makefile.syscalls +include $(srctree)/scripts/Kbuild.include +-include $(kbuild-file) + +syshdr := $(srctree)/scripts/syscallhdr.sh +systbl := $(srctree)/scripts/syscalltbl.sh + +# $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. +ifneq ($(SRCARCH),um) +include $(srctree)/$(generic)/Kbuild +endif + +redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y)) +redundant += $(foreach f, $(generic-y), $(if $(wildcard $(src)/$(f)),$(f))) +redundant := $(sort $(redundant)) +$(if $(redundant),\ + $(warning redundant generic-y found in $(src)/Kbuild: $(redundant))) + +# If arch does not implement mandatory headers, fallback to asm-generic ones. +mandatory-y := $(filter-out $(generated-y), $(mandatory-y)) +generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(src)/$(f)),,$(f))) + +generic-y := $(addprefix $(obj)/, $(generic-y)) +syscall-y := $(addprefix $(obj)/, $(syscall-y)) +generated-y := $(addprefix $(obj)/, $(generated-y)) + +# Remove stale wrappers when the corresponding files are removed from generic-y +old-headers := $(wildcard $(obj)/*.h) +unwanted := $(filter-out $(generic-y) $(generated-y) $(syscall-y),$(old-headers)) + +quiet_cmd_wrap = WRAP $@ + cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ + +quiet_cmd_remove = REMOVE $(unwanted) + cmd_remove = rm -f $(unwanted) + +quiet_cmd_syshdr = SYSHDR $@ + cmd_syshdr = $(CONFIG_SHELL) $(syshdr) \ + $(if $(syshdr-args-$*),$(syshdr-args-$*),$(syshdr-args)) \ + $(if $(syscall_compat),--prefix "compat$*_") \ + --abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \ + $< $@ + +quiet_cmd_systbl = SYSTBL $@ + cmd_systbl = $(CONFIG_SHELL) $(systbl) \ + $(if $(systbl-args-$*),$(systbl-args-$*),$(systbl-args)) \ + --abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \ + $< $@ + +all: $(generic-y) $(syscall-y) + $(if $(unwanted),$(call cmd,remove)) + @: + +$(obj)/%.h: $(srctree)/$(generic)/%.h + $(call cmd,wrap) + +$(obj)/unistd_%.h: $(syscalltbl) $(syshdr) FORCE + $(call if_changed,syshdr) + +$(obj)/unistd_compat_%.h: syscall_compat:=1 +$(obj)/unistd_compat_%.h: $(syscalltbl) $(syshdr) FORCE + $(call if_changed,syshdr) + +$(obj)/syscall_table_%.h: $(syscalltbl) $(systbl) FORCE + $(call if_changed,systbl) + +# Create output directory. Skip it if at least one old header exists +# since we know the output directory already exists. +ifeq ($(old-headers),) +$(shell mkdir -p $(obj)) +endif + +FORCE: + +.PHONY: $(PHONY) |