annotate trunk/SConstruct @ 283:ef14c9f2c1d2

-Added modules template -Changed header guard style to be more consistent with the Google style guide -Added Doyxfile to generate doxygen documentation -Added structure diagram -Updated swig script to reflect new modules -Changes Gaussians back to using floats and changed tolerance on tests - doubles are unnecessary here
author tomwalters
date Fri, 19 Feb 2010 12:15:56 +0000
parents 6b4921704eb1
children fb52ca0e6339
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@268 32 # Define the command-line options for running scons
tomwalters@268 33 options = Variables()
tomwalters@268 34 options.Add(BoolVariable('mingw',
tomwalters@268 35 'Compile on Windows using mingw rather than msvc',
tomwalters@268 36 False))
tomwalters@268 37
tomwalters@268 38 # Environment variables
tomwalters@268 39 env = Environment(options = options, ENV = os.environ)
tomwalters@268 40 if env['mingw']:
tomwalters@268 41 # SCons Defaults to MSVC if installed on Windows.
tomwalters@268 42 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
tomwalters@268 43
tomwalters@268 44 # Platform
tomwalters@268 45 build_platform = env['PLATFORM']
tomwalters@268 46 target_platform = build_platform
tomwalters@268 47
tomwalters@268 48 # Build products location and executable name
tomwalters@268 49 build_dir = os.path.join('build', target_platform + '-release')
tomwalters@268 50 target_executable = 'aimc'
tomwalters@268 51
tomwalters@268 52 # Create build products directory if necessary
tomwalters@268 53 if not os.path.exists(build_dir):
tomwalters@268 54 os.makedirs(build_dir)
tomwalters@268 55 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
tomwalters@268 56
tomwalters@268 57 # Set any platform-specific environment variables and options
tomwalters@268 58 if target_platform == 'win32':
tomwalters@268 59 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
tomwalters@268 60 'WINVER=0x0400', '_CONSOLE'])
tomwalters@268 61 elif target_platform == 'darwin':
tomwalters@268 62 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
tomwalters@268 63
tomwalters@268 64 # Compiler selection based on platform
tomwalters@268 65 # compiler can be one of: gcc msvc
tomwalters@268 66 compiler = 'gcc'
tomwalters@268 67 if (build_platform == 'win32'
tomwalters@268 68 and target_platform == 'win32'
tomwalters@268 69 and not env['mingw']):
tomwalters@268 70 compiler = 'msvc'
tomwalters@268 71
tomwalters@268 72 # Compiler-specific options:
tomwalters@268 73 # Microsoft visual studio
tomwalters@268 74 if compiler == 'msvc':
tomwalters@268 75 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
tomwalters@268 76 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
tomwalters@268 77 '_RINT_REQUIRED'])
tomwalters@268 78 env.AppendUnique(CPPFLAGS = ['/Ox'])
tomwalters@268 79 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
tomwalters@268 80
tomwalters@268 81 # GNU compiler collection
tomwalters@268 82 elif compiler == 'gcc':
tomwalters@268 83 env['STRIP'] = 'strip'
tomwalters@268 84 env.AppendUnique(CPPFLAGS = ['-Wall'])
tomwalters@268 85 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
tomwalters@268 86 if env['mingw']:
tomwalters@268 87 if not env['PLATFORM'] == 'win32':
tomwalters@268 88 print('Cross-compilation for Windows is not supported')
tomwalters@268 89 Exit(1)
tomwalters@268 90 else:
tomwalters@268 91 print('Unsupported compiler: ' + compiler)
tomwalters@268 92 Exit(1)
tomwalters@268 93
tomwalters@268 94 # Sources common to every version
tomwalters@268 95 common_sources = ['Support/Common.cc',
tomwalters@273 96 'Support/SignalBank.cc',
tomwalters@268 97 'Support/Parameters.cc',
tomwalters@275 98 'Support/Module.cc',
tomwalters@275 99 'Modules/Input/ModuleFileInput.cc',
tomwalters@277 100 'Modules/BMM/ModuleGammatone.cc',
tomwalters@268 101 'Modules/BMM/ModulePZFC.cc',
tomwalters@268 102 'Modules/NAP/ModuleHCL.cc',
tomwalters@277 103 'Modules/Strobes/ModuleParabola.cc',
tomwalters@277 104 'Modules/SAI/ModuleSAI.cc',
tomwalters@277 105 'Modules/Features/ModuleGaussians.cc',
tomwalters@277 106 'Modules/Output/FileOutputHTK.cc']
tomwalters@268 107
tomwalters@268 108 if not target_platform == 'win32':
tomwalters@268 109 # On windows, utf support is builtin for SimpleIni
tomwalters@283 110 # but not on other platforms
tomwalters@268 111 common_sources += ['Support/ConvertUTF.c']
tomwalters@268 112
tomwalters@268 113 # Choose file which contains main()
tomwalters@273 114 sources = common_sources + ['Main/aimc.cc']
tomwalters@268 115
tomwalters@268 116 # Place the build products in the corect place
tomwalters@268 117 env.BuildDir('#' + build_dir, '#', duplicate = 0)
tomwalters@268 118
tomwalters@268 119 # Look for the sources in the correct place
tomwalters@268 120 env.Append(CPPPATH = '#src')
tomwalters@268 121
tomwalters@268 122 # Dependencies
tomwalters@275 123 deplibs = ['sndfile']
tomwalters@275 124
tomwalters@275 125 for depname in deplibs:
tomwalters@275 126 env.ParseConfig('pkg-config --cflags --libs ' + depname)
tomwalters@275 127
tomwalters@268 128 env.AppendUnique(LIBS = deplibs)
tomwalters@268 129
tomwalters@268 130 # Set up the builder to build the program
tomwalters@268 131 program = env.Program(target = os.path.join(build_dir, target_executable),
tomwalters@268 132 source = map(lambda x: '#' + build_dir + '/src/' + x,
tomwalters@268 133 sources))
tomwalters@268 134 env.Default(program)