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