Skip to content

Commit

Permalink
chore: reformat SConstruct
Browse files Browse the repository at this point in the history
  • Loading branch information
jaqx0r committed Apr 3, 2024
1 parent 2d1315f commit 5a8e648
Showing 1 changed file with 79 additions and 76 deletions.
155 changes: 79 additions & 76 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -12,97 +12,100 @@ env.ParseConfig('pkg-config --cflags --libs gl')

# Merge in glu + glut pkg configs if they exist
for pkg in ['glu', 'glut']:
try:
env.ParseConfig('pkg-config --cflags --libs ' + pkg)
except Exception:
pass
try:
env.ParseConfig('pkg-config --cflags --libs ' + pkg)
except Exception:
pass

# configure
if not env.GetOption("clean"):
conf = Configure(env)
conf = Configure(env)

# 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)
# 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)
# 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("GLUT header file not found!")
Exit(1)
else:
print("GLUT library not found!")
Exit(1)
# 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)

# check whether gettimeofday() exists, and how many arguments it has
print("Checking for gettimeofday() semantics...", end=' ')
if conf.TryCompile("""#include <stdlib.h>
# 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)

# 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("GLUT header file not found!")
Exit(1)
else:
print("GLUT 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)
""", '.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'
]
'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'])
LIBS=['m', 'GL', 'GLU', 'glut'])

0 comments on commit 5a8e648

Please sign in to comment.