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. 6 7PHONY := all 8all: 9 10obj := $(OUTPUT)arch/$(SRCARCH)/include/generated/asm 11 12syscall_abis_32 := common,32 13syscall_abis_64 := common,64 14syscalltbl := $(srctree)/tools/scripts/syscall.tbl 15 16# let architectures override $(syscall_abis_%) and $(syscalltbl) 17-include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Makefile.syscalls 18include $(srctree)/tools/build/Build.include 19-include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Kbuild 20 21systbl := $(srctree)/tools/perf/scripts/syscalltbl.sh 22 23syscall-y := $(addprefix $(obj)/, $(syscall-y)) 24 25# Remove stale wrappers when the corresponding files are removed from generic-y 26old-headers := $(wildcard $(obj)/*.h) 27unwanted := $(filter-out $(syscall-y),$(old-headers)) 28 29quiet_cmd_remove = REMOVE $(unwanted) 30 cmd_remove = rm -f $(unwanted) 31 32quiet_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_$*))) \ 36 $< $@ 37 38all: $(syscall-y) 39 $(if $(unwanted),$(call cmd,remove)) 40 @: 41 42$(obj)/syscalls_%.h: $(syscalltbl) $(systbl) FORCE 43 $(call if_changed,systbl) 44 45targets := $(syscall-y) 46 47# Create output directory. Skip it if at least one old header exists 48# since we know the output directory already exists. 49ifeq ($(old-headers),) 50$(shell mkdir -p $(obj)) 51endif 52 53PHONY += FORCE 54 55FORCE: 56 57existing-targets := $(wildcard $(sort $(targets))) 58 59-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 60 61.PHONY: $(PHONY) 62