1 # SPDX-License-Identifier: GPL-2.0
2 # This Makefile generates headers in
3 # tools/perf/arch/$(SRCARCH)/include/generated/asm from the architecture's
4 # syscall table. This will either be from the generic syscall table, or from a
5 # table that is specific to that architecture.
10 obj := $(OUTPUT)arch/$(SRCARCH)/include/generated/asm
12 syscall_abis_32 := common,32
13 syscall_abis_64 := common,64
14 syscalltbl := $(srctree)/tools/scripts/syscall.tbl
16 # let architectures override $(syscall_abis_%) and $(syscalltbl)
17 -include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Makefile.syscalls
18 include $(srctree)/tools/build/Build.include
19 -include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Kbuild
21 systbl := $(srctree)/tools/perf/scripts/syscalltbl.sh
23 syscall-y := $(addprefix $(obj)/, $(syscall-y))
25 # Remove stale wrappers when the corresponding files are removed from generic-y
26 old-headers := $(wildcard $(obj)/*.h)
27 unwanted := $(filter-out $(syscall-y),$(old-headers))
29 quiet_cmd_remove = REMOVE $(unwanted)
30 cmd_remove = rm -f $(unwanted)
32 quiet_cmd_systbl = SYSTBL $@
33 cmd_systbl = $(CONFIG_SHELL) $(systbl) \
34 $(if $(systbl-args-$*),$(systbl-args-$*),$(systbl-args)) \
35 --abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \
39 $(if $(unwanted),$(call cmd,remove))
42 $(obj)/syscalls_%.h: $(syscalltbl) $(systbl) FORCE
43 $(call if_changed,systbl)
45 targets := $(syscall-y)
47 # Create output directory. Skip it if at least one old header exists
48 # since we know the output directory already exists.
49 ifeq ($(old-headers),)
50 $(shell mkdir -p $(obj))
57 existing-targets := $(wildcard $(sort $(targets)))
59 -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)