3
def _PackageOption(pkgName, default=1):
4
""" Allow user to choose whether a package should be used if available. This results in a commandline option use<Pkgname>,
5
where Pkgname is the name of the package with a capitalized first letter.
6
@param pkgName: Name of package.
7
@param default: The default value for this option ("yes"/"no").
9
return BoolOption("use%s" % pkgName[0].upper() + pkgName[1:], "use %s if available" % (pkgName), default)
11
def _BoolOption(opt, explanation, default=1):
12
""" Allow user to enable/disable a certain option. This results in a commandline option enable<Option>, where Option
13
is the name of the option with a capitalized first letter.
14
@param opt: Name of option.
15
@param explanation: Explanation of option.
16
@param default: The default value for this option (1/0).
18
return BoolOption("enable%s" % opt[0].upper() + opt[1:], explanation, default)
20
def _EnumOption(opt, explanation, allowedValues, default):
21
""" Allow the user to choose among a set of values for an option. This results in a commandline option with<Option>,
22
where Option is the name of the option with a capitalized first letter.
23
@param opt: The name of the option.
24
@param explanation: Explanation of option.
25
@param allowedValues: The set of values to choose from.
26
@param default: The default value.
28
assert default in allowedValues
29
return EnumOption("with%s" % opt[0].upper() + opt[1:], explanation, default, allowed_values=allowedValues)
31
def _DirectoryOption(opt, explanation, default):
32
""" Allow the user to configure the location for a certain directory, for instance the prefix. This results in a
33
commandline option which is simply the name of this option.
34
@param opt: The configurable directory, for instance "prefix".
35
@param explanation: Explanation of option.
36
@param default: The default value for this option.
38
return PathOption(opt, explanation, default)
39
# Incompatible with the latest stable SCons
40
# return PathOption(path, help, default, PathOption.PathIsDir)
44
Import("Platform", "Posix")
45
except SCons.Errors.UserError:
46
# The common objects must be exported first
47
SConscript("SConscript_common")
48
Import("Platform", "Posix")
50
# Expose the options as a dictionary of sets of options
54
opts["Installation Dirs"] = [_DirectoryOption("prefix", "installation prefix", "/usr/local")]
55
elif Platform in Windows:
56
if Platform == "cygwin":
57
opts["Installation Dirs"] = [_DirectoryOption("prefix", "installation prefix", "/usr/local")]
59
opts["Build Targets"] = [_BoolOption("shared", "create shared library"), _BoolOption("static", "create static library"),
60
_BoolOption("tests", "build test programs")]
64
apis.append(_PackageOption("OSS"))
65
apis.append(_PackageOption("JACK"))
66
apis.append(_PackageOption("ALSA", Platform == "linux"))
67
apis.append(_PackageOption("ASIHPI", Platform == "linux"))
68
apis.append(_PackageOption("COREAUDIO", Platform == "darwin"))
69
elif Platform in Windows:
70
if Platform == "cygwin":
71
apis.append(_EnumOption("winAPI", "Windows API to use", ("wmme", "directx", "asio"), "wmme"))
73
opts["Host APIs"] = apis
75
opts["Build Parameters"] = [\
76
_BoolOption("debug", "compile with debug symbols"),
77
_BoolOption("optimize", "compile with optimization", default=0),
78
_BoolOption("asserts", "runtime assertions are helpful for debugging, but can be detrimental to performance",
80
_BoolOption("debugOutput", "enable debug output", default=0),
81
# _BoolOption("python", "create Python binding"),
82
("customCFlags", "customize compilation of C code", ""),
83
("customCxxFlags", "customize compilation of C++ code", ""),
84
("customLinkFlags", "customize linking", ""),
88
_BoolOption("cxx", "build Merlijn Blaauw's PA C++ wrapper", default=0)