2005-03-01 07:50:22 +00:00
|
|
|
#This file is part of Photon (http://photon.sourceforge.net)
|
|
|
|
#Copyright (C) 2004-2005 James Turk
|
|
|
|
#
|
|
|
|
# Author:
|
|
|
|
# James Turk (jpt2433@rit.edu)
|
|
|
|
#
|
|
|
|
# Version:
|
2005-11-23 19:38:51 +00:00
|
|
|
# $Id: SConstruct,v 1.27 2005/11/23 19:38:51 cozman Exp $
|
2005-03-01 07:50:22 +00:00
|
|
|
|
|
|
|
import os,os.path
|
|
|
|
import glob
|
2005-05-14 02:30:10 +00:00
|
|
|
import string
|
2005-03-01 07:50:22 +00:00
|
|
|
|
2005-04-21 18:39:26 +00:00
|
|
|
def getFilesMulti(paths, pat):
|
|
|
|
"""Get all files which match a glob in a set of directories"""
|
|
|
|
filelist = []
|
|
|
|
for d in paths:
|
2005-05-14 02:16:42 +00:00
|
|
|
filelist += glob.glob( os.path.join(d,pat) )
|
2005-08-08 21:39:40 +00:00
|
|
|
filelist = [ f.replace(os.path.sep,'/') for f in filelist]
|
2005-04-21 18:39:26 +00:00
|
|
|
return filelist
|
2005-07-04 06:33:06 +00:00
|
|
|
|
2005-05-14 02:16:42 +00:00
|
|
|
## config variables ##
|
|
|
|
LIBRARY = 'photon'
|
|
|
|
SUB_DIRS = ['', 'audio', 'math', 'util', 'util/filesys', 'video']
|
|
|
|
SRC_DIRS = ["src/%s" % d for d in SUB_DIRS]
|
|
|
|
INC_DIRS = ["include/%s" % d for d in SUB_DIRS]
|
|
|
|
SRC_FILES = [f.replace('src','build') for f in getFilesMulti(SRC_DIRS, '*.cpp')]
|
|
|
|
INC_FILES = getFilesMulti(INC_DIRS, '*.hpp')
|
2005-04-21 18:39:26 +00:00
|
|
|
|
2005-08-10 05:36:30 +00:00
|
|
|
libsMap = { 'nt':('opengl32','glu32','openal32'),
|
2005-05-14 02:16:42 +00:00
|
|
|
'posix':('GL','GLU','openal'),
|
2005-06-10 07:06:06 +00:00
|
|
|
'mac':('GL','GLU','openal')}
|
2005-05-14 02:16:42 +00:00
|
|
|
try:
|
|
|
|
OGL_LIB,GLU_LIB,OAL_LIB = libsMap[os.name]
|
|
|
|
except KeyError:
|
|
|
|
print """Building on this platform (' + os.name + ') is not
|
|
|
|
supported. Contact James (jpt2433@rit.edu) to check on
|
|
|
|
support."""
|
|
|
|
Exit(1)
|
2005-03-04 13:06:49 +00:00
|
|
|
|
2005-07-04 06:33:06 +00:00
|
|
|
def BuildSuperHeader(target = None, source = None, env = None):
|
|
|
|
header = file('include/'+LIBRARY+'.hpp','w')
|
|
|
|
incGuard = LIBRARY.upper()+'_HPP'
|
|
|
|
header.write('#ifndef '+incGuard+'\n')
|
|
|
|
header.write('#define '+incGuard+'\n\n')
|
|
|
|
for inc in INC_FILES:
|
|
|
|
header.write('#include "'+inc.replace('include/','')+'"\n')
|
|
|
|
header.write('\n#endif // '+incGuard+'\n')
|
|
|
|
header.close()
|
|
|
|
print "Built 'SuperHeader' " + LIBRARY + ".hpp"
|
|
|
|
return 0
|
2005-05-15 02:51:51 +00:00
|
|
|
|
2005-07-04 06:33:06 +00:00
|
|
|
SuperHeaderAction = Action(BuildSuperHeader)
|
2005-07-04 03:06:06 +00:00
|
|
|
|
2005-08-16 06:32:39 +00:00
|
|
|
# Configure the environment
|
2005-08-18 02:23:47 +00:00
|
|
|
env = Environment(ENV = os.environ)
|
2005-08-16 06:32:39 +00:00
|
|
|
env.Append(CPPPATH='include', CPPFLAGS=['-Wall', '-fmessage-length=0'])
|
2005-07-04 06:33:06 +00:00
|
|
|
env.ParseConfig('freetype-config --cflags')
|
2005-08-16 06:32:39 +00:00
|
|
|
# Configure (Check Libraries)
|
2005-07-04 06:33:06 +00:00
|
|
|
if not env.GetOption('clean'):
|
2005-07-04 03:06:06 +00:00
|
|
|
conf = Configure(env)
|
|
|
|
if not conf.CheckLibWithHeader(OGL_LIB, 'GL/gl.h', 'C++'):
|
|
|
|
print 'OpenGL not found, exiting.'
|
|
|
|
Exit(1)
|
|
|
|
if not conf.CheckLibWithHeader(GLU_LIB, 'GL/glu.h', 'C++'):
|
|
|
|
print 'GLU not found, exiting.'
|
|
|
|
Exit(1)
|
|
|
|
if not conf.CheckLibWithHeader('glfw', 'GL/glfw.h', 'C++'):
|
|
|
|
print 'GLFW not found, exiting.'
|
|
|
|
Exit(1)
|
|
|
|
if not conf.CheckLibWithHeader('freetype', 'ft2build.h', 'C++'):
|
|
|
|
print 'Freetype2 not found, exiting.'
|
2005-11-13 07:59:48 +00:00
|
|
|
Exit(1)
|
2005-07-04 03:06:06 +00:00
|
|
|
if not conf.CheckLibWithHeader('corona', 'corona.h', 'C++'):
|
|
|
|
print 'Corona not found, exiting.'
|
|
|
|
Exit(1)
|
2005-11-13 07:59:48 +00:00
|
|
|
if not conf.CheckCXXHeader('boost/utility.hpp'):
|
|
|
|
print 'Boost not found, exiting.'
|
|
|
|
Exit(1)
|
2005-07-05 06:44:55 +00:00
|
|
|
if conf.CheckLibWithHeader(OAL_LIB, 'AL/al.h', 'C++'):
|
2005-07-04 03:06:06 +00:00
|
|
|
conf.env.Append(CPPFLAGS='-DPHOTON_USE_OPENAL')
|
|
|
|
else:
|
|
|
|
print 'OpenAL not found, continuing without OpenAL support.'
|
2005-07-18 05:14:18 +00:00
|
|
|
OAL_LIB = '' # no OpenAL library name
|
2005-07-04 03:06:06 +00:00
|
|
|
env = conf.Finish()
|
2005-07-04 06:33:06 +00:00
|
|
|
env.Append(CPPFLAGS='-pedantic') # tests fail pedantic, so add after tests
|
2005-07-04 03:06:06 +00:00
|
|
|
|
2005-07-04 06:33:06 +00:00
|
|
|
## Define Builds ##
|
|
|
|
BuildDir('build', 'src', duplicate=0)
|
|
|
|
|
|
|
|
# Library
|
|
|
|
lib = env.Library(os.path.join('lib',LIBRARY), source=SRC_FILES)
|
|
|
|
env.AddPostAction(lib, SuperHeaderAction)
|
|
|
|
env.Alias(LIBRARY,lib)
|
|
|
|
env.Default(LIBRARY)
|
2005-07-04 03:06:06 +00:00
|
|
|
|
2005-07-04 06:33:06 +00:00
|
|
|
# Documentation
|
|
|
|
ndoc = env.Command('docs/index.html', './include',
|
2005-11-15 02:59:08 +00:00
|
|
|
"""NaturalDocs -nag -i $SOURCES -i ndoc/pages -i ndoc/tutorials -o HTML ./docs -p ./ndoc""")
|
2005-07-04 06:33:06 +00:00
|
|
|
env.Alias("docs",ndoc)
|
2005-11-13 07:59:48 +00:00
|
|
|
env.AlwaysBuild(ndoc)
|
|
|
|
|
2005-07-04 06:33:06 +00:00
|
|
|
|
|
|
|
# Tests:
|
|
|
|
tests = []
|
|
|
|
test_srcs = glob.glob( os.path.join('test', '*_test.cpp') )
|
|
|
|
|
|
|
|
for test_src in test_srcs:
|
|
|
|
test_name = test_src.replace('_test.cpp','')
|
|
|
|
tests.append(env.Program(test_name, source=test_src, LIBPATH='./lib',
|
2005-07-18 05:14:18 +00:00
|
|
|
LIBS=['photon','glfw',OAL_LIB,OGL_LIB,GLU_LIB,
|
2005-11-23 19:38:51 +00:00
|
|
|
'physfs','corona','freetype']))
|
2005-11-19 05:30:53 +00:00
|
|
|
|
2005-08-16 06:32:39 +00:00
|
|
|
env.Alias('tests',tests)
|
2005-07-04 03:06:06 +00:00
|
|
|
|