#!/usr/bin/python import os, sys, glob options = Variables('options.cache', ARGUMENTS) options.Add(PathVariable('clam_prefix', 'The prefix where CLAM was installed', '')) options.Add(BoolVariable('release', 'Build CLAM Annotator enabling compiler optimizations', 'no') ) options.Add(BoolVariable('verbose', 'Display the full command line instead a short command description', 'no') ) if sys.platform=="linux2" : options.Add(BoolVariable('crossmingw', 'Using MinGW crosscompiler mode', 'no') ) def scanFiles(pattern, paths) : files = [] for path in paths : files+=glob.glob(path+"/"+pattern) return files def recursiveDirs(root) : return filter( (lambda a : a.rfind( ".svn")==-1 ), [ a[0] for a in os.walk(root)] ) def unique(list) : return dict.fromkeys(list).keys() toolchain='default' if sys.platform == 'win32': toolchain = 'mingw' env = Environment(ENV=os.environ, tools=[toolchain], options=options) options.Update(env) options.Save('options.cache', env) Help(options.GenerateHelpText(env)) env.SConsignFile() # Single signature file crosscompiling = env.has_key("crossmingw") and env["crossmingw"] isWindowsPlatform = sys.platform=='win32' or crosscompiling isLinuxPlatform = sys.platform=='linux2' and not crosscompiling isDarwinPlatform = sys.platform=='darwin' CLAMInstallDir = env['clam_prefix'] clam_sconstoolspath = os.path.join(CLAMInstallDir,'share','clam','sconstools') env.Tool('qt4', toolpath=[clam_sconstoolspath]) env.Tool('clam', toolpath=[clam_sconstoolspath]) env.Tool('nsis', toolpath=[clam_sconstoolspath]) if crosscompiling : env.Tool('crossmingw', toolpath=[clam_sconstoolspath]) env['CXXFILESUFFIX'] = '.cxx' env['QT4_UICDECLSUFFIX'] = '.hxx' env.moveIntermediateInto('generated') env.activateColorCommandLine() if not env['verbose']: env.ClamQuietCompilation() env.EnableQt4Modules([ 'QtCore', 'QtGui', 'QtOpenGL', ], debug=False, crosscompiling=crosscompiling, ) env.EnableClamModules([ 'clam_core', 'clam_audioio', 'clam_processing', ], CLAMInstallDir) libSourcePaths = [] libSourcePaths += recursiveDirs("plot") libSourcePaths += recursiveDirs("render") libSourcePaths += recursiveDirs("data") libSourcePaths += recursiveDirs("util") libSourcePaths += recursiveDirs("player") libSourcePaths += recursiveDirs("misc") libSourcePaths += recursiveDirs("widget") extraPaths = [] extraPaths += recursiveDirs("examples/utils") extraPaths += [ CLAMInstallDir+'/include', CLAMInstallDir+'/include/CLAM', # KLUDGE to keep old style includes ] includePaths = libSourcePaths + extraPaths sources = scanFiles('*.cxx', libSourcePaths) sources += filter( (lambda a : a.rfind( "moc_")==-1 ), sources ) sources += filter( (lambda a : a.rfind( "qrc_")==-1 ), sources ) uifiles = scanFiles("*.qt4.ui", libSourcePaths) if uifiles : uiheaders = env.Uic4(source=uifiles) qrcfiles = scanFiles("*.qrc", libSourcePaths) if qrcfiles : sources += env.Qrc(source=qrcfiles) sources = unique(sources) env.Append(CPPPATH=includePaths) examplesMainSources = [ "examples/src/audio_plot_example.cxx", "examples/src/fundamental_plot_example.cxx", "examples/src/segmentation_plot_example.cxx", "examples/src/sintracks_plot_example.cxx", "examples/src/spectrum_plot_example.cxx", "examples/src/spectrogram_plot_example.cxx", "examples/src/audio_stereo_plot_example.cxx", "examples/src/bpf_plot_example.cxx", "examples/src/multibpf_plot_example.cxx", "examples/src/playable_audio_plot_example.cxx", "examples/src/playable_audio_stereo_plot_example.cxx", "examples/src/playable_bpf_plot_example.cxx", "examples/src/playable_fundamental_plot_example.cxx", "examples/src/playable_multibpf_plot_example.cxx", ] if sys.platform=='darwin' : env.AppendUnique(CXXFLAGS="-F"+os.path.join(env['QTDIR'],'lib')) env.AppendUnique(LINKFLAGS="-F"+os.path.join(env['QTDIR'],'lib')) env.AppendUnique(LINKFLAGS='-framework QtCore') env.AppendUnique(LINKFLAGS='-framework QtGui') env.AppendUnique(LINKFLAGS='-framework QtOpenGL') env.AppendUnique(LINKFLAGS='-dynamic') # env.AppendUnique(FRAMEWORKPATH=[os.path.join(env['QTDIR'],'lib')]) # env.AppendUnique(FRAMEWORKS=['QtCore','QtGui','QtOpenGL']) exampleSources = scanFiles('*.cxx', ['examples/utils']) env.Append( CCFLAGS=['-g','-O3','-fomit-frame-pointer','-Wall'] ) staticLibrary = env.StaticLibrary(target='clam_vmqt4', source=sources) env.Append(LIBPATH='.') env.Prepend(LIBS='clam_vmqt4') examples = [] for main in examplesMainSources : executable = 'examples/'+os.path.splitext(os.path.basename(main))[0] examples += [ env.Program(target=executable, source = exampleSources + [main] ) ] env.Alias('examples',examples) env.Default(staticLibrary)