-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall
More file actions
50 lines (40 loc) · 1.51 KB
/
install
File metadata and controls
50 lines (40 loc) · 1.51 KB
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
#!/bin/bash
#####################################################
## OS X always complains about __nonnull and __wur ##
#####################################################
if [ "${OSTYPE}" == "darwin" ] || [ "${OSTYPE}" == "freebsd" ] ; then
sed -i '' 's/ __nonnull.*;/;/' "./snake.c" "./libs/screenlib.c" "./libs/screenlib.h"
sed -i '' 's/ __wur.*;/;/' "./snake.c" "./libs/screenlib.c" "./libs/screenlib.h"
fi
#####################################################
## Compile and install the custom shared object ##
#####################################################
gcc -c -Wall -Werror -fPIC -o "./libs/screenlib.o" "./libs/screenlib.c"
if [ $? -ne 0 ]; then
echo "[-] Failed to compile object file from ./libs/screenlib.c"
exit 1
fi
gcc -shared -o "./libs/libscreenlib.so" "./libs/screenlib.o"
if [ $? -ne 0 ]; then
echo "[-] Failed to compiled shared object from ./libs/screenlib.o"
exit 1
fi
echo "[+] Compiled shared object"
sudo cp "./libs/screenlib.h" "/usr/include"
sudo chmod 644 "/usr/include/screenlib.h"
sudo cp "./libs/libscreenlib.so" "/usr/lib"
sudo chmod 755 "/usr/lib/libscreenlib.so"
echo "[+] Compiling snake binary"
gcc -c -O2 -Wall -Werror "./snake.c"
if [ $? -ne 0 ]; then
echo "[-] Failed to create object file from snake.c"
exit 1
fi
gcc -O2 -Wall -Werror -o "./snake" "./snake.o" -lscreenlib
if [ $? -ne 0 ]; then
echo "[-] Failed to compile binary from object file"
exit 1
fi
sudo cp "./snake" "${PATH%%:*}"
sudo chmod 755 "${PATH%%:*}/snake"
echo "[+] Successfully compiled and installed snake"