dri = env['dri']
machine = env['machine']
platform = env['platform']
-drawllvm = 'llvmpipe' in env['drivers']
-
-# LLVM support in the Draw module
-if drawllvm:
- env.Tool('llvm')
- if not env.has_key('LLVM_VERSION'):
- drawllvm = False
-if drawllvm:
- env.Append(CFLAGS = ['-DDRAW_LLVM=1'])
# derived options
x86 = machine == 'x86'
'x86',
'ppc',
'dri',
- 'drawllvm',
'platform',
'gcc',
'msvc',
'dl',
])
-# LLVM support in the Draw module
-if drawllvm:
- env.Append(CPPDEFINES = ['DRAW_LLVM'])
-
# for debugging
#print env.Dump()
import os
import os.path
+import subprocess
import sys
import platform as _platform
default_machine = _platform.machine()
default_machine = _machine_map.get(default_machine, 'generic')
+if 'LLVM' in os.environ or subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0:
+ default_llvm = 'yes'
+else:
+ default_llvm = 'no'
+
if default_platform in ('linux', 'freebsd'):
default_dri = 'yes'
elif default_platform in ('winddk', 'windows', 'wince', 'darwin'):
opts.Add(EnumOption('platform', 'target platform', default_platform,
allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded')))
opts.Add('toolchain', 'compiler toolchain', 'default')
- opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
+ opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
OPT_FLAGS = -O3 -ansi -pedantic
ARCH_FLAGS = -mmmx -msse -msse2 -mstackrealign
-DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DDRAW_LLVM -DHAVE_UDIS86
+DEFINES += -DNDEBUG -DGALLIUM_LLVMPIPE -DHAVE_UDIS86
# override -std=c99
CFLAGS += -std=gnu99
# configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
build_topdir = 'build'
build_subdir = env['platform']
- if env['llvm']:
- build_subdir += "-llvm"
if env['machine'] != 'generic':
build_subdir += '-' + env['machine']
if env['debug']:
# Default libs
env.Append(LIBS = [])
+ # Load LLVM
+ if env['llvm']:
+ env.Tool('llvm')
+
# Custom builders and methods
env.Tool('custom')
createInstallMethods(env)
if env['platform'] == 'windows':
# XXX: There is no llvm-config on Windows, so assume a standard layout
if llvm_dir is None:
- return
+ print 'scons: LLVM environment variable must be specified when building for windows'
+ env.Exit(1)
# Try to determine the LLVM version from llvm/Config/config.h
llvm_config = os.path.join(llvm_dir, 'include/llvm/Config/config.h')
if not os.path.exists(llvm_config):
print 'scons: could not find %s' % llvm_config
- return
+ env.Exit(1)
llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"')
llvm_version = None
for line in open(llvm_config, 'rt'):
break
if llvm_version is None:
print 'scons: could not determine the LLVM version from %s' % llvm_config
- return
+ env.Exit(1)
env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
env.AppendUnique(CPPDEFINES = [
# debug build we'll be linking against LIBCMTD, so disable
# that.
env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT'])
- elif env.Detect('llvm-config'):
+ else:
+ if not env.Detect('llvm-config'):
+ print 'scons: llvm-config script not found' % llvm_version
+ env.Exit(1)
+
llvm_version = env.backtick('llvm-config --version').rstrip()
llvm_version = distutils.version.LooseVersion(llvm_version)
env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
env.ParseConfig('llvm-config --ldflags')
except OSError:
- print 'llvm-config version %s failed' % llvm_version
+ print 'scons: llvm-config version %s failed' % llvm_version
+ env.Exit(1)
else:
env['LINK'] = env['CXX']
- else:
- return
assert llvm_version is not None
'target-helpers/wrap_screen.c',
]
-if drawllvm:
+if env['llvm']:
source += [
'gallivm/lp_bld_alpha.c',
'gallivm/lp_bld_arit.c',
const struct pipe_rasterizer_state *rasterizer,
unsigned prim );
-#ifdef DRAW_LLVM
+#ifdef HAVE_LLVM
/*******************************************************************************
* LLVM integration
*/
-#ifndef DRAW_LLVM_H
-#define DRAW_LLVM_H
+#ifndef HAVE_LLVM_H
+#define HAVE_LLVM_H
#include "draw/draw_private.h"
#include "tgsi/tgsi_scan.h"
-#ifdef DRAW_LLVM
+#ifdef HAVE_LLVM
#include <llvm-c/ExecutionEngine.h>
#endif
unsigned instance_id;
-#ifdef DRAW_LLVM
+#ifdef HAVE_LLVM
LLVMExecutionEngineRef engine;
#endif
void *driver_private;
if (!draw->pt.middle.fetch_shade_emit)
return FALSE;
-#if DRAW_LLVM
+#if HAVE_LLVM
draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit_llvm( draw );
#else
draw->pt.middle.general = NULL;
#include "tgsi/tgsi_parse.h"
-#ifdef DRAW_LLVM
+#ifdef HAVE_LLVM
struct draw_llvm_vertex_shader {
struct draw_vertex_shader base;
#include <llvm-c/Core.h>
-/** Set version to 0 if missing to avoid #ifdef HAVE_LLVM everywhere */
+/** Ensure HAVE_LLVM is set to avoid #ifdef HAVE_LLVM everywhere */
#ifndef HAVE_LLVM
-#define HAVE_LLVM 0x0207
+#error "HAVE_LLVM should be set with LLVM's version number, e.g. (0x0207 for 2.7)"
#endif
Import('*')
-env = env.Clone()
-
-env.Tool('llvm')
-if not env.has_key('LLVM_VERSION'):
- print 'warning: LLVM not found: not building llvmpipe'
+if not env['llvm']:
+ print 'warning: LLVM disabled: not building llvmpipe'
Return()
+env = env.Clone()
+
env.Tool('udis86')
env.Append(CPPPATH = ['.'])
env.Prepend(LIBS = [softpipe])
if 'llvmpipe' in env['drivers']:
- env.Tool('llvm')
- if 'LLVM_VERSION' in env:
- env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
- env.Tool('udis86')
- env.Prepend(LIBS = [llvmpipe])
+ env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+ env.Tool('udis86')
+ env.Prepend(LIBS = [llvmpipe])
if 'cell' in env['drivers']:
env.Append(CPPDEFINES = 'GALLIUM_CELL')
if 'llvmpipe' in env['drivers']:
env.Append(CPPDEFINES = ['HAVE_LLVMPIPE'])
- env.Tool('llvm')
env.Prepend(LIBS = [llvmpipe])
if 'softpipe' in env['drivers']:
env.Append(CPPDEFINES = ['HAVE_SOFTPIPE'])
env.Prepend(LIBS = [softpipe])
if 'llvmpipe' in env['drivers']:
- env.Tool('llvm')
- if 'LLVM_VERSION' in env:
- env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
- env.Tool('udis86')
- env.Prepend(LIBS = [llvmpipe])
+ env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+ env.Tool('udis86')
+ env.Prepend(LIBS = [llvmpipe])
swrastg_sources = [
'swrast_drm_api.c'
env.Prepend(LIBS = [softpipe])
if 'llvmpipe' in env['drivers']:
- env.Tool('llvm')
- if 'LLVM_VERSION' in env:
- env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
- env.Tool('udis86')
- env.Prepend(LIBS = [llvmpipe])
+ env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+ env.Tool('udis86')
+ env.Prepend(LIBS = [llvmpipe])
# Need this for trace, identity drivers referenced by
# gallium_wrap_screen().
drivers = [softpipe]
if 'llvmpipe' in env['drivers']:
- env.Tool('llvm')
- if 'LLVM_VERSION' in env:
- sources = ['gdi_llvmpipe_winsys.c']
- drivers = [llvmpipe]
+ sources = ['gdi_llvmpipe_winsys.c']
+ drivers = [llvmpipe]
if not sources or not drivers:
print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled'
env.Prepend(LIBS = [softpipe])
if 'llvmpipe' in env['drivers']:
- env.Tool('llvm')
- if 'LLVM_VERSION' in env:
- env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
- env.Tool('udis86')
- env.Prepend(LIBS = [llvmpipe])
+ env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+ env.Tool('udis86')
+ env.Prepend(LIBS = [llvmpipe])
if 'cell' in env['drivers']:
env.Append(CPPDEFINES = 'GALLIUM_CELL')