-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathLinuxBuild.sh
110 lines (89 loc) · 2.88 KB
/
LinuxBuild.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
#!/bin/bash
# Compile Mako Server as follows:
# wget -O - https://raw.githubusercontent.com/RealTimeLogic/BAS/main/LinuxBuild.sh | bash
# Details: https://github.com/RealTimeLogic/BAS
function abort() {
printf "$1\n\n";
read -p "Press ENTER to exit script"
exit 1;
}
function install() {
abort "Run the following prior to running this script:\nsudo apt-get install git zip unzip gcc make"
}
executables="git zip unzip gcc make"
for i in $executables; do
if ! command -v $i &> /dev/null; then
install
exit 1
fi
done
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) XLIB=-ldl;XCFLAGS=-DLUA_USE_LINUX;machine=Linux;export EPOLL=TRUE;;
Darwin*) machine=Mac;;
CYGWIN*) XLIB=-ldl;XCFLAGS="-DLUA_USE_LINUX -DUSE_FORKPTY=0";machine=Cygwin;;
# MINGW*) machine=MinGw;;
*) abort "Unknown machine ${unameOut}"
esac
if [ -z ${CC+x} ]; then
command -v gcc >/dev/null 2>&1 || install
CC=gcc
echo "Setting default compiler"
fi
echo "Using compiler $CC"
if [ -f src/BAS.c ]; then
abort "Incorrect use! This script should not be run in the BAS directory.\nDetails: https://github.com/RealTimeLogic/BAS"
fi
if ! [ -d "BAS" ]; then
git clone https://github.com/RealTimeLogic/BAS.git || abort "Cloning BAS failed"
fi
if ! [ -d "BAS-Resources" ]; then
git clone https://github.com/RealTimeLogic/BAS-Resources.git || abort "Cloning BAS-Resources failed"
chmod +x BAS-Resources/build/*.sh
fi
if ! [ -f "LPeg/lpcode.c" ]; then
echo "Downloading LPeg"
git clone https://github.com/roberto-ieru/LPeg.git LPeg
fi
if ! [ -f "lua-protobuf/pb.c" ]; then
echo "Downloading Google Protobuf for Lua"
git clone https://github.com/starwing/lua-protobuf.git lua-protobuf
fi
if ! [ -f "CBOR/cbor_c.c" ]; then
echo "Downloading CBOR"
git clone https://github.com/spc476/CBOR.git CBOR
fi
cd BAS || abort $LINENO
if ! [ -f "src/sqlite3.c" ]; then
# if SQLITEURL url not set
if [ -z ${SQLITEURL+x} ]; then
# There is no 'latest' with SQLite :-(
SQLITEURL="https://www.sqlite.org/2025/sqlite-amalgamation-3490100.zip"
fi
SQLITE=${SQLITEURL##*/}
pushd /tmp || abort $LINENO
echo "Downloading: $SQLITEURL"
command -v wget >/dev/null 2>&1
if [ $? -eq 0 ]; then
wget --no-check-certificate $SQLITEURL || abort $LINENO
else
curl $SQLITEURL -o $SQLITE
fi
unzip -o $SQLITE || abort $LINENO
popd
mv /tmp/${SQLITE%.zip}/* src/ || abort $LINENO
fi
if [ -n "${NOCOMPILE+set}" ]; then
exit 0
fi
make -f mako.mk || abort $LINENO
if [[ -z "${CROSS_COMPILE}" ]]; then
read -p "Do you want to install the Mako Server in /usr/local/bin (Y/n)?" </dev/tty
if [ "$REPLY" != "n" ]; then
sudo cp mako mako.zip /usr/local/bin/ || abort
echo "Installed; you may now run mako"
exit 0
fi
fi
echo "Done"
echo "You may now run BAS/mako"