blob: 1a99df41c01ca6a175850263d71ad11dd0288e0b [file] [log] [blame]
José Fonseca94090432008-02-27 17:36:28 +09001#######################################################################
2# Common SCons code
3
4import os
5import os.path
6import sys
7import platform as _platform
8
9
10#######################################################################
11# Defaults
12
13_platform_map = {
14 'linux2': 'linux',
15 'win32': 'winddk',
16}
17
18default_platform = sys.platform
19default_platform = _platform_map.get(default_platform, default_platform)
20
21_machine_map = {
22 'x86': 'x86',
23 'i386': 'x86',
24 'i486': 'x86',
25 'i586': 'x86',
26 'i686': 'x86',
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020027 'ppc' : 'ppc',
José Fonseca94090432008-02-27 17:36:28 +090028 'x86_64': 'x86_64',
29}
30if 'PROCESSOR_ARCHITECTURE' in os.environ:
31 default_machine = os.environ['PROCESSOR_ARCHITECTURE']
32else:
33 default_machine = _platform.machine()
34default_machine = _machine_map.get(default_machine, 'generic')
35
36if default_platform in ('linux', 'freebsd', 'darwin'):
37 default_dri = 'yes'
José Fonsecab215d7d2008-05-28 01:24:06 +090038elif default_platform in ('winddk', 'windows', 'wince'):
José Fonseca94090432008-02-27 17:36:28 +090039 default_dri = 'no'
40else:
41 default_dri = 'no'
42
43
44#######################################################################
45# Common options
46
José Fonseca13174c12008-03-03 18:52:37 +010047def AddOptions(opts):
José Fonsecac9acd432008-05-01 00:58:04 +090048 try:
49 from SCons.Options.BoolOption import BoolOption
50 except ImportError:
51 from SCons.Variables.BoolVariable import BoolVariable as BoolOption
52 try:
53 from SCons.Options.EnumOption import EnumOption
54 except ImportError:
55 from SCons.Variables.EnumVariable import EnumVariable as EnumOption
José Fonseca059a6522008-05-24 19:25:02 +090056 opts.Add(BoolOption('debug', 'debug build', 'no'))
57 opts.Add(BoolOption('profile', 'profile build', 'no'))
José Fonseca5aa10822008-03-04 14:29:27 +010058 #opts.Add(BoolOption('quiet', 'quiet command lines', 'no'))
José Fonseca94090432008-02-27 17:36:28 +090059 opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
Michel Dänzer6b69e3c2008-10-23 10:28:48 +020060 allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
José Fonseca94090432008-02-27 17:36:28 +090061 opts.Add(EnumOption('platform', 'target platform', default_platform,
José Fonsecab215d7d2008-05-28 01:24:06 +090062 allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince')))
José Fonseca6cf59e12008-11-18 19:13:32 +090063 opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default',
José Fonsecafa6ee2c2008-12-12 09:44:47 +090064 allowed_values=('default', 'crossmingw', 'winddk')))
José Fonseca94090432008-02-27 17:36:28 +090065 opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
66 opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
José Fonseca94090432008-02-27 17:36:28 +090067