-
Notifications
You must be signed in to change notification settings - Fork 4
/
build
executable file
·57 lines (49 loc) · 1.75 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
if [[ "$1" == "measure" ]]; then
CC=gcc
CFLAGS="-Wall -Wextra -Werror -O3 -I./include -DMEASURE"
LFLAGS="-lturbojpeg -lglfw -lavformat -lavcodec -lavutil -lm -O3"
elif [[ "$1" == "debug" ]]; then
CC=gcc
CFLAGS="-Wall -Wextra -Werror -g -I./include"
LFLAGS="-lturbojpeg -lglfw -lavformat -lavcodec -lavutil -lm -g"
else
CC=gcc
CFLAGS="-Wall -Wextra -Werror -O3 -I./include"
LFLAGS="-lturbojpeg -lglfw -lavformat -lavcodec -lavutil -lm -O3"
fi
rm -rf ./obj
mkdir -p ./obj
rm -rf ./bin
mkdir -p ./bin
compile(){
echo $CC $CFLAGS -c $1 -o $2
$CC $CFLAGS -c $1 -o $2
if [ $? -ne 0 ]; then
echo "Compilation failed for $cFilename!"
exit 1
fi
}
link() {
filenames=("${@:1:$#-1}")
output_file="${!#}"
echo $CC "${filenames[@]}" $LFLAGS -o "$output_file"
$CC "${filenames[@]}" $LFLAGS -o "$output_file"
if [ $? -ne 0 ]; then
echo "Linking failed!"
exit 1
fi
}
compile "./src/GLAD.c" "./obj/GLAD.o"
compile "./src/VideoCapture.c" "./obj/VideoCapture.o"
compile "./src/VideoDecoder.c" "./obj/VideoDecoder.o"
compile "./src/VideoPipe.c" "./obj/VideoPipe.o"
compile "./src/VideoRecorder.c" "./obj/VideoRecorder.o"
compile "./src/VideoRenderer.c" "./obj/VideoRenderer.o"
compile "./src/VideoUDPReceiver.c" "./obj/VideoUDPReceiver.o"
compile "./src/VideoUDPSender.c" "./obj/VideoUDPSender.o"
compile "./src/VideoUDPShared.c" "./obj/VideoUDPShared.o"
compile "./src/FastMJPG.c" "./obj/FastMJPG.o"
link "./obj/GLAD.o" "./obj/VideoCapture.o" "./obj/VideoDecoder.o" "./obj/VideoPipe.o" "./obj/VideoRecorder.o" "./obj/VideoRenderer.o" "./obj/VideoUDPReceiver.o" "./obj/VideoUDPSender.o" "./obj/VideoUDPShared.o" "./obj/FastMJPG.o" "./bin/FastMJPG"
echo "Build successful!"
exit 0