def checkStaticZ(context): context.Message("Checking for static z... ") tmp = context.env.Clone() env = context.env (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config zlib --cflags') # Strip off the -L part libdir = utils.readExec( 'pkg-config zlib --libs-only-L')[2:].rstrip() # Hack to hardcode these libraries zlib = env.Install('misc', "%s/libz.a" % libdir) env.Append(LIBS=[zlib]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 # FIXME: write proper test ret = context.TryLink( """ int main(int argc, char ** argv){ return 0; } """, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def checkMpg123(context): context.Message("Checking for libmpg123... ") tmp = context.env.Clone() env = context.env env['HAVE_MP3_MPG123'] = True env.Append(CPPDEFINES = ['HAVE_MP3_MPG123']) (ok, stuff) = context.TryAction(env.Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env,'pkg-config libmpg123 --libs --cflags') except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 ret = context.TryLink(""" #include <mpg123.h> int main(int argc, char ** argv){ int err = mpg123_init(); if (err == MPG123_OK){ return 0; } return 1; } """, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def checkStaticSDL(context): context.Message("Checking for static SDL... ") env = context.env try: utils.safeParseConfig(env, 'sdl-config --static-libs --cflags') env.Append(CPPDEFINES = ['USE_SDL']) except Exception: context.Result(utils.colorResult(0)) return 0 if False: sdl = env.Install('misc', readExec('sdl-config --prefix') + '/lib/libSDL.a') env.Append(LIBS = [sdl]) utils.safeParseConfig(env, 'sdl-config --cflags') env.Append(CPPDEFINES = ['USE_SDL']) if isOSX() or isOSX104(): def framework(x): return "-framework %s" % x frameworks = Split(""" Cocoa Carbon IOKit System CoreAudio AudioUnit AudioToolbox QuickTime OpenGL """) # env.Append(LINKFLAGS = map(framework, frameworks)) env.Append(FRAMEWORKS = frameworks) context.Result(utils.colorResult(1)) return 1
def checkStaticZ(context): context.Message("Checking for static z... ") tmp = context.env.Clone() env = context.env (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config zlib --cflags') # Strip off the -L part libdir = utils.readExec('pkg-config zlib --libs-only-L')[2:].rstrip() # Hack to hardcode these libraries zlib = env.Install('misc', "%s/libz.a" % libdir) env.Append(LIBS = [zlib]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 # FIXME: write proper test ret = context.TryLink(""" int main(int argc, char ** argv){ return 0; } """, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def checkFreetype(context): context.Message('Checking for freetype2 ... ') ok = False try: env = context.env utils.safeParseConfig(env, 'freetype-config --libs --cflags') context.Message('found') ok = True except Exception, ex: context.Message('Not found, install libfreetype2')
def tryPkgConfig(): (ok, stuff) = context.TryAction(env.Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config mad --libs --cflags') return True except OSError: # context.sconf.env = tmp # context.Result(utils.colorResult(0)) return False return False
def doParse(libs, env): def make(name): return '%s%s-%s' % (name, use_debug[0], version) libraries = [] for lib in libs: libraries.append(make(lib)) try: utils.safeParseConfig(env, 'pkg-config %s --cflags --libs' % ' '.join(libraries)) env.Append(CPPDEFINES = ['USE_ALLEGRO5']) context.Message('found version {0} [{1}]'.format(version, 'Monolithic' if len(libraries) == 1 else 'Non-monolithic')) except Exception, e: raise e
def tryNormal(): tmp = context.env.Clone() env = context.env try: utils.safeParseConfig(env, 'sdl-config --cflags --libs') env.Append(CPPDEFINES = ['USE_SDL']) if build('a'): return True else: raise Exception() except Exception: context.sconf.env = tmp return False
def checkStaticSDL(context): context.Message("Checking for static SDL... ") env = context.env try: utils.safeParseConfig(env, 'sdl-config --static-libs --cflags') env.Append(CPPDEFINES = ['USE_SDL']) # FIXME: move sdl main to a new check env.Append(CPPDEFINES = ['USE_SDL_MAIN']) except Exception: context.Result(utils.colorResult(0)) return 0 context.Result(utils.colorResult(1)) return 1
def checkStaticSDL(context): context.Message("Checking for static SDL... ") env = context.env try: utils.safeParseConfig(env, 'sdl-config --static-libs --cflags') env.Append(CPPDEFINES=['USE_SDL']) # FIXME: move sdl main to a new check env.Append(CPPDEFINES=['USE_SDL_MAIN']) except Exception: context.Result(utils.colorResult(0)) return 0 context.Result(utils.colorResult(1)) return 1
def checkStaticOgg(context): context.Message("Checking for static ogg and vorbis... ") tmp = context.env.Clone() env = context.env env['HAVE_OGG'] = True env.Append(CPPDEFINES=['HAVE_OGG']) (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config vorbisfile --cflags') # Strip off the -L part libdir = utils.readExec( 'pkg-config vorbisfile --libs-only-L')[2:].rstrip() # Hack to hardcode these libraries vorbisfile = env.Install('misc', "%s/libvorbisfile.a" % libdir) ogg = env.Install('misc', "%s/libogg.a" % libdir) vorbis = env.Install('misc', "%s/libvorbis.a" % libdir) env.Append(LIBS=[vorbisfile, ogg, vorbis]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 main = 'int main(int argc, char ** argv)' try: if env['HAVE_SDL_MAIN']: main = 'int SDL_main(int argc, char ** argv)' except KeyError: pass ret = context.TryLink( """ #include <vorbis/vorbisfile.h> #include <stdio.h> %(main)s { OggVorbis_File ovf; FILE * f; ov_open_callbacks(f, &ovf, 0, 0, OV_CALLBACKS_DEFAULT); return 0; } """ % {'main': main}, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def allegro44(context): tmp = context.env.Clone() env = context.env ok = 1 try: utils.safeParseConfig(env, 'pkg-config allegro --cflags --libs') env.Append(CPPDEFINES = ['USE_ALLEGRO']) ok = testAllegro(context) except OSError: ok = 0 if not ok: context.sconf.env = tmp else: context.Message('found 4.4') return ok
def checkStaticOgg(context): context.Message("Checking for static ogg and vorbis... ") tmp = context.env.Clone() env = context.env env['HAVE_OGG'] = True env.Append(CPPDEFINES = ['HAVE_OGG']) (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config vorbisfile --cflags') # Strip off the -L part libdir = utils.readExec('pkg-config vorbisfile --libs-only-L')[2:].rstrip() # Hack to hardcode these libraries vorbisfile = env.Install('misc', "%s/libvorbisfile.a" % libdir) ogg = env.Install('misc', "%s/libogg.a" % libdir) vorbis = env.Install('misc', "%s/libvorbis.a" % libdir) env.Append(LIBS = [vorbisfile, ogg, vorbis]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 main = 'int main(int argc, char ** argv)' try: if env['HAVE_SDL_MAIN']: main = 'int SDL_main(int argc, char ** argv)' except KeyError: pass ret = context.TryLink(""" #include <vorbis/vorbisfile.h> #include <stdio.h> %(main)s { OggVorbis_File ovf; FILE * f; ov_open_callbacks(f, &ovf, 0, 0, OV_CALLBACKS_DEFAULT); return 0; } """ % {'main' : main}, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def allegro44(context): tmp = context.env.Clone() env = context.env ok = 1 try: utils.safeParseConfig(env, 'pkg-config allegro --cflags --libs') env.Append(CPPDEFINES=['USE_ALLEGRO']) ok = testAllegro(context) except OSError: ok = 0 if not ok: context.sconf.env = tmp else: context.Message('found 4.4') return ok
def find(version): context.Message(str(version)) try: def make(name): return '%s-%s' % (name, version) libraries = [make('allegro'), make('allegro_ttf'), make('allegro_memfile'), make('allegro_image'), make('allegro_primitives'), make('allegro_audio'), make('allegro_acodec')] utils.safeParseConfig(env, 'pkg-config %s --cflags --libs' % ' '.join(libraries)) env.Append(CPPDEFINES = ['USE_ALLEGRO5']) context.Message('found version %s' % version) return True except Exception: return False
def checkStaticPng(context): context.Message("Checking for static png... ") tmp = context.env.Clone() env = context.env try: utils.safeParseConfig(env, 'libpng-config --cflags') libdir = utils.readExec('libpng-config --libdir') # Hack to hardcode these libraries png = env.Install('misc', '%s/libpng.a' % libdir) env.Append(LIBS = [png]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 except Exception, e: print e context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0
def find(version): context.Message(str(version)) try: def make(name): return '%s%s-%s' % (name, use_debug[0], version) libraries = [make('allegro'), make('allegro_ttf'), make('allegro_memfile'), make('allegro_image'), make('allegro_primitives'), make('allegro_audio'), make('allegro_acodec')] utils.safeParseConfig(env, 'pkg-config %s --cflags --libs' % ' '.join(libraries)) env.Append(CPPDEFINES = ['USE_ALLEGRO5']) context.Message('found version %s ' % version) return True except Exception, e: print e return False
def checkStaticPng(context): context.Message("Checking for static png... ") tmp = context.env.Clone() env = context.env try: utils.safeParseConfig(env, 'libpng-config --cflags') libdir = utils.readExec('libpng-config --libdir') # Hack to hardcode these libraries png = env.Install('misc', '%s/libpng.a' % libdir) env.Append(LIBS=[png]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 except Exception, e: print e context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0
def allegro42(context): tmp = context.env.Clone() env = context.env ok = 1 try: def enableAllegro(env2): utils.safeParseConfig(env2, 'allegro-config --cflags --libs') env2.Append(CPPDEFINES = ['USE_ALLEGRO']) utils.safeParseConfig(env, 'allegro-config --cflags --libs') env['paintown_enableAllegro'] = enableAllegro env.Append(CPPDEFINES = ['USE_ALLEGRO']) ok = testAllegro(context) except OSError: ok = 0 if not ok: context.sconf.env = tmp else: context.Message('found 4.2') return ok
def checkNativeOgg(context): context.Message("Checking for ogg and vorbis... ") tmp = context.env.Clone() env = context.env env['HAVE_OGG'] = True env.Append(CPPDEFINES=['HAVE_OGG']) (ok, stuff) = context.TryAction(env.Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config vorbisfile --libs --cflags') except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 main = 'int main(int argc, char ** argv)' try: if env['HAVE_SDL_MAIN']: main = 'int SDL_main(int argc, char ** argv)' except KeyError: pass ret = context.TryLink( """ #include <vorbis/vorbisfile.h> #include <stdio.h> %(main)s { OggVorbis_File ovf; FILE * f; ov_open_callbacks(f, &ovf, 0, 0, OV_CALLBACKS_DEFAULT); return 0; } """ % {'main': main}, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def checkStaticFreetype(context): context.Message("Checking for static freetype... ") tmp = context.env.Clone() env = context.env (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'freetype-config --cflags') # Strip off the -L part libdir = findLibDir(utils.readExec('freetype-config --libs')) # Hack to hardcode these libraries freetype = env.Install('misc', '%s/libfreetype.a' % libdir) env.Append(LIBS = [freetype]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 except Exception, e: print e context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0
def checkNativeOgg(context): context.Message("Checking for ogg and vorbis... ") tmp = context.env.Clone() env = context.env env['HAVE_OGG'] = True env.Append(CPPDEFINES = ['HAVE_OGG']) (ok, stuff) = context.TryAction(env.Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config vorbisfile --libs --cflags') except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 main = 'int main(int argc, char ** argv)' try: if env['HAVE_SDL_MAIN']: main = 'int SDL_main(int argc, char ** argv)' except KeyError: pass ret = context.TryLink(""" #include <vorbis/vorbisfile.h> #include <stdio.h> %(main)s { OggVorbis_File ovf; FILE * f; ov_open_callbacks(f, &ovf, 0, 0, OV_CALLBACKS_DEFAULT); return 0; } """ % {'main' : main}, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def tryMoveLibs(): tmp = context.env.Clone() env = context.env try: libs = [] try: libs = env['LIBS'] except KeyError: pass env.Replace(LIBS = []) utils.safeParseConfig(env, 'sdl-config --cflags --libs') env.Append(LIBS = libs) env.Append(CPPDEFINES = ['USE_SDL']) m = build('b') if m: return True else: raise Exception("Couldn't build it") except Exception, e: # print "Moving libraries failed! because '%s'" % e context.sconf.env = tmp return False
def checkStaticFreetype(context): context.Message("Checking for static freetype... ") tmp = context.env.Clone() env = context.env (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'freetype-config --cflags') # Strip off the -L part libdir = findLibDir(utils.readExec('freetype-config --libs')) # Hack to hardcode these libraries freetype = env.Install('misc', '%s/libfreetype.a' % libdir) env.Append(LIBS=[freetype]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 except Exception, e: print e context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0
def checkStaticMpg123(context): context.Message("Checking for static libmpg123... ") tmp = context.env.Clone() env = context.env env['HAVE_MP3_MPG123'] = True env.Append(CPPDEFINES=['HAVE_MP3_MPG123']) (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env, 'pkg-config libmpg123 --cflags') # Strip off the -L part libdir = utils.readExec( 'pkg-config libmpg123 --libs-only-L')[2:].rstrip() # Hack to hardcode these libraries mpg123 = env.Install('misc', "%s/libmpg123.a" % libdir) env.Append(LIBS=[mpg123]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 ret = context.TryLink( """ #include <mpg123.h> int main(int argc, char ** argv){ int err = mpg123_init(); if (err == MPG123_OK){ return 0; } return 1; } """, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def allegro42(context): tmp = context.env.Clone() env = context.env ok = 1 try: def enableAllegro(env2): utils.safeParseConfig(env2, 'allegro-config --cflags --libs') env2.Append(CPPDEFINES=['USE_ALLEGRO']) utils.safeParseConfig(env, 'allegro-config --cflags --libs') env['paintown_enableAllegro'] = enableAllegro env.Append(CPPDEFINES=['USE_ALLEGRO']) ok = testAllegro(context) except OSError: ok = 0 if not ok: context.sconf.env = tmp else: context.Message('found 4.2') return ok
def checkStaticMpg123(context): context.Message("Checking for static libmpg123... ") tmp = context.env.Clone() env = context.env env['HAVE_MP3_MPG123'] = True env.Append(CPPDEFINES = ['HAVE_MP3_MPG123']) (ok, stuff) = context.TryAction(Action("pkg-config --version")) if ok: try: utils.safeParseConfig(env,'pkg-config libmpg123 --cflags') # Strip off the -L part libdir = utils.readExec('pkg-config libmpg123 --libs-only-L')[2:].rstrip() # Hack to hardcode these libraries mpg123 = env.Install('misc', "%s/libmpg123.a" % libdir) env.Append(LIBS = [mpg123]) except OSError: context.sconf.env = tmp context.Result(utils.colorResult(0)) return 0 ret = context.TryLink(""" #include <mpg123.h> int main(int argc, char ** argv){ int err = mpg123_init(); if (err == MPG123_OK){ return 0; } return 1; } """, ".c") if not ret: context.sconf.env = tmp context.Result(utils.colorResult(ret)) return ret
def wii(env): bin_path = "%s/bin" % os.environ['DEVKITPPC'] ogc_bin_path = "%s/libogc/bin" % os.environ['DEVKITPRO'] prefix = 'powerpc-eabi-' def setup(x): return '%s%s' % (prefix, x) env['CC'] = setup('gcc') env['LD'] = setup('ld') env['CXX'] = setup('g++') env['AS'] = setup('as') env['AR'] = setup('ar') env['OBJCOPY'] = setup('objcopy') if utils.isWindows(): env.Append(CPPPATH=[ "%s/libogc/include" % os.environ['DEVKITPRO'], "%s/libogc/include/SDL" % os.environ['DEVKITPRO'], "%s/libogc/include/freetype2" % os.environ['DEVKITPRO'] ]) env.Append(LIBPATH=[ "%s/libogc/lib" % os.environ['DEVKITPRO'], "%s/libogc/lib/wii" % os.environ['DEVKITPRO'] ]) env.Append( LIBS=['SDL', 'SDL_image', 'SDL_mixer', 'png', 'freetype', 'z']) else: env.Append(CPPPATH=["%s/libogc/include" % os.environ['DEVKITPRO']]) env.Append(CPPDEFINES=['GEKKO', 'WII']) flags = ['-mrvl', '-mcpu=750', '-meabi', '-mhard-float'] env.Append(CCFLAGS=flags) env.Append(CXXFLAGS=flags) env.Append(LINKFLAGS=flags) # env.Append(CPPPATH = ['#src/wii']) env['LINKCOM'] = '$CXX $LINKFLAGS -Wl,--start-group $ARCHIVES $SOURCES $_LIBDIRFLAGS $_LIBFLAGS -Wl,--end-group -o $TARGET' env.Append( LIBS=['wiiuse', 'wiikeyboard', 'iberty', 'bte', 'fat', 'ogc', 'm']) # os.environ['PATH'] = "%s:%s:%s" % (bin_path, ogc_bin_path, os.environ['PATH']) env.PrependENVPath('PATH', bin_path) env.PrependENVPath('PATH', ogc_bin_path) env.Append(CPPDEFINES=['USE_SDL_MAIN']) utils.safeParseConfig(env, 'sdl-config --cflags --libs') utils.safeParseConfig(env, 'freetype-config --libs --cflags') utils.safeParseConfig(env, 'libpng-config --libs --cflags') return env
def wii(env): bin_path = "%s/bin" % os.environ['DEVKITPPC'] ogc_bin_path = "%s/libogc/bin" % os.environ['DEVKITPRO'] prefix = 'powerpc-eabi-' def setup(x): return '%s%s' % (prefix, x) env['CC'] = setup('gcc') env['LD'] = setup('ld') env['CXX'] = setup('g++') env['AS'] = setup('as') env['AR'] = setup('ar') env['OBJCOPY'] = setup('objcopy') if utils.isWindows(): env.Append(CPPPATH = ["%s/libogc/include" % os.environ['DEVKITPRO'], "%s/libogc/include/SDL" % os.environ['DEVKITPRO'], "%s/libogc/include/freetype2" % os.environ['DEVKITPRO']]) env.Append(LIBPATH = ["%s/libogc/lib" % os.environ['DEVKITPRO'], "%s/libogc/lib/wii" % os.environ['DEVKITPRO']]) env.Append(LIBS = ['SDL', 'SDL_image', 'SDL_mixer', 'png', 'freetype', 'z']) else: env.Append(CPPPATH = ["%s/libogc/include" % os.environ['DEVKITPRO']]) env.Append(CPPDEFINES = ['GEKKO', 'WII']) flags = ['-mrvl', '-mcpu=750', '-meabi', '-mhard-float'] env.Append(CCFLAGS = flags) env.Append(CXXFLAGS = flags) env.Append(LINKFLAGS = flags) # env.Append(CPPPATH = ['#src/wii']) env['LINKCOM'] = '$CXX $LINKFLAGS -Wl,--start-group $ARCHIVES $SOURCES $_LIBDIRFLAGS $_LIBFLAGS -Wl,--end-group -o $TARGET' env.Append(LIBS = ['wiiuse', 'wiikeyboard', 'iberty', 'bte', 'fat', 'ogc', 'm']) # os.environ['PATH'] = "%s:%s:%s" % (bin_path, ogc_bin_path, os.environ['PATH']) env.PrependENVPath('PATH', bin_path) env.PrependENVPath('PATH', ogc_bin_path) env.Append(CPPDEFINES = ['USE_SDL_MAIN']) utils.safeParseConfig(env, 'sdl-config --cflags --libs') utils.safeParseConfig(env, 'freetype-config --libs --cflags') utils.safeParseConfig(env, 'libpng-config --libs --cflags') return env
def enableAllegro(env2): utils.safeParseConfig(env2, 'allegro-config --cflags --libs') env2.Append(CPPDEFINES = ['USE_ALLEGRO'])
def enableAllegro(env2): utils.safeParseConfig(env2, 'allegro-config --cflags --libs') env2.Append(CPPDEFINES=['USE_ALLEGRO'])