tomwalters@157
|
1 # Copyright 2006-2010, Willem van Engen, Thomas Walters
|
tomwalters@157
|
2 #
|
tomwalters@157
|
3 # AIM-C: A C++ implementation of the Auditory Image Model
|
tomwalters@157
|
4 # http://www.acousticscale.org/AIMC
|
tomwalters@157
|
5 #
|
tomwalters@157
|
6 # Licensed under the Apache License, Version 2.0 (the "License");
|
tomwalters@157
|
7 # you may not use this file except in compliance with the License.
|
tomwalters@157
|
8 # You may obtain a copy of the License at
|
tomwalters@157
|
9 #
|
tomwalters@157
|
10 # http://www.apache.org/licenses/LICENSE-2.0
|
tomwalters@157
|
11 #
|
tomwalters@157
|
12 # Unless required by applicable law or agreed to in writing, software
|
tomwalters@157
|
13 # distributed under the License is distributed on an "AS IS" BASIS,
|
tomwalters@157
|
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
tomwalters@157
|
15 # See the License for the specific language governing permissions and
|
tomwalters@157
|
16 # limitations under the License.
|
tomwalters@157
|
17
|
tomwalters@157
|
18 ## @author Thomas Walters <tom@acousticscale.org>
|
tomwalters@157
|
19 # @author Willem van Engen <cnbh@willem.engen.nl>
|
tomwalters@157
|
20 # @date created 2010/02/02
|
tomwalters@157
|
21 # @version \$Id$
|
tomwalters@157
|
22
|
tomwalters@157
|
23 """@package SConstruct
|
tomwalters@157
|
24 SConstruct file for the aimc project
|
tomwalters@157
|
25
|
tomwalters@157
|
26 """
|
tomwalters@157
|
27
|
tomwalters@157
|
28 import os
|
tomwalters@157
|
29 import shutil
|
tomwalters@157
|
30
|
tomwalters@161
|
31 # Location of libsndfile on Windows
|
tomwalters@161
|
32 windows_libsndfile_location = "C:\\Program Files\\Mega-Nerd\\libsndfile\\"
|
tomwalters@161
|
33
|
tomwalters@157
|
34 # Sources common to every version
|
tomwalters@157
|
35 common_sources = ['Support/Common.cc',
|
tomwalters@157
|
36 'Support/FileList.cc',
|
tomwalters@157
|
37 'Support/SignalBank.cc',
|
tomwalters@157
|
38 'Support/Parameters.cc',
|
tomwalters@157
|
39 'Support/Module.cc',
|
tomwalters@157
|
40 'Support/ModuleFactory.cc',
|
tomwalters@157
|
41 'Modules/Input/ModuleFileInput.cc',
|
tomwalters@157
|
42 'Modules/BMM/ModuleGammatone.cc',
|
tomwalters@157
|
43 'Modules/BMM/ModulePZFC.cc',
|
tomwalters@157
|
44 'Modules/NAP/ModuleHCL.cc',
|
tomwalters@157
|
45 'Modules/Strobes/ModuleParabola.cc',
|
tomwalters@157
|
46 'Modules/Strobes/ModuleLocalMax.cc',
|
tomwalters@157
|
47 'Modules/SAI/ModuleSAI.cc',
|
tomwalters@157
|
48 'Modules/SNR/ModuleNoise.cc',
|
tomwalters@157
|
49 'Modules/SSI/ModuleSSI.cc',
|
tomwalters@157
|
50 'Modules/Profile/ModuleSlice.cc',
|
tomwalters@157
|
51 'Modules/Profile/ModuleScaler.cc',
|
tomwalters@157
|
52 'Modules/Features/ModuleGaussians.cc',
|
tomwalters@157
|
53 'Modules/Output/FileOutputHTK.cc',
|
tomwalters@157
|
54 'Modules/Output/FileOutputAIMC.cc']
|
tomwalters@157
|
55
|
tomwalters@157
|
56 # File which contains main()
|
tomwalters@157
|
57 #sources = common_sources + ['Main/AIMCopy_SSI_Features_v4_PZFC.cc']
|
tomwalters@160
|
58 sources = common_sources + ['Main/AIMCopy_SSI_Features_v5_smooth_nap.cc']
|
tomwalters@157
|
59
|
tomwalters@157
|
60 # Test sources
|
tomwalters@157
|
61 test_sources = ['Modules/Profile/ModuleSlice_unittest.cc']
|
tomwalters@157
|
62 test_sources += common_sources
|
tomwalters@157
|
63
|
tomwalters@157
|
64 # Define the command-line options for running scons
|
tomwalters@157
|
65 options = Variables()
|
tomwalters@157
|
66 options.Add(BoolVariable('mingw',
|
tomwalters@157
|
67 'Compile on Windows using mingw rather than msvc',
|
tomwalters@157
|
68 False))
|
tomwalters@157
|
69 options.Add(BoolVariable('symbols',
|
tomwalters@157
|
70 'Add debuging symbols when compiling on gcc',
|
tomwalters@157
|
71 False))
|
tomwalters@157
|
72
|
tomwalters@157
|
73 # Environment variables
|
tomwalters@157
|
74 env = Environment(options = options, ENV = os.environ)
|
tomwalters@157
|
75 if env['mingw']:
|
tomwalters@157
|
76 # SCons Defaults to MSVC if installed on Windows.
|
tomwalters@157
|
77 env = Environment(options = opts, ENV = os.environ, tools = ['mingw'])
|
tomwalters@157
|
78
|
tomwalters@157
|
79 # Platform
|
tomwalters@157
|
80 build_platform = env['PLATFORM']
|
tomwalters@157
|
81 target_platform = build_platform
|
tomwalters@157
|
82
|
tomwalters@157
|
83 # Build products location and executable name
|
tomwalters@157
|
84 build_dir = os.path.join('build', target_platform + '-release')
|
tomwalters@160
|
85 #target_executable = 'aimc'
|
tomwalters@160
|
86 target_executable = 'AIMCopy'
|
tomwalters@157
|
87 test_executable = 'aimc_tests'
|
tomwalters@157
|
88
|
tomwalters@157
|
89 # Create build products directory if necessary
|
tomwalters@157
|
90 if not os.path.exists(build_dir):
|
tomwalters@157
|
91 os.makedirs(build_dir)
|
tomwalters@157
|
92 env.SConsignFile(os.path.join(build_dir,'.sconsign'))
|
tomwalters@157
|
93
|
tomwalters@157
|
94 # Set any platform-specific environment variables and options
|
tomwalters@157
|
95 if target_platform == 'win32':
|
tomwalters@157
|
96 env.AppendUnique(CPPDEFINES = ['_WINDOWS', 'WIN32',
|
tomwalters@157
|
97 'WINVER=0x0400', '_CONSOLE'])
|
tomwalters@157
|
98 elif target_platform == 'darwin':
|
tomwalters@157
|
99 env.AppendUnique(CPPDEFINES = ['_MACOSX'])
|
tomwalters@157
|
100
|
tomwalters@157
|
101 # Compiler selection based on platform
|
tomwalters@157
|
102 # compiler can be one of: gcc msvc
|
tomwalters@157
|
103 compiler = 'gcc'
|
tomwalters@157
|
104 if (build_platform == 'win32'
|
tomwalters@157
|
105 and target_platform == 'win32'
|
tomwalters@157
|
106 and not env['mingw']):
|
tomwalters@157
|
107 compiler = 'msvc'
|
tomwalters@157
|
108
|
tomwalters@157
|
109 # Compiler-specific options:
|
tomwalters@157
|
110 # Microsoft visual studio
|
tomwalters@157
|
111 if compiler == 'msvc':
|
tomwalters@157
|
112 env.AppendUnique(CPPFLAGS = ['/arch:SSE2', '/nologo', '/W3', '/EHsc'])
|
tomwalters@157
|
113 env.AppendUnique(CPPDEFINES = ['_CRT_SECURE_NO_DEPRECATE',
|
tomwalters@157
|
114 '_RINT_REQUIRED'])
|
tomwalters@157
|
115 env.AppendUnique(CPPFLAGS = ['/Ox'])
|
tomwalters@157
|
116 env.AppendUnique(CPPDEFINES = ['NDEBUG', '_ATL_MIN_CRT'])
|
tomwalters@157
|
117
|
tomwalters@157
|
118 # GNU compiler collection
|
tomwalters@157
|
119 elif compiler == 'gcc':
|
tomwalters@157
|
120 env['STRIP'] = 'strip'
|
tomwalters@157
|
121 env.AppendUnique(CPPFLAGS = ['-Wall'])
|
tomwalters@157
|
122 env.AppendUnique(CPPFLAGS = ['-O3', '-fomit-frame-pointer'])
|
tomwalters@157
|
123 if env['symbols']:
|
tomwalters@157
|
124 env.AppendUnique(CPPFLAGS = ['-g'])
|
tomwalters@157
|
125 if env['mingw']:
|
tomwalters@157
|
126 if not env['PLATFORM'] == 'win32':
|
tomwalters@157
|
127 print('Cross-compilation for Windows is not supported')
|
tomwalters@157
|
128 Exit(1)
|
tomwalters@157
|
129 else:
|
tomwalters@157
|
130 print('Unsupported compiler: ' + compiler)
|
tomwalters@157
|
131 Exit(1)
|
tomwalters@157
|
132
|
tomwalters@157
|
133 # To make a statically-linked version for os 10.4 and up...
|
tomwalters@157
|
134 #if build_platform == 'darwin':
|
tomwalters@157
|
135 # env.AppendUnique(CPPFLAGS = ['-arch', 'i386'])
|
tomwalters@157
|
136 # env.AppendUnique(LINKFLAGS = ['-arch', 'i386'])
|
tomwalters@157
|
137 # env.AppendUnique(LINKFLAGS = ['-Wl'])
|
tomwalters@157
|
138 # env.AppendUnique(LINKFLAGS = ['-search_paths_first'])
|
tomwalters@157
|
139 # env.AppendUnique(MACOSX_DEPLOYMENT_TARGET = ['10.4'])
|
tomwalters@157
|
140 # env.AppendUnique(GCC_VERSION = ['4.0'])
|
tomwalters@157
|
141 # env.Replace(CC = ['gcc-4.0'])
|
tomwalters@157
|
142 # env.Replace(CXX = ['gcc-4.0'])
|
tomwalters@157
|
143 # env.AppendUnique(CPPFLAGS = ['-fno-stack-protector','-isysroot', '/Developer/SDKs/MacOSX10.5.sdk', '-mmacosx-version-min=10.4'])
|
tomwalters@157
|
144 # deplibs = ['sndfile', 'flac', 'vorbis', 'vorbisenc', 'ogg']
|
tomwalters@157
|
145 if not target_platform == 'win32':
|
tomwalters@157
|
146 # On windows, utf support is builtin for SimpleIni
|
tomwalters@157
|
147 # but not on other platforms
|
tomwalters@157
|
148 sources += ['Support/ConvertUTF.c']
|
tomwalters@157
|
149
|
tomwalters@157
|
150 # Place the build products in the corect place
|
tomwalters@157
|
151 env.VariantDir('#' + build_dir, '#', duplicate = 0)
|
tomwalters@157
|
152
|
tomwalters@157
|
153 # Look for the sources in the correct place
|
tomwalters@157
|
154 env.Append(CPPPATH = ['#src'])
|
tomwalters@157
|
155
|
tomwalters@157
|
156 # Dependencies
|
tomwalters@157
|
157 deplibs = ['sndfile']
|
tomwalters@157
|
158
|
tomwalters@161
|
159 if target_platform != 'win32':
|
tomwalters@161
|
160 for depname in deplibs:
|
tomwalters@161
|
161 env.ParseConfig('pkg-config --cflags --libs ' + depname)
|
tomwalters@161
|
162 env.AppendUnique(LIBS = deplibs)
|
tomwalters@161
|
163 else:
|
tomwalters@161
|
164 #env.AppendUnique(LIBS = ['wsock32', 'winmm'])
|
tomwalters@161
|
165 if 'sndfile' in deplibs:
|
tomwalters@161
|
166 ###### libsndfile ########################################
|
tomwalters@161
|
167 # This one is only valid for win32 and already precompiled
|
tomwalters@161
|
168 # Only need to create .lib file from .def
|
tomwalters@161
|
169 shutil.copyfile(windows_libsndfile_location + '/libsndfile-1.dll',
|
tomwalters@161
|
170 build_dir+'/libsndfile-1.dll')
|
tomwalters@161
|
171 if compiler=='msvc':
|
tomwalters@161
|
172 shutil.copyfile(windows_libsndfile_location + '/libsndfile-1.def',
|
tomwalters@161
|
173 build_dir+'/libsndfile-1.def')
|
tomwalters@161
|
174 env.Command(build_dir + '/libsndfile.lib', build_dir + '/libsndfile.def',
|
tomwalters@161
|
175 env['AR'] + ' /nologo /machine:i386 /def:$SOURCE /out:$TARGET')
|
tomwalters@161
|
176 env.Append(CPPPATH = [windows_libsndfile_location])
|
tomwalters@161
|
177 env.AppendUnique(LIBPATH = [build_dir])
|
tomwalters@161
|
178 # Replace 'sndfile' with 'sndfile-1'
|
tomwalters@161
|
179 deplibs.remove('sndfile')
|
tomwalters@161
|
180 deplibs.append('sndfile-1')
|
tomwalters@157
|
181
|
tomwalters@157
|
182
|
tomwalters@157
|
183
|
tomwalters@157
|
184 # Builder for the main program
|
tomwalters@157
|
185 program = env.Program(target = os.path.join(build_dir, target_executable),
|
tomwalters@157
|
186 source = map(lambda x: '#' + build_dir + '/src/' + x,
|
tomwalters@157
|
187 sources))
|
tomwalters@157
|
188 env.Alias(target_executable, os.path.join(build_dir, target_executable))
|
tomwalters@157
|
189 env.Default(program)
|
tomwalters@157
|
190
|
tomwalters@157
|
191 #test_env = env.Clone()
|
tomwalters@157
|
192 #test_libs = ['gtest', 'gtest_main']
|
tomwalters@157
|
193 ##for depname in test_libs:
|
tomwalters@157
|
194 ## test_env.ParseConfig('pkg-config --cflags --libs ' + depname)
|
tomwalters@157
|
195 #test_env.AppendUnique(LIBPATH = ['/usr/local/lib'],
|
tomwalters@157
|
196 # CPPPATH = ['/usr/local/lib'],
|
tomwalters@157
|
197 # LIBS = test_libs)
|
tomwalters@157
|
198 #
|
tomwalters@157
|
199 #test = test_env.Program(target = os.path.join(build_dir, test_executable),
|
tomwalters@157
|
200 # source = map(lambda x: '#' + build_dir + '/src/' + x,
|
tomwalters@157
|
201 # test_sources))
|
tomwalters@157
|
202 #env.Alias('test', os.path.join(build_dir, test_executable))
|