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