Framework for exporting system header to user space (#59)
[lunaix-os.git] / lunaix-os / scripts / gen-syscall-header
1 #!/bin/bash
2
3 outfile="$1"
4
5 read -d '' payload <<EOF
6 #define SYSCALL(x) __NR##x __COUNTER__
7 #include <asm/syscall_nr.inc>
8 EOF
9
10 body=$(echo "$payload" \
11       | gcc $CFLAGS -x none -E - -o- -nostdlib -P \
12       | sed -e 's/^__NR__/#define __NR__/' \
13       | sed -e '/#define/!d')
14
15 cat <<EOF > "$outfile" 
16 #ifndef __LUNAIX_SYSCALL_H
17 #define __LUNAIX_SYSCALL_H
18
19 $body
20
21 #endif
22 EOF