Fix example, thanks Juan Gabriel Alzate Romero
[supercollider.git] / SConstruct
blobe36aede8cb954763109f37caa0bbd8c3980e4701
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 #print os.uname()
55 ANY_FILE_RE = re.compile('.*')
56 HELP_FILE_RE = re.compile('.*\.(rtf(d)?|scd|html)$')
57 SC_FILE_RE = re.compile('.*\.sc$')
58 SRC_FILE_RE = re.compile('.*\.(c(pp)|h)$')
60 if PLATFORM == 'darwin':
61 PLATFORM_SYMBOL = 'SC_DARWIN'
62 PLUGIN_EXT = '.scx'
63 DEFAULT_AUDIO_API = 'coreaudio'
64 DEFAULT_PREFIX = '/usr/local'
65 elif PLATFORM == 'freebsd':
66 PLATFORM_SYMBOL = 'SC_FREEBSD'
67 PLUGIN_EXT = '.so'
68 DEFAULT_AUDIO_API = 'jack'
69 DEFAULT_PREFIX = '/usr/local'
70 elif PLATFORM == 'linux':
71 PLATFORM_SYMBOL = 'SC_LINUX'
72 PLUGIN_EXT = '.so'
73 DEFAULT_AUDIO_API = 'jack'
74 DEFAULT_PREFIX = '/usr/local'
75 elif PLATFORM == 'windows':
76 PLATFORM_SYMBOL = 'SC_WIN32'
77 PLUGIN_EXT = '.scx'
78 DEFAULT_AUDIO_API = 'portaudio'
79 DEFAULT_PREFIX = '/'
80 else:
81 print 'Unknown platform: %s' % PLATFORM
82 Exit(1)
84 if CPU in [ 'ppc' , 'ppc64' ]:
85 DEFAULT_OPT_ARCH = '7450'
86 elif CPU in [ 'i586', 'i686' ]:
87 # FIXME: better detection
88 DEFAULT_OPT_ARCH = CPU
89 else:
90 DEFAULT_OPT_ARCH = None
92 if PLATFORM != 'windows':
93 subprocess.call(['sh', 'setMainVersion.sh'])
96 # ======================================================================
97 # util
98 # ======================================================================
101 def make_os_env(*keys):
102 env = os.environ
103 res = {}
104 for key in keys:
105 if env.has_key(key):
106 res[key] = env[key]
107 return res
109 def CheckPKGConfig(context, version):
110 context.Message( 'Checking for pkg-config... ' )
111 ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
112 context.Result( ret )
113 return ret
115 def CheckPKG(context, name):
116 context.Message('Checking for %s... ' % name)
117 ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
118 res = None
119 if ret:
120 res = Environment(ENV = make_os_env('PATH', 'PKG_CONFIG_PATH'))
121 res.ParseConfig('pkg-config --cflags --libs \'%s\'' % name)
122 res['PKGCONFIG'] = name
123 context.Result(ret)
124 return (ret, res)
126 def get_new_pkg_env():
127 return Environment(ENV = make_os_env('PATH', 'PKG_CONFIG_PATH'))
129 def merge_lib_info(env, *others):
130 for other in others:
131 env.AppendUnique(CCFLAGS = other.get('CCFLAGS', []))
132 env.AppendUnique(CPPDEFINES = other.get('CPPDEFINES', []))
133 env.AppendUnique(CPPPATH = other.get('CPPPATH', []))
134 env.AppendUnique(CXXFLAGS = other.get('CXXFLAGS', []))
135 env.AppendUnique(LIBS = other.get('LIBS', []))
136 env.AppendUnique(LIBPATH = other.get('LIBPATH', []))
137 env['LINKFLAGS'] = env['LINKFLAGS'] + other.get('LINKFLAGS', "")
139 def make_pkgconfig_requires(*envs):
140 res = []
141 for env in envs:
142 if env and env.has_key('PKGCONFIG'):
143 res.append(env['PKGCONFIG'])
144 return res
146 def build_pkgconfig_file(target, source, env):
147 def write_field(file, name, prefix, separator=None):
148 if env.has_key(name):
149 if separator:
150 content = separator.join(env[name])
151 else:
152 content = env[name]
153 file.write('%s%s\n' % (prefix, content))
154 out = file(str(target[0]), 'w')
155 out.writelines([
156 'prefix=%s\n' % env['PREFIX'],
157 'exec_prefix=${prefix}\n',
158 'libdir=${exec_prefix}/lib\n',
159 'includedir=${prefix}/include/%s\n' % env['PACKAGE'],
160 '\n'])
161 write_field(out, 'PKGCONFIG_NAME', 'Name: ')
162 write_field(out, 'PKGCONFIG_DESC', 'Description: ')
163 write_field(out, 'URL', 'URL: ')
164 write_field(out, 'VERSION', 'Version: ')
165 write_field(out, 'PKGCONFIG_REQUIRES', 'Requires: ', ', ')
166 write_field(out, 'PKGCONFIG_REQUIRES_PRIVATE', 'Requires.private: ', ', ')
167 write_field(out, 'PKGCONFIG_LIBS', 'Libs: -L${libdir} ', ' ')
168 write_field(out, 'PKGCONFIG_LIBS_PRIVATE', 'Libs.private: ', ' ')
169 write_field(out, 'PKGCONFIG_CFLAGS', 'Cflags: ', ' ')
170 out.close()
172 def flatten_dir(dir):
173 res = []
174 for root, dirs, files in os.walk(dir):
175 if 'CVS' in dirs: dirs.remove('CVS')
176 if '.svn' in dirs: dirs.remove('.svn')
177 for f in files:
178 res.append(os.path.join(root, f))
179 return res
181 def install_dir(env, src_dir, dst_dir, filter_re, strip_levels=0):
182 nodes = []
183 for root, dirs, files in os.walk(src_dir):
184 src_paths = []
185 dst_paths = []
186 if 'CVS' in dirs: dirs.remove('CVS')
187 if '.svn' in dirs: dirs.remove('.svn')
188 for d in dirs[:]:
189 if filter_re.match(d):
190 src_paths += flatten_dir(os.path.join(root, d))
191 dirs.remove(d)
192 for f in files:
193 if filter_re.match(f):
194 src_paths.append(os.path.join(root, f))
195 dst_paths += map(
196 lambda f:
197 os.path.join(
198 dst_dir,
199 *f.split(os.path.sep)[strip_levels:]),
200 src_paths)
201 nodes += env.InstallAs(dst_paths, src_paths)
202 return nodes
204 def is_installing():
205 pat = re.compile('^install.*$')
206 for x in COMMAND_LINE_TARGETS:
207 if pat.match(x): return True
208 return False
210 def is_home_directory(dir):
211 return os.path.normpath(dir) == os.path.normpath(os.environ.get('HOME', '/'))
213 def bin_dir(prefix):
214 return os.path.join(prefix, 'bin')
215 def lib_dir(prefix):
216 return os.path.join(prefix, 'lib')
218 def pkg_data_dir(prefix, *args):
219 if PLATFORM == 'darwin':
220 base = '/Library/Application Support'
221 if is_home_directory(prefix):
222 base = os.path.join(prefix, base)
223 else:
224 base = os.path.join(prefix, 'share')
225 return os.path.join(base, PACKAGE, *args)
226 def pkg_doc_dir(prefix, *args):
227 if PLATFORM == 'darwin':
228 base = '/Library/Documentation'
229 if is_home_directory(prefix):
230 base = os.path.join(prefix, base)
231 else:
232 base = os.path.join(prefix, 'share', 'doc')
233 return os.path.join(base, PACKAGE, *args)
234 def pkg_include_dir(prefix, *args):
235 return os.path.join(prefix, 'include', PACKAGE, *args)
236 def pkg_lib_dir(prefix, *args):
237 return os.path.join(lib_dir(prefix), PACKAGE, *args)
239 def pkg_classlib_dir(prefix, *args):
240 return pkg_data_dir(prefix, 'SCClassLibrary', *args)
241 def pkg_extension_dir(prefix, *args):
242 return pkg_data_dir(prefix, 'Extensions', *args)
244 def make_opt_flags(env):
245 flags = [
246 "-O3",
247 ## "-fomit-frame-pointer", # can behave strangely for sclang
248 "-ffast-math",
249 "-fstrength-reduce"
251 arch = env.get('OPT_ARCH')
252 if arch:
253 if CPU in [ 'ppc' , 'ppc64' ]:
254 flags.extend([ "-mcpu=%s" % (arch,) ])
255 else:
256 flags.extend([ "-march=%s" % (arch,) ])
257 if CPU in [ 'ppc' , 'ppc64' ]:
258 flags.extend([ "-fsigned-char", "-mhard-float",
259 ## "-mpowerpc-gpopt", # crashes sqrt
260 "-mpowerpc-gfxopt"
262 return flags
264 def make_static_object(env, source, postfix="_a"):
265 obj = os.path.splitext(source)[0] + postfix
266 return env.StaticObject(obj, source)
268 def make_static_objects(env, sources, postfix="_a"):
269 return map(lambda x: make_static_object(env, x, postfix), sources)
271 # ======================================================================
272 # command line options
273 # ======================================================================
275 opts = Options('scache.conf', ARGUMENTS)
276 opts.AddOptions(
277 BoolOption('ALSA',
278 'Build with ALSA sequencer support', 1),
279 BoolOption('ALTIVEC',
280 'Build with Altivec support', 1),
281 ('OPT_ARCH', 'Architecture to optimize for', DEFAULT_OPT_ARCH),
282 EnumOption('AUDIOAPI',
283 'Build with specified audio API support',
284 DEFAULT_AUDIO_API, ('jack', 'coreaudio', 'portaudio')),
285 ('CC', 'C compiler executable'),
286 ('CCFLAGS', 'C compiler flags'),
287 ('CXX', 'C++ compiler executable'),
288 ('CXXFLAGS', 'C++ compiler flags'),
289 BoolOption('DEBUG',
290 'Build with debugging information', 0),
291 PathOption('DESTDIR',
292 'Intermediate installation prefix for packaging', '/'),
293 BoolOption('DEVELOPMENT',
294 'Build and install the development files', 0),
295 BoolOption('FFTW',
296 'Use the FFTW libraries', PLATFORM != 'darwin'),
297 BoolOption('JACK_DLL',
298 'Build with delay locked loop support', 0),
299 BoolOption('JACK_DEBUG_DLL',
300 'Build with delay locked loop debugging support', 0),
301 BoolOption('LANG',
302 'Build the language application', 1),
303 BoolOption('LID',
304 'Build with Linux Input Device support [linux]', PLATFORM == 'linux'),
305 BoolOption('WII',
306 'Build with Linux WII support [linux]', PLATFORM == 'linux'),
307 PathOption('PREFIX',
308 'Installation prefix', DEFAULT_PREFIX),
309 BoolOption('RENDEZVOUS',
310 'Enable Zeroconf/Rendezvous.', 1),
311 BoolOption('SCEL',
312 'Enable the SCEL user interface; NOTE for the HTML help system you need emacs-w3m', 1),
313 BoolOption('SCVIM',
314 'Enable the SCVIM user interface; NOTE see the README in /editors/scvim for setting variables', 1),
315 BoolOption('SCED',
316 'Enable the SCED (based on gedit) user interface', 0),
317 BoolOption('SSE',
318 'Build with SSE support', 1),
319 BoolOption('STRIP',
320 'Strip symbols from binaries', 0),
321 BoolOption('CROSSCOMPILE',
322 'Crosscompile for another platform (does not do SSE support check)', 0),
323 BoolOption('TERMINAL_CLIENT',
324 'Build with terminal client interface', 1),
325 BoolOption('CURL',
326 'Build with libcurl - allows server to load files from remote servers by URL', 0),
327 PackageOption('X11',
328 'Build with X11 support', 1)
331 if PLATFORM == 'darwin':
332 opts.AddOptions(
333 BoolOption('UNIVERSAL',
334 'Build universal binaries (see UNIVERSAL_ARCHS)', 1),
335 BoolOption('INTERNAL_LIBSNDFILE',
336 'Use internal version of libsndfile', 1),
337 # ListOption('UNIVERSAL_ARCHS',
338 # 'Architectures to build for',
339 # 'all', ['ppc', 'i386'])
342 # ======================================================================
343 # basic environment
344 # ======================================================================
346 env = Environment(options = opts,
347 ENV = make_os_env('PATH', 'PKG_CONFIG_PATH'),
348 PACKAGE = PACKAGE,
349 VERSION = VERSION,
350 URL = 'http://supercollider.sourceforge.net',
351 TARBALL = PACKAGE + VERSION + '.tbz2')
352 env.Append(PATH = ['/usr/local/bin', '/usr/bin', '/bin'])
354 # checks for DISTCC and CCACHE as used in modern linux-distros:
356 if os.path.exists('/usr/lib/distcc/bin'):
357 os.environ['PATH'] = '/usr/lib/distcc/bin:' + os.environ['PATH']
358 #env['ENV']['DISTCC_HOSTS'] = os.environ['DISTCC_HOSTS']
359 env['ENV']['DISTCC_HOSTS'] = os.environ.get('DISTCC_HOSTS')
361 if os.path.exists('/usr/lib/ccache/bin'):
362 os.environ['PATH'] = '/usr/lib/ccache/bin:' + os.environ['PATH']
363 #env['ENV']['CCACHE_DIR'] = os.environ['CCACHE_DIR']
364 env['ENV']['CCACHE_DIR'] = os.environ.get('CCACHE_DIR')
366 env['ENV']['PATH'] = os.environ['PATH']
367 if PLATFORM == 'windows':
368 env['ENV']['HOME'] = os.environ['HOMEPATH']
369 else:
370 env['ENV']['HOME'] = os.environ['HOME']
372 if PLATFORM == 'linux':
373 env['amd64'] = platform.uname()[2].find( 'amd64' ) > 0
374 if env['amd64']:
375 print "we are on amd64 linux"
378 # ======================================================================
379 # installation directories
380 # ======================================================================
382 FINAL_PREFIX = '$PREFIX'
383 INSTALL_PREFIX = os.path.join('$DESTDIR', '$PREFIX')
385 if env['PREFIX'] == '/usr':
386 FINAL_CONFIG_PREFIX = '/etc'
387 else:
388 FINAL_CONFIG_PREFIX = os.path.join(env['PREFIX'], 'etc')
389 CONFIG_PREFIX = '$DESTDIR' + FINAL_CONFIG_PREFIX
391 env.Append(
392 CPPDEFINES = [('SC_DATA_DIR', '\\"' + pkg_data_dir(FINAL_PREFIX) + '\\"')])
394 # ======================================================================
395 # configuration
396 # ======================================================================
398 def make_conf(env):
399 return Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
400 'CheckPKG' : CheckPKG })
402 def isDefaultBuild():
403 return not env.GetOption('clean') and not 'debian' in COMMAND_LINE_TARGETS
405 conf = make_conf(env)
407 # libraries
408 libraries = { }
409 features = { }
411 if isDefaultBuild():
412 if not conf.CheckPKGConfig('0'):
413 print 'pkg-config not found.'
414 Exit(1)
416 # sndfile
417 if PLATFORM == 'darwin' and env['INTERNAL_LIBSNDFILE']:
418 libraries['sndfile'] = Environment(LINKFLAGS = ['libsndfile/libsndfile.a'],
419 CPPPATH = ['#libsndfile'])
420 else:
421 success, libraries['sndfile'] = conf.CheckPKG('sndfile >= 1.0.16')
422 if not success: Exit(1)
423 succes2, libraries['sndfile18'] = conf.CheckPKG('sndfile >= 1.0.18')
424 if succes2:
425 libraries['sndfile'].Append(CPPDEFINES = ['LIBSNDFILE_1018'])
427 # libcurl
428 success, libraries['libcurl'] = conf.CheckPKG('libcurl >= 7')
429 if env['CURL'] and not success:
430 print 'CURL option was set, but libcurl not found.'
431 Exit(1)
433 # FFTW
434 success, libraries['fftwf'] = conf.CheckPKG('fftw3f')
435 if env['FFTW']:
436 if success:
437 libraries['fftwf'].Append(CPPDEFINES = ['SC_FFT_FFTW'])
438 elif PLATFORM == 'darwin':
439 libraries['fftwf'] = Environment()
440 else:
441 Exit(1)
442 else:
443 libraries['fftwf'] = Environment()
444 if PLATFORM == 'darwin':
445 # needed for vector multiplication
446 libraries['fftwf'].Append(LINKFLAGS = '-framework vecLib')
447 else:
448 libraries['sndfile'] = get_new_pkg_env()
449 libraries['fftwf'] = get_new_pkg_env()
450 libraries['libcurl'] = get_new_pkg_env()
452 # audio api
453 if env['AUDIOAPI'] == 'jack':
454 features['audioapi'] = 'Jack'
455 success, libraries['audioapi'] = conf.CheckPKG('jack >= 0.100')
456 if success:
457 libraries['audioapi'].Append(
458 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_JACK')],
459 ADDITIONAL_SOURCES = ['Source/server/SC_Jack.cpp']
461 else:
462 success, libraries['audioapi'] = conf.CheckPKG('jack')
463 if isDefaultBuild():
464 if not success: Exit(1)
465 else:
466 libraries['audioapi'] = get_new_pkg_env()
467 libraries['audioapi'].Append(
468 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_JACK'),
469 'SC_USE_JACK_CLIENT_NEW'],
470 ADDITIONAL_SOURCES = ['Source/server/SC_Jack.cpp']
472 libraries['audioapi'].Append(
473 CPPDEFINES = [('SC_JACK_USE_DLL', env['JACK_DLL']),
474 ('SC_JACK_DEBUG_DLL', env['JACK_DEBUG_DLL'])]
476 elif env['AUDIOAPI'] == 'coreaudio':
477 features['audioapi'] = 'CoreAudio'
478 libraries['audioapi'] = Environment(
479 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_COREAUDIO')],
480 LINKFLAGS = '-framework CoreAudio',
481 ADDITIONAL_SOURCES = []
483 elif env['AUDIOAPI'] == 'portaudio':
484 features['audioapi'] = 'Portaudio'
485 libraries['audioapi'] = Environment(
486 CPPDEFINES = [('SC_AUDIO_API', 'SC_AUDIO_API_PORTAUDIO')],
487 LIBS = ['portaudio'],
488 ADDITIONAL_SOURCES = []
491 # rendezvous
492 if env['RENDEZVOUS']:
493 features['rendezvous'], libraries['rendezvous'] = conf.CheckPKG('avahi-client')
494 if features['rendezvous']:
495 libraries['rendezvous'].Append(CPPDEFINES = ['HAVE_AVAHI'])
496 else:
497 features['rendezvous'], libraries['rendezvous'] = conf.CheckPKG('howl')
498 if features['rendezvous']:
499 libraries['rendezvous'].Append(CPPDEFINES = ['HAVE_HOWL'])
500 else:
501 features['rendezvous'] = False
502 libraries['rendezvous'] = False
504 # alsa
505 if env['ALSA']:
506 features['alsa'], libraries['alsa'] = conf.CheckPKG('alsa')
507 else:
508 features['alsa'] = False
510 if features['alsa']:
511 libraries['alsa'].Append(CPPDEFINES = ['HAVE_ALSA'])
513 # midi
514 if conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h'):
515 features['midiapi'] = 'CoreMIDI'
516 libraries['midiapi'] = Environment(
517 LINKFLAGS = '-framework CoreMIDI',
519 elif features['alsa']:
520 features['midiapi'] = 'ALSA'
521 libraries['midiapi'] = libraries['alsa'].Clone()
522 else:
523 features['midiapi'] = None
525 # lid
526 features['lid'] = env['LID'] and conf.CheckCHeader('linux/input.h')
528 # wii on linux
529 if PLATFORM == 'linux':
530 features['wii'] = env['WII'] and conf.CheckCHeader('cwiid.h')
531 else:
532 features['wii'] = env['WII']
534 # only _one_ Configure context can be alive at a time
535 env = conf.Finish()
537 # altivec
538 if env['ALTIVEC']:
539 if PLATFORM == 'darwin':
540 altivec_flags = [ '-faltivec' ]
541 else:
542 altivec_flags = [ '-maltivec', '-mabi=altivec' ]
543 libraries['altivec'] = env.Clone()
544 libraries['altivec'].Append(
545 CCFLAGS = altivec_flags,
546 CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 16)])
547 altiConf = Configure(libraries['altivec'])
548 features['altivec'] = altiConf.CheckCHeader('altivec.h')
549 altiConf.Finish()
550 else:
551 features['altivec'] = False
553 # sse
554 if env['SSE']:
555 libraries['sse'] = env.Clone()
556 libraries['sse'].Append(
557 CCFLAGS = ['-msse', '-mfpmath=sse'],
558 CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 16)])
559 sseConf = Configure(libraries['sse'])
560 hasSSEHeader = sseConf.CheckCHeader('xmmintrin.h')
561 if env['CROSSCOMPILE']:
562 build_host_supports_sse = True
563 print 'NOTICE: cross compiling for another platform: assuming SSE support'
564 else:
565 build_host_supports_sse = False
566 #if CPU != 'ppc':
567 if CPU not in [ 'ppc' , 'ppc64' ]:
568 if PLATFORM == 'freebsd':
569 machine_info = os.popen ("sysctl -a hw.instruction_sse").read()[:-1]
570 x86_flags = 'no'
571 if "1" in [x for x in machine_info]:
572 build_host_supports_sse = True
573 x86_flags = 'sse'
574 elif PLATFORM != 'darwin':
575 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
576 x86_flags = flag_line.split (": ")[1:][0].split ()
577 else:
578 machine_info = os.popen ("sysctl -a machdep.cpu").read()[:-1]
579 x86_flags = machine_info.split()
580 if "sse" in [x.lower() for x in x86_flags]:
581 build_host_supports_sse = True
582 print 'NOTICE: CPU has SSE support'
583 else:
584 print 'NOTICE: CPU does not have SSE support'
585 features['sse'] = hasSSEHeader and build_host_supports_sse
586 sseConf.Finish()
587 else:
588 features['sse'] = False
590 if env['X11']:
591 if type(env['X11']) != types.StringType:
592 if os.path.exists('/usr/X11R6'):
593 env['X11'] = '/usr/X11R6'
594 else: env['X11'] = '/usr'
595 x11Env = Environment(
596 CPPPATH = [os.path.join(env['X11'], 'include')],
597 LIBPATH = [os.path.join(env['X11'], 'lib')])
598 x11Conf = Configure(x11Env)
599 features['x11'] = x11Conf.CheckCHeader('X11/Intrinsic.h') \
600 and x11Conf.CheckLib('X11', 'XQueryPointer')
601 libraries['x11'] = x11Conf.Finish()
602 else:
603 features['x11'] = False
607 opts.Save('scache.conf', env)
608 Help(opts.GenerateHelpText(env))
610 # defines and compiler flags
612 env.Append(
613 CPPDEFINES = [ '_REENTRANT', PLATFORM_SYMBOL ],
614 CCFLAGS = [ '-Wno-unknown-pragmas' ],
615 CXXFLAGS = [ '-Wno-deprecated' ]
618 # debugging flags
619 if env['DEBUG']:
620 env.Append(CCFLAGS = '-g')
621 else:
622 env.Append(
623 CCFLAGS = make_opt_flags(env),
624 CPPDEFINES = ['NDEBUG'])
625 if env['STRIP']:
626 env.Append(LINKFLAGS = "-Wl,-s")
628 # platform specific
629 if False: #PLATFORM == 'darwin':
630 # universal binary support
631 if env['UNIVERSAL']:
632 archs = map(lambda x: ['-arch', x], ['ppc', 'i386'])
633 env.Append(
634 CCFLAGS = archs,
635 LINKFLAGS = archs
638 # vectorization
639 if features['altivec']:
640 merge_lib_info(env, libraries['altivec'])
641 elif features['sse']:
642 merge_lib_info(env, libraries['sse'])
643 else:
644 env.AppendUnique(CPPDEFINES = [('SC_MEMORY_ALIGNMENT', 1)])
646 # ======================================================================
647 # Source/common
648 # ======================================================================
650 commonEnv = env.Clone()
651 commonEnv.Append(
652 CPPPATH = ['#Headers/common',
653 '#Headers/plugin_interface',
654 '#Headers/server'],
655 CCFLAGS = ['-fPIC'],
656 CXXFLAGS = ['-fPIC']
659 # strtod
660 conf = Configure(commonEnv)
661 if conf.CheckFunc('strtod'):
662 commonEnv.Append(
663 CPPDEFINES = 'HAVE_STRTOD'
665 commonEnv = conf.Finish()
667 # ======================================================================
668 # Source/common dtoa.c (needs other flags)
669 # ======================================================================
671 dtoaEnv = commonEnv.Clone()
673 dtoaCCFDict = dtoaEnv.Dictionary('CCFLAGS')
674 if not env['DEBUG']:
675 dtoaCCFDict.remove('-O3')
676 dtoaEnv.Replace(CCFLAGS = dtoaCCFDict)
678 dtoaSources = Split('''
679 Source/common/dtoa.c
680 ''')
681 dtoaEnv.StaticObject('dtoa.o', dtoaSources)
683 # ======================================================================
684 # back to common
685 # ======================================================================
687 commonSources = Split('''
688 Source/common/SC_AllocPool.cpp
689 Source/common/SC_DirUtils.cpp
690 Source/common/SC_Sem.cpp
691 Source/common/SC_StringBuffer.cpp
692 Source/common/SC_StringParser.cpp
693 Source/common/g_fmt.c
694 Source/common/scsynthsend.cpp
695 Source/common/dtoa.c
696 Source/common/sc_popen.cpp
697 ''')
698 if PLATFORM == 'darwin':
699 commonSources += [
700 'Source/common/SC_StandAloneInfo_Darwin.cpp'
702 if env['CURL']:
703 commonEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
704 merge_lib_info(commonEnv, libraries['libcurl'])
705 libcommon = commonEnv.Library('build/common', commonSources)
707 #if env['amd64']:
708 #commonSources32 = list(commonSources)
709 #commonEnv32 = commonEnv.Clone()
710 #commonEnv32.Append(
711 #CCFLAGS = ['-m32'],
713 #libcommon32 = commonEnv32.Library('build/common32', commonSources32)
716 # ======================================================================
717 # Source/server
718 # ======================================================================
720 serverEnv = env.Clone()
721 serverEnv.Append(
722 CPPPATH = ['#Headers/common',
723 '#Headers/plugin_interface',
724 '#Headers/server'],
725 CPPDEFINES = [('SC_PLUGIN_DIR', '\\"' + pkg_lib_dir(FINAL_PREFIX, 'plugins') + '\\"'), ('SC_PLUGIN_EXT', '\\"' + PLUGIN_EXT + '\\"')],
726 LIBPATH = 'build')
727 libscsynthEnv = serverEnv.Clone(
728 PKGCONFIG_NAME = 'libscsynth',
729 PKGCONFIG_DESC = 'SuperCollider synthesis server library',
730 PKGCONFIG_PREFIX = FINAL_PREFIX,
731 PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile'],
732 libraries['audioapi'],
733 libraries['rendezvous']),
734 PKGCONFIG_LIBS = ['-lscsynth'],
735 # PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
736 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server']
739 # platform specific
741 # functionality of libdl is included in libc on freebsd
742 if PLATFORM == 'freebsd':
743 serverEnv.Append(LIBS = ['common', 'pthread'])
744 else:
745 serverEnv.Append(LIBS = ['common', 'pthread', 'dl'])
747 if PLATFORM == 'darwin':
748 serverEnv.Append(
749 LINKFLAGS = [
750 '-framework', 'CoreServices'])
751 #'-dylib_install_name', FINAL_PREFIX + '/lib/libsclang.dylib'])
752 elif PLATFORM == 'linux':
753 serverEnv.Append(
754 CPPDEFINES = [('SC_PLUGIN_LOAD_SYM', '\\"load\\"')],
755 LINKFLAGS = '-Wl,-rpath,' + FINAL_PREFIX + '/lib')
757 elif PLATFORM == 'freebsd':
758 serverEnv.Append(CPPDEFINES = [('SC_PLUGIN_LOAD_SYM', '\\"load\\"')])
760 # required libraries
761 merge_lib_info(
762 serverEnv,
763 libraries['sndfile'], libraries['audioapi'])
765 # optional features
766 if features['rendezvous']:
767 serverEnv.Append(CPPDEFINES = ['USE_RENDEZVOUS'])
768 merge_lib_info(serverEnv, libraries['rendezvous'])
770 if env['CURL']:
771 serverEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
772 merge_lib_info(serverEnv, libraries['libcurl'])
774 libscsynthSources = Split('''
775 Source/server/Rendezvous.cpp
776 Source/server/Samp.cpp
777 Source/server/SC_BufGen.cpp
778 Source/server/SC_Carbon.cpp
779 Source/server/SC_Complex.cpp
780 Source/server/SC_ComPort.cpp
781 Source/server/SC_CoreAudio.cpp
782 Source/server/SC_Dimension.cpp
783 Source/server/SC_Errors.cpp
784 Source/server/SC_Graph.cpp
785 Source/server/SC_GraphDef.cpp
786 Source/server/SC_Group.cpp
787 Source/server/SC_Lib_Cintf.cpp
788 Source/server/SC_Lib.cpp
789 Source/server/SC_MiscCmds.cpp
790 Source/server/SC_Node.cpp
791 Source/server/SC_Rate.cpp
792 Source/server/SC_SequencedCommand.cpp
793 Source/server/SC_Str4.cpp
794 Source/server/SC_SyncCondition.cpp
795 Source/server/SC_Unit.cpp
796 Source/server/SC_UnitDef.cpp
797 Source/server/SC_World.cpp
798 ''') + libraries['audioapi']['ADDITIONAL_SOURCES']
800 scsynthSources = ['Source/server/scsynth_main.cpp']
802 libscsynth = serverEnv.SharedLibrary('build/scsynth', libscsynthSources)
803 env.Alias('install-programs', env.Install(lib_dir(INSTALL_PREFIX), [libscsynth]))
805 libscsynthStaticSources = libscsynthSources + make_static_objects(serverEnv, commonSources, "_libscsynthStatic");
806 libscsynthStatic = serverEnv.StaticLibrary('build/scsynth', libscsynthStaticSources)
807 env.Alias('install-programs', env.Install(lib_dir(INSTALL_PREFIX), [libscsynthStatic]))
809 scsynth = serverEnv.Program('build/scsynth', scsynthSources, LIBS = ['scsynth'])
810 env.Alias('install-programs', env.Install(bin_dir(INSTALL_PREFIX), [scsynth]))
812 # ======================================================================
813 # Source/plugins
814 # ======================================================================
816 pluginEnv = env.Clone(
817 SHLIBPREFIX = '',
818 SHLIBSUFFIX = PLUGIN_EXT
820 pluginEnv.Append(
821 CPPPATH = ['#Headers/common',
822 '#Headers/plugin_interface',
823 '#Headers/server'],
824 PKGCONFIG_NAME = 'libscplugin',
825 PKGCONFIG_DESC = 'SuperCollider synthesis plugin headers',
826 PKGCONFIG_PREFIX = FINAL_PREFIX,
827 #PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['scsynth']),
828 #PKGCONFIG_LIBS = [],
829 # PKGCONFIG_LIBS_PRIVATE = ['-lm', '-lpthread', '-ldl'],
830 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/server']
832 if PLATFORM == 'darwin':
833 pluginEnv['SHLINKFLAGS'] = '$LINKFLAGS -bundle -flat_namespace -undefined suppress'
835 if PLATFORM == 'freebsd':
836 merge_lib_info(
837 pluginEnv,
838 libraries['sndfile'])
841 plugins = []
843 def make_plugin_target(name):
844 return os.path.join('build', 'plugins', name)
846 # simple plugins
847 for name in Split('''
848 BinaryOpUGens
849 ChaosUGens
850 DelayUGens
851 DemandUGens
852 DynNoiseUGens
853 FilterUGens
854 GendynUGens
855 IOUGens
856 LFUGens
857 MulAddUGens
858 NoiseUGens
859 OscUGens
860 PanUGens
861 PhysicalModelingUGens
862 TestUGens
863 TriggerUGens
864 UnaryOpUGens
865 GrainUGens
866 ReverbUGens
867 '''):
868 plugins.append(
869 pluginEnv.SharedLibrary(
870 make_plugin_target(name), os.path.join('Source', 'plugins', name + '.cpp')))
872 # complex
873 complexEnv = pluginEnv.Clone()
874 complexSources = Split('Source/plugins/SCComplex.cpp')
875 complexEnv.SharedObject('Source/plugins/SCComplex.o', complexSources)
877 # fft ugens
878 fftEnv = pluginEnv.Clone()
879 fftSources = Split('Source/common/SC_fftlib.cpp Source/plugins/SCComplex.o')
880 merge_lib_info(fftEnv, libraries['fftwf'])
881 plugins.append(
882 fftEnv.SharedLibrary(
883 make_plugin_target('FFT_UGens'),
884 ['Source/plugins/FFTInterfaceTable.cpp',
885 'Source/plugins/FFT_UGens.cpp',
886 'Source/plugins/PV_UGens.cpp',
887 'Source/plugins/PartitionedConvolution.cpp'] + fftSources))
889 plugins.append(
890 fftEnv.SharedLibrary(
891 make_plugin_target('PV_ThirdParty'),
892 ['Source/plugins/Convolution.cpp',
893 'Source/plugins/FFT2InterfaceTable.cpp',
894 'Source/plugins/FeatureDetection.cpp',
895 'Source/plugins/PV_ThirdParty.cpp'] + fftSources))
897 # fft 'unpacking' ugens
898 plugins.append(
899 pluginEnv.SharedLibrary(
900 make_plugin_target('UnpackFFTUGens'), ['Source/plugins/SCComplex.o', 'Source/plugins/UnpackFFTUGens.cpp']))
902 # machine listening ugens
903 # fft ugens
904 mlEnv = pluginEnv.Clone()
905 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')
906 plugins.append(
907 mlEnv.SharedLibrary(
908 make_plugin_target('ML_UGens'), mlSources))
910 # diskio ugens
911 diskIOEnv = pluginEnv.Clone(
912 LIBS = ['common', 'm'],
913 LIBPATH = 'build'
915 if PLATFORM == 'darwin':
916 diskIOEnv.Append(
917 LINKFLAGS = '-framework CoreServices'
920 diskIOSources = [
921 diskIOEnv.SharedObject('Source/plugins/SC_SyncCondition', 'Source/server/SC_SyncCondition.cpp'),
922 'Source/plugins/DiskIO_UGens.cpp']
923 merge_lib_info(diskIOEnv, libraries['sndfile'])
924 plugins.append(
925 diskIOEnv.SharedLibrary(
926 make_plugin_target('DiskIO_UGens'), diskIOSources))
928 # ui ugens
929 if PLATFORM == 'darwin':
930 uiUGensEnv = pluginEnv.Clone(
931 LIBS = 'm',
932 LINKFLAGS = '-framework CoreServices -framework Carbon'
934 plugins.append(
935 uiUGensEnv.SharedLibrary(make_plugin_target('MouseUGens'), 'Source/plugins/MouseUGens.cpp'))
936 plugins.append(
937 uiUGensEnv.SharedLibrary(make_plugin_target('KeyboardUGens'), 'Source/plugins/KeyboardUGens.cpp'))
938 elif features['x11']:
939 uiUGensEnv = pluginEnv.Clone()
940 merge_lib_info(uiUGensEnv, libraries['x11'])
941 plugins.append(
942 uiUGensEnv.SharedLibrary(make_plugin_target('MouseUGens'), 'Source/plugins/MouseUGens.cpp'))
943 plugins.append(
944 uiUGensEnv.SharedLibrary(make_plugin_target('KeyboardUGens'), 'Source/plugins/KeyboardUGens.cpp'))
946 env.Alias('install-plugins', env.Install(
947 pkg_lib_dir(INSTALL_PREFIX, 'plugins'), plugins))
949 # ======================================================================
950 # Source/lang
951 # ======================================================================
953 if env['TERMINAL_CLIENT'] == True:
954 env['TERMINAL_CLIENT'] = 1
955 else:
956 env['TERMINAL_CLIENT'] = 0
958 langEnv = env.Clone()
959 langEnv.Append(
960 CPPPATH = ['#Headers/common',
961 '#Headers/plugin_interface',
962 '#Headers/lang',
963 '#Headers/server',
964 '#Source/lang/LangSource/Bison'],
965 CPPDEFINES = [['USE_SC_TERMINAL_CLIENT', env['TERMINAL_CLIENT']]],
966 LIBPATH = 'build'
969 if env.has_key('amd64') and env['amd64']:
970 langEnv.Append( CXXFLAGS = ['-m32'] )
972 # functionality of libdl is included in libc on freebsd
973 if PLATFORM == 'freebsd':
974 langEnv.Append(LIBS = ['common', 'scsynth', 'pthread', 'm'])
975 else:
976 langEnv.Append(LIBS = ['common', 'scsynth', 'pthread', 'dl', 'm'])
978 if PLATFORM == 'darwin':
979 langEnv.Append(
980 LIBS = ['icucore'],
981 LINKFLAGS = ['-framework', 'CoreServices'], #'-dylib_install_name', FINAL_PREFIX + '/lib/libsclang.dylib'],
982 CPPPATH = ['#Headers/icu/unicode'])
983 elif PLATFORM == 'linux':
984 langEnv.Append(
985 LINKFLAGS = '-Wl,-rpath,build -Wl,-rpath,' + FINAL_PREFIX + '/lib')
986 elif PLATFORM == 'freebsd':
987 langEnv.Append(
988 LINKFLAGS = '-Wl,-rpath,build -Wl,-rpath,' + FINAL_PREFIX + '/lib')
990 if env['CURL']:
991 langEnv.Append(CPPDEFINES = ['HAVE_LIBCURL'])
992 merge_lib_info(langEnv, libraries['libcurl'])
994 merge_lib_info(langEnv, libraries['audioapi'])
996 libsclangEnv = langEnv.Clone(
997 PKGCONFIG_NAME = 'libsclang',
998 PKGCONFIG_DESC = 'SuperCollider synthesis language library',
999 PKGCONFIG_PREFIX = FINAL_PREFIX,
1000 PKGCONFIG_REQUIRES = make_pkgconfig_requires(libraries['sndfile']) + ['libscsynth'],
1001 PKGCONFIG_LIBS = ['-lsclang'],
1002 PKGCONFIG_CFLAGS = ['-D' + PLATFORM_SYMBOL, '-I${includedir}/common', '-I${includedir}/plugin_interface', '-I${includedir}/lang', '-I${includedir}/server']
1005 # required libraries
1006 merge_lib_info(langEnv, libraries['sndfile'])
1008 libsclangSources = Split('''
1009 Source/lang/LangSource/AdvancingAllocPool.cpp
1010 Source/lang/LangSource/ByteCodeArray.cpp
1011 Source/lang/LangSource/DumpParseNode.cpp
1012 Source/lang/LangSource/GC.cpp
1013 Source/lang/LangSource/InitAlloc.cpp
1014 Source/lang/LangSource/PyrFileUtils.cpp
1015 Source/lang/LangSource/PyrInterpreter3.cpp
1016 Source/lang/LangSource/PyrLexer.cpp
1017 Source/lang/LangSource/PyrMathOps.cpp
1018 Source/lang/LangSource/PyrMathSupport.cpp
1019 Source/lang/LangSource/PyrMessage.cpp
1020 Source/lang/LangSource/PyrObject.cpp
1021 Source/lang/LangSource/PyrParseNode.cpp
1022 Source/lang/LangSource/PyrSignal.cpp
1023 Source/lang/LangSource/PyrSymbolTable.cpp
1024 Source/lang/LangSource/SC_LanguageClient.cpp
1025 Source/lang/LangSource/SC_LibraryConfig.cpp
1026 Source/lang/LangSource/SC_TerminalClient.cpp
1027 Source/lang/LangSource/Samp.cpp
1028 Source/lang/LangSource/SimpleStack.cpp
1029 Source/lang/LangSource/VMGlobals.cpp
1030 Source/lang/LangSource/alloca.cpp
1031 Source/lang/LangSource/dumpByteCodes.cpp
1032 Source/lang/LangSource/Bison/lang11d_tab.cpp
1033 Source/lang/LangPrimSource/SC_Wii.cpp
1034 Source/lang/LangPrimSource/PyrSignalPrim.cpp
1035 Source/lang/LangPrimSource/PyrSched.cpp
1036 Source/lang/LangPrimSource/PyrPrimitive.cpp
1037 Source/lang/LangPrimSource/PyrMathPrim.cpp
1038 Source/lang/LangPrimSource/SC_ComPort.cpp
1039 Source/lang/LangPrimSource/OSCData.cpp
1040 Source/lang/LangPrimSource/PyrArchiver.cpp
1041 Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
1042 Source/lang/LangPrimSource/PyrBitPrim.cpp
1043 Source/lang/LangPrimSource/PyrCharPrim.cpp
1044 Source/lang/LangPrimSource/PyrFilePrim.cpp
1045 Source/lang/LangPrimSource/PyrListPrim.cpp
1046 Source/lang/LangPrimSource/PyrPlatformPrim.cpp
1047 Source/lang/LangPrimSource/PyrSerialPrim.cpp
1048 Source/lang/LangPrimSource/PyrStringPrim.cpp
1049 Source/lang/LangPrimSource/PyrUStringPrim.cpp
1050 Source/lang/LangPrimSource/PyrSymbolPrim.cpp
1051 Source/lang/LangPrimSource/PyrUnixPrim.cpp
1052 ''') + [libsclangEnv.SharedObject('Source/lang/LangSource/fftlib', 'Source/common/fftlib.c')]
1054 # optional features
1055 if features['midiapi']:
1056 merge_lib_info(langEnv, libraries['midiapi'])
1057 if features['midiapi'] == 'CoreMIDI':
1058 libsclangSources += ['Source/lang/LangPrimSource/SC_CoreMIDI.cpp']
1059 else:
1060 libsclangSources += ['Source/lang/LangPrimSource/SC_AlsaMIDI.cpp']
1061 else:
1062 # fallback implementation
1063 libsclangSources += ['Source/lang/LangPrimSource/SC_AlsaMIDI.cpp']
1065 if PLATFORM == 'darwin':
1066 langEnv.Append(
1067 CPPPATH = ['#Source/lang/LangPrimSource/HID_Utilities',
1068 '#Source/lang/LangPrimSource/WiiMote_OSX'],
1069 LINKFLAGS = '-framework Carbon -framework IOKit -framework IOBluetooth'
1071 libsclangSources += Split('''
1072 Source/lang/LangPrimSource/SC_HID.cpp
1073 Source/lang/LangPrimSource/SC_CoreAudioPrim.cpp
1074 Source/lang/LangPrimSource/HID_Utilities/HID_Error_Handler.c
1075 Source/lang/LangPrimSource/HID_Utilities/HID_Name_Lookup.c
1076 Source/lang/LangPrimSource/HID_Utilities/HID_Queue_Utilities.c
1077 Source/lang/LangPrimSource/HID_Utilities/HID_Utilities.c
1078 Source/lang/LangPrimSource/WiiMote_OSX/wiiremote.c
1079 ''')
1080 else:
1081 if features['wii']:
1082 langEnv.Append(CPPDEFINES = 'HAVE_WII')
1083 langEnv.Append(LINKFLAGS = '-lcwiid')
1084 #langEnv.Append(LINKFLAGS = '-lbluetooth')
1085 #langEnv.Append(CPPPATH = '-I/usr/local/include/libcwiimote-0.4.0/libcwiimote/' ) #FIXME: to proper include directory
1086 if features['lid']:
1087 langEnv.Append(CPPDEFINES = 'HAVE_LID')
1088 libsclangSources += ['Source/lang/LangPrimSource/SC_LID.cpp']
1090 if PLATFORM == 'darwin':
1091 langEnv.Append(CPPDEFINES = 'HAVE_SPEECH')
1092 libsclangSources += ['Source/lang/LangPrimSource/SC_Speech.cpp']
1094 sclangSources = ['Source/lang/LangSource/cmdLineFuncs.cpp']
1096 if env['LANG']:
1097 libsclang = langEnv.SharedLibrary('build/sclang', libsclangSources)
1098 env.Alias('install-bin', env.Install(lib_dir(INSTALL_PREFIX), [libsclang]))
1099 if PLATFORM == 'darwin':
1100 sclangLibs = ['scsynth', 'sclang']
1101 else:
1102 sclangLibs = ['sclang']
1103 sclang = langEnv.Program('build/sclang', sclangSources, LIBS=sclangLibs)
1104 env.Alias('install-programs', env.Install(bin_dir(INSTALL_PREFIX), [sclang]))
1106 # ======================================================================
1107 # doc/doxygen
1108 # ======================================================================
1110 # doxygen = env.Command(None, 'doc/doxygen/html/index.html', 'doxygen doc/doxygen/doxygen.cfg')
1111 # env.Alias('doxygen', doxygen)
1113 # ======================================================================
1114 # installation
1115 # ======================================================================
1117 installEnv = Environment(
1118 ALL = ['install-bin', 'install-data'],
1119 BIN = ['install-plugins', 'install-programs'],
1120 DATA = ['install-doc']
1122 if env['LANG']:
1123 installEnv.Append(DATA = ['install-library'])
1125 if is_installing():
1126 # class library
1127 env.Alias('install-library', install_dir(
1128 env, 'build/SCClassLibrary',
1129 pkg_data_dir(INSTALL_PREFIX),
1130 SC_FILE_RE, 1))
1131 # help files
1132 env.Alias('install-library', install_dir(
1133 env, 'build/Help',
1134 pkg_data_dir(INSTALL_PREFIX),
1135 HELP_FILE_RE, 1))
1136 # example files
1137 env.Alias('install-library', install_dir(
1138 env, 'build/examples',
1139 pkg_data_dir(INSTALL_PREFIX),
1140 HELP_FILE_RE, 1))
1141 # scel
1142 if env['SCEL']:
1143 env.Alias('install-library', install_dir(
1144 env, 'editors/scel/sc',
1145 pkg_extension_dir(INSTALL_PREFIX, 'scel'),
1146 SC_FILE_RE, 3))
1147 # scvim
1148 if env['SCVIM']:
1149 env.Alias('install-library', install_dir(
1150 env, 'editors/scvim/scclasses',
1151 pkg_extension_dir(INSTALL_PREFIX, 'scvim'),
1152 SC_FILE_RE, 3))
1153 # scvim helpfiles
1154 if env['SCVIM']:
1155 env.Alias('install-library', install_dir(
1156 env, 'editors/scvim/cache/doc',
1157 pkg_data_dir(INSTALL_PREFIX, 'scvim-help'),
1158 HELP_FILE_RE, 4))
1160 #scvim : unhtml help files
1161 #if env['SCVIM']:
1162 #os.execvpe("editors/scvim/bin/scvim_make_help.rb", [ "-c", "-s", "build/Help"],"SCVIM=editors/scvim/")
1163 #os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
1165 #if env['SCVIM']:
1166 #vimenv = env.Clone()
1167 #SConscript('editors/test/SConstruct', exports=['vimenv'])
1169 #if env['SCVIM']:
1170 #print 'installing scvim'
1171 #vimenv = env.Clone()
1172 ##env.Append(FROMTOP=True)
1173 #SConscript('editors/scvim/SConstruct', exports=['vimenv'])
1175 if env['SCVIM']:
1176 SConscript('editors/scvim/SConstruct', exports=['env'])
1178 if env['SCED']:
1179 SConscript('editors/sced/SConstruct', 'env')
1181 # scel
1182 if env['SCEL']:
1183 env.Command('editors/scel/el/sclang-vars.el', 'editors/scel/el/sclang-vars.el.in',
1184 'sed \'s,@PKG_DATA_DIR@,%s,g\' < $SOURCE > $TARGET' %
1185 pkg_data_dir(FINAL_PREFIX))
1186 el_files = glob.glob('editors/scel/el/*.el') + ['editors/scel/el/sclang-vars.el']
1187 elc_files = map(lambda f: os.path.splitext(f)[0] + '.elc', el_files)
1188 elisp_dir = os.path.join(INSTALL_PREFIX, 'share', 'emacs', 'site-lisp')
1189 env.Command(elc_files, el_files,
1190 'emacs -batch --eval "(add-to-list \'load-path (expand-file-name \\"editors/scel/el/\\"))" -f batch-byte-compile $SOURCES')
1191 env.Alias('install-elisp', env.Install(elisp_dir, el_files + elc_files))
1192 installEnv.Append(DATA = 'install-elisp')
1194 # example library configuration file
1195 env.Command('linux/examples/sclang.cfg', 'linux/examples/sclang.cfg.in',
1196 'sed \'s,@PKG_DATA_DIR@,%s,g\' < $SOURCE > $TARGET' %
1197 pkg_data_dir(FINAL_PREFIX))
1199 # headers
1200 if env['DEVELOPMENT']:
1201 header_dirs = Split('common plugin_interface server lang')
1202 if PLATFORM == 'darwin':
1203 header_dirs += 'app'
1204 for d in header_dirs:
1205 env.Alias('install-dev', install_dir(
1206 env, os.path.join('Headers', d),
1207 pkg_include_dir(INSTALL_PREFIX),
1208 re.compile('.*\.h(h|pp)?'), 1)
1210 # other useful headers
1211 env.Alias('install-dev',
1212 env.Install(pkg_include_dir(INSTALL_PREFIX, 'plugin_interface'), 'Source/plugins/FFT_UGens.h'))
1213 pkgconfig_files = [
1214 libscsynthEnv.Command('linux/libscsynth.pc', 'SConstruct',
1215 build_pkgconfig_file),
1216 libsclangEnv.Command('linux/libsclang.pc', 'SConstruct',
1217 build_pkgconfig_file),
1218 pluginEnv.Command('linux/libscplugin.pc', 'SConstruct',
1219 build_pkgconfig_file)]
1220 pkgconfig_dir = os.path.join(lib_dir(INSTALL_PREFIX), 'pkgconfig')
1221 env.Alias('install-dev', env.Install(pkgconfig_dir, pkgconfig_files))
1222 installEnv.Append(ALL = 'install-dev')
1224 # documentation
1225 if is_installing():
1226 # TODO: build html documentation?
1227 doc_dir = pkg_doc_dir(INSTALL_PREFIX)
1228 env.Alias('install-doc',
1229 install_dir(env, 'doc', doc_dir, ANY_FILE_RE, 0) +
1230 install_dir(env, 'build/examples', doc_dir, ANY_FILE_RE, 1) +
1231 install_dir(env, 'build/TestingAndToDo', doc_dir, ANY_FILE_RE, 1))
1233 env.Alias('install-bin', installEnv['BIN'])
1234 env.Alias('install-data', installEnv['DATA'])
1235 env.Alias('install', installEnv['ALL'])
1237 # ======================================================================
1238 # distribution
1239 # ======================================================================
1241 DIST_FILES = Split('''
1242 COPYING
1243 SConstruct
1244 clean-compile.sh
1245 compile.sh
1246 distro
1247 linux/ChangeLog
1248 linux/INSTALL
1249 linux/NEWS
1250 linux/README
1251 linux/examples/onetwoonetwo.sc
1252 linux/examples/sclang.cfg.in
1253 linux/examples/sclang.sc
1254 editors/scel/README
1255 editors/scvim/README
1256 editors/sced/README
1257 scsynthlib_exp
1258 ''')
1260 DIST_SPECS = [
1261 ('build', HELP_FILE_RE),
1262 ('Headers', SRC_FILE_RE),
1263 ('editors/scel/sc', SC_FILE_RE),
1264 ('editors/scel/el', re.compile('.*\.el$')),
1265 ('editors/scvim/scclasses', SC_FILE_RE),
1266 ('Source', SRC_FILE_RE)
1269 def dist_paths():
1270 paths = DIST_FILES[:]
1271 specs = DIST_SPECS[:]
1272 while specs:
1273 base, re = specs.pop()
1274 if not re: re = ANY_FILE_RE
1275 for root, dirs, files in os.walk(base):
1276 if 'CVS' in dirs: dirs.remove('CVS')
1277 if '.svn' in dirs: dirs.remove('.svn')
1278 for path in dirs[:]:
1279 if re.match(path):
1280 specs.append((os.path.join(root, path), re))
1281 dirs.remove(path)
1282 for path in files:
1283 if re.match(path):
1284 paths.append(os.path.join(root, path))
1285 paths.sort()
1286 return paths
1288 def build_tar(env, target, source):
1289 paths = dist_paths()
1290 tarfile_name = str(target[0])
1291 tar_name = os.path.splitext(os.path.basename(tarfile_name))[0]
1292 tar = tarfile.open(tarfile_name, "w:bz2")
1293 for path in paths:
1294 tar.add(path, os.path.join(tar_name, path))
1295 tar.close()
1297 if 'dist' in COMMAND_LINE_TARGETS:
1298 env.Alias('dist', env['TARBALL'])
1299 env.Command(env['TARBALL'], 'SConstruct', build_tar)
1301 # ======================================================================
1302 # cleanup
1303 # ======================================================================
1305 if 'scrub' in COMMAND_LINE_TARGETS:
1306 env.Clean('scrub', Split('config.log scache.conf .sconf_temp'))
1308 # ======================================================================
1309 # configuration summary
1310 # ======================================================================
1312 def yesorno(p):
1313 if p: return 'yes'
1314 else: return 'no'
1316 print '------------------------------------------------------------------------'
1317 print ' ALTIVEC: %s' % yesorno(features['altivec'])
1318 print ' AUDIOAPI: %s' % features['audioapi']
1319 print ' MIDIAPI: %s' % features['midiapi']
1320 print ' DEBUG: %s' % yesorno(env['DEBUG'])
1321 # print ' DESTDIR: %s' % env['DESTDIR']
1322 print ' DEVELOPMENT: %s' % yesorno(env['DEVELOPMENT'])
1323 print ' LANG: %s' % yesorno(env['LANG'])
1324 print ' LID: %s' % yesorno(features['lid'])
1325 print ' WII: %s' % yesorno(features['wii'])
1326 print ' PREFIX: %s' % env['PREFIX']
1327 print ' RENDEZVOUS: %s' % yesorno(features['rendezvous'])
1328 print ' SCEL: %s' % yesorno(env['SCEL'])
1329 print ' SCVIM: %s' % yesorno(env['SCVIM'])
1330 print ' SCED: %s' % yesorno(env['SCED'])
1331 print ' SSE: %s' % yesorno(features['sse'])
1332 print ' STRIP: %s' % yesorno(env['STRIP'])
1333 print ' CROSSCOMPILE: %s' % yesorno(env['CROSSCOMPILE'])
1334 print ' TERMINAL_CLIENT: %s' % yesorno(env['TERMINAL_CLIENT'])
1335 print ' X11: %s' % yesorno(features['x11'])
1336 print '------------------------------------------------------------------------'
1338 # ======================================================================
1339 # EOF