-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·38 lines (33 loc) · 902 Bytes
/
build
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
#!/bin/bash
FLAGS="`pkg-config --cflags --libs opengl glu glut` -lm"
SOURCES="`find src/ -name *.c`"
# make sure out/ directory exists
mkdir -p out/
# for each source file compile as object file
for src in `echo $SOURCES`; do
obj=out/${src#"src/"}.o
# if object file exists
if [ -f $obj ]; then
obj_time=`stat $obj -c %Y`
src_time=`stat $src -c %Y`
# source file more recent. Then it was modified, so compile it again
if [ $src_time -gt $obj_time ]; then
gcc -c $FLAGS $src -o $obj
echo "$src Recompiled"
else
echo "$obj is up-to-date"
fi
else # otherwise
gcc -c $FLAGS $src -o $obj
echo "$src Compiled"
fi
done
for obj in `find out/ -name *.o`; do
tmp=${obj%.o}
src=src/${tmp#"out/"}
if [ ! -f $src ]; then
rm $obj
echo "$obj deleted since $src doesn't exist."
fi
done
gcc $FLAGS `find out/ -name *.o` -o flattybird.out