Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: add syscall table generation to scripts/Makefile.asm-headers

There are 11 copies of arch/*/kernel/syscalls/Makefile that all implement
the same basic logic in a somewhat awkward way.

I tried out various ways of unifying the existing copies and ended up
with something that hooks into the logic for generating the redirections
to asm-generic headers. This gives a nicer syntax of being able to list
the generated files in $(syscall-y) inside of arch/*/include/asm/Kbuild
instead of both $(generated-y) in that place and also in another
Makefile.

The configuration for which syscall.tbl file to use and which ABIs to
enable is now done in arch/*/kernel/Makefile.syscalls. I have done
patches for all architectures and made sure that the new generic
rules implement a superset of all the architecture specific corner
cases.

ince the header file is not specific to asm-generic/*.h redirects
now, I ended up renaming the file to scripts/Makefile.asm-headers.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+99 -59
+1 -1
Makefile
··· 1219 1219 $(Q)$(srctree)/scripts/remove-stale-files 1220 1220 1221 1221 # Support for using generic headers in asm-generic 1222 - asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj 1222 + asm-generic := -f $(srctree)/scripts/Makefile.asm-headers obj 1223 1223 1224 1224 PHONY += asm-generic uapi-asm-generic 1225 1225 asm-generic: uapi-asm-generic
-58
scripts/Makefile.asm-generic
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - # include/asm-generic contains a lot of files that are used 3 - # verbatim by several architectures. 4 - # 5 - # This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild 6 - # and for each file listed in this file with generic-y creates 7 - # a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm. 8 - 9 - PHONY := all 10 - all: 11 - 12 - src := $(srctree)/$(subst /generated,,$(obj)) 13 - 14 - include $(srctree)/scripts/Kbuild.include 15 - -include $(kbuild-file) 16 - 17 - # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. 18 - ifneq ($(SRCARCH),um) 19 - include $(srctree)/$(generic)/Kbuild 20 - endif 21 - 22 - redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y)) 23 - redundant += $(foreach f, $(generic-y), $(if $(wildcard $(src)/$(f)),$(f))) 24 - redundant := $(sort $(redundant)) 25 - $(if $(redundant),\ 26 - $(warning redundant generic-y found in $(src)/Kbuild: $(redundant))) 27 - 28 - # If arch does not implement mandatory headers, fallback to asm-generic ones. 29 - mandatory-y := $(filter-out $(generated-y), $(mandatory-y)) 30 - generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(src)/$(f)),,$(f))) 31 - 32 - generic-y := $(addprefix $(obj)/, $(generic-y)) 33 - generated-y := $(addprefix $(obj)/, $(generated-y)) 34 - 35 - # Remove stale wrappers when the corresponding files are removed from generic-y 36 - old-headers := $(wildcard $(obj)/*.h) 37 - unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) 38 - 39 - quiet_cmd_wrap = WRAP $@ 40 - cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ 41 - 42 - quiet_cmd_remove = REMOVE $(unwanted) 43 - cmd_remove = rm -f $(unwanted) 44 - 45 - all: $(generic-y) 46 - $(if $(unwanted),$(call cmd,remove)) 47 - @: 48 - 49 - $(obj)/%.h: $(srctree)/$(generic)/%.h 50 - $(call cmd,wrap) 51 - 52 - # Create output directory. Skip it if at least one old header exists 53 - # since we know the output directory already exists. 54 - ifeq ($(old-headers),) 55 - $(shell mkdir -p $(obj)) 56 - endif 57 - 58 - .PHONY: $(PHONY)
+98
scripts/Makefile.asm-headers
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # include/asm-generic contains a lot of files that are used 3 + # verbatim by several architectures. 4 + # 5 + # This Makefile generates arch/$(SRCARCH)/include/generated/(uapi/)/asm 6 + # headers from multiple sources: 7 + # - a small wrapper to include the corresponding asm-generic/*.h 8 + # is generated for each file listed as generic-y 9 + # - uapi/asm/unistd_*.h files listed as syscalls-y are generated from 10 + # syscall.tbl with the __NR_* macros 11 + # - Corresponding asm/syscall_table_*.h are generated from the same input 12 + 13 + PHONY := all 14 + all: 15 + 16 + src := $(srctree)/$(subst /generated,,$(obj)) 17 + 18 + syscall_abis_32 += common,32 19 + syscall_abis_64 += common,64 20 + syscalltbl := $(srctree)/scripts/syscall.tbl 21 + syshdr-args := --emit-nr 22 + 23 + # let architectures override $(syscall_abis_%) and $(syscalltbl) 24 + -include $(srctree)/arch/$(SRCARCH)/kernel/Makefile.syscalls 25 + include $(srctree)/scripts/Kbuild.include 26 + -include $(kbuild-file) 27 + 28 + syshdr := $(srctree)/scripts/syscallhdr.sh 29 + systbl := $(srctree)/scripts/syscalltbl.sh 30 + 31 + # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. 32 + ifneq ($(SRCARCH),um) 33 + include $(srctree)/$(generic)/Kbuild 34 + endif 35 + 36 + redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y)) 37 + redundant += $(foreach f, $(generic-y), $(if $(wildcard $(src)/$(f)),$(f))) 38 + redundant := $(sort $(redundant)) 39 + $(if $(redundant),\ 40 + $(warning redundant generic-y found in $(src)/Kbuild: $(redundant))) 41 + 42 + # If arch does not implement mandatory headers, fallback to asm-generic ones. 43 + mandatory-y := $(filter-out $(generated-y), $(mandatory-y)) 44 + generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(src)/$(f)),,$(f))) 45 + 46 + generic-y := $(addprefix $(obj)/, $(generic-y)) 47 + syscall-y := $(addprefix $(obj)/, $(syscall-y)) 48 + generated-y := $(addprefix $(obj)/, $(generated-y)) 49 + 50 + # Remove stale wrappers when the corresponding files are removed from generic-y 51 + old-headers := $(wildcard $(obj)/*.h) 52 + unwanted := $(filter-out $(generic-y) $(generated-y) $(syscall-y),$(old-headers)) 53 + 54 + quiet_cmd_wrap = WRAP $@ 55 + cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@ 56 + 57 + quiet_cmd_remove = REMOVE $(unwanted) 58 + cmd_remove = rm -f $(unwanted) 59 + 60 + quiet_cmd_syshdr = SYSHDR $@ 61 + cmd_syshdr = $(CONFIG_SHELL) $(syshdr) \ 62 + $(if $(syshdr-args-$*),$(syshdr-args-$*),$(syshdr-args)) \ 63 + $(if $(syscall_compat),--prefix "compat$*_") \ 64 + --abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \ 65 + $< $@ 66 + 67 + quiet_cmd_systbl = SYSTBL $@ 68 + cmd_systbl = $(CONFIG_SHELL) $(systbl) \ 69 + $(if $(systbl-args-$*),$(systbl-args-$*),$(systbl-args)) \ 70 + --abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \ 71 + $< $@ 72 + 73 + all: $(generic-y) $(syscall-y) 74 + $(if $(unwanted),$(call cmd,remove)) 75 + @: 76 + 77 + $(obj)/%.h: $(srctree)/$(generic)/%.h 78 + $(call cmd,wrap) 79 + 80 + $(obj)/unistd_%.h: $(syscalltbl) $(syshdr) FORCE 81 + $(call if_changed,syshdr) 82 + 83 + $(obj)/unistd_compat_%.h: syscall_compat:=1 84 + $(obj)/unistd_compat_%.h: $(syscalltbl) $(syshdr) FORCE 85 + $(call if_changed,syshdr) 86 + 87 + $(obj)/syscall_table_%.h: $(syscalltbl) $(systbl) FORCE 88 + $(call if_changed,systbl) 89 + 90 + # Create output directory. Skip it if at least one old header exists 91 + # since we know the output directory already exists. 92 + ifeq ($(old-headers),) 93 + $(shell mkdir -p $(obj)) 94 + endif 95 + 96 + FORCE: 97 + 98 + .PHONY: $(PHONY)