annotate SConstruct @ 36:74196ff1cb98

-Added debug symbols option for GCC -Fixed SSI bug - too early to try -1 for the other bits - oops again! -Added boost libraries to EC2 script
author tomwalters
date Fri, 26 Feb 2010 16:58:26 +0000
parents 9122efd2b227
children 814dd2a74cdb
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@23 34 'Support/FileList.cc',
tomwalters@17 35 'Support/SignalBank.cc',
tomwalters@17 36 'Support/Parameters.cc',
tomwalters@17 37 'Support/Module.cc',
tomwalters@23 38 'Support/ModuleFactory.cc',
tomwalters@17 39 'Modules/Input/ModuleFileInput.cc',
tomwalters@17 40 'Modules/BMM/ModuleGammatone.cc',
tomwalters@17 41 'Modules/BMM/ModulePZFC.cc',
tomwalters@17 42 'Modules/NAP/ModuleHCL.cc',
tomwalters@17 43 'Modules/Strobes/ModuleParabola.cc',
tomwalters@32 44 'Modules/Strobes/ModuleLocalMax.cc',
tomwalters@17 45 'Modules/SAI/ModuleSAI.cc',
tomwalters@32 46 'Modules/SNR/ModuleNoise.cc',
tomwalters@17 47 'Modules/SSI/ModuleSSI.cc',
tomwalters@17 48 'Modules/Profile/ModuleSlice.cc',
tomwalters@20 49 'Modules/Profile/ModuleScaler.cc',
tomwalters@17 50 'Modules/Features/ModuleGaussians.cc',
tomwalters@17 51 'Modules/Output/FileOutputHTK.cc']
tomwalters@17 52
tomwalters@17 53 # File which contains main()
tomwalters@32 54 sources = common_sources + ['Main/AIMCopy_SSI_Features.cc']
tomwalters@17 55
tomwalters@17 56 # Test sources
tomwalters@17 57 test_sources = ['Modules/Profile/ModuleSlice_unittest.cc']
tomwalters@17 58 test_sources += common_sources
tomwalters@17 59
tomwalters@0 60 # Define the command-line options for running scons
tomwalters@0 61 options = Variables()
tomwalters@0 62 options.Add(BoolVariable('mingw',
tomwalters@0 63 'Compile on Windows using mingw rather than msvc',
tomwalters@0 64 False))
tomwalters@36 65 options.Add(BoolVariable('symbols',
tomwalters@36 66 'Add debuging symbols when compiling on gcc',
tomwalters@36 67 False))
tomwalters@0 68
tomwalters@0 69 # Environment variables
tomwalters@0 70 env = Environment(options = options, ENV = os.environ)
tomwalters@0 71 if env['mingw']:
tomwalters@0 72 # SCons Defaults to MSVC if installed on Windows.
tomwalters@0 73 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@0 74
tomwalters@0 75 # Platform
tomwalters@0 76 build_platform = env['PLATFORM']
tomwalters@0 77 target_platform = build_platform
tomwalters@0 78
tomwalters@0 79 # Build products location and executable name
tomwalters@0 80 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@25 81 target_executable = 'AIMCopy'
tomwalters@17 82 test_executable = 'aimc_tests'
tomwalters@0 83
tomwalters@0 84 # Create build products directory if necessary
tomwalters@0 85 if not os.path.exists(build_dir):
tomwalters@0 86 os.makedirs(build_dir)
tomwalters@0 87 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@0 88
tomwalters@0 89 # Set any platform-specific environment variables and options
tomwalters@0 90 if target_platform == 'win32':
tomwalters@0 91 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@0 92 'WINVER=0x0400', '_CONSOLE'])
tomwalters@0 93 elif target_platform == 'darwin':
tomwalters@0 94 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@0 95
tomwalters@0 96 # Compiler selection based on platform
tomwalters@0 97 # compiler can be one of: gcc msvc
tomwalters@0 98 compiler = 'gcc'
tomwalters@0 99 if (build_platform == 'win32'
tomwalters@0 100 and target_platform == 'win32'
tomwalters@0 101 and not env['mingw']):
tomwalters@0 102 compiler = 'msvc'
tomwalters@0 103
tomwalters@0 104 # Compiler-specific options:
tomwalters@0 105 # Microsoft visual studio
tomwalters@0 106 if compiler == 'msvc':
tomwalters@0 107 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tomwalters@0 108 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@0 109 '_RINT_REQUIRED'])
tomwalters@0 110 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@0 111 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@0 112
tomwalters@0 113 # GNU compiler collection
tomwalters@0 114 elif compiler == 'gcc':
tomwalters@0 115 env['STRIP'] = 'strip'
tomwalters@0 116 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@0 117 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
tomwalters@36 118 if env['symbols']:
tomwalters@36 119 env.AppendUnique(CPPFLAGS = ['-g'])
tomwalters@0 120 if env['mingw']:
tomwalters@0 121 if not env['PLATFORM'] == 'win32':
tomwalters@0 122 print('Cross-compilation for Windows is not supported')
tomwalters@0 123 Exit(1)
tomwalters@0 124 else:
tomwalters@0 125 print('Unsupported compiler: ' + compiler)
tomwalters@0 126 Exit(1)
tomwalters@25 127
tomwalters@25 128 # To make a statically-linked version for os 10.4 and up...
tomwalters@25 129 #if build_platform == 'darwin':
tomwalters@25 130 # env.AppendUnique(CPPFLAGS = ['-arch', 'i386'])
tomwalters@25 131 # env.AppendUnique(LINKFLAGS = ['-arch', 'i386'])
tomwalters@25 132 # env.AppendUnique(LINKFLAGS = ['-Wl'])
tomwalters@25 133 # env.AppendUnique(LINKFLAGS = ['-search_paths_first'])
tomwalters@25 134 # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4'])
tomwalters@25 135 # env.AppendUnique(GCC_VERSION = ['4.0'])
tomwalters@25 136 # env.Replace(CC = ['gcc-4.0'])
tomwalters@25 137 # env.Replace(CXX = ['gcc-4.0'])
tomwalters@25 138 # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4'])
tomwalters@26 139 # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg']
tomwalters@0 140 if not target_platform == 'win32':
tomwalters@0 141 # On windows, utf support is builtin for SimpleIni
tomwalters@11 142 # but not on other platforms
tomwalters@17 143 sources += ['Support/ConvertUTF.c']
tomwalters@0 144
tomwalters@0 145 # Place the build products in the corect place
tomwalters@17 146 env.VariantDir('#' + build_dir, '#', duplicate = 0)
tomwalters@0 147
tomwalters@0 148 # Look for the sources in the correct place
tomwalters@21 149 env.Append(CPPPATH = ['#src'])
tomwalters@0 150
tomwalters@0 151 # Dependencies
tomwalters@26 152 deplibs = ['sndfile']
tomwalters@3 153
tomwalters@3 154 for depname in deplibs:
tomwalters@3 155 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@3 156
tomwalters@0 157 env.AppendUnique(LIBS = deplibs)
tomwalters@0 158
tomwalters@17 159
tomwalters@17 160 # Builder for the main program
tomwalters@0 161 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@0 162 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@0 163 sources))
tomwalters@17 164 env.Alias(target_executable, os.path.join(build_dir, target_executable))
tomwalters@0 165 env.Default(program)
tomwalters@17 166
tomwalters@21 167 #test_env = env.Clone()
tomwalters@21 168 #test_libs = ['gtest', 'gtest_main']
tomwalters@25 169 ##for depname in test_libs:
tomwalters@25 170 ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@21 171 #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'],
tomwalters@21 172 # CPPPATH = ['/usr/local/lib'],
tomwalters@21 173 # LIBS = test_libs)
tomwalters@25 174 #
tomwalters@21 175 #test = test_env.Program(target = os.path.join(build_dir, test_executable),
tomwalters@21 176 # source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@21 177 # test_sources))
tomwalters@21 178 #env.Alias('test', os.path.join(build_dir, test_executable))