Update for renamed libfile
[supercollider.git] / SConstruct
blob6d71e0f6791caa87b9e8c0848534d29cb9837285
1 # -*- python -*- =======================================================
2 # FILE: SConstruct
3 # CONTENTS: scons build script for SuperCollider
4 # AUTHOR: sk AT k-hornz DOT de
5 # modifications: nescivi AT gmail DOT com
6 # ======================================================================
8 # ======================================================================
9 # NOTE: Please use an indentation level of 4 spaces, i.e. no mixing of
10 # tabs and spaces.
11 # ======================================================================
13 # ======================================================================
14 # setup
15 # ======================================================================
17 EnsureSConsVersion(0,96)
18 EnsurePythonVersion(2,3)
19 SConsignFile()
21 # ======================================================================
22 # imports
23 # ======================================================================
25 import glob
26 import os
27 import subprocess
28 import re
29 import types
30 import tarfile
31 import platform # Seems to have more portable uname() than os
33 # ======================================================================
34 # constants
35 # ======================================================================
37 PACKAGE = 'SuperCollider'
41 f = open('VERSION')
42 VERSION = f.readline()
43 f.close()
45 def short_cpu_name(cpu):
46 if cpu == 'Power Macintosh':
47 cpu = 'ppc'
48 return cpu.lower()
50 PLATFORM = platform.uname()[0].lower()
51 CPU = short_cpu_name(platform.uname()[4])
53 ANY_FILE_RE = re.compile('.*')
54 HELP_FILE_RE = re.compile('.*\.(rtf(d)?|scd|html)$')
55 SC_FILE_RE = re.compile('.*\.sc$')
56 SRC_FILE_RE = re.compile('.*\.(c(pp)|h)$')
58 if PLATFORM == 'darwin':
59 PLATFORM_SYMBOL = 'SC_DARWIN'
60 PLUGIN_EXT = '.scx'
61 DEFAULT_AUDIO_API = 'coreaudio'
62 DEFAULT_PREFIX = '/usr/local'
63 elif PLATFORM == 'freebsd':
64 PLATFORM_SYMBOL = 'SC_FREEBSD'
65 PLUGIN_EXT = '.so'
66 DEFAULT_AUDIO_API = 'jack'
67 DEFAULT_PREFIX = '/usr/local'
68 elif PLATFORM == 'linux':
69 PLATFORM_SYMBOL = 'SC_LINUX'
70 PLUGIN_EXT = '.so'
71 DEFAULT_AUDIO_API = 'jack'
72 DEFAULT_PREFIX = '/usr/local'
73 elif PLATFORM == 'windows':
74 PLATFORM_SYMBOL = 'SC_WIN32'
75 PLUGIN_EXT = '.scx'
76 DEFAULT_AUDIO_API = 'portaudio'
77 DEFAULT_PREFIX = '/'
78 else:
79 print 'Unknown platform: %s' % PLATFORM
80 Exit(1)
82 if CPU in [ 'ppc' , 'ppc64' ]:
83 DEFAULT_OPT_ARCH = '7450'
84 elif CPU in [ 'i586', 'i686' ]:
85 # FIXME: better detection
86 DEFAULT_OPT_ARCH = CPU
87 else:
88 DEFAULT_OPT_ARCH = None
90 if PLATFORM != 'windows':
91 subprocess.call(['sh', 'setMainVersion.sh'])
94 # ======================================================================
95 # util
96 # ======================================================================
99 def make_os_env(*keys):
100 env = os.environ
101 res = {}
102 for key in keys:
103 if env.has_key(key):
104 res[key] = env[key]
105 return res
107 def CheckPKGConfig(context, version):
108 context.Message( 'Checking for pkg-config... ' )
109 ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
110 context.Result( ret )
111 return ret
113 def CheckPKG(context, name):
114 context.Message('Checking for %s... ' % name)
115 ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
116 res = None
117 if ret:
118 res = Environment(ENV = make_os_env('PATH', 'PKG_CONFIG_PATH'))
119 res.ParseConfig('pkg-config --cflags --libs \'%s\'' % name)
120 res['PKGCONFIG'] = name
121 context.Result(ret)
122 return (ret, res)
124 def get_new_pkg_env():
125 return Environment(ENV = make_os_env('PATH', 'PKG_CONFIG_PATH'))
127 def merge_lib_info(env, *others):
128 for other in others:
129 env.AppendUnique(CCFLAGS = other.get('CCFLAGS', []))
130 env.AppendUnique(CPPDEFINES = other.get('CPPDEFINES', []))
131 env.AppendUnique(CPPPATH = other.get('CPPPATH', []))
132 env.AppendUnique(CXXFLAGS = other.get('CXXFLAGS', []))
133 env.AppendUnique(LIBS = other.get('LIBS', []))
134 env.AppendUnique(LIBPATH = other.get('LIBPATH', []))
135 env['LINKFLAGS'] = env['LINKFLAGS'] + other.get('LINKFLAGS', "")
137 def make_pkgconfig_requires(*envs):
138 res = []
139 for env in envs:
140 if env and env.has_key('PKGCONFIG'):
141 res.append(env['PKGCONFIG'])
142 return res
144 def build_pkgconfig_file(target, source, env):
145 def write_field(file, name, prefix, separator=None):
146 if env.has_key(name):
147 if separator:
148 content = separator.join(env[name])
149 else:
150 content = env[name]
151 file.write('%s%s\n' % (prefix, content))
152 out = file(str(target[0]), 'w')
153 out.writelines([
154 'prefix=%s\n' % env['PREFIX'],
155 'exec_prefix=${prefix}\n',
156 'libdir=${exec_prefix}/lib\n',
157 'includedir=${prefix}/include/%s\n' % env['PACKAGE'],
158 '\n'])
159 write_field(out, 'PKGCONFIG_NAME', 'Name: ')
160 write_field(out, 'PKGCONFIG_DESC', 'Description: ')
161 write_field(out, 'URL', 'URL: ')
162 write_field(out, 'VERSION', 'Version: ')
163 write_field(out, 'PKGCONFIG_REQUIRES', 'Requires: ', ', ')
164 write_field(out, 'PKGCONFIG_REQUIRES_PRIVATE', 'Requires.private: ', ', ')
165 write_field(out, 'PKGCONFIG_LIBS', 'Libs: -L${libdir} ', ' ')
166 write_field(out, 'PKGCONFIG_LIBS_PRIVATE', 'Libs.private: ', ' ')
167 write_field(out, 'PKGCONFIG_CFLAGS', 'Cflags: ', ' ')
168 out.close()
170 def flatten_dir(dir):
171 res = []
172 for root, dirs, files in os.walk(dir):
173 if 'CVS' in dirs: dirs.remove('CVS')
174 if '.svn' in dirs: dirs.remove('.svn')
175 for f in files:
176 res.append(os.path.join(root, f))
177 return res
179 def install_dir(env, src_dir, dst_dir, filter_re, strip_levels=0):
180 nodes = []
181 for root, dirs, files in os.walk(src_dir):
182 src_paths = []
183 dst_paths = []
184 if 'CVS' in dirs: dirs.remove('CVS')
185 if '.svn' in dirs: dirs.remove('.svn')
186 for d in dirs[:]:
187 if filter_re.match(d):
188 src_paths += flatten_dir(os.path.join(root, d))
189 dirs.remove(d)
190 for f in files:
191 if filter_re.match(f):
192 src_paths.append(os.path.join(root, f))
193 dst_paths += map(
194 lambda f:
195 os.path.join(
196 dst_dir,
197 *f.split(os.path.sep)[strip_levels:]),
198 src_paths)
199 nodes += env.InstallAs(dst_paths, src_paths)
200 return nodes
202 def is_installing():
203 pat = re.compile('^install.*$')
204 for x in COMMAND_LINE_TARGETS:
205 if pat.match(x): return True
206 return False
208 def is_home_directory(dir):
209 return os.path.normpath(dir) == os.path.normpath(os.environ.get('HOME', '/'))
211 def bin_dir(prefix):
212 return os.path.join(prefix, 'bin')
213 def lib_dir(prefix):
214 return os.path.join(prefix, 'lib')
216 def pkg_data_dir(prefix, *args):
217 if PLATFORM == 'darwin':
218 base = '/Library/Application Support'
219 if is_home_directory(prefix):
220 base = os.path.join(prefix, base)
221 else:
222 base = os.path.join(prefix, 'share')
223 return os.path.join(base, PACKAGE, *args)
224 def pkg_doc_dir(prefix, *args):
225 if PLATFORM == 'darwin':
226 base = '/Library/Documentation'
227 if is_home_directory(prefix):
228 base = os.path.join(prefix, base)
229 else:
230 base = os.path.join(prefix, 'share', 'doc')
231 return os.path.join(base, PACKAGE, *args)
232 def pkg_include_dir(prefix, *args):
233 return os.path.join(prefix, 'include', PACKAGE, *args)
234 def pkg_lib_dir(prefix, *args):
235 return os.path.join(lib_dir(prefix), PACKAGE, *args)
237 def pkg_classlib_dir(prefix, *args):
238 return pkg_data_dir(prefix, 'SCClassLibrary', *args)
239 def pkg_extension_dir(prefix, *args):
240 return pkg_data_dir(prefix, 'Extensions', *args)
242 def make_opt_flags(env):
243 flags = [
244 "-O3",
245 ## "-fomit-frame-pointer", # can behave strangely for sclang
246 "-ffast-math",
247 "-fno-finite-math-only",
248 "-fstrength-reduce"
250 arch = env.get('OPT_ARCH')
251 if arch:
252 if CPU in [ 'ppc' , 'ppc64' ]:
253 flags.extend([ "-mcpu=%s" % (arch,) ])
254 else:
255 flags.extend([ "-march=%s" % (arch,) ])
256 if CPU in [ 'ppc' , 'ppc64' ]:
257 flags.extend([ "-fsigned-char", "-mhard-float",
258 ## "-mpowerpc-gpopt", # crashes sqrt
259 "-mpowerpc-gfxopt"
261 return flags
263 def make_static_object(env, source, postfix="_a"):
264 obj = os.path.splitext(source)[0] + postfix
265 return env.StaticObject(obj, source)
267 def make_static_objects(env, sources, postfix="_a"):
268 return map(lambda x: make_static_object(env, x, postfix), sources)
270 # ======================================================================
271 # command line options
272 # ======================================================================
274 opts = Options('scache.conf', ARGUMENTS)
275 opts.AddOptions(
276 BoolOption('ALSA',
277 'Build with ALSA sequencer support', 1),
278 BoolOption('ALTIVEC',
279 'Build with Altivec support', 1),
280 ('OPT_ARCH', 'Architecture to optimize for', DEFAULT_OPT_ARCH),
281 EnumOption('AUDIOAPI',
282 'Build with specified audio API support',
283 DEFAULT_AUDIO_API, ('jack', 'coreaudio', 'portaudio')),
284 ('CC', 'C compiler executable'),
285 ('CCFLAGS', 'C compiler flags'),
286 ('CXX', 'C++ compiler executable'),
287 ('CXXFLAGS', 'C++ compiler flags'),
288 BoolOption('DEBUG',
289 'Build with debugging information', 0),
290 PathOption('DESTDIR',
291 'Intermediate installation prefix for packaging', '/'),
292 BoolOption('DEVELOPMENT',
293 'Build and install the development files', 0),
294 BoolOption('FFTW',
295 'Use the FFTW libraries', PLATFORM != 'darwin'),
296 BoolOption('JACK_DLL',
297 'Build with delay locked loop support', 0),
298 BoolOption('JACK_DEBUG_DLL',
299 'Build with delay locked loop debugging support', 0),
300 BoolOption('LANG',
301 'Build the language application', 1),
302 BoolOption('LID',
303 'Build with Linux Input Device support [linux]', PLATFORM == 'linux'),
304 BoolOption('NO_LIBSNDFILE',
305 'Disable libsndfile (audio file reading/writing)', 0),
306 BoolOption('WII',
307 'Build with Linux WII support [linux]', PLATFORM == 'linux'),
308 PathOption('PREFIX',
309 'Installation prefix', DEFAULT_PREFIX),
310 BoolOption('RENDEZVOUS',
311 'Enable Zeroconf/Rendezvous.', 1),
312 BoolOption('SCEL',
313 'Enable the SCEL user interface; NOTE for the HTML help system you need emacs-w3m', 1),
314 BoolOption('SCVIM',
315 'Enable the SCVIM user interface; NOTE see the README in /editors/scvim for setting variables', 1),
316 BoolOption('SCED',
317 'Enable the SCED (based on gedit) user interface; NOTE see the README in /editors/sced for setting variables', 0),
318 BoolOption('SSE',
319 'Build with SSE support', 1),
320 BoolOption('SSE2',
321 'Build with SSE2 support', 1),
322 BoolOption('STRIP',
323 'Strip symbols from binaries', 0),
324 BoolOption('CROSSCOMPILE',
325 'Crosscompile for another platform (does not do SSE support check)', 0),
326 BoolOption('TERMINAL_CLIENT',
327 'Build with terminal client interface', 1),
328 BoolOption('CURL',
329 'Build with libcurl - allows server to load files from remote servers by URL', 0),
330 BoolOption('READLINE',
331 'Build with GNU readline for nice command-line sclang interface', PLATFORM == 'linux'),
332 BoolOption('GPL3',
333 'Allow the inclusion of gpl-3 licensed code. Makes the license of the whole package gpl-3', 1),
334 PackageOption('X11',
335 'Build with X11 support', 1),
336 BoolOption('SCLANG64',
337 'Build 64bit sclang (only affects compilation on 64bit systems)', 0),
340 if PLATFORM == 'darwin':
341 opts.AddOptions(
342 BoolOption('UNIVERSAL',
343 'Build universal binaries (see UNIVERSAL_ARCHS)', 1),
344 BoolOption('INTERNAL_LIBSNDFILE',
345 'Use internal version of libsndfile', 1),
346 # ListOption('UNIVERSAL_ARCHS',
347 # 'Architectures to build for',
348 # 'all', ['ppc', 'i386'])
351 # ======================================================================
352 # basic environment
353 # ======================================================================
355 env = Environment(options = opts,
356 ENV = make_os_env('PATH', 'PKG_CONFIG_PATH'),
357 PACKAGE = PACKAGE,
358 VERSION = VERSION,
359 URL = 'http://supercollider.sourceforge.net',
360 TARBALL = PACKAGE + VERSION + '.tbz2')
361 env.Append(PATH = ['/usr/local/bin', '/usr/bin', '/bin'])
363 # for nova-simd
364 env.Append(CPPPATH = ["xtralibs/include/nova-simd"])
365 env.Append(CPPDEFINES = ["NOVA_SIMD"])
367 if not env['GPL3']:
368 env.Append(CPPDEFINES = ["NO_GPL3_CODE"])
369 if env['READLINE']:
370 print 'WARNING: option READLINE is on and option GPL3 is off, yet readline is GPL3+ licensed, so it will NOT be activated.'
372 # checks for DISTCC and CCACHE as used in modern linux-distros:
374 if os.path.exists('/usr/lib/distcc/bin'):
375 os.environ['PATH'] = '/usr/lib/distcc/bin:' + os.environ['PATH']
376 #env['ENV']['DISTCC_HOSTS'] = os.environ['DISTCC_HOSTS']
377 env['ENV']['DISTCC_HOSTS'] = os.environ.get('DISTCC_HOSTS')
379 if os.path.exists('/usr/lib/ccache/bin'):
380 os.environ['PATH'] = '/usr/lib/ccache/bin:' + os.environ['PATH']
381 #env['ENV']['CCACHE_DIR'] = os.environ['CCACHE_DIR']
382 env['ENV']['CCACHE_DIR'] = os.environ.get('CCACHE_DIR')
384 env['ENV']['PATH'] = os.environ['PATH']
385 if PLATFORM == 'windows':
386 env['ENV']['HOME'] = os.environ['HOMEPATH']
387 else:
388 env['ENV']['HOME'] = os.environ['HOME']
390 if PLATFORM == 'linux':
391 env['amd64'] = 'x86_64' in platform.uname()
392 if env['amd64']:
393 print "we are on amd64 linux"
396 # ======================================================================
397 # installation directories
398 # ======================================================================
400 FINAL_PREFIX = '$PREFIX'
401 INSTALL_PREFIX = os.path.join('$DESTDIR', '$PREFIX')
403 if env['PREFIX'] == '/usr':
404 FINAL_CONFIG_PREFIX = '/etc'
405 else:
406 FINAL_CONFIG_PREFIX = os.path.join(env['PREFIX'], 'etc')
407 CONFIG_PREFIX = '$DESTDIR' + FINAL_CONFIG_PREFIX
409 env.Append(
410 CPPDEFINES = [('SC_DATA_DIR', '\\"' + pkg_data_dir(FINAL_PREFIX) + '\\"')])
412 # ======================================================================
413 # configuration
414 # ======================================================================
416 def make_conf(env):
417 return Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
418 'CheckPKG' : CheckPKG })
420 def isDefaultBuild():
421 return not env.GetOption('clean') and not 'debian' in COMMAND_LINE_TARGETS
423 conf = make_conf(env)
425 # libraries
426 libraries = { }
427 features = { }
429 if isDefaultBuild():
430 if not conf.CheckPKGConfig('0'):
431 print 'pkg-config not found.'
432 Exit(1)
434 # sndfile
435 if env['NO_LIBSNDFILE']:
436 libraries['sndfile'] = Environment(CPPDEFINES = ['NO_LIBSNDFILE'])
437 else:
438 if PLATFORM == 'darwin' and env['INTERNAL_LIBSNDFILE']:
439 libraries['sndfile'] = Environment(LINKFLAGS = ['xtralibs/mac/scUBlibsndfile.a'],
440 CPPPATH = ['#xtralibs/include/libsndfile'])
441 else:
442 success, libraries['sndfile'] = conf.CheckPKG('sndfile >= 1.0.16')
443 if not success: Exit(1)
444 succes2, libraries['sndfile18'] = conf.CheckPKG('sndfile >= 1.0.18')
445 if succes2:
446 libraries['sndfile'].Append(CPPDEFINES = ['LIBSNDFILE_1018'])
448 # libcurl
449 success, libraries['libcurl'] = conf.CheckPKG('libcurl >= 7')
450 if env['CURL'] and not success:
451 print 'CURL option was set, but libcurl not found.'
452 Exit(1)
454 # FFTW
455 libraries['fftwf'] = Environment()
456 if env['FFTW']:
457 success, libraries['fftwf'] = conf.CheckPKG('fftw3f')
458 if success:
459 libraries['fftwf'].Append(CPPDEFINES = ['SC_FFT_FFTW'])
460 else:
461 libraries['fftwf'].Append(CPPDEFINES = ['SC_FFT_NONE'])
462 else:
463 libraries['fftwf'].Append(CPPDEFINES = ['SC_FFT_NONE'])
464 if PLATFORM == 'darwin':
465 # needed for vector multiplication
466 libraries['fftwf'] = Environment(LINKFLAGS = '-framework vecLib')
467 else:
468 libraries['sndfile'] = get_new_pkg_env()
469 libraries['fftwf'] = get_new_pkg_env()
470 libraries['libcurl'] = get_new_pkg_env()
472 # audio api
473 if env['AUDIOAPI'] == 'jack':
474 features['audioapi'] = 'Jack'
475 success, libraries['audioapi'] = conf.CheckPKG('jack >= 0.100')
476 if success:
477 libraries['audioapi'].Append(
478 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_JACK')],
479 ADDITIONAL_SOURCES = ['Source/server/SC_Jack.cpp']
481 else:
482 success, libraries['audioapi'] = conf.CheckPKG('jack')
483 if isDefaultBuild():
484 if not success: Exit(1)
485 else:
486 libraries['audioapi'] = get_new_pkg_env()
487 libraries['audioapi'].Append(
488 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_JACK'),
489 'SC_USE_JACK_CLIENT_NEW'],
490 ADDITIONAL_SOURCES = ['Source/server/SC_Jack.cpp']
492 libraries['audioapi'].Append(
493 CPPDEFINES = [('SC_JACK_USE_DLL', env['JACK_DLL']),
494 ('SC_JACK_DEBUG_DLL', env['JACK_DEBUG_DLL'])]
496 elif env['AUDIOAPI'] == 'coreaudio':
497 features['audioapi'] = 'CoreAudio'
498 libraries['audioapi'] = Environment(
499 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_COREAUDIO')],
500 LINKFLAGS = '-framework CoreAudio',
501 ADDITIONAL_SOURCES = []
503 elif env['AUDIOAPI'] == 'portaudio':
504 features['audioapi'] = 'Portaudio'
505 libraries['audioapi'] = Environment(
506 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_PORTAUDIO')],
507 LIBS = ['portaudio'],
508 ADDITIONAL_SOURCES = []
511 # rendezvous
512 if env['RENDEZVOUS']:
513 features['rendezvous'], libraries['rendezvous'] = conf.CheckPKG('avahi-client')
514 if features['rendezvous']:
515 libraries['rendezvous'].Append(CPPDEFINES = ['HAVE_AVAHI'])
516 else:
517 features['rendezvous'], libraries['rendezvous'] = conf.CheckPKG('howl')
518 if features['rendezvous']:
519 libraries['rendezvous'].Append(CPPDEFINES = ['HAVE_HOWL'])
520 else:
521 features['rendezvous'] = False
522 libraries['rendezvous'] = False
524 # alsa
525 if env['ALSA']:
526 features['alsa'], libraries['alsa'] = conf.CheckPKG('alsa')
527 else:
528 features['alsa'] = False
530 if features['alsa']:
531 libraries['alsa'].Append(CPPDEFINES = ['HAVE_ALSA'])
533 # midi
534 if conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h'):
535 features['midiapi'] = 'CoreMIDI'
536 libraries['midiapi'] = Environment(
537 LINKFLAGS = '-framework CoreMIDI',
539 elif features['alsa']:
540 features['midiapi'] = 'ALSA'
541 libraries['midiapi'] = libraries['alsa'].Clone()
542 else:
543 features['midiapi'] = None
545 # lid
546 features['lid'] = env['LID'] and conf.CheckCHeader('linux/input.h')
548 # wii on linux
549 if PLATFORM == 'linux':
550 features['wii'] = env['WII'] and conf.CheckCHeader('cwiid.h')
551 else:
552 features['wii'] = env['WII']
554 # libicu
555 if env['LANG']:
556 if PLATFORM == 'darwin' or conf.CheckCHeader('unicode/uregex.h'):
557 libraries['libicu'] = Environment(
558 LINKFLAGS = '-licui18n -licuuc -licudata',
560 else:
561 print "libicu not found"
562 Exit(1)
564 # readline
565 if env['LANG'] and env['READLINE'] and env['GPL3']:
566 if conf.CheckCHeader('readline/readline.h'):
567 libraries['readline'] = Environment(
568 LINKFLAGS = '-lreadline',
570 else:
571 print "libreadline not found"
572 Exit(1)
574 # only _one_ Configure context can be alive at a time
575 env = conf.Finish()
577 # altivec
578 if env['ALTIVEC']:
579 if PLATFORM == 'darwin':
580 altivec_flags = [ '-faltivec' ]
581 else:
582 altivec_flags = [ '-maltivec', '-mabi=altivec' ]
583 libraries['altivec'] = env.Clone()
584 libraries['altivec'].Append(
585 CCFLAGS = altivec_flags,
586 CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 16)])
587 altiConf = Configure(libraries['altivec'])
588 features['altivec'] = altiConf.CheckCHeader('altivec.h')
589 altiConf.Finish()
590 else:
591 features['altivec'] = False
593 # sse
594 if env['SSE']:
595 libraries['sse'] = env.Clone()
596 libraries['sse'].Append(
597 CCFLAGS = ['-msse', '-mfpmath=sse'],
598 CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 16)])
599 if env['SSE2']:
600 libraries['sse'].Append(
601 CCFLAGS = ['-msse2'])
603 sseConf = Configure(libraries['sse'])
604 hasSSEHeader = sseConf.CheckCHeader('xmmintrin.h')
605 if env['CROSSCOMPILE']:
606 build_host_supports_sse = True
607 print 'NOTICE: cross compiling for another platform: assuming SSE support'
608 else:
609 build_host_supports_sse = False
610 #if CPU != 'ppc':
611 if CPU not in [ 'ppc' , 'ppc64' ]:
612 if PLATFORM == 'freebsd':
613 machine_info = os.popen ("sysctl -a hw.instruction_sse").read()[:-1]
614 x86_flags = 'no'
615 if "1" in [x for x in machine_info]:
616 build_host_supports_sse = True
617 x86_flags = 'sse'
618 elif PLATFORM != 'darwin':
619 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
620 x86_flags = flag_line.split (": ")[1:][0].split ()
621 else:
622 machine_info = os.popen ("sysctl -a machdep.cpu").read()[:-1]
623 x86_flags = machine_info.split()
624 if "sse" in [x.lower() for x in x86_flags]:
625 build_host_supports_sse = True
626 print 'NOTICE: CPU has SSE support'
627 else:
628 print 'NOTICE: CPU does not have SSE support'
629 features['sse'] = hasSSEHeader and build_host_supports_sse
630 sseConf.Finish()
631 else:
632 features['sse'] = False
634 if env['X11']:
635 # features['x11'], libraries['x11'] = conf.CheckPKG('xt')
636 if type(env['X11']) != types.StringType:
637 if os.path.exists('/usr/X11R6'):
638 env['X11'] = '/usr/X11R6'
639 elif os.path.exists('/usr/lib/X11'):
640 env['X11'] = '/usr/lib/X11'
641 else: env['X11'] = '/usr'
642 x11Env = Environment(
643 CPPPATH = [os.path.join(env['X11'], 'include')],
644 LIBPATH = [os.path.join(env['X11'], 'lib')])
645 x11Conf = Configure(x11Env)
646 features['x11'] = x11Conf.CheckCHeader('X11/Intrinsic.h') \
647 and x11Conf.CheckLib('X11', 'XQueryPointer')
648 libraries['x11'] = x11Conf.Finish()
649 else:
650 features['x11'] = False
653 opts.Save('scache.conf', env)
654 Help(opts.GenerateHelpText(env))
656 # defines and compiler flags
658 env.Append(
659 CPPDEFINES = [ '_REENTRANT', PLATFORM_SYMBOL ],
660 CCFLAGS = [ '-Wno-unknown-pragmas' ],
661 CXXFLAGS = [ '-Wno-deprecated' ]
664 # debugging flags
665 if env['DEBUG']:
666 env.Append(CCFLAGS = '-g')
667 else:
668 env.Append(
669 CCFLAGS = make_opt_flags(env),
670 CPPDEFINES = ['NDEBUG'])
671 if env['STRIP']:
672 env.Append(LINKFLAGS = "-Wl,-s")
674 # platform specific
675 if False: #PLATFORM == 'darwin':
676 # universal binary support
677 if env['UNIVERSAL']:
678 archs = map(lambda x: ['-arch', x], ['ppc', 'i386'])
679 env.Append(
680 CCFLAGS = archs,
681 LINKFLAGS = archs
684 # vectorization
685 if features['altivec']:
686 merge_lib_info(env, libraries['altivec'])
687 elif features['sse']:
688 merge_lib_info(env, libraries['sse'])
689 else:
690 env.AppendUnique(CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 1)])
692 # ======================================================================
693 # Source/common
694 # ======================================================================
696 commonEnv = env.Clone()
697 commonEnv.Append(
698 CPPPATH = ['#Headers/common',
699 '#Headers/plugin_interface',
700 '#Headers/server'],
701 CCFLAGS = ['-fPIC'],
702 CXXFLAGS = ['-fPIC']
705 # strtod
706 conf = Configure(commonEnv)
707 if conf.CheckFunc('strtod'):
708 commonEnv.Append(
709 CPPDEFINES = 'HAVE_STRTOD'
711 commonEnv = conf.Finish()
714 # ======================================================================
715 # back to common
716 # ======================================================================
718 commonSources = Split('''
719 Source/common/SC_AllocPool.cpp
720 Source/common/SC_DirUtils.cpp
721 Source/common/SC_Sem.cpp
722 Source/common/SC_StringBuffer.cpp
723 Source/common/SC_StringParser.cpp
724 Source/common/scsynthsend.cpp
725 Source/common/sc_popen.cpp
726 ''')
727 if PLATFORM == 'darwin':
728 commonSources += [
729 'Source/common/SC_StandAloneInfo_Darwin.cpp'
731 if env['CURL']:
732 commonEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
733 merge_lib_info(commonEnv, libraries['libcurl'])
734 libcommon = commonEnv.Library('build/common', commonSources)
736 #if env['amd64']:
737 #commonSources32 = list(commonSources)
738 #commonEnv32 = commonEnv.Clone()
739 #commonEnv32.Append(
740 #CCFLAGS = ['-m32'],
742 #libcommon32 = commonEnv32.Library('build/common32', commonSources32)
745 # ======================================================================
746 # Source/server
747 # ======================================================================
749 serverEnv = env.Clone()
750 serverEnv.Append(
751 CPPPATH = ['#Headers/common',
752 '#Headers/plugin_interface',
753 '#Headers/server'],
754 CPPDEFINES = [('SC_PLUGIN_DIR', '\\"' + pkg_lib_dir(FINAL_PREFIX, 'plugins') + '\\"'), ('SC_PLUGIN_EXT', '\\"' + PLUGIN_EXT + '\\"')],
755 LIBPATH = 'build')
756 libscsynthEnv = serverEnv.Clone(
757 PKGCONFIG_NAME = 'libscsynth',
758 PKGCONFIG_DESC = 'SuperCollider synthesis server library',
759 PKGCONFIG_PREFIX = FINAL_PREFIX,
760 PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile'],
761 libraries['audioapi'],
762 libraries['rendezvous']),
763 PKGCONFIG_LIBS = ['-lscsynth'],
764 # PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
765 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server']
768 # platform specific
770 # functionality of libdl is included in libc on freebsd
771 if PLATFORM == 'freebsd':
772 serverEnv.Append(LIBS = ['common', 'pthread'])
773 else:
774 serverEnv.Append(LIBS = ['common', 'pthread', 'dl'])
776 if PLATFORM == 'darwin':
777 serverEnv.Append(
778 LINKFLAGS = [
779 '-framework', 'CoreServices'])
780 #'-dylib_install_name', FINAL_PREFIX + '/lib/libsclang.dylib'])
781 elif PLATFORM == 'linux':
782 serverEnv.Append(
783 CPPDEFINES = [('SC_PLUGIN_LOAD_SYM', '\\"load\\"')],
784 LINKFLAGS = '-Wl,-rpath,' + FINAL_PREFIX + '/lib')
786 elif PLATFORM == 'freebsd':
787 serverEnv.Append(CPPDEFINES = [('SC_PLUGIN_LOAD_SYM', '\\"load\\"')])
789 # required libraries
790 merge_lib_info(
791 serverEnv,
792 libraries['sndfile'], libraries['audioapi'])
794 # optional features
795 if features['rendezvous']:
796 serverEnv.Append(CPPDEFINES = ['USE_RENDEZVOUS'])
797 merge_lib_info(serverEnv, libraries['rendezvous'])
799 if env['CURL']:
800 serverEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
801 merge_lib_info(serverEnv, libraries['libcurl'])
803 libscsynthSources = Split('''
804 Source/server/Rendezvous.cpp
805 Source/server/Samp.cpp
806 Source/server/SC_BufGen.cpp
807 Source/server/SC_Carbon.cpp
808 Source/server/SC_Complex.cpp
809 Source/server/SC_ComPort.cpp
810 Source/server/SC_CoreAudio.cpp
811 Source/server/SC_Dimension.cpp
812 Source/server/SC_Errors.cpp
813 Source/server/SC_Graph.cpp
814 Source/server/SC_GraphDef.cpp
815 Source/server/SC_Group.cpp
816 Source/server/SC_Lib_Cintf.cpp
817 Source/server/SC_Lib.cpp
818 Source/server/SC_MiscCmds.cpp
819 Source/server/SC_Node.cpp
820 Source/server/SC_Rate.cpp
821 Source/server/SC_SequencedCommand.cpp
822 Source/server/SC_Str4.cpp
823 Source/server/SC_SyncCondition.cpp
824 Source/server/SC_Unit.cpp
825 Source/server/SC_UnitDef.cpp
826 Source/server/SC_World.cpp
827 ''') + libraries['audioapi']['ADDITIONAL_SOURCES']
829 scsynthSources = ['Source/server/scsynth_main.cpp']
831 libscsynth = serverEnv.SharedLibrary('build/scsynth', libscsynthSources)
832 env.Alias('install-programs', env.Install(lib_dir(INSTALL_PREFIX), [libscsynth]))
834 libscsynthStaticSources = libscsynthSources + make_static_objects(serverEnv, commonSources, "_libscsynthStatic");
835 libscsynthStatic = serverEnv.StaticLibrary('build/scsynth', libscsynthStaticSources)
836 env.Alias('install-programs', env.Install(lib_dir(INSTALL_PREFIX), [libscsynthStatic]))
838 scsynth = serverEnv.Program('build/scsynth', scsynthSources, LIBS = ['scsynth'])
839 env.Alias('install-programs', env.Install(bin_dir(INSTALL_PREFIX), [scsynth]))
841 # ======================================================================
842 # Source/plugins
843 # ======================================================================
845 pluginEnv = env.Clone(
846 SHLIBPREFIX = '',
847 SHLIBSUFFIX = PLUGIN_EXT
849 pluginEnv.Append(
850 CPPPATH = ['#Headers/common',
851 '#Headers/plugin_interface',
852 '#Headers/server'],
853 PKGCONFIG_NAME = 'libscplugin',
854 PKGCONFIG_DESC = 'SuperCollider synthesis plugin headers',
855 PKGCONFIG_PREFIX = FINAL_PREFIX,
856 #PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['scsynth']),
857 #PKGCONFIG_LIBS = [],
858 # PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
859 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server']
861 if PLATFORM == 'darwin':
862 pluginEnv['SHLINKFLAGS'] = '$LINKFLAGS -bundle -flat_namespace -undefined suppress'
864 # we merge this in even if no libsndfile (it'll pass in the NO_LIBSNDFILE flag)
865 merge_lib_info(
866 pluginEnv,
867 libraries['sndfile'])
870 plugins = []
872 def make_plugin_target(name):
873 return os.path.join('build', 'plugins', name)
875 # simple plugins
876 for name in Split('''
877 BinaryOpUGens
878 ChaosUGens
879 DelayUGens
880 DemandUGens
881 DynNoiseUGens
882 FilterUGens
883 GendynUGens
884 IOUGens
885 LFUGens
886 MulAddUGens
887 NoiseUGens
888 OscUGens
889 PanUGens
890 PhysicalModelingUGens
891 TestUGens
892 TriggerUGens
893 UnaryOpUGens
894 GrainUGens
895 ReverbUGens
896 '''):
897 plugins.append(
898 pluginEnv.SharedLibrary(
899 make_plugin_target(name), os.path.join('Source', 'plugins', name + '.cpp')))
901 # complex
902 complexEnv = pluginEnv.Clone()
903 complexSources = Split('Source/plugins/SCComplex.cpp')
904 complexEnv.SharedObject('Source/plugins/SCComplex.o', complexSources)
906 # fft ugens
907 fftEnv = pluginEnv.Clone()
908 fftSources = Split('Source/common/SC_fftlib.cpp Source/plugins/SCComplex.o')
909 merge_lib_info(fftEnv, libraries['fftwf'])
910 plugins.append(
911 fftEnv.SharedLibrary(
912 make_plugin_target('FFT_UGens'),
913 ['Source/plugins/FFTInterfaceTable.cpp',
914 'Source/plugins/FFT_UGens.cpp',
915 'Source/plugins/PV_UGens.cpp',
916 'Source/plugins/PartitionedConvolution.cpp'] + fftSources))
918 plugins.append(
919 fftEnv.SharedLibrary(
920 make_plugin_target('PV_ThirdParty'),
921 ['Source/plugins/Convolution.cpp',
922 'Source/plugins/FFT2InterfaceTable.cpp',
923 'Source/plugins/FeatureDetection.cpp',
924 'Source/plugins/PV_ThirdParty.cpp'] + fftSources))
926 # fft 'unpacking' ugens
927 plugins.append(
928 pluginEnv.SharedLibrary(
929 make_plugin_target('UnpackFFTUGens'), ['Source/plugins/SCComplex.o', 'Source/plugins/UnpackFFTUGens.cpp']))
931 # machine listening ugens
932 # fft ugens
933 mlEnv = pluginEnv.Clone()
934 mlSources = Split('Source/plugins/ML.cpp Source/plugins/Loudness.cpp Source/plugins/BeatTrack.cpp Source/plugins/Onsets.cpp Source/plugins/onsetsds.c Source/plugins/KeyTrack.cpp Source/plugins/MFCC.cpp Source/plugins/SCComplex.o Source/plugins/BeatTrack2.cpp Source/plugins/ML_SpecStats.cpp')
935 plugins.append(
936 mlEnv.SharedLibrary(
937 make_plugin_target('ML_UGens'), mlSources))
939 # diskio ugens
940 if not env['NO_LIBSNDFILE']: # (libsndfile needed for all of these, so skip if unavailable)
941 diskIOEnv = pluginEnv.Clone(
942 LIBS = ['common', 'm'],
943 LIBPATH = 'build'
945 if PLATFORM == 'darwin':
946 diskIOEnv.Append(
947 LINKFLAGS = '-framework CoreServices'
950 diskIOSources = [
951 diskIOEnv.SharedObject('Source/plugins/SC_SyncCondition', 'Source/server/SC_SyncCondition.cpp'),
952 'Source/plugins/DiskIO_UGens.cpp']
953 merge_lib_info(diskIOEnv, libraries['sndfile'])
954 plugins.append(
955 diskIOEnv.SharedLibrary(
956 make_plugin_target('DiskIO_UGens'), diskIOSources))
958 # ui ugens
959 if PLATFORM == 'darwin':
960 uiUGensEnv = pluginEnv.Clone(
961 LIBS = 'm',
962 LINKFLAGS = '-framework CoreServices -framework Carbon'
964 plugins.append(
965 uiUGensEnv.SharedLibrary(make_plugin_target('MouseUGens'), 'Source/plugins/MouseUGens.cpp'))
966 plugins.append(
967 uiUGensEnv.SharedLibrary(make_plugin_target('KeyboardUGens'), 'Source/plugins/KeyboardUGens.cpp'))
968 elif features['x11']:
969 uiUGensEnv = pluginEnv.Clone()
970 merge_lib_info(uiUGensEnv, libraries['x11'])
971 plugins.append(
972 uiUGensEnv.SharedLibrary(make_plugin_target('MouseUGens'), 'Source/plugins/MouseUGens.cpp'))
973 plugins.append(
974 uiUGensEnv.SharedLibrary(make_plugin_target('KeyboardUGens'), 'Source/plugins/KeyboardUGens.cpp'))
976 env.Alias('install-plugins', env.Install(
977 pkg_lib_dir(INSTALL_PREFIX, 'plugins'), plugins))
979 # ======================================================================
980 # Source/lang
981 # ======================================================================
983 if env['TERMINAL_CLIENT'] == True:
984 env['TERMINAL_CLIENT'] = 1
985 else:
986 env['TERMINAL_CLIENT'] = 0
988 langEnv = env.Clone()
989 langEnv.Append(
990 CPPPATH = ['#Headers/common',
991 '#Headers/plugin_interface',
992 '#Headers/lang',
993 '#Headers/server',
994 '#Source/lang/LangSource/Bison'],
995 CPPDEFINES = [['USE_SC_TERMINAL_CLIENT', env['TERMINAL_CLIENT']]],
996 LIBPATH = 'build'
999 if env.get('amd64') and not env.get('SCLANG64'):
1000 langEnv.Append( CFLAGS = ['-m32'],
1001 CXXFLAGS = ['-m32'],
1002 LINKFLAGS = ['-m32'],
1003 CPPDEFINES = "NO_INTERNAL_SERVER")
1004 else:
1005 langEnv.Append(LIBS = ['common', 'scsynth'])
1006 merge_lib_info(langEnv, libraries['audioapi'])
1008 if PLATFORM == 'windows':
1009 langEnv.Append(CPPDEFINES = "NO_INTERNAL_SERVER")
1011 # functionality of libdl is included in libc on freebsd
1012 if PLATFORM == 'freebsd':
1013 langEnv.Append(LIBS = ['pthread', 'm'])
1014 else:
1015 langEnv.Append(LIBS = ['pthread', 'dl', 'm'])
1017 if PLATFORM == 'darwin':
1018 langEnv.Append(
1019 LIBS = ['icucore'],
1020 LINKFLAGS = ['-framework', 'CoreServices'], #'-dylib_install_name', FINAL_PREFIX + '/lib/libsclang.dylib'],
1021 CPPPATH = ['#xtralibs/include/icu/unicode'])
1022 elif PLATFORM == 'linux':
1023 langEnv.Append(
1024 LINKFLAGS = '-Wl,-rpath,build -Wl,-rpath,' + FINAL_PREFIX + '/lib')
1026 if env.get('amd64') and not env.get('SCLANG64'):
1027 langEnv.Append(LIBPATH="/emul/ia32-linux/usr/lib/,/usr/lib32/",
1028 LINKFLAGS = '-Wl,-rpath,/emul/ia32-linux/usr/lib/')
1030 elif PLATFORM == 'freebsd':
1031 langEnv.Append(
1032 LINKFLAGS = '-Wl,-rpath,build -Wl,-rpath,' + FINAL_PREFIX + '/lib')
1034 if env['CURL']:
1035 langEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
1036 merge_lib_info(langEnv, libraries['libcurl'])
1038 if env['READLINE'] and env['LANG'] and env['GPL3']:
1039 langEnv.Append(CPPDEFINES = ['HAVE_READLINE'])
1040 merge_lib_info(langEnv, libraries['readline'])
1043 libsclangEnv = langEnv.Clone(
1044 PKGCONFIG_NAME = 'libsclang',
1045 PKGCONFIG_DESC = 'SuperCollider synthesis language library',
1046 PKGCONFIG_PREFIX = FINAL_PREFIX,
1047 PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile']) + ['libscsynth'],
1048 PKGCONFIG_LIBS = ['-lsclang'],
1049 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/lang', '-I${includedir}/server']
1052 # required libraries
1053 merge_lib_info(langEnv, libraries['sndfile'])
1055 libsclangSources = Split('''
1056 Source/lang/LangSource/AdvancingAllocPool.cpp
1057 Source/lang/LangSource/ByteCodeArray.cpp
1058 Source/lang/LangSource/DumpParseNode.cpp
1059 Source/lang/LangSource/GC.cpp
1060 Source/lang/LangSource/InitAlloc.cpp
1061 Source/lang/LangSource/PyrFileUtils.cpp
1062 Source/lang/LangSource/PyrInterpreter3.cpp
1063 Source/lang/LangSource/PyrLexer.cpp
1064 Source/lang/LangSource/PyrMathOps.cpp
1065 Source/lang/LangSource/PyrMathSupport.cpp
1066 Source/lang/LangSource/PyrMessage.cpp
1067 Source/lang/LangSource/PyrObject.cpp
1068 Source/lang/LangSource/PyrParseNode.cpp
1069 Source/lang/LangSource/PyrSignal.cpp
1070 Source/lang/LangSource/PyrSymbolTable.cpp
1071 Source/lang/LangSource/SC_LanguageClient.cpp
1072 Source/lang/LangSource/SC_LibraryConfig.cpp
1073 Source/lang/LangSource/SC_TerminalClient.cpp
1074 Source/lang/LangSource/Samp.cpp
1075 Source/lang/LangSource/SimpleStack.cpp
1076 Source/lang/LangSource/VMGlobals.cpp
1077 Source/lang/LangSource/alloca.cpp
1078 Source/lang/LangSource/dumpByteCodes.cpp
1079 Source/lang/LangSource/Bison/lang11d_tab.cpp
1080 Source/lang/LangPrimSource/SC_Wii.cpp
1081 Source/lang/LangPrimSource/PyrSignalPrim.cpp
1082 Source/lang/LangPrimSource/PyrSched.cpp
1083 Source/lang/LangPrimSource/PyrPrimitive.cpp
1084 Source/lang/LangPrimSource/PyrMathPrim.cpp
1085 Source/lang/LangPrimSource/SC_ComPort.cpp
1086 Source/lang/LangPrimSource/OSCData.cpp
1087 Source/lang/LangPrimSource/PyrArchiver.cpp
1088 Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
1089 Source/lang/LangPrimSource/PyrBitPrim.cpp
1090 Source/lang/LangPrimSource/PyrCharPrim.cpp
1091 Source/lang/LangPrimSource/PyrFilePrim.cpp
1092 Source/lang/LangPrimSource/PyrListPrim.cpp
1093 Source/lang/LangPrimSource/PyrPlatformPrim.cpp
1094 Source/lang/LangPrimSource/PyrSerialPrim.cpp
1095 Source/lang/LangPrimSource/PyrStringPrim.cpp
1096 Source/lang/LangPrimSource/PyrUStringPrim.cpp
1097 Source/lang/LangPrimSource/PyrSymbolPrim.cpp
1098 Source/lang/LangPrimSource/PyrUnixPrim.cpp
1099 Source/common/fftlib.c
1100 ''')
1102 if env['LANG']:
1103 merge_lib_info(langEnv, libraries['libicu'])
1105 # optional features
1106 if features['midiapi']:
1107 merge_lib_info(langEnv, libraries['midiapi'])
1108 if features['midiapi'] == 'CoreMIDI':
1109 libsclangSources += ['Source/lang/LangPrimSource/SC_CoreMIDI.cpp']
1110 else:
1111 libsclangSources += ['Source/lang/LangPrimSource/SC_AlsaMIDI.cpp']
1112 else:
1113 # fallback implementation
1114 libsclangSources += ['Source/lang/LangPrimSource/SC_AlsaMIDI.cpp']
1116 if PLATFORM == 'darwin':
1117 langEnv.Append(
1118 CPPPATH = ['#Source/lang/LangPrimSource/HID_Utilities',
1119 '#Source/lang/LangPrimSource/WiiMote_OSX'],
1120 LINKFLAGS = '-framework Carbon -framework IOKit -framework IOBluetooth'
1122 libsclangSources += Split('''
1123 Source/lang/LangPrimSource/SC_HID.cpp
1124 Source/lang/LangPrimSource/SC_CoreAudioPrim.cpp
1125 Source/lang/LangPrimSource/HID_Utilities/HID_Error_Handler.c
1126 Source/lang/LangPrimSource/HID_Utilities/HID_Name_Lookup.c
1127 Source/lang/LangPrimSource/HID_Utilities/HID_Queue_Utilities.c
1128 Source/lang/LangPrimSource/HID_Utilities/HID_Utilities.c
1129 Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.c
1130 ''')
1132 if env.has_key('amd64') and env['amd64']:
1133 libsclangSources += commonSources
1135 if PLATFORM == 'linux':
1136 # HAVE_LID does the right thing in SC_LID.cpp source
1137 libsclangSources += ['Source/lang/LangPrimSource/SC_LID.cpp']
1138 if features['wii']:
1139 langEnv.Append(CPPDEFINES = 'HAVE_WII')
1140 langEnv.Append(LINKFLAGS = '-lcwiid')
1141 #langEnv.Append(LINKFLAGS = '-lbluetooth')
1142 #langEnv.Append(CPPPATH = '-I/usr/local/include/libcwiimote-0.4.0/libcwiimote/' ) #FIXME: to proper include directory
1143 if features['lid']:
1144 langEnv.Append(CPPDEFINES = 'HAVE_LID')
1146 if PLATFORM == 'darwin':
1147 langEnv.Append(CPPDEFINES = 'HAVE_SPEECH')
1148 libsclangSources += ['Source/lang/LangPrimSource/SC_Speech.cpp']
1150 sclangSources = ['Source/lang/LangSource/cmdLineFuncs.cpp']
1152 if env['LANG']:
1153 libsclang = langEnv.SharedLibrary('build/sclang', libsclangSources)
1154 env.Alias('install-bin', env.Install(lib_dir(INSTALL_PREFIX), [libsclang]))
1155 if PLATFORM == 'darwin':
1156 sclangLibs = ['scsynth', 'sclang']
1157 else:
1158 sclangLibs = ['sclang']
1159 sclang = langEnv.Program('build/sclang', sclangSources, LIBS=sclangLibs)
1160 env.Alias('install-programs', env.Install(bin_dir(INSTALL_PREFIX), [sclang]))
1162 # ======================================================================
1163 # doc/doxygen
1164 # ======================================================================
1166 # doxygen = env.Command(None, 'doc/doxygen/html/index.html', 'doxygen doc/doxygen/doxygen.cfg')
1167 # env.Alias('doxygen', doxygen)
1169 # ======================================================================
1170 # installation
1171 # ======================================================================
1173 installEnv = Environment(
1174 ALL = ['install-bin', 'install-data'],
1175 BIN = ['install-plugins', 'install-programs'],
1176 DATA = ['install-doc']
1178 if env['LANG']:
1179 installEnv.Append(DATA = ['install-library'])
1181 if is_installing():
1182 # class library
1183 env.Alias('install-library', install_dir(
1184 env, 'build/SCClassLibrary',
1185 pkg_data_dir(INSTALL_PREFIX),
1186 SC_FILE_RE, 1))
1187 # help files
1188 env.Alias('install-library', install_dir(
1189 env, 'build/Help',
1190 pkg_data_dir(INSTALL_PREFIX),
1191 HELP_FILE_RE, 1))
1192 # example files
1193 env.Alias('install-library', install_dir(
1194 env, 'build/examples',
1195 pkg_data_dir(INSTALL_PREFIX),
1196 HELP_FILE_RE, 1))
1197 # scel
1198 if env['SCEL']:
1199 env.Alias('install-library', install_dir(
1200 env, 'editors/scel/sc',
1201 pkg_extension_dir(INSTALL_PREFIX, 'scide_scel'),
1202 SC_FILE_RE, 3))
1203 # scvim
1204 # if env['SCVIM']:
1205 # env.Alias('install-library', install_dir(
1206 # env, 'editors/scvim/scclasses',
1207 # pkg_extension_dir(INSTALL_PREFIX, 'scvim'),
1208 # SC_FILE_RE, 3))
1209 # # scvim helpfiles
1210 # if env['SCVIM']:
1211 # env.Alias('install-library', install_dir(
1212 # env, 'editors/scvim/cache/doc',
1213 # pkg_data_dir(INSTALL_PREFIX, 'scvim-help'),
1214 # HELP_FILE_RE, 4))
1216 #scvim : unhtml help files
1217 #if env['SCVIM']:
1218 #os.execvpe("editors/scvim/bin/scvim_make_help", [ "-c", "-s", "build/Help"],"SCVIM=editors/scvim/")
1219 #os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
1221 #if env['SCVIM']:
1222 #vimenv = env.Clone()
1223 #SConscript('editors/test/SConstruct', exports=['vimenv'])
1225 #if env['SCVIM']:
1226 #print 'installing scvim'
1227 #vimenv = env.Clone()
1228 ##env.Append(FROMTOP=True)
1229 #SConscript('editors/scvim/SConstruct', exports=['vimenv'])
1231 #### scvim and sced scripts need to be called independently, until someone fixes setting the proper variables from the parent script
1233 if env['SCVIM']:
1234 print '----------------------------------------------------'
1235 # SConscript('editors/scvim/SConstruct', exports=['env'])
1236 print 'To install SCVIM, please use scons in the directory editors/scvim/'
1238 if env['SCED']:
1239 # SConscript('editors/sced/SConstruct', 'env')
1240 print '----------------------------------------------------'
1241 print 'To install SCED, please use the scons in the directory editors/sced/'
1243 # scel
1244 if env['SCEL']:
1245 env.Command('editors/scel/el/sclang-vars.el', 'editors/scel/el/sclang-vars.el.in',
1246 'sed \'s,@PKG_DATA_DIR@,%s,g\' < $SOURCE > $TARGET' %
1247 pkg_data_dir(FINAL_PREFIX))
1248 el_files = glob.glob('editors/scel/el/*.el') + ['editors/scel/el/sclang-vars.el']
1249 elc_files = map(lambda f: os.path.splitext(f)[0] + '.elc', el_files)
1250 elisp_dir = os.path.join(INSTALL_PREFIX, 'share', 'emacs', 'site-lisp')
1251 env.Command(elc_files, el_files,
1252 'emacs -batch --eval "(add-to-list \'load-path (expand-file-name \\"editors/scel/el/\\"))" -f batch-byte-compile $SOURCES')
1253 env.Alias('install-elisp', env.Install(elisp_dir, el_files + elc_files))
1254 installEnv.Append(DATA = 'install-elisp')
1256 # example library configuration file
1257 env.Command('linux/examples/sclang.cfg', 'linux/examples/sclang.cfg.in',
1258 'sed \'s,@PKG_DATA_DIR@,%s,g\' < $SOURCE > $TARGET' %
1259 pkg_data_dir(FINAL_PREFIX))
1261 # headers
1262 if env['DEVELOPMENT']:
1263 header_dirs = Split('common plugin_interface server lang')
1264 if PLATFORM == 'darwin':
1265 header_dirs += 'app'
1266 for d in header_dirs:
1267 env.Alias('install-dev', install_dir(
1268 env, os.path.join('Headers', d),
1269 pkg_include_dir(INSTALL_PREFIX),
1270 re.compile('.*\.h(h|pp)?'), 1)
1272 # other useful headers
1273 env.Alias('install-dev',
1274 env.Install(pkg_include_dir(INSTALL_PREFIX, 'plugin_interface'), 'Source/plugins/FFT_UGens.h'))
1275 pkgconfig_files = [
1276 libscsynthEnv.Command('linux/libscsynth.pc', 'SConstruct',
1277 build_pkgconfig_file),
1278 libsclangEnv.Command('linux/libsclang.pc', 'SConstruct',
1279 build_pkgconfig_file),
1280 pluginEnv.Command('linux/libscplugin.pc', 'SConstruct',
1281 build_pkgconfig_file)]
1282 pkgconfig_dir = os.path.join(lib_dir(INSTALL_PREFIX), 'pkgconfig')
1283 env.Alias('install-dev', env.Install(pkgconfig_dir, pkgconfig_files))
1284 installEnv.Append(ALL = 'install-dev')
1286 # documentation
1287 if is_installing():
1288 # TODO: build html documentation?
1289 doc_dir = pkg_doc_dir(INSTALL_PREFIX)
1290 env.Alias('install-doc',
1291 install_dir(env, 'doc', doc_dir, ANY_FILE_RE, 0) +
1292 install_dir(env, 'build/examples', doc_dir, ANY_FILE_RE, 1) +
1293 install_dir(env, 'build/TestingAndToDo', doc_dir, ANY_FILE_RE, 1))
1295 env.Alias('install-bin', installEnv['BIN'])
1296 env.Alias('install-data', installEnv['DATA'])
1297 env.Alias('install', installEnv['ALL'])
1299 # ======================================================================
1300 # distribution
1301 # ======================================================================
1303 DIST_FILES = Split('''
1304 COPYING
1305 SConstruct
1306 clean-compile.sh
1307 compile.sh
1308 distro
1309 linux/examples/onetwoonetwo.sc
1310 linux/examples/sclang.cfg.in
1311 linux/examples/sclang.sc
1312 editors/scel/README
1313 editors/scvim/README
1314 editors/sced/README
1315 scsynthlib_exp
1316 ''')
1318 DIST_SPECS = [
1319 ('build', HELP_FILE_RE),
1320 ('Headers', SRC_FILE_RE),
1321 ('editors/scel/sc', SC_FILE_RE),
1322 ('editors/scel/el', re.compile('.*\.el$')),
1323 ('editors/scvim/scclasses', SC_FILE_RE),
1324 ('Source', SRC_FILE_RE)
1327 def dist_paths():
1328 paths = DIST_FILES[:]
1329 specs = DIST_SPECS[:]
1330 while specs:
1331 base, re = specs.pop()
1332 if not re: re = ANY_FILE_RE
1333 for root, dirs, files in os.walk(base):
1334 if 'CVS' in dirs: dirs.remove('CVS')
1335 if '.svn' in dirs: dirs.remove('.svn')
1336 for path in dirs[:]:
1337 if re.match(path):
1338 specs.append((os.path.join(root, path), re))
1339 dirs.remove(path)
1340 for path in files:
1341 if re.match(path):
1342 paths.append(os.path.join(root, path))
1343 paths.sort()
1344 return paths
1346 def build_tar(env, target, source):
1347 paths = dist_paths()
1348 tarfile_name = str(target[0])
1349 tar_name = os.path.splitext(os.path.basename(tarfile_name))[0]
1350 tar = tarfile.open(tarfile_name, "w:bz2")
1351 for path in paths:
1352 tar.add(path, os.path.join(tar_name, path))
1353 tar.close()
1355 if 'dist' in COMMAND_LINE_TARGETS:
1356 env.Alias('dist', env['TARBALL'])
1357 env.Command(env['TARBALL'], 'SConstruct', build_tar)
1359 # ======================================================================
1360 # cleanup
1361 # ======================================================================
1363 if 'scrub' in COMMAND_LINE_TARGETS:
1364 env.Clean('scrub', Split('config.log scache.conf .sconf_temp'))
1366 # ======================================================================
1367 # configuration summary
1368 # ======================================================================
1370 def yesorno(p):
1371 if p: return 'yes'
1372 else: return 'no'
1374 print '------------------------------------------------------------------------'
1375 print ' ALTIVEC: %s' % yesorno(features['altivec'])
1376 print ' AUDIOAPI: %s' % features['audioapi']
1377 print ' MIDIAPI: %s' % features['midiapi']
1378 print ' DEBUG: %s' % yesorno(env['DEBUG'])
1379 # print ' DESTDIR: %s' % env['DESTDIR']
1380 print ' DEVELOPMENT: %s' % yesorno(env['DEVELOPMENT'])
1381 print ' LANG: %s' % yesorno(env['LANG'])
1382 print ' LID: %s' % yesorno(features['lid'])
1383 print ' NO_LIBSNDFILE: %s' % yesorno(env['NO_LIBSNDFILE'])
1384 print ' WII: %s' % yesorno(features['wii'])
1385 print ' PREFIX: %s' % env['PREFIX']
1386 print ' RENDEZVOUS: %s' % yesorno(features['rendezvous'])
1387 print ' SCEL: %s' % yesorno(env['SCEL'])
1388 print ' SCVIM: %s' % yesorno(env['SCVIM'])
1389 print ' SCED: %s' % yesorno(env['SCED'])
1390 print ' SSE: %s' % yesorno(features['sse'])
1391 print ' STRIP: %s' % yesorno(env['STRIP'])
1392 print ' CROSSCOMPILE: %s' % yesorno(env['CROSSCOMPILE'])
1393 print ' TERMINAL_CLIENT: %s' % yesorno(env['TERMINAL_CLIENT'])
1394 print ' X11: %s' % yesorno(features['x11'])
1395 print ' GPL3: %s' % yesorno(env['GPL3'])
1396 print ' SCLANG64: %s' % yesorno(env.get('SCLANG64'))
1397 print '------------------------------------------------------------------------'
1399 # ======================================================================
1400 # EOF