-
Notifications
You must be signed in to change notification settings - Fork 26
/
install-sdk
258 lines (239 loc) · 7.2 KB
/
install-sdk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/sh
set -e
unamestr=$(uname)
cygwin() {
if [ "$unamestr" = 'Darwin' ]; then
[ "$(uname -s | sed -E "s/-.*$//")" = "CYGWIN_NT" ]
else
[ "$(uname -s | sed -re "s/-.*$//")" = "CYGWIN_NT" ]
fi
}
prereqs() {
missing=0
hash cmake 2>/dev/null || { missing=1; echo >&2 "Please install cmake, which is available through your package manager or http://www.cmake.org/"; }
hash git 2>/dev/null || { missing=1; echo >&2 "Please install git, which is available through your package manager or http://git-scm.com/"; }
hash a2x 2>/dev/null || { missing=1; echo >&2 "Please install asciidoc, which is available through your package manager or http://asciidoc.org/"; }
hash gcc 2>/dev/null || { missing=1; echo >&2 "Please install gcc, which is available through your package manager or https://gcc.gnu.org/"; }
hash make 2>/dev/null || { missing=1; echo >&2 "Please install GNU make, which is available through your package manager or http://www.gnu.org/software/make/"; }
hash flex 2>/dev/null || { missing=1; echo >&2 "Please install flex, which is available through your package manager or http://flex.sourceforge.net/"; }
hash bison 2>/dev/null || { missing=1; echo >&2 "Please install bison, which is available through your package manager or https://www.gnu.org/software/bison/"; }
hash python3 2>/dev/null || { missing=1; echo >&2 "Please install Python 3, which is available through your package manager or https://www.python.org/"; }
if ! cygwin; then
hash mono 2>/dev/null || { missing=1; echo >&2 "Please install mono, which is available through your package manager or http://mono-project.com/"; }
hash pip3 2>/dev/null || { missing=1; echo >&2 "Please install pip3, which is available through your package manager or https://pip.pypa.io/en/latest/installing.html"; }
hash sdl-config 2>/dev/null || { missing=1; echo >&2 "Please install SDL (and its headers), which is available through your package manager or http://www.libsdl.org/"; }
fi
if [ "$unamestr" = 'Darwin' ]; then
[ -e "/usr/local/Cellar/boost/" ] || { missing=1; echo >&2 "Please install boost (and its headers) via Homebrew"; }
[ -e /usr/local/include/readline/readline.h ] || { missing=1; echo >&2 "Please install readline (and its headers) via Homebrew"; }
else
[ -e /usr/include/boost/config.hpp ] || { missing=1; echo >&2 "Please install boost (and its headers), which is available through your package manager"; }
[ -e /usr/include/readline/readline.h ] || { missing=1; echo >&2 "Please install readline (and its headers), which is available through your package manager (libreadline-dev on Debian/Ubuntu)"; }
fi
if [ $missing -eq 1 ]; then
exit 1
fi
if cygwin; then
echo "Cygwin users - make sure you're running cygwin as administrator!"
fi
}
quiet() {
output=$("$@" 2>&1) || { echo "$output"; exit 1; }
}
install() {
wd=$(pwd)
cd "$(mktemp -dt SDK.XXXXXX)"
"$@"
cd "$wd"
}
asroot() {
if [ "$unamestr" = 'Darwin' ]; then
sudo "$@"
elif [ "$(uname -s | sed -re "s/-.*$//")" = "CYGWIN_NT" ]; then
quiet "$@"
elif [ -n "$(which sudo)" ]
then
sudo "$@"
elif [ -n "$(which doas)" ]
then
doas "$@"
else
echo No method of running as root detected!
exit 1
fi
}
info() {
printf '\e[0;34m%s\e[0m\n' "$*"
}
genkfs() {
info Downloading genkfs...
quiet git clone git://github.com/KnightOS/genkfs.git
cd genkfs
info Compiling genkfs...
quiet cmake .
quiet make
info Installing genkfs...
asroot make install
}
mktiupgrade() {
info Downloading mktiupgrade...
quiet git clone git://github.com/KnightOS/mktiupgrade
cd mktiupgrade
info Compiling mktiupgrade...
quiet cmake .
quiet make
info Installing mktiupgrade...
asroot make install
}
kpack() {
info Downloading kpack...
quiet git clone git://github.com/KnightOS/kpack.git
cd kpack
info Compiling kpack...
quiet cmake .
quiet make
info Installing kpack...
asroot make install
}
kimg() {
info Downloading kimg...
quiet git clone git://github.com/KnightOS/kimg.git
cd kimg
info Compiling kimg...
quiet cmake .
quiet make
info Installing kimg...
asroot make install
}
z80e() {
info Downloading z80e...
quiet git clone --recursive git://github.com/KnightOS/z80e.git
cd z80e
info Compiling z80e...
quiet cmake -Denable-sdl=YES .
quiet make
info Installing z80e...
asroot make install
}
scas() {
info Downloading scas...
quiet git clone git://github.com/KnightOS/scas.git
cd scas
info Compiling scas...
quiet cmake -DINSTRUCTION_SET_PATH=/usr/share/scas/instruction_sets/ -DSCAS_LIBRARY=TRUE .
quiet make
info Installing scas...
asroot make install
}
kcc() {
info Downloading kcc...
quiet git clone git://github.com/KnightOS/kcc.git
cd kcc
info Compiling kcc...
quiet cmake .
quiet make
info Installing kcc...
asroot make install
}
sass() {
info Downloading sass...
quiet git clone git://github.com/KnightOS/sass.git
cd sass
info Compiling sass...
quiet make
info Installing sass...
asroot make install
}
pip() { # cygwin only
info Installing pip...
quiet wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
quiet python3 ez_setup.py
quiet /usr/bin/easy_install-3.2 pip
}
sdk() {
info Downloading SDK...
quiet git clone git://github.com/KnightOS/sdk.git
info Installing SDK requirements...
asroot pip3 install docopt
asroot pip3 install requests
asroot pip3 install pystache
asroot pip3 install pyyaml
cd sdk
info Installing SDK...
asroot ./setup.py install
}
force_all() {
install genkfs
install mktiupgrade
install kpack
install kimg
install sass
install scas
install kcc
if cygwin; then
install pip
else
install z80e
fi
install sdk
info KnightOS SDK installed!
}
prereqs
if [ $# -eq 0 ]; then
force_all
echo "Thanks for installing the KnightOS SDK!"
echo "You can run 'knightos --help' to find out how to use it."
echo "Resources are available online at http://www.knightos.org/documentation"
echo "Have fun!"
else
case "$1" in
genkfs)
install genkfs
shift 1
;;
mktiupgrade)
install mktiupgrade
shift 1
;;
kpack)
install kpack
shift 1
;;
kimg)
install kimg
shift 1
;;
z80e)
install z80e
shift 1
;;
sass)
install sass
shift 1
;;
scas)
install scas
shift 1
;;
kcc)
install kcc
shift 1
;;
sdk)
install sdk
shift 1
;;
pip)
install pip
shift 1
;;
all)
force_all
shift 1
;;
*)
echo "Error: $1 is not a valid option."
exit 1
;;
esac
fi