9 # Variables for 'waf dist'
34 def fetch_svn_revision (path):
35 cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'"
36 return commands.getoutput(cmd)
38 def fetch_git_revision (path):
39 cmd = "LANG= git log --abbrev HEAD^..HEAD " + path
40 output = commands.getoutput(cmd).splitlines()
41 rev = output[0].replace ("commit", "git")[0:10]
44 if "git-svn-id" in line:
45 line = line.split('@')[1].split(' ')
51 def create_stored_revision():
53 if os.path.exists('.svn'):
54 rev = fetch_svn_revision('.');
55 elif os.path.exists('.git'):
56 rev = fetch_git_revision('.');
57 elif os.path.exists('libs/ardour/svn_revision.cc'):
58 print "Using packaged svn revision"
61 print "Missing libs/ardour/svn_revision.cc. Blame the packager."
65 text = '#include <ardour/svn_revision.h>\n'
66 text += 'namespace ARDOUR { extern const char* svn_revision = \"' + rev + '\"; }\n'
67 print 'Writing svn revision info to libs/ardour/svn_revision.cc'
68 o = file('libs/ardour/svn_revision.cc', 'w')
72 print 'Could not open libs/ardour/svn_revision.cc for writing\n'
76 def set_compiler_flags (conf,opt):
78 # Compiler flags and other system-dependent stuff
81 build_host_supports_sse = 0
82 optimization_flags = []
84 debug_flags = [ '-pg' ]
86 debug_flags = [ ] # waf adds -O0 -g itself. thanks waf!
88 # guess at the platform, used to define compiler flags
90 config_guess = os.popen("tools/config.guess").read()[:-1]
96 config = config_guess.split ("-")
98 print "system triple: " + config_guess
101 if opt.dist_target == 'auto':
102 if config[config_arch] == 'apple':
103 # The [.] matches to the dot after the major version, "." would match any character
104 if re.search ("darwin[0-7][.]", config[config_kernel]) != None:
105 conf.define ('build_target', 'panther')
106 if re.search ("darwin8[.]", config[config_kernel]) != None:
107 conf.define ('build_target', 'tiger')
109 conf.define ('build_target', 'leopard')
111 if re.search ("x86_64", config[config_cpu]) != None:
112 conf.define ('build_target', 'x86_64')
113 elif re.search("i[0-5]86", config[config_cpu]) != None:
114 conf.define ('build_target', 'i386')
115 elif re.search("powerpc", config[config_cpu]) != None:
116 conf.define ('build_target', 'powerpc')
118 conf.define ('build_target', 'i686')
120 conf.define ('build_target', opt.dist_target)
122 if config[config_cpu] == 'powerpc' and conf.env['build_target'] != 'none':
124 # Apple/PowerPC optimization options
126 # -mcpu=7450 does not reliably work with gcc 3.*
128 if opt.dist_target == 'panther' or opt.dist_target == 'tiger':
129 if config[config_arch] == 'apple':
130 # optimization_flags.extend ([ "-mcpu=7450", "-faltivec"])
131 # to support g3s but still have some optimization for above
132 optimization_flags.extend ([ "-mcpu=G3", "-mtune=7450"])
134 optimization_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
136 optimization_flags.extend([ "-mcpu=750", "-mmultiple" ])
137 optimization_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
138 optimization_flags.extend (["-Os"])
140 elif ((re.search ("i[0-9]86", config[config_cpu]) != None) or (re.search ("x86_64", config[config_cpu]) != None)) and conf.env['build_target'] != 'none':
144 # ARCH_X86 means anything in the x86 family from i386 to x86_64
145 # USE_X86_64_ASM is used to distingush 32 and 64 bit assembler
148 if (re.search ("(i[0-9]86|x86_64)", config[config_cpu]) != None):
149 debug_flags.append ("-DARCH_X86")
150 optimization_flags.append ("-DARCH_X86")
152 if config[config_kernel] == 'linux' :
155 # determine processor flags via /proc/cpuinfo
158 if conf.env['build_target'] != 'i386':
160 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
161 x86_flags = flag_line.split (": ")[1:][0].split ()
163 if "mmx" in x86_flags:
164 optimization_flags.append ("-mmmx")
165 if "sse" in x86_flags:
166 build_host_supports_sse = 1
167 if "3dnow" in x86_flags:
168 optimization_flags.append ("-m3dnow")
170 if config[config_cpu] == "i586":
171 optimization_flags.append ("-march=i586")
172 elif config[config_cpu] == "i686":
173 optimization_flags.append ("-march=i686")
175 if ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
176 optimization_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
177 debug_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
179 # end of processor-specific section
181 # optimization section
182 if conf.env['FPU_OPTIMIZATION']:
183 if conf.env['build_target'] == 'tiger' or conf.env['build_target'] == 'leopard':
184 optimization_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
185 debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
186 libraries['core'].Append(LINKFLAGS= '-framework Accelerate')
187 elif conf.env['build_target'] == 'i686' or conf.env['build_target'] == 'x86_64':
188 optimization_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
189 debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
190 if conf.env['build_target'] == 'x86_64':
191 optimization_flags.append ("-DUSE_X86_64_ASM")
192 debug_flags.append ("-DUSE_X86_64_ASM")
193 if build_host_supports_sse != 1:
194 print "\nWarning: you are building Ardour with SSE support even though your system does not support these instructions. (This may not be an error, especially if you are a package maintainer)"
196 # end optimization section
202 if conf.env['build_target'] == 'x86_64' and opt.vst:
203 print "\n\n=================================================="
204 print "You cannot use VST plugins with a 64 bit host. Please run scons with VST=0"
205 print "\nIt is theoretically possible to build a 32 bit host on a 64 bit system."
206 print "However, this is tricky and not recommended for beginners."
210 # a single way to test if we're on OS X
213 if conf.env['build_target'] in ['panther', 'tiger', 'leopard' ]:
214 conf.define ('IS_OSX', 1)
215 # force tiger or later, to avoid issues on PPC which defaults
216 # back to 10.1 if we don't tell it otherwise.
217 conf.env.append_value (CCFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
219 if conf.env['build_target'] == 'leopard':
220 # need this to force build against the 10.4 SDK when building on later versions of OS X
221 # ideally this would be configurable, but lets just do that later when we need it
222 conf.env.append_value(CCFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
223 conf.env.append_value(LINKFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
226 conf.define ('IS_OSX', 0)
229 # save off guessed arch element in an env
231 conf.define ('CONFIG_ARCH', config[config_arch])
234 # ARCH="..." overrides all
238 optimization_flags = opt.arch.split()
241 # prepend boiler plate optimization flags that work on all architectures
244 optimization_flags[:0] = [
246 "-fomit-frame-pointer",
253 conf.env.append_value('CCFLAGS', debug_flags)
254 conf.env.append_value('CXXFLAGS', debug_flags)
255 conf.env.append_value('LINKFLAGS', debug_flags)
257 conf.env.append_value('CCFLAGS', optimization_flags)
258 conf.env.append_value('LINKFLAGS', optimization_flags)
261 conf.env.append_value('CXXFLAGS', "-D_GLIBCXX_DEBUG")
264 conf.env.append_value('CCFLAGS', "-arch i386 -arch ppc")
265 conf.env.append_value('CXXFLAGS', "-arch i386 -arch ppc")
266 conf.env.append_value('LINKFLAGS', "-arch i386 -arch ppc")
272 conf.env.append_value('CCFLAGS', "-Wall")
273 conf.env.append_value('CXXFLAGS', [ '-Wall', '-Woverloaded-virtual'])
276 conf.env.append_value('CCFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
277 conf.env.append_value('CXXFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
278 #conf.env.append_value('CFLAGS', "-iso")
285 conf.env.append_value('CCFLAGS', [ '-D_LARGEFILE64_SOURCE', '-D_LARGEFILE_SOURCE' ])
286 conf.env.append_value('CXXFLAGS', [ '-D_LARGEFILE_SOURCE', '-D_LARGEFILE_SOURCE' ])
288 conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
289 conf.env.append_value('CCFLAGS', '-DENABLE_NLS')
292 #----------------------------------------------------------------
296 def set_options(opt):
297 autowaf.set_options(opt)
298 opt.add_option('--arch', type='string', action='store', dest='arch',
299 help='Architecture-specific compiler flags')
300 opt.add_option('--aubio', action='store_true', default=True, dest='aubio',
301 help="Use Paul Brossier's aubio library for feature detection (if available)")
302 opt.add_option('--audiounits', action='store_true', default=False, dest='audiounits',
303 help='Compile with Apple\'s AudioUnit library (experimental)')
304 opt.add_option('--coreaudio', action='store_true', default=False, dest='coreaudio',
305 help='Compile with Apple\'s CoreAudio library')
306 opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
307 help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]')
308 opt.add_option('--extra-warn', action='store_true', default=False, dest='extra_warn',
309 help='Build with even more compiler warning flags')
310 opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
311 help='Build runtime checked assembler code')
312 opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
313 help='Install MIME type, icons and .desktop file as per freedesktop.org standards')
314 opt.add_option('--freesound', action='store_true', default=False, dest='freesound',
315 help='Include Freesound database lookup')
316 opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
317 help='Compile for use with gprofile')
318 opt.add_option('--gtkosx', action='store_true', default=False, dest='gtkosx',
319 help='Compile for use with GTK-OSX, not GTK-X11')
320 opt.add_option('--lv2', action='store_true', default=False, dest='lv2',
321 help='Compile with support for LV2 (if slv2 is available)')
322 opt.add_option('--nls', action='store_true', default=True, dest='nls',
323 help='Enable i18n (native language support)')
324 opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
325 help='Build with debugging for the STL')
326 opt.add_option('--syslibs', action='store_true', default=True, dest='syslibs',
327 help='Use existing system versions of various libraries instead of internal ones')
328 opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
329 help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
330 opt.add_option('--universal', action='store_true', default=False, dest='universal',
331 help='Compile as universal binary (requires that external libraries are universal)')
332 opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
333 help='Add revision information to executable name inside the build directory')
334 opt.add_option('--vst', action='store_true', default=False, dest='vst',
335 help='Compile with support for VST')
336 opt.add_option('--wiimote', action='store_true', default=False, dest='wiimote',
337 help='Build the wiimote control surface')
338 opt.add_option('--windows-key', type='string', dest='windows_key',
339 help='Set X Modifier (Mod1,Mod2,Mod3,Mod4,Mod5) for "Windows" key [Default: Mod4]', default='Mod4><Super')
343 def sub_config_and_use(conf, name, has_objects = True):
344 conf.sub_config(name)
345 autowaf.set_local_lib(conf, name, has_objects)
348 create_stored_revision()
349 autowaf.set_recursive()
350 autowaf.configure(conf)
351 autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')
352 autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0')
354 sub_config_and_use(conf, i)
356 # Fix utterly braindead FLAC include path to not smash assert.h
357 conf.env['CPPPATH_FLAC'] = []
359 # Tell everyone that this is a waf build
361 conf.env.append_value('CCFLAGS', '-DWAF_BUILD')
362 conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
364 autowaf.print_summary(conf)
365 opts = Options.options
366 autowaf.display_header('Ardour Configuration')
367 autowaf.display_msg(conf, 'Build Target', conf.env['build_target'])
368 autowaf.display_msg(conf, 'Architecture flags', opts.arch)
369 autowaf.display_msg(conf, 'Aubio', bool(conf.env['HAVE_AUBIO']))
370 autowaf.display_msg(conf, 'AudioUnits', opts.audiounits)
372 conf.define('AUDIOUNITS',1)
373 autowaf.display_msg(conf, 'FPU Optimization', opts.fpu_optimization)
374 if opts.fpu_optimization:
375 conf.define('FPU_OPTIMIZATION', 1)
376 autowaf.display_msg(conf, 'Freedesktop Files', opts.freedesktop)
377 autowaf.display_msg(conf, 'Freesound', opts.freesound)
379 conf.define('FREESOUND',1)
380 autowaf.display_msg(conf, 'GtkOSX', opts.gtkosx)
382 conf.define ('GTKOSX', 1)
383 autowaf.display_msg(conf, 'LV2 Support', bool(conf.env['HAVE_SLV2']))
384 autowaf.display_msg(conf, 'Rubberband', bool(conf.env['HAVE_RUBBERBAND']))
385 autowaf.display_msg(conf, 'Samplerate', bool(conf.env['HAVE_SAMPLERATE']))
386 autowaf.display_msg(conf, 'Soundtouch', bool(conf.env['HAVE_SOUNDTOUCH']))
387 autowaf.display_msg(conf, 'Translation', opts.nls)
388 autowaf.display_msg(conf, 'System Libraries', opts.syslibs)
389 autowaf.display_msg(conf, 'Tranzport', opts.tranzport)
391 conf.define('TRANZPORT', 1)
392 autowaf.display_msg(conf, 'Universal Binary', opts.universal)
393 autowaf.display_msg(conf, 'VST Support', opts.vst)
395 conf.define('VST_SUPPORT', 1)
396 autowaf.display_msg(conf, 'Wiimote Support', opts.wiimote)
398 conf.define('WIIMOTE',1)
399 autowaf.display_msg(conf, 'Windows Key', opts.windows_key)
401 conf.define('WINDOWS_KEY', opts.windows_key)
403 set_compiler_flags (conf, Options.options)
405 autowaf.display_msg(conf, 'C Compiler flags', conf.env['CCFLAGS'])
406 autowaf.display_msg(conf, 'C++ Compiler flags', conf.env['CXXFLAGS'])
409 autowaf.set_recursive()