summaryrefslogblamecommitdiffstats
path: root/linux/syscall-table.mk
blob: 1b993e62af5775a8b9769ab9b7726bce7832efc5 (plain) (tree)
1
2

                                                     



























































                                                                                                                              
# See LICENSE file for copyright and license details.

OBJ += linux/syscall-table.o


linux/syscall-table.o: generated/linux-syscall-table.h linux/syscalls.h $(LINUX_SYSCALLS_HDR) generated/linux-syscall-dedup.h
linux/syscall-table.lo: generated/linux-syscall-table.h linux/syscalls.h $(LINUX_SYSCALLS_HDR) generated/linux-syscall-dedup.h

libsyscalls_get_syscall_range.o: $(LINUX_SYSCALLS_HDR)
libsyscalls_get_syscall_range.lo: $(LINUX_SYSCALLS_HDR)


generated/linux-syscall-table.h: linux/syscall-table.c common.h linux/linux-support.mk
	set -e; \
	macros="$$(sed -n 's/^\s*\x23\s*define\s\+MAKE_\([^(]*\)(.*$$/\1/p' < linux/syscall-table.c)"; \
	for arch in $(SUPPORTED_LINUX_ARCHES); do \
		for macro in $$macros; do \
			printf '\43define MAKE_%s_%s(...) MAKE_%s(%s, __VA_ARGS__)\n' \
				"$$arch" "$$macro" "$$macro" "$$arch"; \
		done; \
	done > $@


generated/linux-syscalls.h: linux/syscalls.mk
	mkdir -p -- generated
	printf '\43include "%s"\n' $(LINUX_SYSCALLS_HDR) \
	| grep -v '"$@"' \
	| sed 's:generated/::' > $@


generated/linux-syscall-ranges.h: $(LINUX_SYSCALLS_ARCH_HDR)
	printf '%s\n' 'This may take some time ...'; \
	set -e; arch=; \
	cat -- $(LINUX_SYSCALLS_ARCH_HDR) \
	| sed 's/^\s*X[A-Z_]*(\([^,]*\).*$$/\1/' \
	| sed 's/\x23\s*define\s\+LIST_LINUX_SYSCALLS_FOR_\(.*\)(.*/\1/' \
	| sed '/^\s*$$/d' \
	| (\
		while read line; do \
			if test -z "$$(printf '%s\n' "$$line" | sed 's/^[A-Z].*$$//')"; then \
				if test -n "$$arch"; then \
					printf '\43define %s_LINUX_SYSCALL_FOR_%s %i\n' \
						MIN "$$arch" "$$min" \
						MAX "$$arch" "$$max"; \
				fi; \
				arch="$$line"; \
				min=; \
				max=; \
			else \
				val=$$(( $$line )); \
				if test -z "$$min" || test "$$val" -lt "$$min"; then \
					min=$$val; \
				fi; \
				if test -z "$$max" || test "$$val" -gt "$$max"; then \
					max=$$val; \
				fi; \
			fi; \
		done; \
		printf '\43define %s_LINUX_SYSCALL_FOR_%s %i\n' \
			MIN "$$arch" "$$min" \
			MAX "$$arch" "$$max"; \
	) > $@