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