Tue Jul 9 09:37:55 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / sysdeps / unix / make-syscalls.sh
blob260769ed7b9d14d60513887d2e1e386b20f5ed5c
1 #! /bin/sh
3 # Usage: make-syscalls.sh ../sysdeps unix/common
4 # Expects $sysdirs in environment.
6 sysbase=$1; shift
7 thisdir=$1; shift
9 # Get the list of system calls for this directory.
10 calls=`sed 's/#.*$//
11 /^[ ]*$/d' $sysbase/$thisdir/syscalls.list`
13 # Check each sysdep dir with higher priority than this one,
14 # and remove from $calls all the functions found in other dirs.
15 for dir in $sysdirs; do
17 # Punt when we reach the directory defining these syscalls.
18 test $dir = $thisdir && break
20 # Remove each syscall that is implemented by a file in $dir.
21 # If a syscall specified a "caller", then only compile that syscall
22 # if the caller function is also implemented in this directory.
23 calls=`echo "$calls" | while read file caller rest; do
24 test -f $sysbase/$dir/$file.c && continue
25 test -f $sysbase/$dir/$file.S && continue
26 test -f $sysbase/$dir/$file.s && continue
27 if test x$caller != x-; then
28 test -f $sysbase/$dir/$caller.c && continue
29 test -f $sysbase/$dir/$caller.S && continue
30 test -f $sysbase/$dir/$caller.s && continue
32 echo $file $caller $rest
33 done`
35 done
37 # Any calls left?
38 test -n "$calls" || exit 0
40 files=
42 # Emit rules to compile the syscalls remaining in $calls.
43 echo "$calls" | while read file caller syscall nargs strong weak; do
45 # Figure out if $syscall is defined with a number in syscall.h.
46 $asm_CPP - << EOF | grep "^@@@ .*$syscall" >/dev/null && continue
47 #include <sysdep.h>
48 @@@ SYS_ify ($syscall)
49 EOF
51 # Make sure only the first syscall rule is used, if multiple dirs
52 # define the same syscall.
53 echo "ifeq (,\$(filter $file,\$(unix-syscalls)))"
55 # Accumulate the list of syscall files for this directory.
56 echo "unix-syscalls += $file"
57 test x$caller = x- || echo "unix-extra-syscalls += $file"
59 # Emit a compilation rule for this syscall.
60 echo "\
61 \$(foreach o,\$(object-suffixes),\$(objpfx)$file\$o): \$(objpfx)s-proto.d
62 (echo '#include <sysdep.h>'; \\
63 echo 'PSEUDO ($strong, $syscall, $nargs)'; \\
64 echo ' ret'; \\
65 echo 'PSEUDO_END($strong)'; \\"
67 # Append any weak aliases defined for this syscall function.
68 for name in $weak; do
69 echo " echo 'weak_alias ($strong, $name)'; \\"
70 done
72 # And finally, pipe this all into the compiler.
73 echo ' ) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'
75 echo endif
77 done