Merging various recent changes from trunk into 34 - inc sc.app menu tweak, synthdef...
[supercollider.git] / common / wscript
blob62e5b4b433968caa14fca5e4b2c6643be224f3fc
1 #! /usr/bin/env python
2 # encoding: utf-8
4 # =====================================================================
5 # Experimental waf build script for SuperCollider, currently Linux-only
6 # use with caution!!
7 # --artfwo
9 import os
10 import sys
12 VERSION='3.3.1' # TODO: grab the version from the VERSION file, as in the SConstruct
13 APPNAME='supercollider'
14 srcdir = '.'
15 blddir = 'build/waf' # FIXME
17 SC3_API_VERSION=VERSION
19 def set_options(opt):
20 opt.tool_options('gnu_dirs')
21 opt.tool_options('compiler_cc')
22 opt.tool_options('compiler_cxx')
24 def configure(conf):
25 import Utils
26 platform = Utils.detect_platform()
28 conf.env['IS_LINUX'] = platform == 'linux'
29 conf.env['IS_WIN32'] = platform == 'win32'
30 conf.env['IS_MACOSX'] = platform == 'darwin'
31 conf.env['IS_FREEBSD'] = platform == 'freebsd'
33 if not conf.env['IS_LINUX']:
34 Utils.pprint('RED', 'Sorry, waf builder currently does not work on %s platform!' % platform)
35 sys.exit(1)
37 conf.check_tool('gnu_dirs')
38 conf.check_tool('compiler_cc')
39 conf.check_tool('compiler_cxx')
40 #conf.check_tool('misc')
42 conf.check_cfg(atleast_pkgconfig_version='0.0.0')
44 conf.check_cfg(package='sndfile', atleast_version='1.0.16',
45 args='--cflags --libs', mandatory=True)
46 conf.check_cfg(package='jack', atleast_version='0.100',
47 args='--cflags --libs', mandatory=True)
48 conf.check_cfg(package='avahi-client',
49 args='--cflags --libs', mandatory=True)
50 conf.check_cfg(package='alsa',
51 args='--cflags --libs', mandatory=True)
52 conf.check_cfg(package='xt',
53 args='--cflags --libs', mandatory=True)
54 conf.check_cfg(package='fftw3f',
55 args='--cflags --libs', mandatory=True)
57 conf.check_cc(header_name='cwiid.h', lib='cwiid', uselib_store='CWIID')
58 conf.check_cc(header_name='linux/input.h')
59 conf.check_cc(header_name='xmmintrin.h', ccflags=['-msse', '-mfpmath=sse'], define_name='HAVE_SSE')
61 if conf.env['HAVE_SSE']:
62 conf.env.append_unique('CCFLAGS', ['-msse', '-mfpmath=sse'])
63 conf.env.append_unique('CXXFLAGS', ['-msse', '-mfpmath=sse'])
64 conf.define('SC_MEMORY_ALIGNMENT', 16)
65 else:
66 conf.define('SC_MEMORY_ALIGNMENT', 1)
68 #conf.env['LIBDIR'] = os.path.join(conf.env['PREFIX'], 'lib')
69 #conf.env['DATADIR'] = os.path.join(conf.env['PREFIX'], 'share')
71 # global defines
72 conf.define('HAVE_ALSA', 1)
73 conf.define('HAVE_AVAHI', 1)
74 conf.define('HAVE_LID', 1)
75 conf.define('HAVE_WII', 1)
76 #conf.define('SC_AUDIO_API=SC_AUDIO_API_JACK')
77 conf.define('SC_FFT_FFTW', 1)
78 conf.define('SC_LINUX', 1)
79 #conf.define('SC_MEMORY_ALIGNMENT', 16)
80 conf.define('SC_USE_JACK_CLIENT_NEW', 1)
81 conf.define('USE_RENDEZVOUS', 1)
82 conf.define('USE_SC_TERMINAL_CLIENT', 1)
84 conf.define('SC_DATA_DIR', os.path.join(conf.env['DATADIR'], 'SuperCollider'))
85 conf.define('SC_PLUGIN_DIR', os.path.join(conf.env['LIBDIR'], 'SuperCollider', 'plugins'))
86 conf.define('SC_PLUGIN_EXT', '.so')
87 conf.define('SC_PLUGIN_LOAD_SYM', 'load')
89 # other defines from SConstruct
90 conf.env.append_unique('CCFLAGS', ['-Wno-unknown-pragmas'])
91 conf.env.append_unique('CXXFLAGS', ['-Wno-unknown-pragmas', '-Wno-deprecated'])
93 # FIXME: ugly hack but SC3 does not use config.h now
94 conf.env.append_value('CPPFLAGS', ['-include','default/waf_config.h'])
95 conf.write_config_header('waf_config.h')
97 def sc_plugin_gen(bld, name, source, uselib='', add_objects=[]):
98 obj = bld.new_task_gen('cxx', 'shlib')
99 obj.add_objects = add_objects
100 obj.env['shlib_PATTERN'] = '%s.so'
101 obj.includes = '#Headers/common #Headers/plugin_interface #Headers/server'
102 obj.install_path = '${SC_PLUGIN_DIR}/'
103 obj.source = source
104 obj.target = name
105 obj.uselib = uselib
106 return obj
108 def build(bld):
109 # objects for other targets
110 fftlib = bld.new_task_gen('cc')
111 fftlib.includes = '#Headers/common'
112 fftlib.source = 'Source/common/fftlib.c'
113 fftlib.target = 'fftlib'
115 # libcommon
116 libcommon = bld.new_task_gen('cxx', 'staticlib')
117 libcommon.includes = '#Headers/common #Headers/plugin_interface #Headers/server'
118 libcommon.source = [
119 'Source/common/SC_AllocPool.cpp',
120 'Source/common/SC_DirUtils.cpp',
121 'Source/common/sc_popen.cpp',
122 'Source/common/SC_Sem.cpp',
123 'Source/common/SC_StringBuffer.cpp',
124 'Source/common/SC_StringParser.cpp',
125 'Source/common/scsynthsend.cpp',
126 ] # libcommon_source
127 libcommon.target = 'common'
128 libcommon.install_path = None
130 # libscsynth
131 libscsynth = bld.new_task_gen('cxx', 'shlib')
132 # FIXME: AUDIOAPI -> top
133 libscsynth.defines = 'SC_AUDIO_API=SC_AUDIO_API_JACK'
134 libscsynth.includes = '#Headers/common #Headers/plugin_interface #Headers/server'
135 libscsynth.uselib = 'JACK SNDFILE AVAHI-CLIENT' # FIXME
136 libscsynth.uselib_local = 'common'
137 libscsynth.vnum = SC3_API_VERSION # FIXME
138 libscsynth.source = [
139 'Source/server/Rendezvous.cpp',
140 'Source/server/Samp.cpp',
141 'Source/server/SC_BufGen.cpp',
142 'Source/server/SC_Carbon.cpp',
143 'Source/server/SC_Complex.cpp',
144 'Source/server/SC_ComPort.cpp',
145 'Source/server/SC_CoreAudio.cpp',
146 'Source/server/SC_Errors.cpp',
147 'Source/server/SC_Graph.cpp',
148 'Source/server/SC_GraphDef.cpp',
149 'Source/server/SC_Group.cpp',
150 'Source/server/SC_Lib_Cintf.cpp',
151 'Source/server/SC_Lib.cpp',
152 'Source/server/SC_MiscCmds.cpp',
153 'Source/server/SC_Node.cpp',
154 'Source/server/SC_Rate.cpp',
155 'Source/server/SC_SequencedCommand.cpp',
156 'Source/server/SC_Str4.cpp',
157 'Source/server/SC_SyncCondition.cpp',
158 'Source/server/SC_Unit.cpp',
159 'Source/server/SC_UnitDef.cpp',
160 'Source/server/SC_World.cpp',
161 # FIXME:
162 'Source/server/SC_Jack.cpp',
163 ] # libscsynth_source
164 libscsynth.target = 'scsynth'
166 #uselib_local = 'my_static_lib',
168 scsynth = bld.new_task_gen('cxx', 'program')
169 #scsynth.defines = sc3_defines
170 scsynth.includes = '#Headers/common #Headers/plugin_interface #Headers/server'
171 scsynth.source = ['Source/server/scsynth_main.cpp'] #+ common_sources
172 scsynth.target = 'scsynth'
173 scsynth.uselib_local = 'scsynth' # FIXME
174 #scsynth.uselib = ['JACK']
176 # libsclang
177 libsclang = bld.new_task_gen('cxx', 'shlib')
178 #libsclang.defines = sc3_defines
179 libsclang.includes = '#Headers/common #Headers/plugin_interface #Headers/lang #Source/lang/LangSource/Bison'
180 libsclang.target = 'sclang'
181 libsclang.uselib_local = 'common'
182 libsclang.uselib = 'SNDFILE CWIID ALSA'
183 libsclang.vnum = SC3_API_VERSION # FIXME
184 libsclang.source = [
185 'Source/lang/LangPrimSource/OSCData.cpp',
186 'Source/lang/LangPrimSource/PyrArchiver.cpp',
187 'Source/lang/LangPrimSource/PyrArrayPrimitives.cpp',
188 'Source/lang/LangPrimSource/PyrBitPrim.cpp',
189 'Source/lang/LangPrimSource/PyrCharPrim.cpp',
190 'Source/lang/LangPrimSource/PyrFilePrim.cpp',
191 'Source/lang/LangPrimSource/PyrListPrim.cpp',
192 'Source/lang/LangPrimSource/PyrMathPrim.cpp',
193 'Source/lang/LangPrimSource/PyrPlatformPrim.cpp',
194 'Source/lang/LangPrimSource/PyrPrimitive.cpp',
195 'Source/lang/LangPrimSource/PyrSched.cpp',
196 'Source/lang/LangPrimSource/PyrSerialPrim.cpp',
197 'Source/lang/LangPrimSource/PyrSignalPrim.cpp',
198 'Source/lang/LangPrimSource/PyrStringPrim.cpp',
199 'Source/lang/LangPrimSource/PyrSymbolPrim.cpp',
200 'Source/lang/LangPrimSource/PyrUnixPrim.cpp',
201 'Source/lang/LangPrimSource/PyrUStringPrim.cpp',
202 'Source/lang/LangPrimSource/SC_ComPort.cpp',
203 'Source/lang/LangPrimSource/SC_Wii.cpp',
204 'Source/lang/LangSource/AdvancingAllocPool.cpp',
205 'Source/lang/LangSource/alloca.cpp',
206 'Source/lang/LangSource/Bison/lang11d_tab.cpp',
207 'Source/lang/LangSource/ByteCodeArray.cpp',
208 'Source/lang/LangSource/dumpByteCodes.cpp',
209 'Source/lang/LangSource/DumpParseNode.cpp',
210 'Source/lang/LangSource/GC.cpp',
211 'Source/lang/LangSource/InitAlloc.cpp',
212 'Source/lang/LangSource/PyrFileUtils.cpp',
213 'Source/lang/LangSource/PyrInterpreter3.cpp',
214 'Source/lang/LangSource/PyrLexer.cpp',
215 'Source/lang/LangSource/PyrMathOps.cpp',
216 'Source/lang/LangSource/PyrMathSupport.cpp',
217 'Source/lang/LangSource/PyrMessage.cpp',
218 'Source/lang/LangSource/PyrObject.cpp',
219 'Source/lang/LangSource/PyrParseNode.cpp',
220 'Source/lang/LangSource/PyrSignal.cpp',
221 'Source/lang/LangSource/PyrSymbolTable.cpp',
222 'Source/lang/LangSource/Samp.cpp',
223 'Source/lang/LangSource/SC_LanguageClient.cpp',
224 'Source/lang/LangSource/SC_LibraryConfig.cpp',
225 'Source/lang/LangSource/SC_TerminalClient.cpp',
226 'Source/lang/LangSource/SimpleStack.cpp',
227 'Source/lang/LangSource/VMGlobals.cpp',
228 # FIXME:
229 #'Source/common/fftlib.c',
230 'Source/lang/LangPrimSource/SC_LID.cpp',
231 'Source/lang/LangPrimSource/SC_AlsaMIDI.cpp',
232 ] # libsclang_source
233 libsclang.add_objects = 'fftlib' # FIXME
235 # sclang
236 sclang = bld.new_task_gen('cxx', 'program')
237 sclang.includes = '#Headers/lang #Headers/plugin_interface #Headers/common'
238 sclang.source = ['Source/lang/LangSource/cmdLineFuncs.cpp'] #+ common_sources
239 sclang.target = 'sclang'
240 sclang.uselib_local = 'sclang scsynth'
242 # plugins
243 sccomplex = bld.new_task_gen('cxx')
244 sccomplex.includes = '#Headers/common #Headers/plugin_interface #Headers/server'
245 sccomplex.source = 'Source/plugins/SCComplex.cpp'
246 sccomplex.target = 'SCComplex'
248 stdugens = [
249 'BinaryOpUGens',
250 'ChaosUGens',
251 'DelayUGens',
252 'DemandUGens',
253 'DynNoiseUGens',
254 'FilterUGens',
255 'GendynUGens',
256 'IOUGens',
257 'LFUGens',
258 'MulAddUGens',
259 'NoiseUGens',
260 'OscUGens',
261 'PanUGens',
262 'PhysicalModelingUGens',
263 'TestUGens',
264 'TriggerUGens',
265 'UnaryOpUGens',
266 'GrainUGens',
267 'ReverbUGens'
268 ] # ugens
269 for name in stdugens:
270 sc_plugin_gen(bld, name, source=os.path.join('Source', 'plugins', name + '.cpp'))
272 sc_plugin_gen(bld, 'FFTUgens', source=[
273 'Source/plugins/FFTInterfaceTable.cpp',
274 'Source/plugins/FFT_UGens.cpp',
275 'Source/plugins/PV_UGens.cpp',
276 'Source/plugins/PartitionedConvolution.cpp',
277 'Source/common/SC_fftlib.cpp'], # XXX: special inline
278 uselib='FFTW3F',
279 add_objects='SCComplex')
281 sc_plugin_gen(bld, 'PVThirdParty', source=[
282 'Source/plugins/Convolution.cpp',
283 'Source/plugins/FFT2InterfaceTable.cpp',
284 'Source/plugins/FeatureDetection.cpp',
285 'Source/plugins/PV_ThirdParty.cpp',
286 'Source/common/SC_fftlib.cpp'], # XXX: special inline
287 uselib='FFTW3F',
288 add_objects='SCComplex')
290 sc_plugin_gen(bld, 'UnpackFFTUGens', source=[
291 'Source/plugins/UnpackFFTUGens.cpp'],
292 add_objects='SCComplex')
294 sc_plugin_gen(bld, 'MLUgens', source=[
295 'Source/plugins/ML.cpp',
296 'Source/plugins/Loudness.cpp',
297 'Source/plugins/BeatTrack.cpp',
298 'Source/plugins/Onsets.cpp',
299 'Source/plugins/onsetsds.c',
300 'Source/plugins/KeyTrack.cpp',
301 'Source/plugins/MFCC.cpp',
302 'Source/plugins/BeatTrack2.cpp',
303 'Source/plugins/ML_SpecStats.cpp'],
304 add_objects='SCComplex')
306 sc_plugin_gen(bld, 'DiskIOUgens', source=[
307 'Source/server/SC_SyncCondition.cpp',
308 'Source/plugins/DiskIO_UGens.cpp'])
310 sc_plugin_gen(bld, 'MouseUGens',
311 source=os.path.join('Source', 'plugins', 'MouseUGens.cpp'),
312 uselib='XT')
313 sc_plugin_gen(bld, 'KeyboardUGens',
314 source=os.path.join('Source', 'plugins', 'KeyboardUGens.cpp'),
315 uselib='XT')
317 # install headers
318 bld.install_files('${PREFIX}/include/SuperCollider/common', 'Headers/common/*.h')
319 bld.install_files('${PREFIX}/include/SuperCollider/lang', 'Headers/lang/*.h')
320 bld.install_files('${PREFIX}/include/SuperCollider/plugin_interface', 'Headers/plugin_interface/*.h')
321 bld.install_files('${PREFIX}/include/SuperCollider/server', 'Headers/server/*.h')
323 #bld.install_files('${PREFIX}/share/SuperCollider/',
324 # bld.path.ant_glob('build/SCClassLibrary/**/*.sc'),
325 # relative_trick=True)
326 #classfiles = bld.path.ant_glob('build/SCClassLibrary/**/*.sc', flat=True)
327 #for f in classfiles.split('build/'):
328 # print f