-
Notifications
You must be signed in to change notification settings - Fork 2
/
SConstruct
115 lines (103 loc) · 2.98 KB
/
SConstruct
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from __future__ import print_function
import os
EnsureSConsVersion(0, 95)
SConsignFile('.sconsign')
env = Environment(ENV={'PATH': os.environ['PATH']})
# configure
if not env.GetOption("clean"):
conf = Configure(env)
# Require gl
try:
env.ParseConfig('pkg-config --cflags --libs gl')
print("pkg-config provided libGL")
except OSError:
# check for GL
if conf.CheckLib('GL', 'glLightfv'):
if conf.CheckCHeader('GL/gl.h'):
conf.env.AppendUnique(CPPFLAGS=['-DHAVE_GL'])
else:
print("GL header file not found!")
Exit(1)
else:
print("GL library not found!")
Exit(1)
try:
env.ParseConfig('pkg-config --cflags --libs glu')
print("pkg-config provided libglu")
except OSError:
# check for GLU
if conf.CheckLib('GLU', 'gluOrtho2D'):
if conf.CheckCHeader('GL/glu.h'):
conf.env.AppendUnique(CPPFLAGS=['-DHAVE_GLU'])
else:
print("GLU header file not found!")
Exit(1)
else:
print("GLU library not found!")
Exit(1)
try:
env.ParseConfig('pkg-config --cflags --libs glut')
print("pkg-config provided libglut")
conf.env.AppendUnique(CPPFLAGS=['-DHAVE_GLUT'])
except OSError:
# check for GLUT
if conf.CheckLib('glut', 'glutMainLoop'):
if conf.CheckCHeader('GL/glut.h'):
conf.env.AppendUnique(CPPFLAGS=['-DHAVE_GLUT'])
else:
print("GLUT header file not found!")
Exit(1)
else:
print("GLUT library not found!")
Exit(1)
# check for libm
if conf.CheckLib('m', 'fmod'):
if conf.CheckCHeader('math.h'):
conf.env.AppendUnique(CPPFLAGS=['-DHAVE_GLUT'])
else:
print("math header file not found!")
Exit(1)
else:
print("libm library not found!")
Exit(1)
# check whether gettimeofday() exists, and how many arguments it has
print("Checking for gettimeofday() semantics...", end=' ')
if conf.TryCompile("""#include <stdlib.h>
#include <sys/time.h>
int main() {
struct timeval tv;
struct timezone tzp;
gettimeofday(&tv, &tzp);
}
""", '.c'):
conf.env.AppendUnique(CPPFLAGS=['-DHAVE_GETTIMEOFDAY',
'-DGETTIMEOFDAY_TWO_ARGS'])
print("two args")
else:
if conf.TryCompile("""#include <stdlib.h>
#include <sys/time.h>
int main() {
struct timeval tv; gettimeofday(&tv);
}""", '.c'):
conf.env.AppendUnique(CPPFLAGS=['-DHAVE_GETTIMEOFDAY'])
print("one arg")
else:
print("unknown")
print("gettimeofday() has unknown number of arguments")
Exit(1)
# set warning flags
warnings = ['',
'all',
'error',
'aggregate-return',
'cast-align',
'cast-qual',
'nested-externs',
'shadow',
'bad-function-cast',
'write-strings'
]
env.AppendUnique(CCFLAGS=['-W%s' % (w,) for w in warnings])
glsnake_sources = 'glsnake.c'
glsnake = env.Program('glsnake', glsnake_sources,
LIBS=['m', 'GL', 'GLU', 'glut'])