-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·62 lines (46 loc) · 1.11 KB
/
build.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
#!/bin/bash
echo "<!> Building ascii maker..."
echo "<-> Cleaning up..."
set -e
rm -rf bin
rm -rf obj
find src -name "*.h" -type f -delete
echo "<-> Making headers..."
for file in $(find src -name "*.[ch]")
do
makeheaders $file
echo "<!> Headers for" $file "made"
done
echo "<-> Adding header guards..."
for file in $(find src -name "*.[h]")
do
fbname=$(basename "$file" .h)
upper=${fbname^^}
echo -e "#ifndef" "$upper" "\n""#define" "$upper" "\n" "$(<$file)" "\n""#endif" > $file
echo "<!> Headers guards for" $file "made"
done
cp include/* src/
mkdir bin
mkdir obj
echo "<-> Building source files"
for file in $(find src -name "*.[c]")
do
echo "<!> Building $file ..."
if [[ $1 == "release" ]]
then
gcc -c -Wall -fopenmp -march=native -O3 -g0 -lm $file
else
gcc -c -Wall -fopenmp -march=native -Og -g -lm $file
fi
done
mv *.o obj/
echo "<-> Compiling executable"
if [[ $1 == "release" ]]
then
gcc -march=native -fopenmp -O3 -g0 -lm -o bin/asciimaker obj/*.o
else
gcc -march=native -fopenmp -Og -g -lm -o bin/asciimaker obj/*.o
fi
echo "<-> Done!"
chmod +x bin/asciimaker
./bin/asciimaker