forked from zephir-lang/zephir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·47 lines (38 loc) · 1.12 KB
/
install
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
#!/bin/bash
cd parser
rm -f *.o *.lo
#Compile lemon
if [ ! -f lemon ]; then
gcc -w lemon.c -o lemon
fi
TEST=`re2c -v`
if [ $? != 2 ]; then
echo "error: re2c is not installed"
exit 2
fi
re2c -o scanner.c scanner.re && ./lemon -s parser.lemon && cat base.c >> parser.c
if [ ! -f parser.c ]; then
echo "error: re2c is not installed"
exit 2
fi
sed s/"\#line"/"\/\/"/g scanner.c > xx && mv -f xx scanner.c
sed s/"#line"/"\/\/"/g parser.c > xx && mv -f xx parser.c
export CFLAGS="-g3 -O0"
gcc -Wl,-rpath /usr/local/lib -I/usr/local/include -L/usr/local/lib -L/opt/local/lib -g3 -w parser.c scanner.c -ljson-c -o ../bin/zephir-parser
cd ..
# Using the -c option will copy zephir in /usr/local/bin
options='c'
while getopts $options option
do
if [[ "$option" == "c" ]]; then
ZEPHIRDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
sed "s#%ZEPHIRDIR%#$ZEPHIRDIR#g" bin/zephir > bin/zephir-cmd
chmod 755 bin/zephir-cmd
sudo cp bin/zephir-cmd /usr/local/bin/zephir
rm bin/zephir-cmd
exit 0
fi
done
if [ -d "/etc/bash_completion.d/" ]; then
sudo cp bin/bash_completion /etc/bash_completion.d/zephir
fi