julian+alberto classlib merges for 3.4 (10125, 10130, 10133)
[supercollider.git] / common / SConstruct
blob204f3669215e10a4f66f4e224c0b79f222369013
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),
338 if PLATFORM == 'darwin':
339 opts.AddOptions(
340 BoolOption('UNIVERSAL',
341 'Build universal binaries (see UNIVERSAL_ARCHS)', 1),
342 BoolOption('INTERNAL_LIBSNDFILE',
343 'Use internal version of libsndfile', 1),
344 # ListOption('UNIVERSAL_ARCHS',
345 # 'Architectures to build for',
346 # 'all', ['ppc', 'i386'])
349 # ======================================================================
350 # basic environment
351 # ======================================================================
353 env = Environment(options = opts,
354 ENV = make_os_env('PATH', 'PKG_CONFIG_PATH'),
355 PACKAGE = PACKAGE,
356 VERSION = VERSION,
357 URL = 'http://supercollider.sourceforge.net',
358 TARBALL = PACKAGE + VERSION + '.tbz2')
359 env.Append(PATH = ['/usr/local/bin', '/usr/bin', '/bin'])
361 # for nova-simd
362 env.Append(CPPPATH = ["include/nova-simd"])
363 env.Append(CPPDEFINES = ["NOVA_SIMD"])
365 if not env['GPL3']:
366 env.Append(CPPDEFINES = ["NO_GPL3_CODE"])
367 if env['READLINE']:
368 print 'WARNING: option READLINE is on and option GPL3 is off, yet readline is GPL3+ licensed, so it will NOT be activated.'
370 # checks for DISTCC and CCACHE as used in modern linux-distros:
372 if os.path.exists('/usr/lib/distcc/bin'):
373 os.environ['PATH'] = '/usr/lib/distcc/bin:' + os.environ['PATH']
374 #env['ENV']['DISTCC_HOSTS'] = os.environ['DISTCC_HOSTS']
375 env['ENV']['DISTCC_HOSTS'] = os.environ.get('DISTCC_HOSTS')
377 if os.path.exists('/usr/lib/ccache/bin'):
378 os.environ['PATH'] = '/usr/lib/ccache/bin:' + os.environ['PATH']
379 #env['ENV']['CCACHE_DIR'] = os.environ['CCACHE_DIR']
380 env['ENV']['CCACHE_DIR'] = os.environ.get('CCACHE_DIR')
382 env['ENV']['PATH'] = os.environ['PATH']
383 if PLATFORM == 'windows':
384 env['ENV']['HOME'] = os.environ['HOMEPATH']
385 else:
386 env['ENV']['HOME'] = os.environ['HOME']
388 if PLATFORM == 'linux':
389 env['amd64'] = 'x86_64' in platform.uname()
390 if env['amd64']:
391 print "we are on amd64 linux"
394 # ======================================================================
395 # installation directories
396 # ======================================================================
398 FINAL_PREFIX = '$PREFIX'
399 INSTALL_PREFIX = os.path.join('$DESTDIR', '$PREFIX')
401 if env['PREFIX'] == '/usr':
402 FINAL_CONFIG_PREFIX = '/etc'
403 else:
404 FINAL_CONFIG_PREFIX = os.path.join(env['PREFIX'], 'etc')
405 CONFIG_PREFIX = '$DESTDIR' + FINAL_CONFIG_PREFIX
407 env.Append(
408 CPPDEFINES = [('SC_DATA_DIR', '\\"' + pkg_data_dir(FINAL_PREFIX) + '\\"')])
410 # ======================================================================
411 # configuration
412 # ======================================================================
414 def make_conf(env):
415 return Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
416 'CheckPKG' : CheckPKG })
418 def isDefaultBuild():
419 return not env.GetOption('clean') and not 'debian' in COMMAND_LINE_TARGETS
421 conf = make_conf(env)
423 # libraries
424 libraries = { }
425 features = { }
427 if isDefaultBuild():
428 if not conf.CheckPKGConfig('0'):
429 print 'pkg-config not found.'
430 Exit(1)
432 # sndfile
433 if env['NO_LIBSNDFILE']:
434 libraries['sndfile'] = Environment(CPPDEFINES = ['NO_LIBSNDFILE'])
435 else:
436 if PLATFORM == 'darwin' and env['INTERNAL_LIBSNDFILE']:
437 libraries['sndfile'] = Environment(LINKFLAGS = ['../mac/lib/scUBlibsndfile.a'],
438 CPPPATH = ['#include/libsndfile'])
439 else:
440 success, libraries['sndfile'] = conf.CheckPKG('sndfile >= 1.0.16')
441 if not success: Exit(1)
442 succes2, libraries['sndfile18'] = conf.CheckPKG('sndfile >= 1.0.18')
443 if succes2:
444 libraries['sndfile'].Append(CPPDEFINES = ['LIBSNDFILE_1018'])
446 # libcurl
447 success, libraries['libcurl'] = conf.CheckPKG('libcurl >= 7')
448 if env['CURL'] and not success:
449 print 'CURL option was set, but libcurl not found.'
450 Exit(1)
452 # FFTW
453 libraries['fftwf'] = Environment()
454 if env['FFTW']:
455 success, libraries['fftwf'] = conf.CheckPKG('fftw3f')
456 if success:
457 libraries['fftwf'].Append(CPPDEFINES = ['SC_FFT_FFTW'])
458 else:
459 libraries['fftwf'].Append(CPPDEFINES = ['SC_FFT_NONE'])
460 else:
461 libraries['fftwf'].Append(CPPDEFINES = ['SC_FFT_NONE'])
462 if PLATFORM == 'darwin':
463 # needed for vector multiplication
464 libraries['fftwf'] = Environment(LINKFLAGS = '-framework vecLib')
465 else:
466 libraries['sndfile'] = get_new_pkg_env()
467 libraries['fftwf'] = get_new_pkg_env()
468 libraries['libcurl'] = get_new_pkg_env()
470 # audio api
471 if env['AUDIOAPI'] == 'jack':
472 features['audioapi'] = 'Jack'
473 success, libraries['audioapi'] = conf.CheckPKG('jack >= 0.100')
474 if success:
475 libraries['audioapi'].Append(
476 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_JACK')],
477 ADDITIONAL_SOURCES = ['Source/server/SC_Jack.cpp']
479 else:
480 success, libraries['audioapi'] = conf.CheckPKG('jack')
481 if isDefaultBuild():
482 if not success: Exit(1)
483 else:
484 libraries['audioapi'] = get_new_pkg_env()
485 libraries['audioapi'].Append(
486 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_JACK'),
487 'SC_USE_JACK_CLIENT_NEW'],
488 ADDITIONAL_SOURCES = ['Source/server/SC_Jack.cpp']
490 libraries['audioapi'].Append(
491 CPPDEFINES = [('SC_JACK_USE_DLL', env['JACK_DLL']),
492 ('SC_JACK_DEBUG_DLL', env['JACK_DEBUG_DLL'])]
494 elif env['AUDIOAPI'] == 'coreaudio':
495 features['audioapi'] = 'CoreAudio'
496 libraries['audioapi'] = Environment(
497 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_COREAUDIO')],
498 LINKFLAGS = '-framework CoreAudio',
499 ADDITIONAL_SOURCES = []
501 elif env['AUDIOAPI'] == 'portaudio':
502 features['audioapi'] = 'Portaudio'
503 libraries['audioapi'] = Environment(
504 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_PORTAUDIO')],
505 LIBS = ['portaudio'],
506 ADDITIONAL_SOURCES = []
509 # rendezvous
510 if env['RENDEZVOUS']:
511 features['rendezvous'], libraries['rendezvous'] = conf.CheckPKG('avahi-client')
512 if features['rendezvous']:
513 libraries['rendezvous'].Append(CPPDEFINES = ['HAVE_AVAHI'])
514 else:
515 features['rendezvous'], libraries['rendezvous'] = conf.CheckPKG('howl')
516 if features['rendezvous']:
517 libraries['rendezvous'].Append(CPPDEFINES = ['HAVE_HOWL'])
518 else:
519 features['rendezvous'] = False
520 libraries['rendezvous'] = False
522 # alsa
523 if env['ALSA']:
524 features['alsa'], libraries['alsa'] = conf.CheckPKG('alsa')
525 else:
526 features['alsa'] = False
528 if features['alsa']:
529 libraries['alsa'].Append(CPPDEFINES = ['HAVE_ALSA'])
531 # midi
532 if conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h'):
533 features['midiapi'] = 'CoreMIDI'
534 libraries['midiapi'] = Environment(
535 LINKFLAGS = '-framework CoreMIDI',
537 elif features['alsa']:
538 features['midiapi'] = 'ALSA'
539 libraries['midiapi'] = libraries['alsa'].Clone()
540 else:
541 features['midiapi'] = None
543 # lid
544 features['lid'] = env['LID'] and conf.CheckCHeader('linux/input.h')
546 # wii on linux
547 if PLATFORM == 'linux':
548 features['wii'] = env['WII'] and conf.CheckCHeader('cwiid.h')
549 else:
550 features['wii'] = env['WII']
552 # libicu
553 if env['LANG']:
554 if PLATFORM == 'darwin' or conf.CheckCHeader('unicode/uregex.h'):
555 libraries['libicu'] = Environment(
556 LINKFLAGS = '-licui18n -licuuc -licudata',
558 else:
559 print "libicu not found"
560 Exit(1)
562 # readline
563 if env['LANG'] and env['READLINE'] and env['GPL3']:
564 if conf.CheckCHeader('readline/readline.h'):
565 libraries['readline'] = Environment(
566 LINKFLAGS = '-lreadline',
568 else:
569 print "libreadline not found"
570 Exit(1)
572 # only _one_ Configure context can be alive at a time
573 env = conf.Finish()
575 # altivec
576 if env['ALTIVEC']:
577 if PLATFORM == 'darwin':
578 altivec_flags = [ '-faltivec' ]
579 else:
580 altivec_flags = [ '-maltivec', '-mabi=altivec' ]
581 libraries['altivec'] = env.Clone()
582 libraries['altivec'].Append(
583 CCFLAGS = altivec_flags,
584 CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 16)])
585 altiConf = Configure(libraries['altivec'])
586 features['altivec'] = altiConf.CheckCHeader('altivec.h')
587 altiConf.Finish()
588 else:
589 features['altivec'] = False
591 # sse
592 if env['SSE']:
593 libraries['sse'] = env.Clone()
594 libraries['sse'].Append(
595 CCFLAGS = ['-msse', '-mfpmath=sse'],
596 CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 16)])
597 if env['SSE2']:
598 libraries['sse'].Append(
599 CCFLAGS = ['-msse2'])
601 sseConf = Configure(libraries['sse'])
602 hasSSEHeader = sseConf.CheckCHeader('xmmintrin.h')
603 if env['CROSSCOMPILE']:
604 build_host_supports_sse = True
605 print 'NOTICE: cross compiling for another platform: assuming SSE support'
606 else:
607 build_host_supports_sse = False
608 #if CPU != 'ppc':
609 if CPU not in [ 'ppc' , 'ppc64' ]:
610 if PLATFORM == 'freebsd':
611 machine_info = os.popen ("sysctl -a hw.instruction_sse").read()[:-1]
612 x86_flags = 'no'
613 if "1" in [x for x in machine_info]:
614 build_host_supports_sse = True
615 x86_flags = 'sse'
616 elif PLATFORM != 'darwin':
617 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
618 x86_flags = flag_line.split (": ")[1:][0].split ()
619 else:
620 machine_info = os.popen ("sysctl -a machdep.cpu").read()[:-1]
621 x86_flags = machine_info.split()
622 if "sse" in [x.lower() for x in x86_flags]:
623 build_host_supports_sse = True
624 print 'NOTICE: CPU has SSE support'
625 else:
626 print 'NOTICE: CPU does not have SSE support'
627 features['sse'] = hasSSEHeader and build_host_supports_sse
628 sseConf.Finish()
629 else:
630 features['sse'] = False
632 if env['X11']:
633 # features['x11'], libraries['x11'] = conf.CheckPKG('xt')
634 if type(env['X11']) != types.StringType:
635 if os.path.exists('/usr/X11R6'):
636 env['X11'] = '/usr/X11R6'
637 elif os.path.exists('/usr/lib/X11'):
638 env['X11'] = '/usr/lib/X11'
639 else: env['X11'] = '/usr'
640 x11Env = Environment(
641 CPPPATH = [os.path.join(env['X11'], 'include')],
642 LIBPATH = [os.path.join(env['X11'], 'lib')])
643 x11Conf = Configure(x11Env)
644 features['x11'] = x11Conf.CheckCHeader('X11/Intrinsic.h') \
645 and x11Conf.CheckLib('X11', 'XQueryPointer')
646 libraries['x11'] = x11Conf.Finish()
647 else:
648 features['x11'] = False
651 opts.Save('scache.conf', env)
652 Help(opts.GenerateHelpText(env))
654 # defines and compiler flags
656 env.Append(
657 CPPDEFINES = [ '_REENTRANT', PLATFORM_SYMBOL ],
658 CCFLAGS = [ '-Wno-unknown-pragmas' ],
659 CXXFLAGS = [ '-Wno-deprecated' ]
662 # debugging flags
663 if env['DEBUG']:
664 env.Append(CCFLAGS = '-g')
665 else:
666 env.Append(
667 CCFLAGS = make_opt_flags(env),
668 CPPDEFINES = ['NDEBUG'])
669 if env['STRIP']:
670 env.Append(LINKFLAGS = "-Wl,-s")
672 # platform specific
673 if False: #PLATFORM == 'darwin':
674 # universal binary support
675 if env['UNIVERSAL']:
676 archs = map(lambda x: ['-arch', x], ['ppc', 'i386'])
677 env.Append(
678 CCFLAGS = archs,
679 LINKFLAGS = archs
682 # vectorization
683 if features['altivec']:
684 merge_lib_info(env, libraries['altivec'])
685 elif features['sse']:
686 merge_lib_info(env, libraries['sse'])
687 else:
688 env.AppendUnique(CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 1)])
690 # ======================================================================
691 # Source/common
692 # ======================================================================
694 commonEnv = env.Clone()
695 commonEnv.Append(
696 CPPPATH = ['#Headers/common',
697 '#Headers/plugin_interface',
698 '#Headers/server'],
699 CCFLAGS = ['-fPIC'],
700 CXXFLAGS = ['-fPIC']
703 # strtod
704 conf = Configure(commonEnv)
705 if conf.CheckFunc('strtod'):
706 commonEnv.Append(
707 CPPDEFINES = 'HAVE_STRTOD'
709 commonEnv = conf.Finish()
712 # ======================================================================
713 # back to common
714 # ======================================================================
716 commonSources = Split('''
717 Source/common/SC_AllocPool.cpp
718 Source/common/SC_DirUtils.cpp
719 Source/common/SC_Sem.cpp
720 Source/common/SC_StringBuffer.cpp
721 Source/common/SC_StringParser.cpp
722 Source/common/scsynthsend.cpp
723 Source/common/sc_popen.cpp
724 ''')
725 if PLATFORM == 'darwin':
726 commonSources += [
727 'Source/common/SC_StandAloneInfo_Darwin.cpp'
729 if env['CURL']:
730 commonEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
731 merge_lib_info(commonEnv, libraries['libcurl'])
732 libcommon = commonEnv.Library('build/common', commonSources)
734 #if env['amd64']:
735 #commonSources32 = list(commonSources)
736 #commonEnv32 = commonEnv.Clone()
737 #commonEnv32.Append(
738 #CCFLAGS = ['-m32'],
740 #libcommon32 = commonEnv32.Library('build/common32', commonSources32)
743 # ======================================================================
744 # Source/server
745 # ======================================================================
747 serverEnv = env.Clone()
748 serverEnv.Append(
749 CPPPATH = ['#Headers/common',
750 '#Headers/plugin_interface',
751 '#Headers/server'],
752 CPPDEFINES = [('SC_PLUGIN_DIR', '\\"' + pkg_lib_dir(FINAL_PREFIX, 'plugins') + '\\"'), ('SC_PLUGIN_EXT', '\\"' + PLUGIN_EXT + '\\"')],
753 LIBPATH = 'build')
754 libscsynthEnv = serverEnv.Clone(
755 PKGCONFIG_NAME = 'libscsynth',
756 PKGCONFIG_DESC = 'SuperCollider synthesis server library',
757 PKGCONFIG_PREFIX = FINAL_PREFIX,
758 PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile'],
759 libraries['audioapi'],
760 libraries['rendezvous']),
761 PKGCONFIG_LIBS = ['-lscsynth'],
762 # PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
763 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server']
766 # platform specific
768 # functionality of libdl is included in libc on freebsd
769 if PLATFORM == 'freebsd':
770 serverEnv.Append(LIBS = ['common', 'pthread'])
771 else:
772 serverEnv.Append(LIBS = ['common', 'pthread', 'dl'])
774 if PLATFORM == 'darwin':
775 serverEnv.Append(
776 LINKFLAGS = [
777 '-framework', 'CoreServices'])
778 elif PLATFORM == 'linux':
779 serverEnv.Append(
780 CPPDEFINES = [('SC_PLUGIN_LOAD_SYM', '\\"load\\"')],
781 LINKFLAGS = ['-Wl,-rpath,' + FINAL_PREFIX + '/lib'])
783 elif PLATFORM == 'freebsd':
784 serverEnv.Append(CPPDEFINES = [('SC_PLUGIN_LOAD_SYM', '\\"load\\"')])
786 # required libraries
787 merge_lib_info(
788 serverEnv,
789 libraries['sndfile'], libraries['audioapi'])
791 # optional features
792 if features['rendezvous']:
793 serverEnv.Append(CPPDEFINES = ['USE_RENDEZVOUS'])
794 merge_lib_info(serverEnv, libraries['rendezvous'])
796 if env['CURL']:
797 serverEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
798 merge_lib_info(serverEnv, libraries['libcurl'])
800 libscsynthSources = Split('''
801 Source/server/Rendezvous.cpp
802 Source/server/Samp.cpp
803 Source/server/SC_BufGen.cpp
804 Source/server/SC_Carbon.cpp
805 Source/server/SC_Complex.cpp
806 Source/server/SC_ComPort.cpp
807 Source/server/SC_CoreAudio.cpp
808 Source/server/SC_Errors.cpp
809 Source/server/SC_Graph.cpp
810 Source/server/SC_GraphDef.cpp
811 Source/server/SC_Group.cpp
812 Source/server/SC_Lib_Cintf.cpp
813 Source/server/SC_Lib.cpp
814 Source/server/SC_MiscCmds.cpp
815 Source/server/SC_Node.cpp
816 Source/server/SC_Rate.cpp
817 Source/server/SC_SequencedCommand.cpp
818 Source/server/SC_Str4.cpp
819 Source/server/SC_SyncCondition.cpp
820 Source/server/SC_Unit.cpp
821 Source/server/SC_UnitDef.cpp
822 Source/server/SC_World.cpp
823 ''') + libraries['audioapi']['ADDITIONAL_SOURCES']
825 scsynthSources = ['Source/server/scsynth_main.cpp']
827 libscsynth = serverEnv.SharedLibrary('build/scsynth', libscsynthSources)
828 env.Alias('install-programs', env.Install(lib_dir(INSTALL_PREFIX), [libscsynth]))
830 libscsynthStaticSources = libscsynthSources + make_static_objects(serverEnv, commonSources, "_libscsynthStatic");
831 libscsynthStatic = serverEnv.StaticLibrary('build/scsynth', libscsynthStaticSources)
832 env.Alias('install-programs', env.Install(lib_dir(INSTALL_PREFIX), [libscsynthStatic]))
834 scsynth = serverEnv.Program('build/scsynth', scsynthSources, LIBS = ['scsynth'])
835 env.Alias('install-programs', env.Install(bin_dir(INSTALL_PREFIX), [scsynth]))
837 # ======================================================================
838 # Source/plugins
839 # ======================================================================
841 pluginEnv = env.Clone(
842 SHLIBPREFIX = '',
843 SHLIBSUFFIX = PLUGIN_EXT
845 pluginEnv.Append(
846 CPPPATH = ['#Headers/common',
847 '#Headers/plugin_interface',
848 '#Headers/server'],
849 PKGCONFIG_NAME = 'libscplugin',
850 PKGCONFIG_DESC = 'SuperCollider synthesis plugin headers',
851 PKGCONFIG_PREFIX = FINAL_PREFIX,
852 #PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['scsynth']),
853 #PKGCONFIG_LIBS = [],
854 # PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
855 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server']
857 if PLATFORM == 'darwin':
858 pluginEnv['SHLINKFLAGS'] = '$LINKFLAGS -bundle -flat_namespace -undefined suppress'
860 # we merge this in even if no libsndfile (it'll pass in the NO_LIBSNDFILE flag)
861 merge_lib_info(
862 pluginEnv,
863 libraries['sndfile'])
866 plugins = []
868 def make_plugin_target(name):
869 return os.path.join('build', 'plugins', name)
871 # simple plugins
872 for name in Split('''
873 BinaryOpUGens
874 ChaosUGens
875 DelayUGens
876 DemandUGens
877 DynNoiseUGens
878 FilterUGens
879 GendynUGens
880 IOUGens
881 LFUGens
882 MulAddUGens
883 NoiseUGens
884 OscUGens
885 PanUGens
886 PhysicalModelingUGens
887 TestUGens
888 TriggerUGens
889 UnaryOpUGens
890 GrainUGens
891 ReverbUGens
892 '''):
893 plugins.append(
894 pluginEnv.SharedLibrary(
895 make_plugin_target(name), os.path.join('Source', 'plugins', name + '.cpp')))
897 # complex
898 complexEnv = pluginEnv.Clone()
899 complexSources = Split('Source/plugins/SCComplex.cpp')
900 complexEnv.SharedObject('Source/plugins/SCComplex.o', complexSources)
902 # fft ugens
903 fftEnv = pluginEnv.Clone()
904 fftSources = Split('Source/common/SC_fftlib.cpp Source/plugins/SCComplex.o')
905 merge_lib_info(fftEnv, libraries['fftwf'])
906 plugins.append(
907 fftEnv.SharedLibrary(
908 make_plugin_target('FFT_UGens'),
909 ['Source/plugins/FFTInterfaceTable.cpp',
910 'Source/plugins/FFT_UGens.cpp',
911 'Source/plugins/PV_UGens.cpp',
912 'Source/plugins/PartitionedConvolution.cpp'] + fftSources))
914 plugins.append(
915 fftEnv.SharedLibrary(
916 make_plugin_target('PV_ThirdParty'),
917 ['Source/plugins/Convolution.cpp',
918 'Source/plugins/FFT2InterfaceTable.cpp',
919 'Source/plugins/FeatureDetection.cpp',
920 'Source/plugins/PV_ThirdParty.cpp'] + fftSources))
922 # fft 'unpacking' ugens
923 plugins.append(
924 pluginEnv.SharedLibrary(
925 make_plugin_target('UnpackFFTUGens'), ['Source/plugins/SCComplex.o', 'Source/plugins/UnpackFFTUGens.cpp']))
927 # machine listening ugens
928 # fft ugens
929 mlEnv = pluginEnv.Clone()
930 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')
931 plugins.append(
932 mlEnv.SharedLibrary(
933 make_plugin_target('ML_UGens'), mlSources))
935 # diskio ugens
936 if not env['NO_LIBSNDFILE']: # (libsndfile needed for all of these, so skip if unavailable)
937 diskIOEnv = pluginEnv.Clone(
938 LIBS = ['common', 'm'],
939 LIBPATH = 'build'
941 if PLATFORM == 'darwin':
942 diskIOEnv.Append(
943 LINKFLAGS = '-framework CoreServices'
946 diskIOSources = [
947 diskIOEnv.SharedObject('Source/plugins/SC_SyncCondition', 'Source/server/SC_SyncCondition.cpp'),
948 'Source/plugins/DiskIO_UGens.cpp']
949 merge_lib_info(diskIOEnv, libraries['sndfile'])
950 plugins.append(
951 diskIOEnv.SharedLibrary(
952 make_plugin_target('DiskIO_UGens'), diskIOSources))
954 # ui ugens
955 if PLATFORM == 'darwin':
956 uiUGensEnv = pluginEnv.Clone(
957 LIBS = 'm',
958 LINKFLAGS = '-framework CoreServices -framework Carbon'
960 plugins.append(
961 uiUGensEnv.SharedLibrary(make_plugin_target('MouseUGens'), 'Source/plugins/MouseUGens.cpp'))
962 plugins.append(
963 uiUGensEnv.SharedLibrary(make_plugin_target('KeyboardUGens'), 'Source/plugins/KeyboardUGens.cpp'))
964 elif features['x11']:
965 uiUGensEnv = pluginEnv.Clone()
966 merge_lib_info(uiUGensEnv, libraries['x11'])
967 plugins.append(
968 uiUGensEnv.SharedLibrary(make_plugin_target('MouseUGens'), 'Source/plugins/MouseUGens.cpp'))
969 plugins.append(
970 uiUGensEnv.SharedLibrary(make_plugin_target('KeyboardUGens'), 'Source/plugins/KeyboardUGens.cpp'))
972 env.Alias('install-plugins', env.Install(
973 pkg_lib_dir(INSTALL_PREFIX, 'plugins'), plugins))
975 # ======================================================================
976 # Source/lang
977 # ======================================================================
979 if env['TERMINAL_CLIENT'] == True:
980 env['TERMINAL_CLIENT'] = 1
981 else:
982 env['TERMINAL_CLIENT'] = 0
984 langEnv = env.Clone()
985 langEnv.Append(
986 CPPPATH = ['#Headers/common',
987 '#Headers/plugin_interface',
988 '#Headers/lang',
989 '#Headers/server',
990 '#Source/lang/LangSource/Bison'],
991 CPPDEFINES = [['USE_SC_TERMINAL_CLIENT', env['TERMINAL_CLIENT']]],
992 LIBPATH = 'build'
995 langEnv.Append(LIBS = ['common', 'scsynth'])
996 merge_lib_info(langEnv, libraries['audioapi'])
998 if PLATFORM == 'windows':
999 langEnv.Append(CPPDEFINES = "NO_INTERNAL_SERVER")
1001 # functionality of libdl is included in libc on freebsd
1002 if PLATFORM == 'freebsd':
1003 langEnv.Append(LIBS = ['pthread', 'm'])
1004 else:
1005 langEnv.Append(LIBS = ['pthread', 'dl', 'm'])
1007 if PLATFORM == 'darwin':
1008 langEnv.Append(
1009 LIBS = ['icucore'],
1010 LINKFLAGS = ['-framework', 'CoreServices'],
1011 CPPPATH = ['#include/icu/unicode'])
1012 elif PLATFORM == 'linux':
1013 langEnv.Append(
1014 LINKFLAGS = ['-Wl,-rpath,build', '-Wl,-rpath,' + FINAL_PREFIX + '/lib'])
1017 elif PLATFORM == 'freebsd':
1018 langEnv.Append(
1019 LINKFLAGS = '-Wl,-rpath,build -Wl,-rpath,' + FINAL_PREFIX + '/lib')
1021 if env['CURL']:
1022 langEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
1023 merge_lib_info(langEnv, libraries['libcurl'])
1025 if env['READLINE'] and env['LANG'] and env['GPL3']:
1026 langEnv.Append(CPPDEFINES = ['HAVE_READLINE'])
1027 merge_lib_info(langEnv, libraries['readline'])
1030 libsclangEnv = langEnv.Clone(
1031 PKGCONFIG_NAME = 'libsclang',
1032 PKGCONFIG_DESC = 'SuperCollider synthesis language library',
1033 PKGCONFIG_PREFIX = FINAL_PREFIX,
1034 PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile']) + ['libscsynth'],
1035 PKGCONFIG_LIBS = ['-lsclang'],
1036 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/lang', '-I${includedir}/server']
1038 if PLATFORM == 'linux':
1039 libsclangEnv.Append(
1040 LINKFLAGS = ['-Wl,-soname,libsclang.so'])
1042 # required libraries
1043 merge_lib_info(langEnv, libraries['sndfile'])
1045 libsclangSources = Split('''
1046 Source/lang/LangSource/AdvancingAllocPool.cpp
1047 Source/lang/LangSource/ByteCodeArray.cpp
1048 Source/lang/LangSource/DumpParseNode.cpp
1049 Source/lang/LangSource/GC.cpp
1050 Source/lang/LangSource/InitAlloc.cpp
1051 Source/lang/LangSource/PyrFileUtils.cpp
1052 Source/lang/LangSource/PyrInterpreter3.cpp
1053 Source/lang/LangSource/PyrLexer.cpp
1054 Source/lang/LangSource/PyrMathOps.cpp
1055 Source/lang/LangSource/PyrMathSupport.cpp
1056 Source/lang/LangSource/PyrMessage.cpp
1057 Source/lang/LangSource/PyrObject.cpp
1058 Source/lang/LangSource/PyrParseNode.cpp
1059 Source/lang/LangSource/PyrSignal.cpp
1060 Source/lang/LangSource/PyrSymbolTable.cpp
1061 Source/lang/LangSource/SC_LanguageClient.cpp
1062 Source/lang/LangSource/SC_LibraryConfig.cpp
1063 Source/lang/LangSource/SC_TerminalClient.cpp
1064 Source/lang/LangSource/Samp.cpp
1065 Source/lang/LangSource/SimpleStack.cpp
1066 Source/lang/LangSource/VMGlobals.cpp
1067 Source/lang/LangSource/alloca.cpp
1068 Source/lang/LangSource/dumpByteCodes.cpp
1069 Source/lang/LangSource/Bison/lang11d_tab.cpp
1070 Source/lang/LangPrimSource/SC_Wii.cpp
1071 Source/lang/LangPrimSource/PyrSignalPrim.cpp
1072 Source/lang/LangPrimSource/PyrSched.cpp
1073 Source/lang/LangPrimSource/PyrPrimitive.cpp
1074 Source/lang/LangPrimSource/PyrMathPrim.cpp
1075 Source/lang/LangPrimSource/SC_ComPort.cpp
1076 Source/lang/LangPrimSource/OSCData.cpp
1077 Source/lang/LangPrimSource/PyrArchiver.cpp
1078 Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
1079 Source/lang/LangPrimSource/PyrBitPrim.cpp
1080 Source/lang/LangPrimSource/PyrCharPrim.cpp
1081 Source/lang/LangPrimSource/PyrFilePrim.cpp
1082 Source/lang/LangPrimSource/PyrListPrim.cpp
1083 Source/lang/LangPrimSource/PyrPlatformPrim.cpp
1084 Source/lang/LangPrimSource/PyrSerialPrim.cpp
1085 Source/lang/LangPrimSource/PyrStringPrim.cpp
1086 Source/lang/LangPrimSource/PyrUStringPrim.cpp
1087 Source/lang/LangPrimSource/PyrSymbolPrim.cpp
1088 Source/lang/LangPrimSource/PyrUnixPrim.cpp
1089 Source/common/fftlib.c
1090 ''')
1092 if env['LANG']:
1093 merge_lib_info(langEnv, libraries['libicu'])
1095 # optional features
1096 if features['midiapi']:
1097 merge_lib_info(langEnv, libraries['midiapi'])
1098 if features['midiapi'] == 'CoreMIDI':
1099 libsclangSources += ['Source/lang/LangPrimSource/SC_CoreMIDI.cpp']
1100 else:
1101 libsclangSources += ['Source/lang/LangPrimSource/SC_AlsaMIDI.cpp']
1102 else:
1103 # fallback implementation
1104 libsclangSources += ['Source/lang/LangPrimSource/SC_AlsaMIDI.cpp']
1106 if PLATFORM == 'darwin':
1107 langEnv.Append(
1108 CPPPATH = ['#Source/lang/LangPrimSource/HID_Utilities',
1109 '#Source/lang/LangPrimSource/WiiMote_OSX'],
1110 LINKFLAGS = '-framework Carbon -framework IOKit -framework IOBluetooth'
1112 libsclangSources += Split('''
1113 Source/lang/LangPrimSource/SC_HID.cpp
1114 Source/lang/LangPrimSource/SC_CoreAudioPrim.cpp
1115 Source/lang/LangPrimSource/HID_Utilities/HID_Error_Handler.c
1116 Source/lang/LangPrimSource/HID_Utilities/HID_Name_Lookup.c
1117 Source/lang/LangPrimSource/HID_Utilities/HID_Queue_Utilities.c
1118 Source/lang/LangPrimSource/HID_Utilities/HID_Utilities.c
1119 Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.c
1120 ''')
1122 if env.has_key('amd64') and env['amd64']:
1123 libsclangSources += commonSources
1125 if PLATFORM == 'linux':
1126 # HAVE_LID does the right thing in SC_LID.cpp source
1127 libsclangSources += ['Source/lang/LangPrimSource/SC_LID.cpp']
1128 if features['wii']:
1129 langEnv.Append(CPPDEFINES = 'HAVE_WII')
1130 langEnv.Append(LINKFLAGS = '-lcwiid')
1131 #langEnv.Append(LINKFLAGS = '-lbluetooth')
1132 #langEnv.Append(CPPPATH = '-I/usr/local/include/libcwiimote-0.4.0/libcwiimote/' ) #FIXME: to proper include directory
1133 if features['lid']:
1134 langEnv.Append(CPPDEFINES = 'HAVE_LID')
1136 if PLATFORM == 'darwin':
1137 langEnv.Append(CPPDEFINES = 'HAVE_SPEECH')
1138 libsclangSources += ['Source/lang/LangPrimSource/SC_Speech.cpp']
1140 sclangSources = ['Source/lang/LangSource/cmdLineFuncs.cpp']
1142 if env['LANG']:
1143 libsclang = langEnv.SharedLibrary('build/sclang', libsclangSources)
1144 env.Alias('install-bin', env.Install(lib_dir(INSTALL_PREFIX), [libsclang]))
1145 if PLATFORM == 'darwin':
1146 sclangLibs = ['scsynth', 'sclang']
1147 else:
1148 sclangLibs = ['sclang']
1149 sclang = langEnv.Program('build/sclang', sclangSources, LIBS=sclangLibs)
1150 env.Alias('install-programs', env.Install(bin_dir(INSTALL_PREFIX), [sclang]))
1152 # ======================================================================
1153 # doc/doxygen
1154 # ======================================================================
1156 # doxygen = env.Command(None, 'doc/doxygen/html/index.html', 'doxygen doc/doxygen/doxygen.cfg')
1157 # env.Alias('doxygen', doxygen)
1159 # ======================================================================
1160 # installation
1161 # ======================================================================
1163 installEnv = Environment(
1164 ALL = ['install-bin', 'install-data'],
1165 BIN = ['install-plugins', 'install-programs'],
1166 DATA = ['install-doc']
1168 if env['LANG']:
1169 installEnv.Append(DATA = ['install-library'])
1171 if is_installing():
1172 # class library
1173 env.Alias('install-library', install_dir(
1174 env, 'build/SCClassLibrary',
1175 pkg_data_dir(INSTALL_PREFIX),
1176 SC_FILE_RE, 1))
1177 # help files
1178 env.Alias('install-library', install_dir(
1179 env, 'build/Help',
1180 pkg_data_dir(INSTALL_PREFIX),
1181 HELP_FILE_RE, 1))
1182 # example files
1183 env.Alias('install-library', install_dir(
1184 env, 'build/examples',
1185 pkg_data_dir(INSTALL_PREFIX),
1186 HELP_FILE_RE, 1))
1187 # scel
1188 if env['SCEL']:
1189 env.Alias('install-library', install_dir(
1190 env, '../editors/scel/sc',
1191 pkg_extension_dir(INSTALL_PREFIX, 'scide_scel'),
1192 SC_FILE_RE, 3))
1193 # scvim
1194 # if env['SCVIM']:
1195 # env.Alias('install-library', install_dir(
1196 # env, 'editors/scvim/scclasses',
1197 # pkg_extension_dir(INSTALL_PREFIX, 'scvim'),
1198 # SC_FILE_RE, 3))
1199 # # scvim helpfiles
1200 # if env['SCVIM']:
1201 # env.Alias('install-library', install_dir(
1202 # env, 'editors/scvim/cache/doc',
1203 # pkg_data_dir(INSTALL_PREFIX, 'scvim-help'),
1204 # HELP_FILE_RE, 4))
1206 #scvim : unhtml help files
1207 #if env['SCVIM']:
1208 #os.execvpe("editors/scvim/bin/scvim_make_help", [ "-c", "-s", "build/Help"],"SCVIM=editors/scvim/")
1209 #os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
1211 #if env['SCVIM']:
1212 #vimenv = env.Clone()
1213 #SConscript('editors/test/SConstruct', exports=['vimenv'])
1215 #if env['SCVIM']:
1216 #print 'installing scvim'
1217 #vimenv = env.Clone()
1218 ##env.Append(FROMTOP=True)
1219 #SConscript('editors/scvim/SConstruct', exports=['vimenv'])
1221 #### scvim and sced scripts need to be called independently, until someone fixes setting the proper variables from the parent script
1223 if env['SCVIM']:
1224 print '----------------------------------------------------'
1225 # SConscript('../editors/scvim/SConstruct', exports=['env'])
1226 print 'To install SCVIM, please use scons in the directory ../editors/scvim/'
1228 if env['SCED']:
1229 # SConscript('../editors/sced/SConstruct', 'env')
1230 print '----------------------------------------------------'
1231 print 'To install SCED, please use the scons in the directory ../editors/sced/'
1233 # scel
1234 if env['SCEL']:
1235 env.Command('../editors/scel/el/sclang-vars.el', '../editors/scel/el/sclang-vars.el.in',
1236 'sed \'s,@PKG_DATA_DIR@,%s,g\' < $SOURCE > $TARGET' %
1237 pkg_data_dir(FINAL_PREFIX))
1238 el_files = glob.glob('../editors/scel/el/*.el') + ['../editors/scel/el/sclang-vars.el']
1239 elc_files = map(lambda f: os.path.splitext(f)[0] + '.elc', el_files)
1240 elisp_dir = os.path.join(INSTALL_PREFIX, 'share', 'emacs', 'site-lisp')
1241 env.Command(elc_files, el_files,
1242 'emacs -batch --eval "(add-to-list \'load-path (expand-file-name \\"../editors/scel/el/\\"))" -f batch-byte-compile $SOURCES')
1243 env.Alias('install-elisp', env.Install(elisp_dir, el_files + elc_files))
1244 installEnv.Append(DATA = 'install-elisp')
1246 # example library configuration file
1247 env.Command('../linux/examples/sclang.cfg', '../linux/examples/sclang.cfg.in',
1248 'sed \'s,@PKG_DATA_DIR@,%s,g\' < $SOURCE > $TARGET' %
1249 pkg_data_dir(FINAL_PREFIX))
1251 # headers
1252 if env['DEVELOPMENT']:
1253 header_dirs = Split('common plugin_interface server lang')
1254 if PLATFORM == 'darwin':
1255 header_dirs += 'app'
1256 for d in header_dirs:
1257 env.Alias('install-dev', install_dir(
1258 env, os.path.join('Headers', d),
1259 pkg_include_dir(INSTALL_PREFIX),
1260 re.compile('.*\.h(h|pp)?'), 1)
1262 # other useful headers
1263 env.Alias('install-dev',
1264 env.Install(pkg_include_dir(INSTALL_PREFIX, 'plugin_interface'), 'Source/plugins/FFT_UGens.h'))
1265 pkgconfig_files = [
1266 libscsynthEnv.Command('../linux/libscsynth.pc', 'SConstruct',
1267 build_pkgconfig_file),
1268 libsclangEnv.Command('../linux/libsclang.pc', 'SConstruct',
1269 build_pkgconfig_file),
1270 pluginEnv.Command('../linux/libscplugin.pc', 'SConstruct',
1271 build_pkgconfig_file)]
1272 pkgconfig_dir = os.path.join(lib_dir(INSTALL_PREFIX), 'pkgconfig')
1273 env.Alias('install-dev', env.Install(pkgconfig_dir, pkgconfig_files))
1274 installEnv.Append(ALL = 'install-dev')
1276 # documentation
1277 if is_installing():
1278 # TODO: build html documentation?
1279 doc_dir = pkg_doc_dir(INSTALL_PREFIX)
1280 env.Alias('install-doc',
1281 install_dir(env, 'doc', doc_dir, ANY_FILE_RE, 0) +
1282 install_dir(env, 'build/examples', doc_dir, ANY_FILE_RE, 1) +
1283 install_dir(env, 'build/TestingAndToDo', doc_dir, ANY_FILE_RE, 1))
1285 env.Alias('install-bin', installEnv['BIN'])
1286 env.Alias('install-data', installEnv['DATA'])
1287 env.Alias('install', installEnv['ALL'])
1289 # ======================================================================
1290 # distribution
1291 # ======================================================================
1293 DIST_FILES = Split('''
1294 ../COPYING
1295 SConstruct
1296 ../mac/clean-compile.sh
1297 ../mac/compile.sh
1298 distro
1299 ../linux/examples/onetwoonetwo.sc
1300 ../linux/examples/sclang.cfg.in
1301 ../linux/examples/sclang.sc
1302 ../editors/scel/README
1303 ../editors/scvim/README
1304 ../editors/sced/README
1305 scsynthlib_exp
1306 ''')
1308 DIST_SPECS = [
1309 ('build', HELP_FILE_RE),
1310 ('Headers', SRC_FILE_RE),
1311 ('../editors/scel/sc', SC_FILE_RE),
1312 ('../editors/scel/el', re.compile('.*\.el$')),
1313 ('../editors/scvim/scclasses', SC_FILE_RE),
1314 ('Source', SRC_FILE_RE)
1317 def dist_paths():
1318 paths = DIST_FILES[:]
1319 specs = DIST_SPECS[:]
1320 while specs:
1321 base, re = specs.pop()
1322 if not re: re = ANY_FILE_RE
1323 for root, dirs, files in os.walk(base):
1324 if 'CVS' in dirs: dirs.remove('CVS')
1325 if '.svn' in dirs: dirs.remove('.svn')
1326 for path in dirs[:]:
1327 if re.match(path):
1328 specs.append((os.path.join(root, path), re))
1329 dirs.remove(path)
1330 for path in files:
1331 if re.match(path):
1332 paths.append(os.path.join(root, path))
1333 paths.sort()
1334 return paths
1336 def build_tar(env, target, source):
1337 paths = dist_paths()
1338 tarfile_name = str(target[0])
1339 tar_name = os.path.splitext(os.path.basename(tarfile_name))[0]
1340 tar = tarfile.open(tarfile_name, "w:bz2")
1341 for path in paths:
1342 tar.add(path, os.path.join(tar_name, path))
1343 tar.close()
1345 if 'dist' in COMMAND_LINE_TARGETS:
1346 env.Alias('dist', env['TARBALL'])
1347 env.Command(env['TARBALL'], 'SConstruct', build_tar)
1349 # ======================================================================
1350 # cleanup
1351 # ======================================================================
1353 if 'scrub' in COMMAND_LINE_TARGETS:
1354 env.Clean('scrub', Split('config.log scache.conf .sconf_temp'))
1356 # ======================================================================
1357 # configuration summary
1358 # ======================================================================
1360 def yesorno(p):
1361 if p: return 'yes'
1362 else: return 'no'
1364 print '------------------------------------------------------------------------'
1365 print ' ALTIVEC: %s' % yesorno(features['altivec'])
1366 print ' AUDIOAPI: %s' % features['audioapi']
1367 print ' MIDIAPI: %s' % features['midiapi']
1368 print ' DEBUG: %s' % yesorno(env['DEBUG'])
1369 # print ' DESTDIR: %s' % env['DESTDIR']
1370 print ' DEVELOPMENT: %s' % yesorno(env['DEVELOPMENT'])
1371 print ' LANG: %s' % yesorno(env['LANG'])
1372 print ' LID: %s' % yesorno(features['lid'])
1373 print ' NO_LIBSNDFILE: %s' % yesorno(env['NO_LIBSNDFILE'])
1374 print ' WII: %s' % yesorno(features['wii'])
1375 print ' PREFIX: %s' % env['PREFIX']
1376 print ' RENDEZVOUS: %s' % yesorno(features['rendezvous'])
1377 print ' SCEL: %s' % yesorno(env['SCEL'])
1378 print ' SCVIM: %s' % yesorno(env['SCVIM'])
1379 print ' SCED: %s' % yesorno(env['SCED'])
1380 print ' SSE: %s' % yesorno(features['sse'])
1381 print ' STRIP: %s' % yesorno(env['STRIP'])
1382 print ' CROSSCOMPILE: %s' % yesorno(env['CROSSCOMPILE'])
1383 print ' TERMINAL_CLIENT: %s' % yesorno(env['TERMINAL_CLIENT'])
1384 print ' X11: %s' % yesorno(features['x11'])
1385 print ' GPL3: %s' % yesorno(env['GPL3'])
1386 print '------------------------------------------------------------------------'
1388 # ======================================================================
1389 # EOF