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