deps = {'libogg':{'libs':('ogg',), 'headers':('ogg/ogg.h', 'ogg/os_types.h')}, 'libvorbis':{'libs':('vorbis',), 'headers':('vorbis/codec.h', 'vorbis/vorbisenc.h', 'vorbis/vorbisfile.h')}, 'libtheora':{'libs':('theora',), 'headers':('theora/theora.h',)}, 'libshout':{'libs':('shout',), 'headers':('shout/shout.h',)}, 'v4l':{'headers':('linux/videodev.h',)}, 'jpeg':{'libs':('jpeg',), 'headers':('jpeglib.h',)}} libs = [] cpppath = ['include'] modules = ['null_cam', 'v4l_jpeg'] modulesrcs = {'null_cam':['modules/null_cam.c'] , 'v4l_jpeg':['modules/v4l_jpeg.c']} moduledeps = {'null_cam':(), 'v4l_jpeg':('v4l', 'jpeg')} modulelibs = {'null_cam':[], 'v4l_jpeg':[]} ######################################################################### # Shouldn't have to edit anything below this line # ######################################################################### def checkdeps(ds, l, checks): for dep in ds : for check in checks: if deps[dep].has_key(check) : for test in deps[dep][check] : if not checks[check](test) : return test if check == 'libs' : l.append(test) return None def configure(): global env conf = Configure(env) checks = {'funcs':conf.CheckFunc, 'libs':conf.CheckLib, 'headers':conf.CheckCHeader} test = checkdeps(('libogg','libvorbis','libtheora','libshout'), libs, checks) if test: print 'Could not find %s, exiting.' % test Exit(1) for module in modules: test = checkdeps(moduledeps[module], modulelibs[module], checks) if test: print 'Could not find %s, not building %s module' % (test, module) modules.remove(module) env = conf.Finish() def saveconfig(): f = open('config.cache','w') f.write('libs=%s\n' % str(libs)) f.write('cpppath=%s\n' % str(cpppath)) f.write('modules=%s\n' % str(modules)) f.close() def loadconfig(): # There has *GOT* to be a simpler way to do this! # ... but at least it's more secure. local_libs = [] local_cpppath = ['include'] local_modules = [] from os.path import exists if exists('config.cache'): f = open('config.cache','r') b = f.read().splitlines() for l in b: exec 'local_'+l f.close() global libs, cpppath, modules libs = local_libs cpppath = local_cpppath modules = local_modules else : configure() def build(): Program('dryice', 'src/core.c', CPPPATH=cpppath, LIBS=libs) for module in modules: SharedLibrary('modules/'+module, modulesrcs[module], CPPPATH=cpppath, LIBS=modulelibs[module]) env = Environment() do = ARGUMENTS.get('do', None) if do=='config' : configure() saveconfig() elif do=='build' : loadconfig() build() else : configure() saveconfig() build()