1 | #!/usr/bin/env bash |
---|
2 | # $Id: build-from-lisp.bash 14846 2016-02-27 07:29:33Z mevenson $ |
---|
3 | # |
---|
4 | # Build ABCL from a supported Lisp |
---|
5 | |
---|
6 | usage() |
---|
7 | { |
---|
8 | echo "WARNING: This build method can produce slightly different results than" |
---|
9 | echo " the canonical Ant build method." |
---|
10 | echo |
---|
11 | echo "USAGE:" |
---|
12 | echo "$0 <implementation> [[ --clean=T | --full=T | --batch=NIL ]]" |
---|
13 | } |
---|
14 | |
---|
15 | if [ -z "$1" ]; then |
---|
16 | usage |
---|
17 | exit 1 |
---|
18 | fi |
---|
19 | |
---|
20 | check_boolean() |
---|
21 | { |
---|
22 | case "$1" in |
---|
23 | [Tt]|[Nn][Ii][Ll]) |
---|
24 | :;; |
---|
25 | *) |
---|
26 | usage |
---|
27 | echo "Error: Argument \`$1' is neither \"nil\" nor \"t\"." |
---|
28 | exit 1 |
---|
29 | ;; |
---|
30 | esac |
---|
31 | } |
---|
32 | |
---|
33 | IMPL="$1" |
---|
34 | TEMP=$(getopt --long clean:,full:,batch: -n "$0" -- "$@") |
---|
35 | |
---|
36 | if [ $? != 0 ] ; then |
---|
37 | usage |
---|
38 | exit 1 |
---|
39 | fi |
---|
40 | eval set -- "$TEMP" |
---|
41 | |
---|
42 | CLEAN="t" |
---|
43 | FULL="t" |
---|
44 | BATCH="t" |
---|
45 | |
---|
46 | while true ; do |
---|
47 | case "$1" in |
---|
48 | --clean) |
---|
49 | check_boolean "$2" |
---|
50 | CLEAN="$2" |
---|
51 | shift 2 |
---|
52 | ;; |
---|
53 | --full) |
---|
54 | check_boolean "$2" |
---|
55 | FULL="$2" |
---|
56 | shift 2 |
---|
57 | ;; |
---|
58 | --batch) |
---|
59 | check_boolean "$2" |
---|
60 | BATCH="$2" |
---|
61 | shift 2 |
---|
62 | ;; |
---|
63 | --) shift; break ;; |
---|
64 | *) echo "Internal error!" ; exit 1 ;; |
---|
65 | esac |
---|
66 | done |
---|
67 | |
---|
68 | FORM="(build-abcl:build-abcl :clean $CLEAN :full $FULL :batch $BATCH)" |
---|
69 | FILE="build-abcl.lisp" |
---|
70 | |
---|
71 | if [[ ! -r customizations.lisp ]]; then |
---|
72 | cat <<-EOF |
---|
73 | |
---|
74 | Failed to find configuration in 'customizations.lisp'. Please copy |
---|
75 | 'customizations.lisp.in' to 'customizations.lisp', editing it to |
---|
76 | reflect local configuration. |
---|
77 | |
---|
78 | EOF |
---|
79 | exit 1 |
---|
80 | fi |
---|
81 | |
---|
82 | |
---|
83 | |
---|
84 | abcl() |
---|
85 | { |
---|
86 | exec "$1" --load "$2" --eval "(progn $3 (ext:quit))" |
---|
87 | } |
---|
88 | |
---|
89 | ecl() |
---|
90 | { |
---|
91 | exec "$1" -norc -load "$2" -eval "(progn $3 (ext:quit))" |
---|
92 | } |
---|
93 | |
---|
94 | clisp() |
---|
95 | { |
---|
96 | exec "$1" -ansi -q -norc -i "$2" -x "(progn $3 (ext:quit))" |
---|
97 | } |
---|
98 | |
---|
99 | sbcl() |
---|
100 | { |
---|
101 | exec "$1" --no-userinit --load "$2" --eval "(progn $3 (sb-ext:quit))" |
---|
102 | } |
---|
103 | |
---|
104 | cmucl() |
---|
105 | { |
---|
106 | exec "$1" -noinit -load "$2" -eval '(setq *load-verbose* nil)' \ |
---|
107 | -eval "(progn $3 (ext:quit))" |
---|
108 | } |
---|
109 | |
---|
110 | ccl() |
---|
111 | { |
---|
112 | exec "$1" -Q --no-init --load "$2" --eval "(progn $3 (ccl:quit))" |
---|
113 | } |
---|
114 | |
---|
115 | notimplemented() |
---|
116 | { |
---|
117 | usage |
---|
118 | echo "Error: The build script does not currently support $1." |
---|
119 | echo "It's easy to change, though. Look at $0, and send a patch!" |
---|
120 | exit 1 |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | |
---|
125 | # We pass along and execute "$1" so users can pass "sbcl-cvs" |
---|
126 | # etc. instead of "sbcl". |
---|
127 | |
---|
128 | case "$IMPL" in |
---|
129 | abcl*) |
---|
130 | abcl "$IMPL" "$FILE" "$FORM" ;; |
---|
131 | clisp*) |
---|
132 | clisp "$IMPL" "$FILE" "$FORM" ;; |
---|
133 | sbcl*) |
---|
134 | sbcl "$IMPL" "$FILE" "$FORM" ;; |
---|
135 | lisp) |
---|
136 | cmucl "$IMPL" "$FILE" "$FORM" ;; |
---|
137 | ccl*) |
---|
138 | ccl "$IMPL" "$FILE" "$FORM" ;; |
---|
139 | gcl*) |
---|
140 | notimplemented "$IMPL" "$FILE" "$FORM" ;; |
---|
141 | ecl*) |
---|
142 | ecl "$IMPL" "$FILE" "$FORM" ;; |
---|
143 | alisp*) |
---|
144 | notimplemented "$IMPL" "$FILE" "$FORM" ;; |
---|
145 | *) |
---|
146 | usage; |
---|
147 | echo "Error: Unrecognized implementation: $IMPL" |
---|
148 | exit 1 |
---|
149 | ;; |
---|
150 | esac |
---|