from sys import executable as python_cmd
import distutils.version

Import('*')

if not env['llvm']:
    print 'warning: LLVM disabled: not building llvmpipe'
    Return()

env = env.Clone()

llvmpipe = env.ConvenienceLibrary(
	target = 'llvmpipe',
	source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
	)

env.Alias('llvmpipe', llvmpipe)


if not env['embedded']:
    env = env.Clone()

    env.Prepend(LIBS = [llvmpipe] + gallium)

    tests = [
        'format',
        'blend',
        'conv',
        'printf',
    ]

    if not env['msvc']:
        tests.append('arit')

    for test in tests:
        testname = 'lp_test_' + test
        target = env.Program(
            target = testname,
            source = [testname + '.c', 'lp_test_main.c'],
        )
        env.InstallProgram(target)
        
        # http://www.scons.org/wiki/UnitTests
        alias = env.Alias(testname, [target], target[0].abspath)
        AlwaysBuild(alias)

Export('llvmpipe')
