forked from dsacre/klick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConstruct
115 lines (99 loc) · 3.12 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import os
import SCons.Util
version = '0.13.0-pre'
env = Environment(
CPPDEFINES = [
('VERSION', '\\"%s\\"' % version),
],
CXXFLAGS = ['-std=c++11'],
ENV = os.environ,
)
if 'CXX' in os.environ:
env.Replace(CXX = os.environ['CXX'])
if 'CXXFLAGS' in os.environ:
env.Append(CXXFLAGS = SCons.Util.CLVar(os.environ['CXXFLAGS']))
if 'CPPFLAGS' in os.environ:
env.Append(CXXFLAGS = SCons.Util.CLVar(os.environ['CPPFLAGS']))
if 'LDFLAGS' in os.environ:
env.Append(LINKFLAGS = SCons.Util.CLVar(os.environ['LDFLAGS']))
# build options
opts = Variables('scache.conf')
opts.AddVariables(
PathVariable('PREFIX', 'install prefix', '/usr/local'),
PathVariable('DESTDIR', 'intermediate install prefix', '', PathVariable.PathAccept),
BoolVariable('DEBUG', 'debug mode', False),
BoolVariable('OSC', 'OSC support', True),
BoolVariable('TERMINAL', 'terminal control support', True),
BoolVariable('RUBBERBAND', 'use Rubber Band for pitch shifting', True),
BoolVariable('GETOPT_LONG', 'enable long options using getopt_long()', True),
)
opts.Update(env)
opts.Save('scache.conf', env)
Help(opts.GenerateHelpText(env))
if env['DEBUG']:
env.Append(CCFLAGS = ['-g', '-Wall', '-Wextra'])
else:
env.Append(CCFLAGS = ['-O2', '-Wall', '-Wextra'])
env.Prepend(CPPDEFINES = 'NDEBUG')
# install paths
prefix_bin = os.path.join(env['PREFIX'], 'bin')
prefix_share = os.path.join(env['PREFIX'], 'share/klick')
env.Append(CPPDEFINES = ('DATA_DIR', '\\"%s\\"' % prefix_share))
# required libraries
env.ParseConfig(
'pkg-config --cflags --libs jack samplerate sndfile'
)
if os.system('pkg-config --atleast-version=1.0.18 sndfile') == 0:
env.Append(CPPDEFINES = ['HAVE_SNDFILE_OGG'])
# source files
sources = [
'src/main.cc',
'src/klick.cc',
'src/options.cc',
'src/audio_interface.cc',
'src/audio_interface_jack.cc',
'src/audio_interface_sndfile.cc',
'src/audio_chunk.cc',
'src/tempomap.cc',
'src/metronome.cc',
'src/metronome_simple.cc',
'src/metronome_map.cc',
'src/metronome_jack.cc',
'src/position.cc',
]
# audio samples
samples = [
'samples/square_emphasis.wav',
'samples/square_normal.wav',
'samples/sine_emphasis.wav',
'samples/sine_normal.wav',
'samples/noise_emphasis.wav',
'samples/noise_normal.wav',
'samples/click_emphasis.wav',
'samples/click_normal.wav',
]
# build options
if env['OSC']:
env.ParseConfig('pkg-config --cflags --libs liblo')
env.Append(CPPDEFINES = ['ENABLE_OSC'])
sources += [
'src/osc_interface.cc',
'src/osc_handler.cc',
]
if env['TERMINAL']:
env.Append(CPPDEFINES = ['ENABLE_TERMINAL'])
sources += [
'src/terminal_handler.cc',
]
if env['RUBBERBAND']:
env.ParseConfig('pkg-config --cflags --libs rubberband')
env.Append(CPPDEFINES = ['ENABLE_RUBBERBAND'])
if env['GETOPT_LONG']:
env.Append(CPPDEFINES = ['ENABLE_GETOPT_LONG'])
env.Program('klick', sources)
Default('klick')
# installation
env.Alias('install', [
env.Install(env['DESTDIR'] + prefix_bin, 'klick'),
env.Install(env['DESTDIR'] + os.path.join(prefix_share, 'samples'), samples)
])