annotate trunk/SConstruct @ 323:0f54006e91ea

- AIMCopy v5 for just smooth NAP features - Reporting of all modules and versions
author tomwalters
date Sun, 11 Jul 2010 03:46:06 +0000
parents c74acd46121b
children 6130fe7f6409
rev   line source
tomwalters@268 1 # Copyright 2006-2010, Willem van Engen, Thomas Walters
tomwalters@268 2 #
tomwalters@268 3 # AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@268 4 # http://www.acousticscale.org/AIMC
tomwalters@268 5 #
tomwalters@318 6 # Licensed under the Apache License, Version 2.0 (the "License");
tomwalters@318 7 # you may not use this file except in compliance with the License.
tomwalters@318 8 # You may obtain a copy of the License at
tomwalters@268 9 #
tomwalters@318 10 # http://www.apache.org/licenses/LICENSE-2.0
tomwalters@268 11 #
tomwalters@318 12 # Unless required by applicable law or agreed to in writing, software
tomwalters@318 13 # distributed under the License is distributed on an "AS IS" BASIS,
tomwalters@318 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
tomwalters@318 15 # See the License for the specific language governing permissions and
tomwalters@318 16 # limitations under the License.
tomwalters@268 17
tomwalters@268 18 ## @author Thomas Walters <tom@acousticscale.org>
tomwalters@268 19 # @author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@268 20 # @date created 2010/02/02
tomwalters@268 21 # @version \$Id$
tomwalters@268 22
tomwalters@268 23 """@package SConstruct
tomwalters@268 24 SConstruct file for the aimc project
tomwalters@268 25
tomwalters@268 26 """
tomwalters@268 27
tomwalters@268 28 import os
tomwalters@268 29 import shutil
tomwalters@268 30
tomwalters@289 31 # Sources common to every version
tomwalters@289 32 common_sources = ['Support/Common.cc',
tomwalters@296 33 'Support/FileList.cc',
tomwalters@289 34 'Support/SignalBank.cc',
tomwalters@289 35 'Support/Parameters.cc',
tomwalters@289 36 'Support/Module.cc',
tomwalters@296 37 'Support/ModuleFactory.cc',
tomwalters@289 38 'Modules/Input/ModuleFileInput.cc',
tomwalters@289 39 'Modules/BMM/ModuleGammatone.cc',
tomwalters@289 40 'Modules/BMM/ModulePZFC.cc',
tomwalters@289 41 'Modules/NAP/ModuleHCL.cc',
tomwalters@289 42 'Modules/Strobes/ModuleParabola.cc',
tomwalters@305 43 'Modules/Strobes/ModuleLocalMax.cc',
tomwalters@289 44 'Modules/SAI/ModuleSAI.cc',
tomwalters@305 45 'Modules/SNR/ModuleNoise.cc',
tomwalters@289 46 'Modules/SSI/ModuleSSI.cc',
tomwalters@289 47 'Modules/Profile/ModuleSlice.cc',
tomwalters@292 48 'Modules/Profile/ModuleScaler.cc',
tomwalters@289 49 'Modules/Features/ModuleGaussians.cc',
tomwalters@320 50 'Modules/Output/FileOutputHTK.cc',
tomwalters@320 51 'Modules/Output/FileOutputAIMC.cc']
tomwalters@289 52
tomwalters@289 53 # File which contains main()
tomwalters@320 54 #sources = common_sources + ['Main/AIMCopy_SSI_Features_v4_PZFC.cc']
tomwalters@323 55 sources = common_sources + ['Main/AIMCopy_SSI_Features_v5_smooth_nap.cc']
tomwalters@289 56
tomwalters@289 57 # Test sources
tomwalters@289 58 test_sources = ['Modules/Profile/ModuleSlice_unittest.cc']
tomwalters@289 59 test_sources += common_sources
tomwalters@289 60
tomwalters@268 61 # Define the command-line options for running scons
tomwalters@268 62 options = Variables()
tomwalters@268 63 options.Add(BoolVariable('mingw',
tomwalters@268 64 'Compile on Windows using mingw rather than msvc',
tomwalters@268 65 False))
tomwalters@309 66 options.Add(BoolVariable('symbols',
tomwalters@309 67 'Add debuging symbols when compiling on gcc',
tomwalters@309 68 False))
tomwalters@268 69
tomwalters@268 70 # Environment variables
tomwalters@268 71 env = Environment(options = options, ENV = os.environ)
tomwalters@268 72 if env['mingw']:
tomwalters@268 73 # SCons Defaults to MSVC if installed on Windows.
tomwalters@268 74 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@268 75
tomwalters@268 76 # Platform
tomwalters@268 77 build_platform = env['PLATFORM']
tomwalters@268 78 target_platform = build_platform
tomwalters@268 79
tomwalters@268 80 # Build products location and executable name
tomwalters@268 81 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@323 82 #target_executable = 'aimc'
tomwalters@323 83 target_executable = 'AIMCopy'
tomwalters@289 84 test_executable = 'aimc_tests'
tomwalters@268 85
tomwalters@268 86 # Create build products directory if necessary
tomwalters@268 87 if not os.path.exists(build_dir):
tomwalters@268 88 os.makedirs(build_dir)
tomwalters@268 89 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@268 90
tomwalters@268 91 # Set any platform-specific environment variables and options
tomwalters@268 92 if target_platform == 'win32':
tomwalters@268 93 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@268 94 'WINVER=0x0400', '_CONSOLE'])
tomwalters@268 95 elif target_platform == 'darwin':
tomwalters@268 96 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@268 97
tomwalters@268 98 # Compiler selection based on platform
tomwalters@268 99 # compiler can be one of: gcc msvc
tomwalters@268 100 compiler = 'gcc'
tomwalters@268 101 if (build_platform == 'win32'
tomwalters@268 102 and target_platform == 'win32'
tomwalters@268 103 and not env['mingw']):
tomwalters@268 104 compiler = 'msvc'
tomwalters@268 105
tomwalters@268 106 # Compiler-specific options:
tomwalters@268 107 # Microsoft visual studio
tomwalters@268 108 if compiler == 'msvc':
tomwalters@268 109 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tomwalters@268 110 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@268 111 '_RINT_REQUIRED'])
tomwalters@268 112 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@268 113 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@268 114
tomwalters@268 115 # GNU compiler collection
tomwalters@268 116 elif compiler == 'gcc':
tomwalters@268 117 env['STRIP'] = 'strip'
tomwalters@268 118 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@268 119 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
tomwalters@309 120 if env['symbols']:
tomwalters@309 121 env.AppendUnique(CPPFLAGS = ['-g'])
tomwalters@268 122 if env['mingw']:
tomwalters@268 123 if not env['PLATFORM'] == 'win32':
tomwalters@268 124 print('Cross-compilation for Windows is not supported')
tomwalters@268 125 Exit(1)
tomwalters@268 126 else:
tomwalters@268 127 print('Unsupported compiler: ' + compiler)
tomwalters@268 128 Exit(1)
tomwalters@298 129
tomwalters@298 130 # To make a statically-linked version for os 10.4 and up...
tomwalters@298 131 #if build_platform == 'darwin':
tomwalters@298 132 # env.AppendUnique(CPPFLAGS = ['-arch', 'i386'])
tomwalters@298 133 # env.AppendUnique(LINKFLAGS = ['-arch', 'i386'])
tomwalters@298 134 # env.AppendUnique(LINKFLAGS = ['-Wl'])
tomwalters@298 135 # env.AppendUnique(LINKFLAGS = ['-search_paths_first'])
tomwalters@298 136 # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4'])
tomwalters@298 137 # env.AppendUnique(GCC_VERSION = ['4.0'])
tomwalters@298 138 # env.Replace(CC = ['gcc-4.0'])
tomwalters@298 139 # env.Replace(CXX = ['gcc-4.0'])
tomwalters@298 140 # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4'])
tomwalters@299 141 # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg']
tomwalters@268 142 if not target_platform == 'win32':
tomwalters@268 143 # On windows, utf support is builtin for SimpleIni
tomwalters@283 144 # but not on other platforms
tomwalters@289 145 sources += ['Support/ConvertUTF.c']
tomwalters@268 146
tomwalters@268 147 # Place the build products in the corect place
tomwalters@289 148 env.VariantDir('#' + build_dir, '#', duplicate = 0)
tomwalters@268 149
tomwalters@268 150 # Look for the sources in the correct place
tomwalters@293 151 env.Append(CPPPATH = ['#src'])
tomwalters@268 152
tomwalters@268 153 # Dependencies
tomwalters@299 154 deplibs = ['sndfile']
tomwalters@275 155
tomwalters@275 156 for depname in deplibs:
tomwalters@275 157 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@275 158
tomwalters@268 159 env.AppendUnique(LIBS = deplibs)
tomwalters@268 160
tomwalters@289 161
tomwalters@289 162 # Builder for the main program
tomwalters@268 163 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@268 164 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@268 165 sources))
tomwalters@289 166 env.Alias(target_executable, os.path.join(build_dir, target_executable))
tomwalters@268 167 env.Default(program)
tomwalters@289 168
tomwalters@293 169 #test_env = env.Clone()
tomwalters@293 170 #test_libs = ['gtest', 'gtest_main']
tomwalters@298 171 ##for depname in test_libs:
tomwalters@298 172 ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@293 173 #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'],
tomwalters@293 174 # CPPPATH = ['/usr/local/lib'],
tomwalters@293 175 # LIBS = test_libs)
tomwalters@298 176 #
tomwalters@293 177 #test = test_env.Program(target = os.path.join(build_dir, test_executable),
tomwalters@293 178 # source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@293 179 # test_sources))
tomwalters@293 180 #env.Alias('test', os.path.join(build_dir, test_executable))