16 EnsureSConsVersion(0, 96)
23 # Command-line options
26 opts = Options('scache.conf')
28 ('ARCH', 'Set architecture-specific compilation flags by hand (all flags as 1 argument)',''),
29 BoolOption('COREAUDIO', 'Compile with Apple\'s CoreAudio library', 0),
30 BoolOption('DEBUG', 'Set to build with debugging information and no optimizations', 0),
31 PathOption('DESTDIR', 'Set the intermediate install "prefix"', '/'),
32 EnumOption('DIST_TARGET', 'Build target for cross compiling packagers', 'auto', allowed_values=('auto', 'i386', 'i686', 'x86_64', 'powerpc', 'tiger', 'panther', 'none' ), ignorecase=2),
33 BoolOption('DMALLOC', 'Compile and link using the dmalloc library', 0),
34 BoolOption('EXTRA_WARN', 'Compile with -Wextra, -ansi, and -pedantic. Might break compilation. For pedants', 0),
35 BoolOption('FFT_ANALYSIS', 'Include FFT analysis window', 0),
36 BoolOption('FPU_OPTIMIZATION', 'Build runtime checked assembler code', 1),
37 BoolOption('LIBLO', 'Compile with support for liblo library', 1),
38 BoolOption('NLS', 'Set to turn on i18n support', 1),
39 PathOption('PREFIX', 'Set the install "prefix"', '/usr/local'),
40 BoolOption('SURFACES', 'Build support for control surfaces', 0),
41 BoolOption('SYSLIBS', 'USE AT YOUR OWN RISK: CANCELS ALL SUPPORT FROM ARDOUR AUTHORS: Use existing system versions of various libraries instead of internal ones', 0),
42 BoolOption('VERSIONED', 'Add version information to ardour/gtk executable name inside the build directory', 0),
43 BoolOption('VST', 'Compile with support for VST', 0)
46 #----------------------------------------------------------------------
47 # a handy helper that provides a way to merge compile/link information
48 # from multiple different "environments"
49 #----------------------------------------------------------------------
51 class LibraryInfo(Environment):
52 def __init__(self,*args,**kw):
53 Environment.__init__ (self,*args,**kw)
55 def Merge (self,others):
57 self.Append (LIBS = other.get ('LIBS',[]))
58 self.Append (LIBPATH = other.get ('LIBPATH', []))
59 self.Append (CPPPATH = other.get('CPPPATH', []))
60 self.Append (LINKFLAGS = other.get('LINKFLAGS', []))
61 self.Replace(LIBPATH = list(Set(self.get('LIBPATH', []))))
62 self.Replace(CPPPATH = list(Set(self.get('CPPPATH',[]))))
63 #doing LINKFLAGS breaks -framework
64 #doing LIBS break link order dependency
66 def ENV_update(self, src_ENV):
67 for k in src_ENV.keys():
68 if k in self['ENV'].keys() and k in [ 'PATH', 'LD_LIBRARY_PATH',
70 self['ENV'][k]=SCons.Util.AppendPath(self['ENV'][k], src_ENV[k])
72 self['ENV'][k]=src_ENV[k]
74 env = LibraryInfo (options = opts,
77 TARBALL='ardour-' + version + '.tar.bz2',
79 DISTTREE = '#ardour-' + version,
80 DISTCHECKDIR = '#ardour-' + version + '/check'
83 env.ENV_update(os.environ)
85 #----------------------------------------------------------------------
87 #----------------------------------------------------------------------
89 # Handy subst-in-file builder
92 def do_subst_in_file(targetfile, sourcefile, dict):
93 """Replace all instances of the keys of dict with their values.
94 For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'},
95 then all instances of %VERSION% in the file will be replaced with 1.2345 etc.
98 f = open(sourcefile, 'rb')
102 raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile
103 for (k,v) in dict.items():
104 contents = re.sub(k, v, contents)
106 f = open(targetfile, 'wb')
110 raise SCons.Errors.UserError, "Can't write target file %s"%targetfile
113 def subst_in_file(target, source, env):
114 if not env.has_key('SUBST_DICT'):
115 raise SCons.Errors.UserError, "SubstInFile requires SUBST_DICT to be set."
116 d = dict(env['SUBST_DICT']) # copy it
117 for (k,v) in d.items():
119 d[k] = env.subst(v())
120 elif SCons.Util.is_String(v):
123 raise SCons.Errors.UserError, "SubstInFile: key %s: %s must be a string or callable"%(k, repr(v))
124 for (t,s) in zip(target, source):
125 return do_subst_in_file(str(t), str(s), d)
127 def subst_in_file_string(target, source, env):
128 """This is what gets printed on the console."""
129 return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t))
130 for (t,s) in zip(target, source)])
132 def subst_emitter(target, source, env):
133 """Add dependency from substituted SUBST_DICT to target.
134 Returns original target, source tuple unchanged.
136 d = env['SUBST_DICT'].copy() # copy it
137 for (k,v) in d.items():
139 d[k] = env.subst(v())
140 elif SCons.Util.is_String(v):
142 Depends(target, SCons.Node.Python.Value(d))
143 # Depends(target, source) # this doesn't help the install-sapphire-linux.sh problem
144 return target, source
146 subst_action = Action (subst_in_file, subst_in_file_string)
147 env['BUILDERS']['SubstInFile'] = Builder(action=subst_action, emitter=subst_emitter)
150 # internationalization
153 # po_builder: builder function to copy po files to the parent directory while updating them
155 # first source: .po file
156 # second source: .pot file
159 def po_builder(target,source,env):
160 os.spawnvp (os.P_WAIT, 'cp', ['cp', str(source[0]), str(target[0])])
166 print 'Updating ' + str(target[0])
167 return os.spawnvp (os.P_WAIT, 'msgmerge', args)
169 po_bld = Builder (action = po_builder)
170 env.Append(BUILDERS = {'PoBuild' : po_bld})
172 # mo_builder: builder function for (binary) message catalogs (.mo)
174 # first source: .po file
177 def mo_builder(target,source,env):
181 target[0].get_path(),
184 return os.spawnvp (os.P_WAIT, 'msgfmt', args)
186 mo_bld = Builder (action = mo_builder)
187 env.Append(BUILDERS = {'MoBuild' : mo_bld})
189 # pot_builder: builder function for message templates (.pot)
191 # source: list of C/C++ etc. files to extract messages from
194 def pot_builder(target,source,env):
199 '-o', target[0].get_path(),
200 "--default-domain=" + env['PACKAGE'],
201 '--copyright-holder="Paul Davis"' ]
202 args += [ src.get_path() for src in source ]
204 return os.spawnvp (os.P_WAIT, 'xgettext', args)
206 pot_bld = Builder (action = pot_builder)
207 env.Append(BUILDERS = {'PotBuild' : pot_bld})
210 # utility function, not a builder
213 def i18n (buildenv, sources, installenv):
214 domain = buildenv['PACKAGE']
215 potfile = buildenv['POTFILE']
217 installenv.Alias ('potupdate', buildenv.PotBuild (potfile, sources))
219 p_oze = [ os.path.basename (po) for po in glob.glob ('po/*.po') ]
220 languages = [ po.replace ('.po', '') for po in p_oze ]
222 for po_file in p_oze:
223 buildenv.PoBuild(po_file, ['po/'+po_file, potfile])
224 mo_file = po_file.replace (".po", ".mo")
225 installenv.Alias ('install', buildenv.MoBuild (mo_file, po_file))
227 for lang in languages:
228 modir = (os.path.join (install_prefix, 'share/locale/' + lang + '/LC_MESSAGES/'))
229 moname = domain + '.mo'
230 installenv.Alias('install', installenv.InstallAs (os.path.join (modir, moname), lang + '.mo'))
233 # A generic builder for version.cc files
235 # note: requires that DOMAIN, MAJOR, MINOR, MICRO are set in the construction environment
236 # note: assumes one source files, the header that declares the version variables
238 def version_builder (target, source, env):
239 text = "int " + env['DOMAIN'] + "_major_version = " + str (env['MAJOR']) + ";\n"
240 text += "int " + env['DOMAIN'] + "_minor_version = " + str (env['MINOR']) + ";\n"
241 text += "int " + env['DOMAIN'] + "_micro_version = " + str (env['MICRO']) + ";\n"
244 o = file (target[0].get_path(), 'w')
248 print "Could not open", target[0].get_path(), " for writing\n"
251 text = "#ifndef __" + env['DOMAIN'] + "_version_h__\n"
252 text += "#define __" + env['DOMAIN'] + "_version_h__\n"
253 text += "extern int " + env['DOMAIN'] + "_major_version;\n"
254 text += "extern int " + env['DOMAIN'] + "_minor_version;\n"
255 text += "extern int " + env['DOMAIN'] + "_micro_version;\n"
256 text += "#endif /* __" + env['DOMAIN'] + "_version_h__ */\n"
259 o = file (target[1].get_path(), 'w')
263 print "Could not open", target[1].get_path(), " for writing\n"
268 version_bld = Builder (action = version_builder)
269 env.Append (BUILDERS = {'VersionBuild' : version_bld})
272 # a builder that makes a hard link from the 'source' executable to a name with
273 # a "build ID" based on the most recent CVS activity that might be reasonably
274 # related to version activity. this relies on the idea that the SConscript
275 # file that builds the executable is updated with new version info and committed
276 # to the source code repository whenever things change.
279 def versioned_builder(target,source,env):
280 # build ID is composed of a representation of the date of the last CVS transaction
281 # for this (SConscript) file
284 o = file (source[0].get_dir().get_path() + '/CVS/Entries', "r")
286 print "Could not CVS/Entries for reading"
290 lines = o.readlines()
292 if line[0:12] == '/SConscript/':
293 parts = line.split ("/")
299 print "No SConscript CVS update info found - versioned executable cannot be built"
302 tag = time.strftime ('%Y%M%d%H%m', time.strptime (last_date))
303 print "The current build ID is " + tag
305 tagged_executable = source[0].get_path() + '-' + tag
307 if os.path.exists (tagged_executable):
308 print "Replacing existing executable with the same build tag."
309 os.unlink (tagged_executable)
311 return os.link (source[0].get_path(), tagged_executable)
313 verbuild = Builder (action = versioned_builder)
314 env.Append (BUILDERS = {'VersionedExecutable' : verbuild})
317 # source tar file builder
320 def distcopy (target, source, env):
321 treedir = str (target[0])
325 except OSError, (errnum, strerror):
326 if errnum != errno.EEXIST:
327 print 'mkdir ', treedir, ':', strerror
331 # we don't know what characters might be in the file names
332 # so quote them all before passing them to the shell
334 all_files = ([ str(s) for s in source ])
335 cmd += " ".join ([ "'%s'" % quoted for quoted in all_files])
336 cmd += ' | (cd ' + treedir + ' && tar xf -)'
340 def tarballer (target, source, env):
341 cmd = 'tar -jcf ' + str (target[0]) + ' ' + str(source[0]) + " --exclude '*~'"
342 print 'running ', cmd, ' ... '
346 dist_bld = Builder (action = distcopy,
347 target_factory = SCons.Node.FS.default_fs.Entry,
348 source_factory = SCons.Node.FS.default_fs.Entry,
351 tarball_bld = Builder (action = tarballer,
352 target_factory = SCons.Node.FS.default_fs.Entry,
353 source_factory = SCons.Node.FS.default_fs.Entry)
355 env.Append (BUILDERS = {'Distribute' : dist_bld})
356 env.Append (BUILDERS = {'Tarball' : tarball_bld})
359 # Make sure they know what they are doing
363 sys.stdout.write ("Are you building Ardour for personal use (rather than distributiont to others)? [no]: ")
364 answer = sys.stdin.readline ()
365 answer = answer.rstrip().strip()
366 if answer != "yes" and answer != "y":
367 print 'You cannot build Ardour with VST support for distribution to others.\nIt is a violation of several different licenses. VST support disabled.'
370 print "OK, VST support will be enabled"
373 # ----------------------------------------------------------------------
374 # Construction environment setup
375 # ----------------------------------------------------------------------
379 libraries['core'] = LibraryInfo (CCFLAGS = '-Ilibs')
381 #libraries['sndfile'] = LibraryInfo()
382 #libraries['sndfile'].ParseConfig('pkg-config --cflags --libs sndfile')
384 libraries['lrdf'] = LibraryInfo()
385 libraries['lrdf'].ParseConfig('pkg-config --cflags --libs lrdf')
387 libraries['raptor'] = LibraryInfo()
388 libraries['raptor'].ParseConfig('pkg-config --cflags --libs raptor')
390 libraries['samplerate'] = LibraryInfo()
391 libraries['samplerate'].ParseConfig('pkg-config --cflags --libs samplerate')
393 if env['FFT_ANALYSIS']:
394 libraries['fftw3f'] = LibraryInfo()
395 libraries['fftw3f'].ParseConfig('pkg-config --cflags --libs fftw3f')
397 libraries['jack'] = LibraryInfo()
398 libraries['jack'].ParseConfig('pkg-config --cflags --libs jack')
400 libraries['xml'] = LibraryInfo()
401 libraries['xml'].ParseConfig('pkg-config --cflags --libs libxml-2.0')
403 libraries['xslt'] = LibraryInfo()
404 libraries['xslt'].ParseConfig('pkg-config --cflags --libs libxslt')
406 libraries['glib2'] = LibraryInfo()
407 libraries['glib2'].ParseConfig ('pkg-config --cflags --libs glib-2.0')
408 libraries['glib2'].ParseConfig ('pkg-config --cflags --libs gobject-2.0')
409 libraries['glib2'].ParseConfig ('pkg-config --cflags --libs gmodule-2.0')
410 libraries['glib2'].ParseConfig ('pkg-config --cflags --libs gthread-2.0')
412 libraries['gtk2'] = LibraryInfo()
413 libraries['gtk2'].ParseConfig ('pkg-config --cflags --libs gtk+-2.0')
415 libraries['pango'] = LibraryInfo()
416 libraries['pango'].ParseConfig ('pkg-config --cflags --libs pango')
418 libraries['libgnomecanvas2'] = LibraryInfo()
419 libraries['libgnomecanvas2'].ParseConfig ('pkg-config --cflags --libs libgnomecanvas-2.0')
421 #libraries['flowcanvas'] = LibraryInfo(LIBS='flowcanvas', LIBPATH='#/libs/flowcanvas', CPPPATH='#libs/flowcanvas')
423 # The Ardour Control Protocol Library
425 libraries['ardour_cp'] = LibraryInfo (LIBS='ardour_cp', LIBPATH='#libs/surfaces/control_protocol',
426 CPPPATH='#libs/surfaces/control_protocol')
428 # The Ardour backend/engine
430 libraries['ardour'] = LibraryInfo (LIBS='ardour', LIBPATH='#libs/ardour', CPPPATH='#libs/ardour')
431 libraries['midi++2'] = LibraryInfo (LIBS='midi++', LIBPATH='#libs/midi++2', CPPPATH='#libs/midi++2')
432 libraries['pbd'] = LibraryInfo (LIBS='pbd', LIBPATH='#libs/pbd', CPPPATH='#libs/pbd')
433 libraries['gtkmm2ext'] = LibraryInfo (LIBS='gtkmm2ext', LIBPATH='#libs/gtkmm2ext', CPPPATH='#libs/gtkmm2ext')
438 libraries['usb'] = LibraryInfo ()
440 conf = Configure (libraries['usb'])
441 if conf.CheckLib ('usb', 'usb_interrupt_write'):
446 libraries['usb'] = conf.Finish ()
451 libraries['flac'] = LibraryInfo ()
453 conf = Configure (libraries['flac'])
454 conf.CheckLib ('FLAC', 'FLAC__stream_decoder_new', language='CXX')
455 libraries['flac'] = conf.Finish ()
457 # or if that fails...
458 #libraries['flac'] = LibraryInfo (LIBS='FLAC')
460 # boost (we don't link against boost, just use some header files)
462 libraries['boost'] = LibraryInfo ()
463 conf = Configure (libraries['boost'])
464 if conf.CheckHeader ('boost/shared_ptr.hpp', language='CXX') == 0:
465 print "Boost header files do not appear to be installed."
468 libraries['boost'] = conf.Finish ()
474 libraries['lo'] = LibraryInfo ()
476 conf = Configure (libraries['lo'])
477 if conf.CheckLib ('lo', 'lo_server_new') == False:
478 print "liblo does not appear to be installed."
481 libraries['lo'] = conf.Finish ()
486 libraries['dmalloc'] = LibraryInfo ()
489 # look for the threaded version
492 conf = Configure (libraries['dmalloc'])
493 if conf.CheckLib ('dmallocth', 'dmalloc_shutdown'):
494 have_libdmalloc = True
496 have_libdmalloc = False
498 libraries['dmalloc'] = conf.Finish ()
503 # Audio/MIDI library (needed for MIDI, since audio is all handled via JACK)
506 conf = Configure(env)
507 if conf.CheckCHeader('jack/midiport.h'):
508 libraries['sysmidi'] = LibraryInfo (LIBS='jack')
509 env['SYSMIDI'] = 'JACK MIDI'
510 subst_dict['%MIDITAG%'] = "control"
511 subst_dict['%MIDITYPE%'] = "jack"
512 print "Using JACK MIDI"
513 elif conf.CheckCHeader('alsa/asoundlib.h'):
514 libraries['sysmidi'] = LibraryInfo (LIBS='asound')
515 env['SYSMIDI'] = 'ALSA Sequencer'
516 subst_dict['%MIDITAG%'] = "seq"
517 subst_dict['%MIDITYPE%'] = "alsa/sequencer"
518 print "Using ALSA MIDI"
519 elif conf.CheckCHeader('/System/Library/Frameworks/CoreMIDI.framework/Headers/CoreMIDI.h'):
520 # this line is needed because scons can't handle -framework in ParseConfig() yet.
521 libraries['sysmidi'] = LibraryInfo (LINKFLAGS= '-framework CoreMIDI -framework CoreFoundation -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox -bind_at_load')
522 env['SYSMIDI'] = 'CoreMIDI'
523 subst_dict['%MIDITAG%'] = "ardour"
524 subst_dict['%MIDITYPE%'] = "coremidi"
525 print "Using CoreMIDI"
527 print "It appears you don't have the required MIDI libraries installed."
534 libraries['sigc2'] = LibraryInfo()
535 libraries['sigc2'].ParseConfig('pkg-config --cflags --libs sigc++-2.0')
536 libraries['glibmm2'] = LibraryInfo()
537 libraries['glibmm2'].ParseConfig('pkg-config --cflags --libs glibmm-2.4')
538 libraries['gdkmm2'] = LibraryInfo()
539 libraries['gdkmm2'].ParseConfig ('pkg-config --cflags --libs gdkmm-2.4')
540 libraries['gtkmm2'] = LibraryInfo()
541 libraries['gtkmm2'].ParseConfig ('pkg-config --cflags --libs gtkmm-2.4')
542 libraries['atkmm'] = LibraryInfo()
543 libraries['atkmm'].ParseConfig ('pkg-config --cflags --libs atkmm-1.6')
544 libraries['pangomm'] = LibraryInfo()
545 libraries['pangomm'].ParseConfig ('pkg-config --cflags --libs pangomm-1.4')
546 libraries['libgnomecanvasmm'] = LibraryInfo()
547 libraries['libgnomecanvasmm'].ParseConfig ('pkg-config --cflags --libs libgnomecanvasmm-2.6')
550 # cannot use system one for the time being
553 libraries['sndfile'] = LibraryInfo(LIBS='libsndfile',
554 LIBPATH='#libs/libsndfile',
555 CPPPATH=['#libs/libsndfile', '#libs/libsndfile/src'])
557 # libraries['libglademm'] = LibraryInfo()
558 # libraries['libglademm'].ParseConfig ('pkg-config --cflags --libs libglademm-2.4')
560 # libraries['flowcanvas'] = LibraryInfo(LIBS='flowcanvas', LIBPATH='#/libs/flowcanvas', CPPPATH='#libs/flowcanvas')
561 libraries['soundtouch'] = LibraryInfo()
562 libraries['soundtouch'].ParseConfig ('pkg-config --cflags --libs libSoundTouch')
564 libraries['appleutility'] = LibraryInfo(LIBS='libappleutility',
565 LIBPATH='#libs/appleutility',
566 CPPPATH='#libs/appleutility')
580 subdirs = ['libs/fst'] + subdirs + ['vst']
583 subdirs = subdirs + ['libs/appleutility']
592 libraries['sigc2'] = LibraryInfo(LIBS='sigc++2',
593 LIBPATH='#libs/sigc++2',
594 CPPPATH='#libs/sigc++2')
595 libraries['glibmm2'] = LibraryInfo(LIBS='glibmm2',
596 LIBPATH='#libs/glibmm2',
597 CPPPATH='#libs/glibmm2')
598 libraries['pangomm'] = LibraryInfo(LIBS='pangomm',
599 LIBPATH='#libs/gtkmm2/pango',
600 CPPPATH='#libs/gtkmm2/pango')
601 libraries['atkmm'] = LibraryInfo(LIBS='atkmm',
602 LIBPATH='#libs/gtkmm2/atk',
603 CPPPATH='#libs/gtkmm2/atk')
604 libraries['gdkmm2'] = LibraryInfo(LIBS='gdkmm2',
605 LIBPATH='#libs/gtkmm2/gdk',
606 CPPPATH='#libs/gtkmm2/gdk')
607 libraries['gtkmm2'] = LibraryInfo(LIBS='gtkmm2',
608 LIBPATH="#libs/gtkmm2/gtk",
609 CPPPATH='#libs/gtkmm2/gtk/')
610 libraries['libgnomecanvasmm'] = LibraryInfo(LIBS='libgnomecanvasmm',
611 LIBPATH='#libs/libgnomecanvasmm',
612 CPPPATH='#libs/libgnomecanvasmm')
614 libraries['soundtouch'] = LibraryInfo(LIBS='soundtouch',
615 LIBPATH='#libs/soundtouch',
616 CPPPATH=['#libs', '#libs/soundtouch'])
617 libraries['sndfile'] = LibraryInfo(LIBS='libsndfile',
618 LIBPATH='#libs/libsndfile',
619 CPPPATH=['#libs/libsndfile', '#libs/libsndfile/src'])
620 # libraries['libglademm'] = LibraryInfo(LIBS='libglademm',
621 # LIBPATH='#libs/libglademm',
622 # CPPPATH='#libs/libglademm')
623 libraries['appleutility'] = LibraryInfo(LIBS='libappleutility',
624 LIBPATH='#libs/appleutility',
625 CPPPATH='#libs/appleutility')
641 subdirs = ['libs/fst'] + subdirs + ['vst']
644 subdirs = subdirs + ['libs/appleutility']
652 'libs/libgnomecanvasmm',
659 # always build the LGPL control protocol lib, since we link against it ourselves
660 # ditto for generic MIDI
663 surface_subdirs = [ 'libs/surfaces/control_protocol', 'libs/surfaces/generic_midi' ]
667 surface_subdirs += [ 'libs/surfaces/tranzport' ]
668 if os.access ('libs/surfaces/sony9pin', os.F_OK):
669 surface_subdirs += [ 'libs/surfaces/sony9pin' ]
671 opts.Save('scache.conf', env)
672 Help(opts.GenerateHelpText(env))
674 if os.environ.has_key('PATH'):
675 env.Append(PATH = os.environ['PATH'])
677 if os.environ.has_key('PKG_CONFIG_PATH'):
678 env.Append(PKG_CONFIG_PATH = os.environ['PKG_CONFIG_PATH'])
680 if os.environ.has_key('CC'):
681 env['CC'] = os.environ['CC']
683 if os.environ.has_key('CXX'):
684 env['CXX'] = os.environ['CXX']
686 if os.environ.has_key('DISTCC_HOSTS'):
687 env['ENV']['DISTCC_HOSTS'] = os.environ['DISTCC_HOSTS']
688 env['ENV']['HOME'] = os.environ['HOME']
690 final_prefix = '$PREFIX'
691 install_prefix = '$DESTDIR/$PREFIX'
693 subst_dict['INSTALL_PREFIX'] = install_prefix;
695 if env['PREFIX'] == '/usr':
696 final_config_prefix = '/etc'
698 final_config_prefix = env['PREFIX'] + '/etc'
700 config_prefix = '$DESTDIR' + final_config_prefix
702 # For colorgcc ( so says the wiki, but it's still not working :/ anyone? )
703 if os.environ.has_key('PATH'):
704 env['PATH'] = os.environ['PATH']
705 if os.environ.has_key('TERM'):
706 env['TERM'] = os.environ['TERM']
707 if os.environ.has_key('HOME'):
708 env['HOME'] = os.environ['HOME']
711 # SCons should really do this for us
713 conf = Configure (env)
715 have_cxx = conf.TryAction (Action (env['CXX'] + ' --version'))
717 print "This system has no functional C++ compiler. You cannot build Ardour from source without one."
720 print "Congratulations, you have a functioning C++ compiler."
725 # Compiler flags and other system-dependent stuff
729 debug_flags = [ '-g' ]
731 # guess at the platform, used to define compiler flags
733 config_guess = os.popen("tools/config.guess").read()[:-1]
739 config = config_guess.split ("-")
741 print "system triple: " + config_guess
744 if env['DIST_TARGET'] == 'auto':
745 if config[config_arch] == 'apple':
746 # The [.] matches to the dot after the major version, "." would match any character
747 if re.search ("darwin[0-7][.]", config[config_kernel]) != None:
748 env['DIST_TARGET'] = 'panther'
750 env['DIST_TARGET'] = 'tiger'
752 if re.search ("x86_64", config[config_cpu]) != None:
753 env['DIST_TARGET'] = 'x86_64'
754 elif re.search("i[0-5]86", config[config_cpu]) != None:
755 env['DIST_TARGET'] = 'i386'
756 elif re.search("powerpc", config[config_cpu]) != None:
757 env['DIST_TARGET'] = 'powerpc'
759 env['DIST_TARGET'] = 'i686'
760 print "\n*******************************"
761 print "detected DIST_TARGET = " + env['DIST_TARGET']
762 print "*******************************\n"
765 if config[config_cpu] == 'powerpc' and env['DIST_TARGET'] != 'none':
767 # Apple/PowerPC optimization options
769 # -mcpu=7450 does not reliably work with gcc 3.*
771 if env['DIST_TARGET'] == 'panther' or env['DIST_TARGET'] == 'tiger':
772 if config[config_arch] == 'apple':
773 opt_flags.extend ([ "-mcpu=7450", "-faltivec"])
775 opt_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
777 opt_flags.extend([ "-mcpu=750", "-mmultiple" ])
778 opt_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
780 elif ((re.search ("i[0-9]86", config[config_cpu]) != None) or (re.search ("x86_64", config[config_cpu]) != None)) and env['DIST_TARGET'] != 'none':
782 build_host_supports_sse = 0
784 debug_flags.append ("-DARCH_X86")
785 opt_flags.append ("-DARCH_X86")
787 if config[config_kernel] == 'linux' :
789 if env['DIST_TARGET'] != 'i386':
791 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
792 x86_flags = flag_line.split (": ")[1:][0].split (' ')
794 if "mmx" in x86_flags:
795 opt_flags.append ("-mmmx")
796 if "sse" in x86_flags:
797 build_host_supports_sse = 1
798 if "3dnow" in x86_flags:
799 opt_flags.append ("-m3dnow")
801 if config[config_cpu] == "i586":
802 opt_flags.append ("-march=i586")
803 elif config[config_cpu] == "i686":
804 opt_flags.append ("-march=i686")
806 if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) and build_host_supports_sse:
807 opt_flags.extend (["-msse", "-mfpmath=sse"])
808 debug_flags.extend (["-msse", "-mfpmath=sse"])
809 # end of processor-specific section
811 # optimization section
812 if env['FPU_OPTIMIZATION']:
813 if env['DIST_TARGET'] == 'tiger':
814 opt_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS")
815 debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS")
816 libraries['core'].Append(LINKFLAGS= '-framework Accelerate')
817 elif env['DIST_TARGET'] == 'i686' or env['DIST_TARGET'] == 'x86_64':
818 opt_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
819 debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
820 if env['DIST_TARGET'] == 'x86_64':
821 opt_flags.append ("-DUSE_X86_64_ASM")
822 debug_flags.append ("-DUSE_X86_64_ASM")
823 if build_host_supports_sse != 1:
824 print "\nWarning: you are building Ardour with SSE support even though your system does not support these instructions. (This may not be an error, especially if you are a package maintainer)"
825 # end optimization section
828 # save off guessed arch element in an env
830 env.Append(CONFIG_ARCH=config[config_arch])
834 # ARCH="..." overrides all
837 if env['ARCH'] != '':
838 opt_flags = env['ARCH'].split()
841 # prepend boiler plate optimization flags
846 "-fomit-frame-pointer",
851 if env['DEBUG'] == 1:
852 env.Append(CCFLAGS=" ".join (debug_flags))
854 env.Append(CCFLAGS=" ".join (opt_flags))
860 env.Append(CCFLAGS="-Wall")
861 env.Append(CXXFLAGS="-Woverloaded-virtual")
863 if env['EXTRA_WARN']:
864 env.Append(CCFLAGS="-Wextra -pedantic")
865 env.Append(CXXFLAGS="-ansi")
868 env.Append(CCFLAGS="-DHAVE_LIBLO")
871 # everybody needs this
874 env.Merge ([ libraries['core'] ])
877 # fix scons nitpickiness on APPLE
880 if env['DIST_TARGET'] == 'panther' or env['DIST_TARGET'] == 'tiger':
881 env.Append(CCFLAGS="-I/opt/local/include", LINKFLAGS="-L/opt/local/lib")
887 conf = Configure (env)
889 nls_error = 'This system is not configured for internationalized applications. An english-only version will be built:'
890 print 'Checking for internationalization support ...'
891 have_gettext = conf.TryAction(Action('xgettext --version'))
892 if have_gettext[0] != 1:
893 nls_error += ' No xgettext command.'
896 print "Found xgettext"
898 have_msgmerge = conf.TryAction(Action('msgmerge --version'))
899 if have_msgmerge[0] != 1:
900 nls_error += ' No msgmerge command.'
903 print "Found msgmerge"
905 if not conf.CheckCHeader('libintl.h'):
906 nls_error += ' No libintl.h.'
912 print "International version will be built."
916 env.Append(CCFLAGS="-DENABLE_NLS")
918 Export('env install_prefix final_prefix config_prefix final_config_prefix libraries i18n version subst_dict')
921 # the configuration file may be system dependent
924 conf = env.Configure ()
926 if conf.CheckCHeader('/System/Library/Frameworks/CoreAudio.framework/Versions/A/Headers/CoreAudio.h'):
927 subst_dict['%JACK_INPUT%'] = "coreaudio:Built-in Audio:in"
928 subst_dict['%JACK_OUTPUT%'] = "coreaudio:Built-in Audio:out"
930 subst_dict['%JACK_INPUT%'] = "alsa_pcm:playback_"
931 subst_dict['%JACK_OUTPUT%'] = "alsa_pcm:capture_"
933 # posix_memalign available
934 if not conf.CheckFunc('posix_memalign'):
935 print 'Did not find posix_memalign(), using malloc'
936 env.Append(CCFLAGS='-DNO_POSIX_MEMALIGN')
941 rcbuild = env.SubstInFile ('ardour.rc','ardour.rc.in', SUBST_DICT = subst_dict)
943 env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour_system.rc'))
944 env.Alias('install', env.Install(os.path.join(config_prefix, 'ardour2'), 'ardour.rc'))
950 Precious (env['DISTTREE'])
953 # note the special "cleanfirst" source name. this triggers removal
954 # of the existing disttree
957 env.Distribute (env['DISTTREE'],
959 'COPYING', 'PACKAGER_README', 'README',
964 glob.glob ('DOCUMENTATION/AUTHORS*') +
965 glob.glob ('DOCUMENTATION/CONTRIBUTORS*') +
966 glob.glob ('DOCUMENTATION/TRANSLATORS*') +
967 glob.glob ('DOCUMENTATION/BUILD*') +
968 glob.glob ('DOCUMENTATION/FAQ*') +
969 glob.glob ('DOCUMENTATION/README*')
972 srcdist = env.Tarball(env['TARBALL'], env['DISTTREE'])
973 env.Alias ('srctar', srcdist)
975 # don't leave the distree around
977 env.AddPreAction (env['DISTTREE'], Action ('rm -rf ' + str (File (env['DISTTREE']))))
978 env.AddPostAction (srcdist, Action ('rm -rf ' + str (File (env['DISTTREE']))))
984 for subdir in coredirs:
985 SConscript (subdir + '/SConscript')
987 for sublistdir in [ subdirs, gtk_subdirs, surface_subdirs ]:
988 for subdir in sublistdir:
989 SConscript (subdir + '/SConscript')
992 env.Clean ('scrub', [ 'scache.conf', '.sconf_temp', '.sconsign.dblite', 'config.log'])