]> git.ipfire.org Git - thirdparty/util-linux.git/blob - tools/all_syscalls
all_errnos/all_syscalls: use sed to extract defines from headers
[thirdparty/util-linux.git] / tools / all_syscalls
1 #!/bin/bash
2
3 set -e
4 set -o pipefail
5
6 SED="$1"
7 shift
8 OUTPUT=syscalls.h
9 SYSCALL_INCLUDES="
10 #include <sys/syscall.h>
11 "
12
13 trap 'rm -f $OUTPUT $OUTPUT.deps' ERR
14
15 "$@" -MD -MF "$OUTPUT.deps" <<< "$SYSCALL_INCLUDES" -dM -E - \
16 | "$SED" -n -e 's/^#define __NR_\([^ ]*\).*$/UL_SYSCALL("\1", __NR_\1)/p' \
17 | sort \
18 > "$OUTPUT"