summaryrefslogtreecommitdiffstats
path: root/linux/syscall-table.mk
blob: 7e6fb1a6057bcd1ad41e61d850f92491589a0aa9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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)*$(h)$(s)*define$(s)\{1,\}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/$(h)$(s)*define$(s)\{1,\}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"; \
	) > $@