-
Notifications
You must be signed in to change notification settings - Fork 0
/
compilation.txt
executable file
·62 lines (45 loc) · 1.63 KB
/
compilation.txt
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
#!/usr/bin/env bash
# run as:
## ./compilation.txt && ./app
# early version
## gcc sdl2-gl.c `sdl2-config --cflags --libs` -lopengl32 -lglu32 && ./a
# test for : pkg-config --cflags --libs
pkg-config --cflags --libs glu 1>/dev/null 2>/dev/null # no stdout , no stderr
if [ $? -eq 0 ];
then
#echo "pkg-config --cflags --libs glu: success"
GL_GLU=`pkg-config --cflags --libs glu`
###gcc sdl2-gl.c `sdl2-config --cflags --libs` `pkg-config --cflags --libs glu` -o app && ./app
else
#echo "pkg-config --cflags --libs glu: failure"
GL_GLU="-lopengl32 -lglu32"
###gcc sdl2-gl.c `sdl2-config --cflags --libs` -lopengl32 -lglu32 -o app && ./app
fi
#echo ":: GL_GLU=$GL_GLU"
# simpler version
###gcc sdl2-gl.c `sdl2-config --cflags --libs` $GL_GLU -o app && ./app
SDL="$(sdl2-config --cflags) $(sdl2-config --libs)"
#echo ":: SDL=$SDL"
COMMAND="gcc sdl2-gl.c $SDL $GL_GLU -o app"
#echo ":: COMMAND=$COMMAND"
echo ">> $COMMAND" && $COMMAND
if [ $? -eq 0 ];
then
echo "compilation success"
#./app
## ./compilation.txt && ./app # compilation, if success then run app
exit 0 # success
else
echo "================================="
echo "compilation FAILURE"
echo "================================="
echo "CHECK whether this works properly: pkg-config --cflags --libs glu"
pkg-config --cflags --libs glu
echo "CHECK proper value assignment of variables: GL_GLU, SDL, COMMAND"
echo ":: GL_GLU=$GL_GLU"
echo ":: SDL=$SDL"
echo ":: COMMAND=$COMMAND"
echo "CHECK: compilation COMMAND follows this SCHEME:"
echo "gcc app-code.c \$SDL \$GL_GLU -o app"
exit 1 # failure
fi