... |
... |
@@ -5,34 +5,76 @@ |
5
|
5
|
# definitions of all the Unix errno values.
|
6
|
6
|
#
|
7
|
7
|
|
|
8
|
+usage ()
|
|
9
|
+{
|
|
10
|
+ cat <<EOF
|
|
11
|
+create-erno.sh [-h?DS]
|
|
12
|
+ -h This help
|
|
13
|
+ -? This help
|
|
14
|
+ -D Do not auto-generate; use default
|
|
15
|
+
|
|
16
|
+ -S Show the resulting generated file; the file is still created.
|
|
17
|
+
|
|
18
|
+Auto-generates, if possible, the file src/code/errno.lisp that
|
|
19
|
+contains the def-unix-error forms.
|
|
20
|
+EOF
|
|
21
|
+ exit 0
|
|
22
|
+}
|
|
23
|
+
|
|
24
|
+while getopts "h?DS" arg
|
|
25
|
+do
|
|
26
|
+ case $arg in
|
|
27
|
+ h) usage ;;
|
|
28
|
+ \?) usage ;;
|
|
29
|
+ D) DEFAULT=yes ;;
|
|
30
|
+ S) SHOW=yes ;;
|
|
31
|
+ esac
|
|
32
|
+done
|
|
33
|
+
|
8
|
34
|
# Where the output should go.
|
9
|
35
|
OUTPUT="src/code/errno.lisp"
|
10
|
36
|
|
11
|
|
-# Copy the main errno template to the output. The template is a lisp
|
12
|
|
-# file so we can read and modify it more easily.
|
13
|
|
-cat bin/errno-template.lisp > $OUTPUT
|
14
|
|
-
|
15
|
|
-# Create appropriate DEF-UNIX-ERROR forms by reading header files
|
16
|
|
-# containing the C definitions.
|
|
37
|
+# Template file containing the default def-unix-error forms and other
|
|
38
|
+# support code.
|
|
39
|
+TEMPLATE="bin/errno-template.lisp"
|
17
|
40
|
|
18
|
41
|
# Set ERRNO_FILES to the files where we can find errno definitions.
|
19
|
|
-case `uname -s` in
|
20
|
|
- Linux) ERRNO_FILES=/usr/include/asm-generic/errno*.h
|
21
|
|
- ;;
|
22
|
|
- Darwin) ERRNO_FILES=/usr/include/sys/errno.h
|
23
|
|
- ;;
|
24
|
|
- SunOS) ERRNO_FILES=/usr/include/sys/errno.h
|
25
|
|
- ;;
|
26
|
|
-esac
|
27
|
|
-
|
28
|
|
-awk -f bin/create-def-unix-error.awk ${ERRNO_FILES} >> $OUTPUT
|
29
|
|
-
|
30
|
|
-# The tail was also copied from code/unix.lisp. It's needed to tell
|
31
|
|
-# Lisp about the errno values.
|
32
|
|
-cat >>$OUTPUT <<EOF
|
33
|
|
-;;; End auto-generated forms, if any.
|
34
|
|
-
|
35
|
|
-;;;
|
36
|
|
-;;; And now for something completely different ...
|
37
|
|
-(emit-unix-errors)
|
|
42
|
+if [ -z "$DEFAULT" ]; then
|
|
43
|
+ case `uname -s` in
|
|
44
|
+ Linux) ERRNO_FILES=/usr/include/asm-generic/errno*.h
|
|
45
|
+ ;;
|
|
46
|
+ Darwin) ERRNO_FILES=/usr/include/sys/errno.h
|
|
47
|
+ ;;
|
|
48
|
+ SunOS) ERRNO_FILES=/usr/include/sys/errno.h
|
|
49
|
+ ;;
|
|
50
|
+ esac
|
|
51
|
+fi
|
|
52
|
+
|
|
53
|
+if [ -z "$ERRNO_FILES" ]; then
|
|
54
|
+ # Copy the main errno template to the output. The template is a lisp
|
|
55
|
+ # file so we can read and modify it more easily.
|
|
56
|
+ cat "$TEMPLATE" > $OUTPUT
|
|
57
|
+else
|
|
58
|
+ # We can autogenerate the def-unix-error forms. Copy just the
|
|
59
|
+ # initial part of the template, up to the first def-unix-error
|
|
60
|
+ # form.
|
|
61
|
+ sed '/^(def-unix-error ESUCCESS/q' "$TEMPLATE" > $OUTPUT
|
|
62
|
+ cat >> $OUTPUT <<EOF
|
|
63
|
+
|
|
64
|
+;; Autogenerated def-unix-error forms
|
38
|
65
|
EOF
|
|
66
|
+
|
|
67
|
+ # Create appropriate DEF-UNIX-ERROR forms by reading header files
|
|
68
|
+ # containing the C definitions.
|
|
69
|
+
|
|
70
|
+ awk -f bin/create-def-unix-error.awk ${ERRNO_FILES} >> $OUTPUT
|
|
71
|
+
|
|
72
|
+ # The tail was also copied from code/unix.lisp. It's needed to tell
|
|
73
|
+ # Lisp about the errno values.
|
|
74
|
+ sed '1,/^;;; End of default/d' "$TEMPLATE" >> $OUTPUT
|
|
75
|
+fi
|
|
76
|
+
|
|
77
|
+# If -S option given, cat the output file to stdout
|
|
78
|
+if [ -n "$SHOW" ]; then
|
|
79
|
+ cat $OUTPUT
|
|
80
|
+fi |