tomwalters@157: # Copyright 2006-2010, Willem van Engen, Thomas Walters tomwalters@157: # tomwalters@157: # AIM-C: A C++ implementation of the Auditory Image Model tomwalters@157: # http://www.acousticscale.org/AIMC tomwalters@157: # tomwalters@157: # Licensed under the Apache License, Version 2.0 (the "License"); tomwalters@157: # you may not use this file except in compliance with the License. tomwalters@157: # You may obtain a copy of the License at tomwalters@157: # tomwalters@157: # http://www.apache.org/licenses/LICENSE-2.0 tomwalters@157: # tomwalters@157: # Unless required by applicable law or agreed to in writing, software tomwalters@157: # distributed under the License is distributed on an "AS IS" BASIS, tomwalters@157: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. tomwalters@157: # See the License for the specific language governing permissions and tomwalters@157: # limitations under the License. tomwalters@157: tomwalters@157: ## @author Thomas Walters tomwalters@157: # @author Willem van Engen tomwalters@157: # @date created 2010/02/02 tomwalters@157: # @version \$Id$ tomwalters@157: tomwalters@157: """@package SConstruct tomwalters@157: SConstruct file for the aimc project tomwalters@157: tomwalters@157: """ tomwalters@157: tomwalters@157: import os tomwalters@157: import shutil tomwalters@157: tomwalters@157: # Sources common to every version tomwalters@157: common_sources = ['Support/Common.cc', tomwalters@157: 'Support/FileList.cc', tomwalters@157: 'Support/SignalBank.cc', tomwalters@157: 'Support/Parameters.cc', tomwalters@157: 'Support/Module.cc', tomwalters@157: 'Support/ModuleFactory.cc', tomwalters@157: 'Modules/Input/ModuleFileInput.cc', tomwalters@157: 'Modules/BMM/ModuleGammatone.cc', tomwalters@157: 'Modules/BMM/ModulePZFC.cc', tomwalters@157: 'Modules/NAP/ModuleHCL.cc', tomwalters@157: 'Modules/Strobes/ModuleParabola.cc', tomwalters@157: 'Modules/Strobes/ModuleLocalMax.cc', tomwalters@157: 'Modules/SAI/ModuleSAI.cc', tomwalters@157: 'Modules/SNR/ModuleNoise.cc', tomwalters@157: 'Modules/SSI/ModuleSSI.cc', tomwalters@157: 'Modules/Profile/ModuleSlice.cc', tomwalters@157: 'Modules/Profile/ModuleScaler.cc', tomwalters@157: 'Modules/Features/ModuleGaussians.cc', tomwalters@157: 'Modules/Output/FileOutputHTK.cc', tomwalters@157: 'Modules/Output/FileOutputAIMC.cc'] tomwalters@157: tomwalters@157: # File which contains main() tomwalters@157: #sources = common_sources + ['Main/AIMCopy_SSI_Features_v4_PZFC.cc'] tomwalters@157: sources = common_sources + ['Main/aimc.cc'] tomwalters@157: tomwalters@157: # Test sources tomwalters@157: test_sources = ['Modules/Profile/ModuleSlice_unittest.cc'] tomwalters@157: test_sources += common_sources tomwalters@157: tomwalters@157: # Define the command-line options for running scons tomwalters@157: options = Variables() tomwalters@157: options.Add(BoolVariable('mingw', tomwalters@157: 'Compile on Windows using mingw rather than msvc', tomwalters@157: False)) tomwalters@157: options.Add(BoolVariable('symbols', tomwalters@157: 'Add debuging symbols when compiling on gcc', tomwalters@157: False)) tomwalters@157: tomwalters@157: # Environment variables tomwalters@157: env = Environment(options = options, ENV = os.environ) tomwalters@157: if env['mingw']: tomwalters@157: # SCons Defaults to MSVC if installed on Windows. tomwalters@157: env = Environment(options = opts, ENV = os.environ, tools = ['mingw']) tomwalters@157: tomwalters@157: # Platform tomwalters@157: build_platform = env['PLATFORM'] tomwalters@157: target_platform = build_platform tomwalters@157: tomwalters@157: # Build products location and executable name tomwalters@157: build_dir = os.path.join('build', target_platform + '-release') tomwalters@157: target_executable = 'aimc' tomwalters@157: test_executable = 'aimc_tests' tomwalters@157: tomwalters@157: # Create build products directory if necessary tomwalters@157: if not os.path.exists(build_dir): tomwalters@157: os.makedirs(build_dir) tomwalters@157: env.SConsignFile(os.path.join(build_dir,'.sconsign')) tomwalters@157: tomwalters@157: # Set any platform-specific environment variables and options tomwalters@157: if target_platform == 'win32': tomwalters@157: env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32', tomwalters@157: 'WINVER=0x0400', '_CONSOLE']) tomwalters@157: elif target_platform == 'darwin': tomwalters@157: env.AppendUnique(CPPDEFINES = ['_MACOSX']) tomwalters@157: tomwalters@157: # Compiler selection based on platform tomwalters@157: # compiler can be one of: gcc msvc tomwalters@157: compiler = 'gcc' tomwalters@157: if (build_platform == 'win32' tomwalters@157: and target_platform == 'win32' tomwalters@157: and not env['mingw']): tomwalters@157: compiler = 'msvc' tomwalters@157: tomwalters@157: # Compiler-specific options: tomwalters@157: # Microsoft visual studio tomwalters@157: if compiler == 'msvc': tomwalters@157: env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc']) tomwalters@157: env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE', tomwalters@157: '_RINT_REQUIRED']) tomwalters@157: env.AppendUnique(CPPFLAGS = ['/Ox']) tomwalters@157: env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT']) tomwalters@157: tomwalters@157: # GNU compiler collection tomwalters@157: elif compiler == 'gcc': tomwalters@157: env['STRIP'] = 'strip' tomwalters@157: env.AppendUnique(CPPFLAGS = ['-Wall']) tomwalters@157: env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer']) tomwalters@157: if env['symbols']: tomwalters@157: env.AppendUnique(CPPFLAGS = ['-g']) tomwalters@157: if env['mingw']: tomwalters@157: if not env['PLATFORM'] == 'win32': tomwalters@157: print('Cross-compilation for Windows is not supported') tomwalters@157: Exit(1) tomwalters@157: else: tomwalters@157: print('Unsupported compiler: ' + compiler) tomwalters@157: Exit(1) tomwalters@157: tomwalters@157: # To make a statically-linked version for os 10.4 and up... tomwalters@157: #if build_platform == 'darwin': tomwalters@157: # env.AppendUnique(CPPFLAGS = ['-arch', 'i386']) tomwalters@157: # env.AppendUnique(LINKFLAGS = ['-arch', 'i386']) tomwalters@157: # env.AppendUnique(LINKFLAGS = ['-Wl']) tomwalters@157: # env.AppendUnique(LINKFLAGS = ['-search_paths_first']) tomwalters@157: # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4']) tomwalters@157: # env.AppendUnique(GCC_VERSION = ['4.0']) tomwalters@157: # env.Replace(CC = ['gcc-4.0']) tomwalters@157: # env.Replace(CXX = ['gcc-4.0']) tomwalters@157: # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4']) tomwalters@157: # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg'] tomwalters@157: if not target_platform == 'win32': tomwalters@157: # On windows, utf support is builtin for SimpleIni tomwalters@157: # but not on other platforms tomwalters@157: sources += ['Support/ConvertUTF.c'] tomwalters@157: tomwalters@157: # Place the build products in the corect place tomwalters@157: env.VariantDir('#' + build_dir, '#', duplicate = 0) tomwalters@157: tomwalters@157: # Look for the sources in the correct place tomwalters@157: env.Append(CPPPATH = ['#src']) tomwalters@157: tomwalters@157: # Dependencies tomwalters@157: deplibs = ['sndfile'] tomwalters@157: tomwalters@157: for depname in deplibs: tomwalters@157: env.ParseConfig('pkg-config --cflags --libs ' + depname) tomwalters@157: tomwalters@157: env.AppendUnique(LIBS = deplibs) tomwalters@157: tomwalters@157: tomwalters@157: # Builder for the main program tomwalters@157: program = env.Program(target = os.path.join(build_dir, target_executable), tomwalters@157: source = map(lambda x: '#' + build_dir + '/src/' + x, tomwalters@157: sources)) tomwalters@157: env.Alias(target_executable, os.path.join(build_dir, target_executable)) tomwalters@157: env.Default(program) tomwalters@157: tomwalters@157: #test_env = env.Clone() tomwalters@157: #test_libs = ['gtest', 'gtest_main'] tomwalters@157: ##for depname in test_libs: tomwalters@157: ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname) tomwalters@157: #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'], tomwalters@157: # CPPPATH = ['/usr/local/lib'], tomwalters@157: # LIBS = test_libs) tomwalters@157: # tomwalters@157: #test = test_env.Program(target = os.path.join(build_dir, test_executable), tomwalters@157: # source = map(lambda x: '#' + build_dir + '/src/' + x, tomwalters@157: # test_sources)) tomwalters@157: #env.Alias('test', os.path.join(build_dir, test_executable))