-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmenu.sh
executable file
·249 lines (234 loc) · 7.74 KB
/
menu.sh
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
#!/usr/bin/env sh
#
# SweetAda configuration and Makefile front-end.
#
# Copyright (C) 2020-2025 Gabriele Galeotti
#
# This work is licensed under the terms of the MIT License.
# Please consult the LICENSE.txt file located in the top-level directory.
#
#
# Arguments:
# <action> = action to perform: "configure", "all", etc
#
# Environment variables:
# PLATFORM
# SUBPLATFORM
#
################################################################################
# Script initialization. #
# #
################################################################################
SCRIPT_FILENAME=$(basename "$0")
LOG_FILENAME=""
if [ "x${LOG_FILENAME}" != "x" ] ; then
rm -f "${LOG_FILENAME}"
touch "${LOG_FILENAME}"
fi
################################################################################
# log_print() #
# #
################################################################################
log_print()
{
if [ "x${LOG_FILENAME}" != "x" ] ; then
printf "%s\n" "$1" | tee -a "${LOG_FILENAME}"
else
printf "%s\n" "$1"
fi
return 0
}
################################################################################
# log_print_error() #
# #
################################################################################
log_print_error()
{
if [ "x${LOG_FILENAME}" != "x" ] ; then
printf "%s\n" "$1" | tee -a "${LOG_FILENAME}" 1>&2
else
printf "%s\n" "$1" 1>&2
fi
return 0
}
################################################################################
# setplatform() #
# #
################################################################################
setplatform()
{
# select a platform
#PLATFORM=Altera10M50GHRD ; SUBPLATFORM=
#PLATFORM=Amiga-FS-UAE ; SUBPLATFORM=68010
#PLATFORM=ArduinoUno ; SUBPLATFORM=
#PLATFORM=DE10-Lite ; SUBPLATFORM=
#PLATFORM=IntegratorCP ; SUBPLATFORM=
#PLATFORM=LEON3 ; SUBPLATFORM=
#PLATFORM=ML605 ; SUBPLATFORM=
#PLATFORM=Malta ; SUBPLATFORM=
PLATFORM=PC-x86 ; SUBPLATFORM=QEMU-ROM
#PLATFORM=PC-x86-64 ; SUBPLATFORM=QEMU-ROM
#PLATFORM=QEMU-RISC-V-32 ; SUBPLATFORM=
#PLATFORM=SBC5206 ; SUBPLATFORM=
#PLATFORM=SPARCstation5 ; SUBPLATFORM=
#PLATFORM=System390 ; SUBPLATFORM=
#PLATFORM=XilinxZynqA9 ; SUBPLATFORM=
return 0
}
################################################################################
# make_tee() #
# #
# $1 make target #
# $2 make errors file #
# $3 tee logfile #
################################################################################
make_tee()
{
exec 4>&1
_exit_status=$( \
{ \
{ \
${MAKE} "$1" 2> "$2" 3>&- ; \
printf "%s" "$?" 1>&3 ; \
} 4>&- | tee "$3" 1>&4 ; \
} 3>&1 \
)
exec 4>&-
return ${_exit_status}
}
################################################################################
# log_build_errors() #
# #
################################################################################
log_build_errors()
{
if [ -s make.errors.log ] ; then
printf "%s\n" ""
printf "%s\n" "Detected errors and/or warnings:"
printf "%s\n" "--------------------------------"
cat make.errors.log
fi
return 0
}
################################################################################
# usage() #
# #
################################################################################
usage()
{
printf "%s\n" "Usage: ${SCRIPT_FILENAME} <action>"
printf "%s\n" ""
printf "%s\n" "<action> is one of:"
printf "%s\n" "help - build system help"
printf "%s\n" "createkernelcfg - create a kernel.cfg file"
printf "%s\n" "configure - configure the system for a build"
printf "%s\n" "infodump - dump essential informations"
printf "%s\n" "all - build target"
printf "%s\n" "postbuild - auxiliary post-processing"
printf "%s\n" "session-start - perform session start activities"
printf "%s\n" "session-end - perform session end activities"
printf "%s\n" "run - run the target"
printf "%s\n" "debug - debug the target"
printf "%s\n" "clean - cleanup a build"
printf "%s\n" "distclean - cleanup and reset the build system"
printf "%s\n" "rts - build an RTS"
printf "%s\n" ""
printf "%s\n" "Specify PLATFORM=<platform> (and optionally SUBPLATFORM) in the"
printf "%s\n" "environment variable space before executing the \"createkernelcfg\" action."
printf "%s\n" ""
printf "%s\n" "Specify CPU=<cpu> TOOLCHAIN_NAME=<toolchain_name> RTS=<rts> (and"
printf "%s\n" "optionally CPU_MODEL=<cpu_model>) in the environment variable space"
printf "%s\n" "before executing the \"rts\" action."
printf "%s\n" ""
printf "%s\n" "MAKE: ${MAKE}"
printf "%s\n" "default PLATFORM: ${PLATFORM}"
printf "%s\n" "default SUBPLATFORM: ${SUBPLATFORM}"
printf "%s\n" ""
return 0
}
################################################################################
# Main loop. #
# #
################################################################################
if [ "x${MAKE}" = "x" ] ; then
MAKE=make
fi
case $1 in
"help")
"${MAKE}" help
;;
"createkernelcfg")
rm -f make.log make.errors.log
if [ "x${PLATFORM}" = "x" ] ; then
setplatform
fi
if [ $? -eq 0 ] ; then
PLATFORM=${PLATFORM} SUBPLATFORM=${SUBPLATFORM} "${MAKE}" createkernelcfg
exit_status=$?
log_build_errors
fi
;;
"configure")
rm -f make.log make.errors.log
"${MAKE}" configure
exit_status=$?
log_build_errors
;;
"infodump")
"${MAKE}" infodump
exit_status=$?
;;
"all")
rm -f make.log make.errors.log
make_tee all make.errors.log make.log
exit_status=$?
log_build_errors
;;
"kernel")
rm -f make.log make.errors.log
make_tee kernel make.errors.log make.log
exit_status=$?
log_build_errors
;;
"postbuild")
rm -f make.log make.errors.log
make_tee postbuild make.errors.log make.log
exit_status=$?
log_build_errors
;;
"session-start")
"${MAKE}" session-start
exit_status=$?
;;
"session-end")
"${MAKE}" session-end
exit_status=$?
;;
"run")
"${MAKE}" run
exit_status=$?
;;
"debug")
"${MAKE}" debug
exit_status=$?
;;
"clean")
"${MAKE}" clean
exit_status=$?
;;
"distclean")
"${MAKE}" distclean
exit_status=$?
;;
"rts")
rm -f make.log make.errors.log
make_tee rts make.errors.log make.log
exit_status=$?
log_build_errors
;;
*)
usage
exit_status=1
;;
esac
exit ${exit_status}