annotate trunk/SConstruct @ 305:ed91095d9240

-New AIMCopy main for the SSI features (temporary hack till I get a working module load system) -LocalMax strobe criterion. This is faster and better than the parabola version, which still seems buggy. -Noise generator module. Adds noise to a signal. Uses boost for the random number generator. -New options for the SSI -Slice now respects all its flags (oops!). -MATLAB functions for visualisation -Scripts for generating data to view in MATLAB -Script to download and build HTK - useful for running experiments
author tomwalters
date Thu, 25 Feb 2010 22:02:00 +0000
parents 57e6c567461c
children 1c58a6f354e2
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@268 6 # This program is free software: you can redistribute it and/or modify
tomwalters@268 7 # it under the terms of the GNU General Public License as published by
tomwalters@268 8 # the Free Software Foundation, either version 3 of the License, or
tomwalters@268 9 # (at your option) any later version.
tomwalters@268 10 #
tomwalters@268 11 # This program is distributed in the hope that it will be useful,
tomwalters@268 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@268 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@268 14 # GNU General Public License for more details.
tomwalters@268 15 #
tomwalters@268 16 # You should have received a copy of the GNU General Public License
tomwalters@268 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@268 18
tomwalters@268 19 ## @author Thomas Walters <tom@acousticscale.org>
tomwalters@268 20 # @author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@268 21 # @date created 2010/02/02
tomwalters@268 22 # @version \$Id$
tomwalters@268 23
tomwalters@268 24 """@package SConstruct
tomwalters@268 25 SConstruct file for the aimc project
tomwalters@268 26
tomwalters@268 27 """
tomwalters@268 28
tomwalters@268 29 import os
tomwalters@268 30 import shutil
tomwalters@268 31
tomwalters@289 32 # Sources common to every version
tomwalters@289 33 common_sources = ['Support/Common.cc',
tomwalters@296 34 'Support/FileList.cc',
tomwalters@289 35 'Support/SignalBank.cc',
tomwalters@289 36 'Support/Parameters.cc',
tomwalters@289 37 'Support/Module.cc',
tomwalters@296 38 'Support/ModuleFactory.cc',
tomwalters@289 39 'Modules/Input/ModuleFileInput.cc',
tomwalters@289 40 'Modules/BMM/ModuleGammatone.cc',
tomwalters@289 41 'Modules/BMM/ModulePZFC.cc',
tomwalters@289 42 'Modules/NAP/ModuleHCL.cc',
tomwalters@289 43 'Modules/Strobes/ModuleParabola.cc',
tomwalters@305 44 'Modules/Strobes/ModuleLocalMax.cc',
tomwalters@289 45 'Modules/SAI/ModuleSAI.cc',
tomwalters@305 46 'Modules/SNR/ModuleNoise.cc',
tomwalters@289 47 'Modules/SSI/ModuleSSI.cc',
tomwalters@289 48 'Modules/Profile/ModuleSlice.cc',
tomwalters@292 49 'Modules/Profile/ModuleScaler.cc',
tomwalters@289 50 'Modules/Features/ModuleGaussians.cc',
tomwalters@289 51 'Modules/Output/FileOutputHTK.cc']
tomwalters@289 52
tomwalters@289 53 # File which contains main()
tomwalters@305 54 sources = common_sources + ['Main/AIMCopy_SSI_Features.cc']
tomwalters@289 55
tomwalters@289 56 # Test sources
tomwalters@289 57 test_sources = ['Modules/Profile/ModuleSlice_unittest.cc']
tomwalters@289 58 test_sources += common_sources
tomwalters@289 59
tomwalters@268 60 # Define the command-line options for running scons
tomwalters@268 61 options = Variables()
tomwalters@268 62 options.Add(BoolVariable('mingw',
tomwalters@268 63 'Compile on Windows using mingw rather than msvc',
tomwalters@268 64 False))
tomwalters@268 65
tomwalters@268 66 # Environment variables
tomwalters@268 67 env = Environment(options = options, ENV = os.environ)
tomwalters@268 68 if env['mingw']:
tomwalters@268 69 # SCons Defaults to MSVC if installed on Windows.
tomwalters@268 70 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@268 71
tomwalters@268 72 # Platform
tomwalters@268 73 build_platform = env['PLATFORM']
tomwalters@268 74 target_platform = build_platform
tomwalters@268 75
tomwalters@268 76 # Build products location and executable name
tomwalters@268 77 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@298 78 target_executable = 'AIMCopy'
tomwalters@289 79 test_executable = 'aimc_tests'
tomwalters@268 80
tomwalters@268 81 # Create build products directory if necessary
tomwalters@268 82 if not os.path.exists(build_dir):
tomwalters@268 83 os.makedirs(build_dir)
tomwalters@268 84 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@268 85
tomwalters@268 86 # Set any platform-specific environment variables and options
tomwalters@268 87 if target_platform == 'win32':
tomwalters@268 88 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@268 89 'WINVER=0x0400', '_CONSOLE'])
tomwalters@268 90 elif target_platform == 'darwin':
tomwalters@268 91 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@268 92
tomwalters@268 93 # Compiler selection based on platform
tomwalters@268 94 # compiler can be one of: gcc msvc
tomwalters@268 95 compiler = 'gcc'
tomwalters@268 96 if (build_platform == 'win32'
tomwalters@268 97 and target_platform == 'win32'
tomwalters@268 98 and not env['mingw']):
tomwalters@268 99 compiler = 'msvc'
tomwalters@268 100
tomwalters@268 101 # Compiler-specific options:
tomwalters@268 102 # Microsoft visual studio
tomwalters@268 103 if compiler == 'msvc':
tomwalters@268 104 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tomwalters@268 105 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@268 106 '_RINT_REQUIRED'])
tomwalters@268 107 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@268 108 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@268 109
tomwalters@268 110 # GNU compiler collection
tomwalters@268 111 elif compiler == 'gcc':
tomwalters@268 112 env['STRIP'] = 'strip'
tomwalters@268 113 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@268 114 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
tomwalters@268 115 if env['mingw']:
tomwalters@268 116 if not env['PLATFORM'] == 'win32':
tomwalters@268 117 print('Cross-compilation for Windows is not supported')
tomwalters@268 118 Exit(1)
tomwalters@268 119 else:
tomwalters@268 120 print('Unsupported compiler: ' + compiler)
tomwalters@268 121 Exit(1)
tomwalters@298 122
tomwalters@298 123 # To make a statically-linked version for os 10.4 and up...
tomwalters@298 124 #if build_platform == 'darwin':
tomwalters@298 125 # env.AppendUnique(CPPFLAGS = ['-arch', 'i386'])
tomwalters@298 126 # env.AppendUnique(LINKFLAGS = ['-arch', 'i386'])
tomwalters@298 127 # env.AppendUnique(LINKFLAGS = ['-Wl'])
tomwalters@298 128 # env.AppendUnique(LINKFLAGS = ['-search_paths_first'])
tomwalters@298 129 # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4'])
tomwalters@298 130 # env.AppendUnique(GCC_VERSION = ['4.0'])
tomwalters@298 131 # env.Replace(CC = ['gcc-4.0'])
tomwalters@298 132 # env.Replace(CXX = ['gcc-4.0'])
tomwalters@298 133 # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4'])
tomwalters@299 134 # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg']
tomwalters@268 135 if not target_platform == 'win32':
tomwalters@268 136 # On windows, utf support is builtin for SimpleIni
tomwalters@283 137 # but not on other platforms
tomwalters@289 138 sources += ['Support/ConvertUTF.c']
tomwalters@268 139
tomwalters@268 140 # Place the build products in the corect place
tomwalters@289 141 env.VariantDir('#' + build_dir, '#', duplicate = 0)
tomwalters@268 142
tomwalters@268 143 # Look for the sources in the correct place
tomwalters@293 144 env.Append(CPPPATH = ['#src'])
tomwalters@268 145
tomwalters@268 146 # Dependencies
tomwalters@299 147 deplibs = ['sndfile']
tomwalters@275 148
tomwalters@275 149 for depname in deplibs:
tomwalters@275 150 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@275 151
tomwalters@268 152 env.AppendUnique(LIBS = deplibs)
tomwalters@268 153
tomwalters@289 154
tomwalters@289 155 # Builder for the main program
tomwalters@268 156 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@268 157 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@268 158 sources))
tomwalters@289 159 env.Alias(target_executable, os.path.join(build_dir, target_executable))
tomwalters@268 160 env.Default(program)
tomwalters@289 161
tomwalters@293 162 #test_env = env.Clone()
tomwalters@293 163 #test_libs = ['gtest', 'gtest_main']
tomwalters@298 164 ##for depname in test_libs:
tomwalters@298 165 ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@293 166 #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'],
tomwalters@293 167 # CPPPATH = ['/usr/local/lib'],
tomwalters@293 168 # LIBS = test_libs)
tomwalters@298 169 #
tomwalters@293 170 #test = test_env.Program(target = os.path.join(build_dir, test_executable),
tomwalters@293 171 # source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@293 172 # test_sources))
tomwalters@293 173 #env.Alias('test', os.path.join(build_dir, test_executable))