162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ciout := arch/$(SRCARCH)/include/generated/asm
362306a36Sopenharmony_ciuapi := arch/$(SRCARCH)/include/generated/uapi/asm
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci# Create output directory if not already present
662306a36Sopenharmony_ci$(shell mkdir -p $(out) $(uapi))
762306a36Sopenharmony_ci
862306a36Sopenharmony_cisyscall32 := $(src)/syscall_32.tbl
962306a36Sopenharmony_cisyscall64 := $(src)/syscall_64.tbl
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cisyshdr := $(srctree)/scripts/syscallhdr.sh
1262306a36Sopenharmony_cisystbl := $(srctree)/scripts/syscalltbl.sh
1362306a36Sopenharmony_cioffset :=
1462306a36Sopenharmony_ciprefix :=
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciquiet_cmd_syshdr = SYSHDR  $@
1762306a36Sopenharmony_ci      cmd_syshdr = $(CONFIG_SHELL) $(syshdr) --abis $(abis) --emit-nr \
1862306a36Sopenharmony_ci		$(if $(offset),--offset $(offset)) \
1962306a36Sopenharmony_ci		$(if $(prefix),--prefix $(prefix)) \
2062306a36Sopenharmony_ci		$< $@
2162306a36Sopenharmony_ciquiet_cmd_systbl = SYSTBL  $@
2262306a36Sopenharmony_ci      cmd_systbl = $(CONFIG_SHELL) $(systbl) --abis $(abis) $< $@
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciquiet_cmd_hypercalls = HYPERCALLS $@
2562306a36Sopenharmony_ci      cmd_hypercalls = $(CONFIG_SHELL) '$<' $@ $(filter-out $<, $(real-prereqs))
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci$(uapi)/unistd_32.h: abis := i386
2862306a36Sopenharmony_ci$(uapi)/unistd_32.h: $(syscall32) $(syshdr) FORCE
2962306a36Sopenharmony_ci	$(call if_changed,syshdr)
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci$(out)/unistd_32_ia32.h: abis := i386
3262306a36Sopenharmony_ci$(out)/unistd_32_ia32.h: prefix := ia32_
3362306a36Sopenharmony_ci$(out)/unistd_32_ia32.h: $(syscall32) $(syshdr) FORCE
3462306a36Sopenharmony_ci	$(call if_changed,syshdr)
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci$(uapi)/unistd_x32.h: abis := common,x32
3762306a36Sopenharmony_ci$(uapi)/unistd_x32.h: offset := __X32_SYSCALL_BIT
3862306a36Sopenharmony_ci$(uapi)/unistd_x32.h: $(syscall64) $(syshdr) FORCE
3962306a36Sopenharmony_ci	$(call if_changed,syshdr)
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci$(uapi)/unistd_64.h: abis := common,64
4262306a36Sopenharmony_ci$(uapi)/unistd_64.h: $(syscall64) $(syshdr) FORCE
4362306a36Sopenharmony_ci	$(call if_changed,syshdr)
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci$(out)/unistd_64_x32.h: abis := x32
4662306a36Sopenharmony_ci$(out)/unistd_64_x32.h: prefix := x32_
4762306a36Sopenharmony_ci$(out)/unistd_64_x32.h: $(syscall64) $(syshdr) FORCE
4862306a36Sopenharmony_ci	$(call if_changed,syshdr)
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci$(out)/syscalls_32.h: abis := i386
5162306a36Sopenharmony_ci$(out)/syscalls_32.h: $(syscall32) $(systbl) FORCE
5262306a36Sopenharmony_ci	$(call if_changed,systbl)
5362306a36Sopenharmony_ci$(out)/syscalls_64.h: abis := common,64
5462306a36Sopenharmony_ci$(out)/syscalls_64.h: $(syscall64) $(systbl) FORCE
5562306a36Sopenharmony_ci	$(call if_changed,systbl)
5662306a36Sopenharmony_ci$(out)/syscalls_x32.h: abis := common,x32
5762306a36Sopenharmony_ci$(out)/syscalls_x32.h: $(syscall64) $(systbl) FORCE
5862306a36Sopenharmony_ci	$(call if_changed,systbl)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci$(out)/xen-hypercalls.h: $(srctree)/scripts/xen-hypercalls.sh FORCE
6162306a36Sopenharmony_ci	$(call if_changed,hypercalls)
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci$(out)/xen-hypercalls.h: $(srctree)/include/xen/interface/xen*.h
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ciuapisyshdr-y			+= unistd_32.h unistd_64.h unistd_x32.h
6662306a36Sopenharmony_cisyshdr-y			+= syscalls_32.h
6762306a36Sopenharmony_cisyshdr-$(CONFIG_X86_64)		+= unistd_32_ia32.h unistd_64_x32.h
6862306a36Sopenharmony_cisyshdr-$(CONFIG_X86_64)		+= syscalls_64.h
6962306a36Sopenharmony_cisyshdr-$(CONFIG_X86_X32_ABI)	+= syscalls_x32.h
7062306a36Sopenharmony_cisyshdr-$(CONFIG_XEN)		+= xen-hypercalls.h
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ciuapisyshdr-y	:= $(addprefix $(uapi)/, $(uapisyshdr-y))
7362306a36Sopenharmony_cisyshdr-y	:= $(addprefix $(out)/, $(syshdr-y))
7462306a36Sopenharmony_citargets		+= $(addprefix ../../../../, $(uapisyshdr-y) $(syshdr-y))
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciPHONY += all
7762306a36Sopenharmony_ciall: $(uapisyshdr-y) $(syshdr-y)
7862306a36Sopenharmony_ci	@:
79