This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-antlr.sh
executable file
·78 lines (59 loc) · 1.72 KB
/
install-antlr.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
#!/bin/sh
set -e # Abort the script at the first error
######################################################################
# Preparation step
# sanity check
if test -d antlr.tmp
then
echo "error: please remove the antlr.tmp directory (probably from a previous attempt)"
exit 1
fi
if test -d antlr
then
echo "error: antlr seems already installed"
exit 1
fi
# cf https://moodle.insa-lyon.fr/mod/forum/discuss.php?d=11522
if ! grep -qs 'insteadof=git://github.com' ~/.gitconfig
then
echo 'patching .gitconfig'
echo '[url "https://github.com/"]' >> ~/.gitconfig
echo ' insteadof=git://github.com' >> ~/.gitconfig
fi
# create a fresh temp directory
mkdir antlr.tmp
cd antlr.tmp
#download both the tool jar and the cpp runtime
curl -O https://www.antlr.org/download/antlr-4.9.2-complete.jar
curl -O https://www.antlr.org/download/antlr4-cpp-runtime-4.9.2-source.zip
######################################################################
# Build step
# CUSTOM ADDITION
# REMOVE IT IF IT FAILS
# Fix GCC stopping on warning by using clang
export CC=clang
export CXX=clang++
unzip *.zip
mkdir build
cd build
cmake ..
make -j8
cd ../..
######################################################################
# install step
# tool jar
mkdir -p antlr/jar
mv antlr.tmp/*.jar antlr/jar
# runtime header files
mkdir antlr/include
cd antlr.tmp/runtime/src
find * -type d -print -exec mkdir ../../../antlr/include/'{}' ';'
find . -name '*.h' -print -exec cp '{}' ../../../antlr/include/'{}' ';'
cd ../../..
# runtime library files
mkdir antlr/lib
mv antlr.tmp/dist/libantlr4-runtime.a antlr/lib
######################################################################
# cleanup step
rm -rf antlr.tmp
echo PLD COMP: ANTLR OK