-
Notifications
You must be signed in to change notification settings - Fork 2
/
rars-version.in
88 lines (73 loc) · 1.8 KB
/
rars-version.in
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
#!/bin/sh
# RARS RISC-V support by Evgeny Chugunnyy <[email protected]>
# Copyright (c) 2016 Alexander Chernov <[email protected]>
LANG_CONFIG_DIR="@lang_config_dir@"
common_config() {
echo 'long_name="RARS RISC-V Simulator"'
echo 'src_sfx=".asm"'
echo 'exe_sfx=".s"'
echo 'arch="linux-shared"'
echo 'insecure=1'
}
failure() {
rm -f conftest*
echo 'version='
echo 'arg="'"${arg}"'"'
common_config
echo 'RARSPATH=/bin/false'
[ "${verbose}" = 1 ] && echo "no" >&2
exit 1
}
unset LANG
unset LC_ALL
unset LC_MESSAGES
unset LANGUAGE
if [ x"$1" = x-v ]
then
verbose=1
shift
fi
# recheck the language
if [ x"$1" = x-r ]
then
arg="$2"
[ x"$2" != x ] && rars="$2"
[ "${rars}" = "" ] && rars="rars-simulator"
[ "${verbose}" = 1 ] && echo -n "checking whether RARS is available..." >&2
"${rars}" v >/dev/null 2>&1 || failure ###
version=`"${rars}" v | head -1 | gawk '{ print $2; }'` || failure
[ "${version}" != "" ] || failure
RARSPATH=`which "${rars}"` || failure
[ "${RARSPATH}" != "" ] || failure
echo 'version="'"${version}"'"'
echo 'arg="'"${arg}"'"'
common_config
echo 'RARSPATH="'"${RARSPATH}"'"'
[ "${verbose}" = 1 ] && echo "yes, ${RARSPATH}, ${version}" >&2
exit 0
fi
if [ x"$1" = x-l ]
then
echo "RARS RISC-V Simulator [https://github.com/TheThirdOne/rars]"
exit 0
fi
[ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/rars.cfg"
if [ -f "${EJUDGE_LANG_CONFIG}" ]
then
. "${EJUDGE_LANG_CONFIG}"
else
RARSPATH="rars-simulator"
fi
if [ x"${RARSPATH}" = x -o x"${RARSPATH}" = x/bin/false ]
then
echo "This language is not supported." >&2
exit 1
fi
if [ x"$1" = x-p ]
then
echo "${RARSPATH}"
exit 0
fi
"${RARSPATH}" v 2>/dev/null >/dev/null || exit 1
[ x"$1" = x-f ] && echo -n "RARS "
"${RARSPATH}" v | head -1 | gawk '{ print $2 }'