3 # Usage: make-syscalls.sh ../sysdeps unix/common
4 # Expects $sysdirs in environment.
9 # Get the list of system calls for this directory.
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
38 test -n "$calls" ||
exit 0
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
48 @@@ SYS_ify ($syscall)
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.
61 \$(foreach o,\$(object-suffixes),\$(objpfx)$file\$o): \$(objpfx)s-proto.d
62 (echo '#include <sysdep.h>'; \\
63 echo 'PSEUDO ($strong, $syscall, $nargs)'; \\
65 echo 'PSEUDO_END($strong)'; \\"
67 # Append any weak aliases defined for this syscall function.
69 echo " echo 'weak_alias ($strong, $name)'; \\"
72 # And finally, pipe this all into the compiler.
73 echo ' ) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'