builtin-name		:= syscalls.built-in.o

CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))

SYS-TYPES		:= ../../include/syscall-types.h
SYS-CODES		:= ../../include/syscall-codes.h
SYS-PROTO		:= ../../include/syscall.h

SYS-DEF			:= syscall.def
SYS-ASM-COMMON		:= syscall-common.S

SYS-GEN			:= ../scripts/arm/gen-syscalls.pl
SYS-GEN-TBL		:= ../scripts/arm/gen-sys-exec-tbl.pl

asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
asflags-y		+= -fpie -Wstrict-prototypes -Wa,--noexecstack
asflags-y		+= -iquote $(obj) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include

SYS-ASM			:= syscalls.S
obj-y			+= $(SYS-ASM:.S=).o

ARCH_BITS		:= 64

SYS-EXEC-TBL		:= sys-exec-tbl.c

$(obj)/$(SYS-ASM): $(obj)/$(SYS-GEN) $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON)
	$(E) "  GEN     " $@
	$(Q) perl				\
		$(obj)/$(SYS-GEN)		\
		$(obj)/syscalls/$(SYS-DEF)	\
		$(obj)/$(SYS-CODES)		\
		$(obj)/$(SYS-PROTO)		\
		$(obj)/$(SYS-ASM)		\
		syscalls/$(SYS-ASM-COMMON)	\
		$(obj)/$(SYS-TYPES)		\
		$(ARCH_BITS)

$(obj)/syscalls.o: $(obj)/$(SYS-ASM)

$(obj)/$(SYS-EXEC-TBL): $(obj)/$(SYS-GEN-TBL) $(obj)/syscalls/$(SYS-DEF)
	$(E) "  GEN     " $@
	$(Q) perl				\
		$(obj)/$(SYS-GEN-TBL)		\
		$(obj)/syscalls/$(SYS-DEF)	\
		$(obj)/$(SYS-EXEC-TBL)		\
		$(ARCH_BITS)

all-y += $(obj)/$(SYS-EXEC-TBL)

mrproper-y += $(obj)/$(SYS-EXEC-TBL) $(obj)/$(SYS-ASM)
mrproper-y += $(obj)/$(SYS-CODES)
mrproper-y += $(obj)/$(SYS-PROTO)
