Mercurial > hg > aimc
comparison SConstruct @ 0:582cbe817f2c
- Initial add of support code and modules. Not everything is working yet.
author | tomwalters |
---|---|
date | Fri, 12 Feb 2010 12:31:23 +0000 |
parents | |
children | bc394a985042 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:582cbe817f2c |
---|---|
1 # Copyright 2006-2010, Willem van Engen, Thomas Walters | |
2 # | |
3 # AIM-C: A C++ implementation of the Auditory Image Model | |
4 # http://www.acousticscale.org/AIMC | |
5 # | |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 # | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU General Public License for more details. | |
15 # | |
16 # You should have received a copy of the GNU General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 ## @author Thomas Walters <tom@acousticscale.org> | |
20 # @author Willem van Engen <cnbh@willem.engen.nl> | |
21 # @date created 2010/02/02 | |
22 # @version \$Id$ | |
23 | |
24 """@package SConstruct | |
25 SConstruct file for the aimc project | |
26 | |
27 """ | |
28 | |
29 import os | |
30 import shutil | |
31 | |
32 # Define the command-line options for running scons | |
33 options = Variables() | |
34 options.Add(BoolVariable('mingw', | |
35 'Compile on Windows using mingw rather than msvc', | |
36 False)) | |
37 | |
38 # Environment variables | |
39 env = Environment(options = options, ENV = os.environ) | |
40 if env['mingw']: | |
41 # SCons Defaults to MSVC if installed on Windows. | |
42 env = Environment(options = opts, ENV = os.environ, tools = ['mingw']) | |
43 | |
44 # Platform | |
45 build_platform = env['PLATFORM'] | |
46 target_platform = build_platform | |
47 | |
48 # Build products location and executable name | |
49 build_dir = os.path.join('build', target_platform + '-release') | |
50 target_executable = 'aimc' | |
51 | |
52 # Create build products directory if necessary | |
53 if not os.path.exists(build_dir): | |
54 os.makedirs(build_dir) | |
55 env.SConsignFile(os.path.join(build_dir,'.sconsign')) | |
56 | |
57 # Set any platform-specific environment variables and options | |
58 if target_platform == 'win32': | |
59 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32', | |
60 'WINVER=0x0400', '_CONSOLE']) | |
61 elif target_platform == 'darwin': | |
62 env.AppendUnique(CPPDEFINES = ['_MACOSX']) | |
63 | |
64 # Compiler selection based on platform | |
65 # compiler can be one of: gcc msvc | |
66 compiler = 'gcc' | |
67 if (build_platform == 'win32' | |
68 and target_platform == 'win32' | |
69 and not env['mingw']): | |
70 compiler = 'msvc' | |
71 | |
72 # Compiler-specific options: | |
73 # Microsoft visual studio | |
74 if compiler == 'msvc': | |
75 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc']) | |
76 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE', | |
77 '_RINT_REQUIRED']) | |
78 env.AppendUnique(CPPFLAGS = ['/Ox']) | |
79 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT']) | |
80 | |
81 # GNU compiler collection | |
82 elif compiler == 'gcc': | |
83 env['STRIP'] = 'strip' | |
84 env.AppendUnique(CPPFLAGS = ['-Wall']) | |
85 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer']) | |
86 if env['mingw']: | |
87 if not env['PLATFORM'] == 'win32': | |
88 print('Cross-compilation for Windows is not supported') | |
89 Exit(1) | |
90 else: | |
91 print('Unsupported compiler: ' + compiler) | |
92 Exit(1) | |
93 | |
94 # Sources common to every version | |
95 common_sources = ['Support/Common.cc', | |
96 'Support/Parameters.cc', | |
97 'Support/Module.cc', | |
98 'Modules/BMM/ModulePZFC.cc', | |
99 'Modules/NAP/ModuleHCL.cc', | |
100 'Modules/SAI/ModuleSAI.cc', | |
101 'Modules/Features/ModuleGaussians.cc'] | |
102 | |
103 if not target_platform == 'win32': | |
104 # On windows, utf support is builtin for SimpleIni | |
105 # bit not on other platforms | |
106 common_sources += ['Support/ConvertUTF.c'] | |
107 | |
108 # Choose file which contains main() | |
109 sources = common_sources + ['Main/aimc.cpp'] | |
110 | |
111 # Place the build products in the corect place | |
112 env.BuildDir('#' + build_dir, '#', duplicate = 0) | |
113 | |
114 # Look for the sources in the correct place | |
115 env.Append(CPPPATH = '#src') | |
116 | |
117 # Dependencies | |
118 deplibs = '' | |
119 env.AppendUnique(LIBS = deplibs) | |
120 | |
121 # Set up the builder to build the program | |
122 program = env.Program(target = os.path.join(build_dir, target_executable), | |
123 source = map(lambda x: '#' + build_dir + '/src/' + x, | |
124 sources)) | |
125 env.Default(program) |