tomwalters@268: # Copyright 2006-2010, Willem van Engen, Thomas Walters tomwalters@268: # tomwalters@268: # AIM-C: A C++ implementation of the Auditory Image Model tomwalters@268: # http://www.acousticscale.org/AIMC tomwalters@268: # tomwalters@268: # This program is free software: you can redistribute it and/or modify tomwalters@268: # it under the terms of the GNU General Public License as published by tomwalters@268: # the Free Software Foundation, either version 3 of the License, or tomwalters@268: # (at your option) any later version. tomwalters@268: # tomwalters@268: # This program is distributed in the hope that it will be useful, tomwalters@268: # but WITHOUT ANY WARRANTY; without even the implied warranty of tomwalters@268: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the tomwalters@268: # GNU General Public License for more details. tomwalters@268: # tomwalters@268: # You should have received a copy of the GNU General Public License tomwalters@268: # along with this program. If not, see . tomwalters@268: tomwalters@268: ## @author Thomas Walters tomwalters@268: # @author Willem van Engen tomwalters@268: # @date created 2010/02/02 tomwalters@268: # @version \$Id$ tomwalters@268: tomwalters@268: """@package SConstruct tomwalters@268: SConstruct file for the aimc project tomwalters@268: tomwalters@268: """ tomwalters@268: tomwalters@268: import os tomwalters@268: import shutil tomwalters@268: tomwalters@268: # Define the command-line options for running scons tomwalters@268: options = Variables() tomwalters@268: options.Add(BoolVariable('mingw', tomwalters@268: 'Compile on Windows using mingw rather than msvc', tomwalters@268: False)) tomwalters@268: tomwalters@268: # Environment variables tomwalters@268: env = Environment(options = options, ENV = os.environ) tomwalters@268: if env['mingw']: tomwalters@268: # SCons Defaults to MSVC if installed on Windows. tomwalters@268: env = Environment(options = opts, ENV = os.environ, tools = ['mingw']) tomwalters@268: tomwalters@268: # Platform tomwalters@268: build_platform = env['PLATFORM'] tomwalters@268: target_platform = build_platform tomwalters@268: tomwalters@268: # Build products location and executable name tomwalters@268: build_dir = os.path.join('build', target_platform + '-release') tomwalters@268: target_executable = 'aimc' tomwalters@268: tomwalters@268: # Create build products directory if necessary tomwalters@268: if not os.path.exists(build_dir): tomwalters@268: os.makedirs(build_dir) tomwalters@268: env.SConsignFile(os.path.join(build_dir,'.sconsign')) tomwalters@268: tomwalters@268: # Set any platform-specific environment variables and options tomwalters@268: if target_platform == 'win32': tomwalters@268: env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32', tomwalters@268: 'WINVER=0x0400', '_CONSOLE']) tomwalters@268: elif target_platform == 'darwin': tomwalters@268: env.AppendUnique(CPPDEFINES = ['_MACOSX']) tomwalters@268: tomwalters@268: # Compiler selection based on platform tomwalters@268: # compiler can be one of: gcc msvc tomwalters@268: compiler = 'gcc' tomwalters@268: if (build_platform == 'win32' tomwalters@268: and target_platform == 'win32' tomwalters@268: and not env['mingw']): tomwalters@268: compiler = 'msvc' tomwalters@268: tomwalters@268: # Compiler-specific options: tomwalters@268: # Microsoft visual studio tomwalters@268: if compiler == 'msvc': tomwalters@268: env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc']) tomwalters@268: env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE', tomwalters@268: '_RINT_REQUIRED']) tomwalters@268: env.AppendUnique(CPPFLAGS = ['/Ox']) tomwalters@268: env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT']) tomwalters@268: tomwalters@268: # GNU compiler collection tomwalters@268: elif compiler == 'gcc': tomwalters@268: env['STRIP'] = 'strip' tomwalters@268: env.AppendUnique(CPPFLAGS = ['-Wall']) tomwalters@268: env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer']) tomwalters@268: if env['mingw']: tomwalters@268: if not env['PLATFORM'] == 'win32': tomwalters@268: print('Cross-compilation for Windows is not supported') tomwalters@268: Exit(1) tomwalters@268: else: tomwalters@268: print('Unsupported compiler: ' + compiler) tomwalters@268: Exit(1) tomwalters@268: tomwalters@268: # Sources common to every version tomwalters@268: common_sources = ['Support/Common.cc', tomwalters@273: 'Support/SignalBank.cc', tomwalters@268: 'Support/Parameters.cc', tomwalters@275: 'Support/Module.cc', tomwalters@275: 'Modules/Input/ModuleFileInput.cc', tomwalters@268: 'Modules/BMM/ModulePZFC.cc', tomwalters@268: 'Modules/NAP/ModuleHCL.cc', tomwalters@273: #'Modules/SAI/ModuleSAI.cc', tomwalters@268: 'Modules/Features/ModuleGaussians.cc'] tomwalters@268: tomwalters@268: if not target_platform == 'win32': tomwalters@268: # On windows, utf support is builtin for SimpleIni tomwalters@268: # bit not on other platforms tomwalters@268: common_sources += ['Support/ConvertUTF.c'] tomwalters@268: tomwalters@268: # Choose file which contains main() tomwalters@273: sources = common_sources + ['Main/aimc.cc'] tomwalters@268: tomwalters@268: # Place the build products in the corect place tomwalters@268: env.BuildDir('#' + build_dir, '#', duplicate = 0) tomwalters@268: tomwalters@268: # Look for the sources in the correct place tomwalters@268: env.Append(CPPPATH = '#src') tomwalters@268: tomwalters@268: # Dependencies tomwalters@275: deplibs = ['sndfile'] tomwalters@275: tomwalters@275: for depname in deplibs: tomwalters@275: env.ParseConfig('pkg-config --cflags --libs ' + depname) tomwalters@275: tomwalters@268: env.AppendUnique(LIBS = deplibs) tomwalters@268: tomwalters@268: # Set up the builder to build the program tomwalters@268: program = env.Program(target = os.path.join(build_dir, target_executable), tomwalters@268: source = map(lambda x: '#' + build_dir + '/src/' + x, tomwalters@268: sources)) tomwalters@268: env.Default(program)