ccflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
asflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/

sys-types		:= $(obj)/include/uapi/std/syscall-types.h
sys-codes		:= $(obj)/include/uapi/std/syscall-codes.h
sys-proto		:= $(obj)/include/uapi/std/syscall.h

sys-def			:= $(PLUGIN_ARCH_DIR)/std/syscalls/syscall.def
sys-asm-common-name	:= std/syscalls/syscall-common.S
sys-asm-common		:= $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
sys-asm-types		:= $(obj)/include/uapi/std/asm/syscall-types.h
sys-exec-tbl		 = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c

sys-gen			:= $(PLUGIN_ARCH_DIR)/std/syscalls/gen-syscalls.pl
sys-gen-tbl		:= $(PLUGIN_ARCH_DIR)/std/syscalls/gen-sys-exec-tbl.pl

sys-asm			:= ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
std-obj-y		+= $(sys-asm:.S=).o

ifeq ($(ARCH),arm)
arch_bits		:= 32
else
arch_bits		:= 64
endif

sys-exec-tbl		:= sys-exec-tbl.c

$(sys-asm) $(sys-types) $(sys-codes) $(sys-proto): $(sys-gen) $(sys-def) $(sys-asm-common)
	$(E) "  GEN     " $@
	$(Q) perl				\
		$(sys-gen)			\
		$(sys-def)			\
		$(sys-codes)			\
		$(sys-proto)			\
		$(sys-asm)			\
		$(sys-asm-common-name)		\
		$(sys-types)			\
		$(arch_bits)

$(sys-asm:.S=).o: $(sys-asm)

$(sys-exec-tbl): $(sys-gen-tbl) $(sys-def)
	$(E) "  GEN     " $@
	$(Q) perl				\
		$(sys-gen-tbl)			\
		$(sys-def)			\
		$(sys-exec-tbl)			\
		$(arch_bits)

$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
	$(call msg-gen, $@)
	$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
	$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.S $(obj)/include/uapi/std/syscall-aux.S
	$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.h $(obj)/include/uapi/std/syscall-aux.h

std-headers-deps	+= $(sys-asm) $(sys-codes) $(sys-proto) $(sys-asm-types)
mrproper-y		+= $(std-headers-deps)
mrproper-y		+= $(obj)/include/uapi/std/syscall-aux.S
mrproper-y		+= $(obj)/include/uapi/std/syscall-aux.h
