tomwalters@268: # Copyright 2006-2010, Willem van Engen, Thomas Walters tomwalters@268: # tomwalters@268: # AIM-C: A C++ implementation of the Auditory Image Model tomwalters@268: # http://www.acousticscale.org/AIMC tomwalters@268: # tomwalters@268: # This program is free software: you can redistribute it and/or modify tomwalters@268: # it under the terms of the GNU General Public License as published by tomwalters@268: # the Free Software Foundation, either version 3 of the License, or tomwalters@268: # (at your option) any later version. tomwalters@268: # tomwalters@268: # This program is distributed in the hope that it will be useful, tomwalters@268: # but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@268: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@268: # GNU General Public License for more details. tomwalters@268: # tomwalters@268: # You should have received a copy of the GNU General Public License tomwalters@268: # along with this program. If not, see . tomwalters@268: tomwalters@268: ## @author Thomas Walters tomwalters@268: # @author Willem van Engen tomwalters@268: # @date created 2010/02/02 tomwalters@268: # @version \$Id$ tomwalters@268: tomwalters@268: """@package SConstruct tomwalters@268: SConstruct file for the aimc project tomwalters@268: tomwalters@268: """ tomwalters@268: tomwalters@268: import os tomwalters@268: import shutil tomwalters@268: tomwalters@289: # Sources common to every version tomwalters@289: common_sources = ['Support/Common.cc', tomwalters@296: 'Support/FileList.cc', tomwalters@289: 'Support/SignalBank.cc', tomwalters@289: 'Support/Parameters.cc', tomwalters@289: 'Support/Module.cc', tomwalters@296: 'Support/ModuleFactory.cc', tomwalters@289: 'Modules/Input/ModuleFileInput.cc', tomwalters@289: 'Modules/BMM/ModuleGammatone.cc', tomwalters@289: 'Modules/BMM/ModulePZFC.cc', tomwalters@289: 'Modules/NAP/ModuleHCL.cc', tomwalters@289: 'Modules/Strobes/ModuleParabola.cc', tomwalters@305: 'Modules/Strobes/ModuleLocalMax.cc', tomwalters@289: 'Modules/SAI/ModuleSAI.cc', tomwalters@305: 'Modules/SNR/ModuleNoise.cc', tomwalters@289: 'Modules/SSI/ModuleSSI.cc', tomwalters@289: 'Modules/Profile/ModuleSlice.cc', tomwalters@292: 'Modules/Profile/ModuleScaler.cc', tomwalters@289: 'Modules/Features/ModuleGaussians.cc', tomwalters@289: 'Modules/Output/FileOutputHTK.cc'] tomwalters@289: tomwalters@289: # File which contains main() tomwalters@305: sources = common_sources + ['Main/AIMCopy_SSI_Features.cc'] tomwalters@289: tomwalters@289: # Test sources tomwalters@289: test_sources = ['Modules/Profile/ModuleSlice_unittest.cc'] tomwalters@289: test_sources += common_sources tomwalters@289: tomwalters@268: # Define the command-line options for running scons tomwalters@268: options = Variables() tomwalters@268: options.Add(BoolVariable('mingw', tomwalters@268: 'Compile on Windows using mingw rather than msvc', tomwalters@268: False)) tomwalters@268: tomwalters@268: # Environment variables tomwalters@268: env = Environment(options = options, ENV = os.environ) tomwalters@268: if env['mingw']: tomwalters@268: # SCons Defaults to MSVC if installed on Windows. tomwalters@268: env = Environment(options = opts, ENV = os.environ, tools = ['mingw']) tomwalters@268: tomwalters@268: # Platform tomwalters@268: build_platform = env['PLATFORM'] tomwalters@268: target_platform = build_platform tomwalters@268: tomwalters@268: # Build products location and executable name tomwalters@268: build_dir = os.path.join('build', target_platform + '-release') tomwalters@298: target_executable = 'AIMCopy' tomwalters@289: test_executable = 'aimc_tests' tomwalters@268: tomwalters@268: # Create build products directory if necessary tomwalters@268: if not os.path.exists(build_dir): tomwalters@268: os.makedirs(build_dir) tomwalters@268: env.SConsignFile(os.path.join(build_dir,'.sconsign')) tomwalters@268: tomwalters@268: # Set any platform-specific environment variables and options tomwalters@268: if target_platform == 'win32': tomwalters@268: env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32', tomwalters@268: 'WINVER=0x0400', '_CONSOLE']) tomwalters@268: elif target_platform == 'darwin': tomwalters@268: env.AppendUnique(CPPDEFINES = ['_MACOSX']) tomwalters@268: tomwalters@268: # Compiler selection based on platform tomwalters@268: # compiler can be one of: gcc msvc tomwalters@268: compiler = 'gcc' tomwalters@268: if (build_platform == 'win32' tomwalters@268: and target_platform == 'win32' tomwalters@268: and not env['mingw']): tomwalters@268: compiler = 'msvc' tomwalters@268: tomwalters@268: # Compiler-specific options: tomwalters@268: # Microsoft visual studio tomwalters@268: if compiler == 'msvc': tomwalters@268: env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc']) tomwalters@268: env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE', tomwalters@268: '_RINT_REQUIRED']) tomwalters@268: env.AppendUnique(CPPFLAGS = ['/Ox']) tomwalters@268: env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT']) tomwalters@268: tomwalters@268: # GNU compiler collection tomwalters@268: elif compiler == 'gcc': tomwalters@268: env['STRIP'] = 'strip' tomwalters@268: env.AppendUnique(CPPFLAGS = ['-Wall']) tomwalters@268: env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer']) tomwalters@268: if env['mingw']: tomwalters@268: if not env['PLATFORM'] == 'win32': tomwalters@268: print('Cross-compilation for Windows is not supported') tomwalters@268: Exit(1) tomwalters@268: else: tomwalters@268: print('Unsupported compiler: ' + compiler) tomwalters@268: Exit(1) tomwalters@298: tomwalters@298: # To make a statically-linked version for os 10.4 and up... tomwalters@298: #if build_platform == 'darwin': tomwalters@298: # env.AppendUnique(CPPFLAGS = ['-arch', 'i386']) tomwalters@298: # env.AppendUnique(LINKFLAGS = ['-arch', 'i386']) tomwalters@298: # env.AppendUnique(LINKFLAGS = ['-Wl']) tomwalters@298: # env.AppendUnique(LINKFLAGS = ['-search_paths_first']) tomwalters@298: # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4']) tomwalters@298: # env.AppendUnique(GCC_VERSION = ['4.0']) tomwalters@298: # env.Replace(CC = ['gcc-4.0']) tomwalters@298: # env.Replace(CXX = ['gcc-4.0']) tomwalters@298: # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4']) tomwalters@299: # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg'] tomwalters@268: if not target_platform == 'win32': tomwalters@268: # On windows, utf support is builtin for SimpleIni tomwalters@283: # but not on other platforms tomwalters@289: sources += ['Support/ConvertUTF.c'] tomwalters@268: tomwalters@268: # Place the build products in the corect place tomwalters@289: env.VariantDir('#' + build_dir, '#', duplicate = 0) tomwalters@268: tomwalters@268: # Look for the sources in the correct place tomwalters@293: env.Append(CPPPATH = ['#src']) tomwalters@268: tomwalters@268: # Dependencies tomwalters@299: deplibs = ['sndfile'] tomwalters@275: tomwalters@275: for depname in deplibs: tomwalters@275: env.ParseConfig('pkg-config --cflags --libs ' + depname) tomwalters@275: tomwalters@268: env.AppendUnique(LIBS = deplibs) tomwalters@268: tomwalters@289: tomwalters@289: # Builder for the main program tomwalters@268: program = env.Program(target = os.path.join(build_dir, target_executable), tomwalters@268: source = map(lambda x: '#' + build_dir + '/src/' + x, tomwalters@268: sources)) tomwalters@289: env.Alias(target_executable, os.path.join(build_dir, target_executable)) tomwalters@268: env.Default(program) tomwalters@289: tomwalters@293: #test_env = env.Clone() tomwalters@293: #test_libs = ['gtest', 'gtest_main'] tomwalters@298: ##for depname in test_libs: tomwalters@298: ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname) tomwalters@293: #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'], tomwalters@293: # CPPPATH = ['/usr/local/lib'], tomwalters@293: # LIBS = test_libs) tomwalters@298: # tomwalters@293: #test = test_env.Program(target = os.path.join(build_dir, test_executable), tomwalters@293: # source = map(lambda x: '#' + build_dir + '/src/' + x, tomwalters@293: # test_sources)) tomwalters@293: #env.Alias('test', os.path.join(build_dir, test_executable))