2008-09-24 11:39:15 -06:00
|
|
|
import os
|
2008-12-09 14:46:32 -07:00
|
|
|
import platform
|
2008-09-24 11:39:15 -06:00
|
|
|
|
|
|
|
# taken from scons wiki
|
|
|
|
def CheckPKGConfig(context, version):
|
2008-10-05 12:49:55 -06:00
|
|
|
context.Message( 'Checking for pkg-config version > %s... ' % version)
|
|
|
|
ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
|
|
|
|
context.Result( ret )
|
|
|
|
return ret
|
|
|
|
|
2008-12-09 16:47:18 -07:00
|
|
|
# TODO: We should use the scons one instead
|
2008-12-09 14:46:32 -07:00
|
|
|
def CheckLib(context, name):
|
|
|
|
context.Message( 'Looking for lib %s... ' % name )
|
|
|
|
lastLIBS = context.env['LIBS']
|
2008-12-09 16:47:18 -07:00
|
|
|
context.env.Append(LIBS = [name])
|
2008-12-09 14:46:32 -07:00
|
|
|
ret = context.TryLink("""
|
|
|
|
int main(int argc, char **argv) {
|
2008-12-09 16:47:18 -07:00
|
|
|
return 0;
|
2010-05-27 16:19:16 -06:00
|
|
|
}
|
2010-05-29 14:31:09 -06:00
|
|
|
""", '.c')
|
2008-12-09 14:46:32 -07:00
|
|
|
if not ret:
|
|
|
|
context.env.Replace(LIBS = lastLIBS)
|
2008-12-09 16:47:18 -07:00
|
|
|
|
2008-12-09 14:46:32 -07:00
|
|
|
return ret
|
|
|
|
|
|
|
|
def ConfigPKG(context, name):
|
|
|
|
context.Message( '\nUsing pkg-config for %s... ' % name )
|
2008-10-05 12:49:55 -06:00
|
|
|
ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
|
2008-12-06 16:32:10 -07:00
|
|
|
context.Result( ret )
|
2008-12-09 11:10:16 -07:00
|
|
|
if ret:
|
|
|
|
context.env.ParseConfig('pkg-config --cflags --libs \'%s\'' % name)
|
2008-12-05 06:46:19 -07:00
|
|
|
return int(ret)
|
2008-12-09 14:46:32 -07:00
|
|
|
|
|
|
|
def CheckPKG(context, name):
|
|
|
|
context.Message( 'Checking for %s... ' % name )
|
2009-03-07 15:12:01 -07:00
|
|
|
if platform.system().lower() == 'windows':
|
|
|
|
return 0
|
2008-12-09 14:46:32 -07:00
|
|
|
ret = 1
|
2010-06-26 13:17:43 -06:00
|
|
|
if not ConfigPKG(context, name.lower()):
|
|
|
|
ret = CheckLib(context, name)
|
2008-12-09 14:46:32 -07:00
|
|
|
|
|
|
|
context.Result(ret)
|
|
|
|
return int(ret)
|
|
|
|
|
2008-09-24 11:39:15 -06:00
|
|
|
def CheckSDL(context, version):
|
2010-06-09 13:41:17 -06:00
|
|
|
context.Message( 'Checking for SDL lib version > %s... ' % version)
|
2009-03-07 15:12:01 -07:00
|
|
|
if platform.system().lower() == 'windows':
|
|
|
|
return 1
|
2008-10-05 12:49:55 -06:00
|
|
|
sdl_config = context.env.WhereIs('sdl-config')
|
|
|
|
if sdl_config == None:
|
|
|
|
ret = 0
|
|
|
|
else:
|
|
|
|
found_ver = os.popen('sdl-config --version').read().strip()
|
|
|
|
required = [int(n) for n in version.split(".")]
|
|
|
|
found = [int(n) for n in found_ver.split(".")]
|
|
|
|
ret = (found >= required)
|
|
|
|
|
2008-12-09 11:10:16 -07:00
|
|
|
context.Result(ret)
|
|
|
|
if ret:
|
|
|
|
context.env.ParseConfig('sdl-config --cflags --libs')
|
2010-06-09 13:41:17 -06:00
|
|
|
ret = CheckLib(context, 'SDL')
|
2008-12-05 06:46:19 -07:00
|
|
|
return int(ret)
|
2008-10-05 12:49:55 -06:00
|
|
|
|
2009-03-03 13:14:39 -07:00
|
|
|
def CheckPortaudio(context, version):
|
2009-03-06 07:48:39 -07:00
|
|
|
found = 0
|
|
|
|
if CheckPKG(context, 'portaudio'):
|
|
|
|
context.Message( 'Checking for lib portaudio version > %s... ' % version)
|
|
|
|
found = context.TryRun("""
|
2009-03-03 13:14:39 -07:00
|
|
|
#include <portaudio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
printf("%d", Pa_GetVersion());
|
|
|
|
return 0;
|
|
|
|
}
|
2010-05-29 14:31:09 -06:00
|
|
|
""", '.c')[1]
|
2009-03-03 13:14:39 -07:00
|
|
|
|
2009-03-03 13:28:51 -07:00
|
|
|
if found:
|
|
|
|
ret = (version <= found)
|
|
|
|
else:
|
|
|
|
ret = 0
|
2009-03-03 13:14:39 -07:00
|
|
|
|
|
|
|
context.Result(ret)
|
|
|
|
return int(ret)
|
|
|
|
|
2008-10-05 12:49:55 -06:00
|
|
|
def GenerateRevFile(flavour, template, output):
|
|
|
|
|
|
|
|
try:
|
|
|
|
svnrev = os.popen('svnversion .').read().strip().split(':')[0]
|
|
|
|
except:
|
|
|
|
svnrev = ""
|
|
|
|
|
2009-10-24 14:29:52 -06:00
|
|
|
revstr = svnrev + "-" + flavour
|
|
|
|
tmpstr = open(template, "r").read().replace("$WCMODS?$WCREV$M:$WCREV$$",revstr)
|
2008-10-05 12:49:55 -06:00
|
|
|
outfile = open(output, 'w')
|
|
|
|
outfile.write(tmpstr +"\n")
|
|
|
|
outfile.close()
|
|
|
|
|
2008-11-13 03:04:10 -07:00
|
|
|
return revstr
|