annotate SConstruct @ 18:01eba86df030

-Moved scripts to new scripts dir -Fixed a bug in the IIR gammatone gain that was causing a resonance at 3kHz -Changes HCL default for do_lowpass to true
author tomwalters
date Mon, 22 Feb 2010 12:42:47 +0000
parents f4e712d41321
children fff25824d1d1
rev   line source
tomwalters@0 1 # Copyright 2006-2010, Willem van Engen, Thomas Walters
tomwalters@0 2 #
tomwalters@0 3 # AIM-C: A C++ implementation of the Auditory Image Model
tomwalters@0 4 # http://www.acousticscale.org/AIMC
tomwalters@0 5 #
tomwalters@0 6 # This program is free software: you can redistribute it and/or modify
tomwalters@0 7 # it under the terms of the GNU General Public License as published by
tomwalters@0 8 # the Free Software Foundation, either version 3 of the License, or
tomwalters@0 9 # (at your option) any later version.
tomwalters@0 10 #
tomwalters@0 11 # This program is distributed in the hope that it will be useful,
tomwalters@0 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
tomwalters@0 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
tomwalters@0 14 # GNU General Public License for more details.
tomwalters@0 15 #
tomwalters@0 16 # You should have received a copy of the GNU General Public License
tomwalters@0 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
tomwalters@0 18
tomwalters@0 19 ## @author Thomas Walters <tom@acousticscale.org>
tomwalters@0 20 # @author Willem van Engen <cnbh@willem.engen.nl>
tomwalters@0 21 # @date created 2010/02/02
tomwalters@0 22 # @version \$Id$
tomwalters@0 23
tomwalters@0 24 """@package SConstruct
tomwalters@0 25 SConstruct file for the aimc project
tomwalters@0 26
tomwalters@0 27 """
tomwalters@0 28
tomwalters@0 29 import os
tomwalters@0 30 import shutil
tomwalters@0 31
tomwalters@17 32 # Sources common to every version
tomwalters@17 33 common_sources = ['Support/Common.cc',
tomwalters@17 34 'Support/SignalBank.cc',
tomwalters@17 35 'Support/Parameters.cc',
tomwalters@17 36 'Support/Module.cc',
tomwalters@17 37 'Modules/Input/ModuleFileInput.cc',
tomwalters@17 38 'Modules/BMM/ModuleGammatone.cc',
tomwalters@17 39 'Modules/BMM/ModulePZFC.cc',
tomwalters@17 40 'Modules/NAP/ModuleHCL.cc',
tomwalters@17 41 'Modules/Strobes/ModuleParabola.cc',
tomwalters@17 42 'Modules/SAI/ModuleSAI.cc',
tomwalters@17 43 'Modules/SSI/ModuleSSI.cc',
tomwalters@17 44 'Modules/Profile/ModuleSlice.cc',
tomwalters@17 45 'Modules/Features/ModuleGaussians.cc',
tomwalters@17 46 'Modules/Output/FileOutputHTK.cc']
tomwalters@17 47
tomwalters@17 48 # File which contains main()
tomwalters@17 49 sources = common_sources + ['Main/aimc.cc']
tomwalters@17 50
tomwalters@17 51 # Test sources
tomwalters@17 52 test_sources = ['Modules/Profile/ModuleSlice_unittest.cc']
tomwalters@17 53 test_sources += common_sources
tomwalters@17 54
tomwalters@0 55 # Define the command-line options for running scons
tomwalters@0 56 options = Variables()
tomwalters@0 57 options.Add(BoolVariable('mingw',
tomwalters@0 58 'Compile on Windows using mingw rather than msvc',
tomwalters@0 59 False))
tomwalters@0 60
tomwalters@0 61 # Environment variables
tomwalters@0 62 env = Environment(options = options, ENV = os.environ)
tomwalters@0 63 if env['mingw']:
tomwalters@0 64 # SCons Defaults to MSVC if installed on Windows.
tomwalters@0 65 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@0 66
tomwalters@0 67 # Platform
tomwalters@0 68 build_platform = env['PLATFORM']
tomwalters@0 69 target_platform = build_platform
tomwalters@0 70
tomwalters@0 71 # Build products location and executable name
tomwalters@0 72 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@0 73 target_executable = 'aimc'
tomwalters@17 74 test_executable = 'aimc_tests'
tomwalters@0 75
tomwalters@0 76 # Create build products directory if necessary
tomwalters@0 77 if not os.path.exists(build_dir):
tomwalters@0 78 os.makedirs(build_dir)
tomwalters@0 79 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@0 80
tomwalters@0 81 # Set any platform-specific environment variables and options
tomwalters@0 82 if target_platform == 'win32':
tomwalters@0 83 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@0 84 'WINVER=0x0400', '_CONSOLE'])
tomwalters@0 85 elif target_platform == 'darwin':
tomwalters@0 86 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@0 87
tomwalters@0 88 # Compiler selection based on platform
tomwalters@0 89 # compiler can be one of: gcc msvc
tomwalters@0 90 compiler = 'gcc'
tomwalters@0 91 if (build_platform == 'win32'
tomwalters@0 92 and target_platform == 'win32'
tomwalters@0 93 and not env['mingw']):
tomwalters@0 94 compiler = 'msvc'
tomwalters@0 95
tomwalters@0 96 # Compiler-specific options:
tomwalters@0 97 # Microsoft visual studio
tomwalters@0 98 if compiler == 'msvc':
tomwalters@0 99 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tomwalters@0 100 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@0 101 '_RINT_REQUIRED'])
tomwalters@0 102 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@0 103 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@0 104
tomwalters@0 105 # GNU compiler collection
tomwalters@0 106 elif compiler == 'gcc':
tomwalters@0 107 env['STRIP'] = 'strip'
tomwalters@0 108 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@0 109 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
tomwalters@0 110 if env['mingw']:
tomwalters@0 111 if not env['PLATFORM'] == 'win32':
tomwalters@0 112 print('Cross-compilation for Windows is not supported')
tomwalters@0 113 Exit(1)
tomwalters@0 114 else:
tomwalters@0 115 print('Unsupported compiler: ' + compiler)
tomwalters@0 116 Exit(1)
tomwalters@0 117
tomwalters@0 118 if not target_platform == 'win32':
tomwalters@0 119 # On windows, utf support is builtin for SimpleIni
tomwalters@11 120 # but not on other platforms
tomwalters@17 121 sources += ['Support/ConvertUTF.c']
tomwalters@0 122
tomwalters@0 123 # Place the build products in the corect place
tomwalters@17 124 env.VariantDir('#' + build_dir, '#', duplicate = 0)
tomwalters@0 125
tomwalters@0 126 # Look for the sources in the correct place
tomwalters@0 127 env.Append(CPPPATH = '#src')
tomwalters@0 128
tomwalters@0 129 # Dependencies
tomwalters@3 130 deplibs = ['sndfile']
tomwalters@3 131
tomwalters@3 132 for depname in deplibs:
tomwalters@3 133 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@3 134
tomwalters@0 135 env.AppendUnique(LIBS = deplibs)
tomwalters@0 136
tomwalters@17 137 test_env = env
tomwalters@17 138 test_libs = ['gtest', 'gtest_main']
tomwalters@17 139 #for depname in test_libs:
tomwalters@17 140 # test_env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@17 141 test_env.AppendUnique(LIBPATH = '/usr/local/lib',
tomwalters@17 142 CPPPATH = '/usr/local/lib',
tomwalters@17 143 LIBS = test_libs)
tomwalters@17 144
tomwalters@17 145 # Builder for the main program
tomwalters@0 146 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@0 147 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@0 148 sources))
tomwalters@17 149 env.Alias(target_executable, os.path.join(build_dir, target_executable))
tomwalters@0 150 env.Default(program)
tomwalters@17 151
tomwalters@17 152 test = test_env.Program(target = os.path.join(build_dir, test_executable),
tomwalters@17 153 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@17 154 test_sources))
tomwalters@17 155 env.Alias('test', os.path.join(build_dir, test_executable))