Update Mackie surface state when something is connected to its output port (#3887).
[ardour.git] / wscript
1 #!/usr/bin/env python
2 import autowaf
3 import Options
4 import os
5 import re
6 import string
7 import subprocess
8 import sys
9 import glob
10
11 # Variables for 'waf dist'
12 VERSION = '3.0alpha10'
13 APPNAME = 'Ardour'
14
15 # Mandatory variables
16 srcdir = '.'
17 blddir = 'build'
18
19 children = [
20         'libs/pbd',
21         'libs/midi++2',
22         'libs/evoral',
23         'libs/vamp-sdk',
24         'libs/qm-dsp',
25         'libs/vamp-plugins',
26         'libs/taglib',
27         'libs/rubberband',
28         'libs/surfaces',
29         'libs/panners',
30         'libs/timecode',
31         'libs/ardour',
32         'libs/gtkmm2ext',
33         'libs/clearlooks-newer',
34         'libs/audiographer',
35         'libs/gnomecanvas',
36         'gtk2_ardour',
37         'templates',
38         'export',
39 # this needs to be conditional at some point, since
40 # we will not build it or use it on OS X
41         'tools/sanity_check'
42 ]
43
44 i18n_children = [
45         'gtk2_ardour',
46         'libs/ardour',
47         'libs/gtkmm2ext',
48 ]
49
50 # Version stuff
51
52 def fetch_svn_revision (path):
53     cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'"
54     return subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
55
56 def fetch_gcc_version (CC):
57     cmd = "LANG= %s --version" % CC
58     output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
59     o = output[0].decode('utf-8')
60     version = o.split(' ')[2].split('.')
61     return version
62
63 def fetch_git_revision (path):
64     cmd = "LANG= git log --abbrev HEAD^..HEAD " + path
65     output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
66     o = output[0].decode('utf-8')
67     rev = o.replace ("commit", "git")[0:10]
68     for line in output:
69         try:
70             if "git-svn-id" in line:
71                 line = line.split('@')[1].split(' ')
72                 rev = line[0]
73         except:
74             pass
75     return rev
76
77 def fetch_bzr_revision (path):
78     cmd = subprocess.Popen("LANG= bzr log -l 1 " + path, stdout=subprocess.PIPE, shell=True)
79     out = cmd.communicate()[0]
80     svn = re.search('^svn revno: [0-9]*', out, re.MULTILINE)
81     str = svn.group(0)
82     chars = 'svnreio: '
83     return string.lstrip(str, chars)
84
85 def create_stored_revision():
86     rev = ""
87     if os.path.exists('.svn'):
88         rev = fetch_svn_revision('.');
89     elif os.path.exists('.git'):
90         rev = fetch_git_revision('.');
91     elif os.path.exists('.bzr'):
92         rev = fetch_bzr_revision('.');
93         print("Revision: %s", rev)
94     elif os.path.exists('libs/ardour/svn_revision.cc'):
95         print("Using packaged svn revision")
96         return
97     else:
98         print("Missing libs/ardour/svn_revision.cc.  Blame the packager.")
99         sys.exit(-1)
100
101     try:
102         text =  '#include "ardour/svn_revision.h"\n'
103         text += 'namespace ARDOUR { const char* svn_revision = \"%s\"; }\n' % rev
104         print('Writing svn revision info to libs/ardour/svn_revision.cc')
105         o = open('libs/ardour/svn_revision.cc', 'w')
106         o.write(text)
107         o.close()
108     except IOError:
109         print('Could not open libs/ardour/svn_revision.cc for writing\n')
110         sys.exit(-1)
111
112 def set_compiler_flags (conf,opt):
113     #
114     # Compiler flags and other system-dependent stuff
115     #
116
117     build_host_supports_sse = False
118     optimization_flags = []
119     debug_flags = []
120
121     # guess at the platform, used to define compiler flags
122
123     config_guess = os.popen("tools/config.guess").read()[:-1]
124
125     config_cpu = 0
126     config_arch = 1
127     config_kernel = 2
128     config_os = 3
129     config = config_guess.split ("-")
130
131     if opt.gprofile:
132         debug_flags = [ '-pg' ]
133     else:
134         if config[config_arch] != 'apple':
135             debug_flags = [ '-rdynamic' ] # waf adds -O0 -g itself. thanks waf!
136
137     # Autodetect
138     if opt.dist_target == 'auto':
139         if config[config_arch] == 'apple':
140             # The [.] matches to the dot after the major version, "." would match any character
141             if re.search ("darwin[0-7][.]", config[config_kernel]) != None:
142                 conf.define ('build_target', 'panther')
143             elif re.search ("darwin8[.]", config[config_kernel]) != None:
144                 conf.define ('build_target', 'tiger')
145             else:
146                 conf.define ('build_target', 'leopard')
147         else:
148             if re.search ("x86_64", config[config_cpu]) != None:
149                 conf.define ('build_target', 'x86_64')
150             elif re.search("i[0-5]86", config[config_cpu]) != None:
151                 conf.define ('build_target', 'i386')
152             elif re.search("powerpc", config[config_cpu]) != None:
153                 conf.define ('build_target', 'powerpc')
154             else:
155                 conf.define ('build_target', 'i686')
156     else:
157         conf.define ('build_target', opt.dist_target)
158
159     if config[config_cpu] == 'powerpc' and conf.env['build_target'] != 'none':
160         #
161         # Apple/PowerPC optimization options
162         #
163         # -mcpu=7450 does not reliably work with gcc 3.*
164         #
165         if opt.dist_target == 'panther' or opt.dist_target == 'tiger':
166             if config[config_arch] == 'apple':
167                 # optimization_flags.extend ([ "-mcpu=7450", "-faltivec"])
168                 # to support g3s but still have some optimization for above
169                 optimization_flags.extend ([ "-mcpu=G3", "-mtune=7450"])
170             else:
171                 optimization_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
172         else:
173             optimization_flags.extend([ "-mcpu=750", "-mmultiple" ])
174         optimization_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
175         optimization_flags.extend (["-Os"])
176
177     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':
178
179
180         #
181         # ARCH_X86 means anything in the x86 family from i386 to x86_64
182         # USE_X86_64_ASM is used to distingush 32 and 64 bit assembler
183         #
184
185         if (re.search ("(i[0-9]86|x86_64)", config[config_cpu]) != None):
186             debug_flags.append ("-DARCH_X86")
187             optimization_flags.append ("-DARCH_X86")
188
189         if config[config_kernel] == 'linux' :
190
191             #
192             # determine processor flags via /proc/cpuinfo
193             #
194
195             if conf.env['build_target'] != 'i386':
196
197                 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
198                 x86_flags = flag_line.split (": ")[1:][0].split ()
199
200                 if "mmx" in x86_flags:
201                     optimization_flags.append ("-mmmx")
202                 if "sse" in x86_flags:
203                     build_host_supports_sse = True
204                 if "3dnow" in x86_flags:
205                     optimization_flags.append ("-m3dnow")
206
207             if config[config_cpu] == "i586":
208                 optimization_flags.append ("-march=i586")
209             elif config[config_cpu] == "i686":
210                 optimization_flags.append ("-march=i686")
211
212         if ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
213             optimization_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
214             debug_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
215
216     # end of processor-specific section
217
218     # optimization section
219     if conf.env['FPU_OPTIMIZATION']:
220         if conf.env['build_target'] == 'tiger' or conf.env['build_target'] == 'leopard':
221             optimization_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
222             debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
223             conf.env.append_value('LINKFLAGS', "-framework Accelerate")
224         elif conf.env['build_target'] == 'i686' or conf.env['build_target'] == 'x86_64':
225             optimization_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
226             debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
227         elif conf.env['build_target'] == 'x86_64':
228             optimization_flags.append ("-DUSE_X86_64_ASM")
229             debug_flags.append ("-DUSE_X86_64_ASM")
230         if not build_host_supports_sse:
231             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)")
232
233     # check this even if we aren't using FPU optimization
234     if not conf.env['HAVE_POSIX_MEMALIGN']:
235         optimization_flags.append("-DNO_POSIX_MEMALIGN")
236
237     # end optimization section
238
239     #
240     # no VST on x86_64
241     #
242
243     if conf.env['build_target'] == 'x86_64' and opt.vst:
244         print("\n\n==================================================")
245         print("You cannot use VST plugins with a 64 bit host. Please run waf with --vst=0")
246         print("\nIt is theoretically possible to build a 32 bit host on a 64 bit system.")
247         print("However, this is tricky and not recommended for beginners.")
248         sys.exit (-1)
249                 
250     if opt.lxvst:
251         if conf.env['build_target'] == 'x86_64':
252             print("\n\n********************************************************")
253             print("* Building with 64Bit linuxVST support is experimental *")
254             print("********************************************************\n\n")
255             conf.env.append_value('CXXFLAGS', "-DLXVST_64BIT")
256         else:
257             conf.env.append_value('CXXFLAGS', "-DLXVST_32BIT")
258
259     #
260     # a single way to test if we're on OS X
261     #
262
263     if conf.env['build_target'] in ['panther', 'tiger', 'leopard' ]:
264         conf.define ('IS_OSX', 1)
265         # force tiger or later, to avoid issues on PPC which defaults
266         # back to 10.1 if we don't tell it otherwise.
267         conf.env.append_value('CCFLAGS', "-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
268
269     else:
270         conf.define ('IS_OSX', 0)
271
272     #
273     # save off guessed arch element in an env
274     #
275     conf.define ('CONFIG_ARCH', config[config_arch])
276
277     #
278     # ARCH="..." overrides all
279     #
280
281     if opt.arch != None:
282         optimization_flags = opt.arch.split()
283
284     #
285     # prepend boiler plate optimization flags that work on all architectures
286     #
287
288     optimization_flags[:0] = [
289             "-O3",
290             "-fomit-frame-pointer",
291             "-ffast-math",
292             "-fstrength-reduce",
293             "-pipe"
294             ]
295
296     if opt.debug:
297         conf.env.append_value('CCFLAGS', debug_flags)
298         conf.env.append_value('CXXFLAGS', debug_flags)
299         conf.env.append_value('LINKFLAGS', debug_flags)
300     else:
301         conf.env.append_value('CCFLAGS', optimization_flags)
302         conf.env.append_value('CXXFLAGS', optimization_flags)
303         conf.env.append_value('LINKFLAGS', optimization_flags)
304
305     if opt.stl_debug:
306         conf.env.append_value('CXXFLAGS', "-D_GLIBCXX_DEBUG")
307
308     if conf.env['DEBUG_RT_ALLOC']:
309         conf.env.append_value('CCFLAGS', '-DDEBUG_RT_ALLOC')
310         conf.env.append_value('CXXFLAGS', '-DDEBUG_RT_ALLOC')
311         conf.env.append_value('LINKFLAGS', '-ldl')
312
313     if opt.universal:
314         conf.env.append_value('CCFLAGS', "-arch i386 -arch ppc")
315         conf.env.append_value('CXXFLAGS', "-arch i386 -arch ppc")
316         conf.env.append_value('LINKFLAGS', "-arch i386 -arch ppc")
317
318     #
319     # warnings flags
320     #
321
322     conf.env.append_value('CCFLAGS', "-Wall")
323     conf.env.append_value('CXXFLAGS', [ '-Wall', '-Woverloaded-virtual'])
324
325     if opt.extra_warn:
326         flags = [ '-Wextra' ]
327         conf.env.append_value('CCFLAGS', flags )
328         conf.env.append_value('CXXFLAGS', flags )
329
330
331     #
332     # more boilerplate
333     #
334
335     conf.env.append_value('CCFLAGS', '-D_LARGEFILE64_SOURCE')
336     conf.env.append_value('CCFLAGS', '-D_FILE_OFFSET_BITS=64')
337     conf.env.append_value('CXXFLAGS', '-D_LARGEFILE64_SOURCE')
338     conf.env.append_value('CXXFLAGS', '-D_FILE_OFFSET_BITS=64')
339
340     conf.env.append_value('CXXFLAGS', '-D__STDC_LIMIT_MACROS')
341     conf.env.append_value('CXXFLAGS', '-D__STDC_FORMAT_MACROS')
342
343     if opt.nls:
344         conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
345         conf.env.append_value('CCFLAGS', '-DENABLE_NLS')
346
347 #----------------------------------------------------------------
348
349 # Waf stages
350
351 def set_options(opt):
352     autowaf.set_options(opt)
353     opt.add_option('--program-name', type='string', action='store', default='Ardour', dest='program_name',
354                     help='The user-visible name of the program being built')
355     opt.add_option('--arch', type='string', action='store', dest='arch',
356                     help='Architecture-specific compiler flags')
357     opt.add_option('--boost-sp-debug', action='store_true', default=False, dest='boost_sp_debug',
358                     help='Compile with Boost shared pointer debugging')
359     opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
360                     help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]')
361     opt.add_option('--extra-warn', action='store_true', default=False, dest='extra_warn',
362                     help='Build with even more compiler warning flags')
363     opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
364                     help='Build runtime checked assembler code (default)')
365     opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization')
366     opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
367                     help='Install MIME type, icons and .desktop file as per freedesktop.org standards')
368     opt.add_option('--freesound', action='store_true', default=False, dest='freesound',
369                     help='Include Freesound database lookup')
370     opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
371                     help='Compile for use with gprofile')
372     opt.add_option('--lv2', action='store_true', default=False, dest='lv2',
373                     help='Compile with support for LV2 (if SLV2 or Lilv+Suil is available)')
374     opt.add_option('--lxvst', action='store_true', default=False, dest='lxvst',
375                     help='Compile with support for linuxVST plugins')
376     opt.add_option('--nls', action='store_true', default=True, dest='nls',
377                     help='Enable i18n (native language support) (default)')
378     opt.add_option('--no-nls', action='store_false', dest='nls')
379     opt.add_option('--phone-home', action='store_false', default=True, dest='phone_home')
380     opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
381                     help='Build with debugging for the STL')
382     opt.add_option('--rt-alloc-debug', action='store_true', default=False, dest='rt_alloc_debug',
383                     help='Build with debugging for memory allocation in the real-time thread')
384     opt.add_option('--test', action='store_true', default=False, dest='build_tests',
385                     help="Build unit tests")
386     opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
387                     help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
388     opt.add_option('--universal', action='store_true', default=False, dest='universal',
389                     help='Compile as universal binary (requires that external libraries are universal)')
390     opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
391                     help='Add revision information to executable name inside the build directory')
392     opt.add_option('--vst', action='store_true', default=False, dest='vst',
393                     help='Compile with support for VST')
394     opt.add_option('--wiimote', action='store_true', default=False, dest='wiimote',
395                     help='Build the wiimote control surface')
396     opt.add_option('--windows-key', type='string', action='store', dest='windows_key', default='Mod4><Super',
397                     help='X Modifier(s) (Mod1,Mod2, etc) for the Windows key (X11 builds only). ' +
398                     'Multiple modifiers must be separated by \'><\'')
399     opt.add_option('--boost-include', type='string', action='store', dest='boost_include', default='',
400                     help='directory where Boost header files can be found')
401     opt.add_option('--wine-include', type='string', action='store', dest='wine_include', default='/usr/include/wine/windows',
402                     help='directory where Wine\'s Windows header files can be found')
403     opt.add_option('--noconfirm', action='store_true', default=False, dest='noconfirm',
404                     help='Do not ask questions that require confirmation during the build')
405     for i in children:
406         opt.sub_options(i)
407
408 def sub_config_and_use(conf, name, has_objects = True):
409     conf.sub_config(name)
410     autowaf.set_local_lib(conf, name, has_objects)
411
412 def configure(conf):
413     if not Options.options.noconfirm:
414         print ('\n\nThis is an alpha version of Ardour 3.0.\n\n' +
415                'You are respectfully requested NOT to ask for assistance with build issues\n' +
416                'and not to report issues with Ardour 3.0 on the forums at ardour.org.\n\n' +
417                'Please use IRC, the bug tracker and/or the ardour mailing lists (-dev or -user)\n\n' +
418                'Thanks for your co-operation with our development process.\n\n' +
419                'Press Enter to continue.\n')
420         sys.stdin.readline()
421     create_stored_revision()
422     conf.env['VERSION'] = VERSION
423     conf.line_just = 52
424     autowaf.set_recursive()
425     autowaf.configure(conf)
426     autowaf.display_header('Ardour Configuration')
427
428     gcc_versions = fetch_gcc_version(str(conf.env['CC']))
429     if not Options.options.debug and gcc_versions[0] == '4' and gcc_versions[1] > '4':
430         print('Version 4.5 of gcc is not ready for use when compiling Ardour with optimization.')
431         print('Please use a different version or re-configure with --debug')
432         exit (1)
433
434     if sys.platform == 'darwin':
435
436         conf.define ('AUDIOUNITS', 1)
437         conf.define ('AU_STATE_SUPPORT', 1)
438         conf.define ('COREAUDIO', 1)
439         conf.define ('GTKOSX', 1)
440         conf.define ('TOP_MENUBAR',1)
441         conf.define ('GTKOSX',1)
442
443         conf.env.append_value('CXXFLAGS_APPLEUTILITY', '-I../libs')
444         #
445         #       Define OSX as a uselib to use when compiling
446         #       on Darwin to add all applicable flags at once
447         #
448         conf.env.append_value('CXXFLAGS_OSX', '-DMAC_OS_X_VERSION_MIN_REQUIRED=1040')
449         conf.env.append_value('CCFLAGS_OSX', '-DMAC_OS_X_VERSION_MIN_REQUIRED=1040')
450         conf.env.append_value('CXXFLAGS_OSX', '-mmacosx-version-min=10.4')
451         conf.env.append_value('CCFLAGS_OSX', '-mmacosx-version-min=10.4')
452
453         #conf.env.append_value('CXXFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
454         #conf.env.append_value('CCFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
455         #conf.env.append_value('LINKFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
456
457         #conf.env.append_value('LINKFLAGS_OSX', "-sysroot /Developer/SDKs/MacOSX10.4u.sdk")
458
459         conf.env.append_value('CXXFLAGS_OSX', "-msse")
460         conf.env.append_value('CCFLAGS_OSX', "-msse")
461         conf.env.append_value('CXXFLAGS_OSX', "-msse2")
462         conf.env.append_value('CCFLAGS_OSX', "-msse2")
463         #
464         #       TODO: The previous sse flags NEED to be based
465         #       off processor type.  Need to add in a check
466         #       for that.
467         #
468         conf.env.append_value('CXXFLAGS_OSX', '-F/System/LibraryFrameworks')
469         conf.env.append_value('CXXFLAGS_OSX', '-F/Library/Frameworks')
470
471         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'AppKit'])
472         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreAudio'])
473         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreFoundation'])
474         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreServices'])
475
476         conf.env.append_value('LINKFLAGS_OSX', ['-undefined', 'suppress' ])
477         conf.env.append_value('LINKFLAGS_OSX', '-flat_namespace')
478
479         conf.env.append_value('LINKFLAGS_GTKOSX', [ '-Xlinker', '-headerpad'])
480         conf.env.append_value('LINKFLAGS_GTKOSX', ['-Xlinker', '2048'])
481         conf.env.append_value('CPPPATH_GTKOSX', "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/")
482
483         conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DHAVE_AUDIOUNITS")
484         conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'Audiotoolbox', '-framework', 'AudioUnit'])
485
486     if Options.options.boost_include != '':
487         conf.env.append_value('CPPPATH', Options.options.boost_include)
488
489     autowaf.check_header(conf, 'boost/signals2.hpp', mandatory = True)
490
491     if Options.options.boost_sp_debug:
492         conf.env.append_value('CXXFLAGS', '-DBOOST_SP_ENABLE_DEBUG_HOOKS')
493
494     autowaf.check_header(conf, 'jack/session.h', define="JACK_SESSION", mandatory = False)
495
496     conf.check_cc(fragment = "#include <boost/version.hpp>\nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n",
497                   execute = "1",
498                   mandatory = True,
499                   msg = 'Checking for boost library >= 1.39',
500                   okmsg = 'ok',
501                   errmsg = 'too old\nPlease install boost version 1.39 or higher.')
502
503     autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=False)
504     autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')
505     autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2')
506     autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0')
507     autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18')
508
509     if sys.platform == 'darwin':
510         sub_config_and_use(conf, 'libs/appleutility')
511     for i in children:
512         sub_config_and_use(conf, i)
513
514     # Fix utterly braindead FLAC include path to not smash assert.h
515     conf.env['CPPPATH_FLAC'] = []
516
517     conf.check_cc(function_name='dlopen', header_name='dlfcn.h', linkflags='-ldl', uselib_store='DL')
518     conf.check_cc(function_name='curl_global_init', header_name='curl/curl.h', linkflags='-lcurl', uselib_store='CURL')
519
520     # Tell everyone that this is a waf build
521
522     conf.env.append_value('CCFLAGS', '-DWAF_BUILD')
523     conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
524
525     # Set up waf environment
526     opts = Options.options
527     if opts.debug:
528         opts.phone_home = False;   # debug builds should not call home
529     if opts.phone_home:
530         conf.env['PHONE_HOME'] = opts.phone_home
531     if opts.fpu_optimization:
532         conf.define('FPU_OPTIMIZATION', 1)
533     if opts.freesound:
534         conf.define('FREESOUND',1)
535     if opts.nls:
536         conf.define ('ENABLE_NLS', 1)
537     if opts.build_tests:
538         conf.env['BUILD_TESTS'] = opts.build_tests
539     if opts.tranzport:
540         conf.define('TRANZPORT', 1)
541     if opts.vst:
542         conf.define('VST_SUPPORT', 1)
543         conf.env.append_value('CPPPATH', Options.options.wine_include)
544         autowaf.check_header(conf, 'windows.h', mandatory = True)
545     if opts.lxvst:
546         conf.define('LXVST_SUPPORT', 1)
547         conf.env['LXVST_SUPPORT'] = True
548     if bool(conf.env['JACK_SESSION']):
549         conf.define ('HAVE_JACK_SESSION', 1)
550     if opts.wiimote:
551         conf.define('WIIMOTE',1)
552     conf.define('WINDOWS_KEY', opts.windows_key)
553     conf.env['PROGRAM_NAME'] = opts.program_name
554     if opts.rt_alloc_debug:
555         conf.define('DEBUG_RT_ALLOC', 1)
556     if not conf.env['HAVE_CPPUNIT']:
557         conf.env['BUILD_TESTS'] = False
558
559     set_compiler_flags (conf, Options.options)
560
561     config_text = open('libs/ardour/config_text.cc', "w")
562     config_text.write('''#include "ardour/ardour.h"
563 namespace ARDOUR {
564 const char* const ardour_config_info = "\\n\\
565 ''')
566
567     def write_config_text(title, val):
568         autowaf.display_msg(conf, title, val)
569         config_text.write(title + ': ')
570         config_text.write(str(val))
571         config_text.write("\\n\\\n")
572
573     write_config_text('Build documentation',   conf.env['DOCS'])
574     write_config_text('Debuggable build',      conf.env['DEBUG'])
575     write_config_text('Install prefix',        conf.env['PREFIX'])
576     write_config_text('Strict compiler flags', conf.env['STRICT'])
577
578     write_config_text('Architecture flags',    opts.arch)
579     write_config_text('Aubio',                 bool(conf.env['HAVE_AUBIO']))
580     write_config_text('Build target',          conf.env['build_target'])
581     write_config_text('CoreAudio',             bool(conf.env['HAVE_COREAUDIO']))
582     write_config_text('FLAC',                  bool(conf.env['HAVE_FLAC']))
583     write_config_text('FPU optimization',      opts.fpu_optimization)
584     write_config_text('Freedesktop files',     opts.freedesktop)
585     write_config_text('Freesound',             opts.freesound)
586     write_config_text('JACK session support',  bool(conf.env['JACK_SESSION']))
587     write_config_text('LV2 UI embedding',      bool(conf.env['HAVE_SUIL']))
588     write_config_text('LV2 support',           bool(conf.env['LV2_SUPPORT']))
589     write_config_text('LXVST support',         bool(conf.env['LXVST_SUPPORT']))
590     write_config_text('OGG',                   bool(conf.env['HAVE_OGG']))
591     write_config_text('Phone home',            bool(conf.env['PHONE_HOME']))
592     write_config_text('Program name',          opts.program_name)
593     write_config_text('Rubberband',            bool(conf.env['HAVE_RUBBERBAND']))
594     write_config_text('Samplerate',            bool(conf.env['HAVE_SAMPLERATE']))
595     write_config_text('Soundtouch',            bool(conf.env['HAVE_SOUNDTOUCH']))
596     write_config_text('Translation',           opts.nls)
597     write_config_text('Tranzport',             opts.tranzport)
598     write_config_text('Unit tests',            bool(conf.env['BUILD_TESTS']))
599     write_config_text('Universal binary',      opts.universal)
600     write_config_text('VST support',           opts.vst)
601     write_config_text('Wiimote support',       opts.wiimote)
602     write_config_text('Windows key',           opts.windows_key)
603
604     write_config_text('C compiler flags',      conf.env['CCFLAGS'])
605     write_config_text('C++ compiler flags',    conf.env['CXXFLAGS'])
606
607     config_text.write ('";\n}\n')
608     config_text.close ()
609     print('')
610
611 def build(bld):
612     # add directories that contain only headers, to workaround an issue with waf
613
614     bld.path.find_dir ('libs/evoral/evoral')
615     bld.path.find_dir ('libs/vamp-sdk/vamp-sdk')
616     bld.path.find_dir ('libs/surfaces/control_protocol/control_protocol')
617     bld.path.find_dir ('libs/timecode/timecode')
618     bld.path.find_dir ('libs/rubberband/rubberband')
619     bld.path.find_dir ('libs/gtkmm2ext/gtkmm2ext')
620     bld.path.find_dir ('libs/ardour/ardour')
621     bld.path.find_dir ('libs/taglib/taglib')
622     bld.path.find_dir ('libs/pbd/pbd')
623
624     autowaf.set_recursive()
625     if sys.platform == 'darwin':
626         bld.add_subdirs('libs/appleutility')
627     for i in children:
628         bld.add_subdirs(i)
629
630     # ideally, we'd like to use the OS-provided MIDI API
631     # for default ports. that doesn't work on at least
632     # Fedora (Nov 9th, 2009) so use JACK MIDI on linux.
633
634     if sys.platform == 'darwin':
635         rc_subst_dict = {
636                 'MIDITAG'    : 'control',
637                 'MIDITYPE'   : 'coremidi',
638                 'JACK_INPUT' : 'auditioner'
639                 }
640     else:
641         rc_subst_dict = {
642                 'MIDITAG'    : 'control',
643                 'MIDITYPE'   : 'jack',
644                 'JACK_INPUT' : 'auditioner'
645                 }
646
647     obj              = bld.new_task_gen('subst')
648     obj.source       = 'ardour.rc.in'
649     obj.target       = 'ardour_system.rc'
650     obj.dict         = rc_subst_dict
651     obj.install_path = '${CONFIGDIR}/ardour3'
652
653 def i18n(bld):
654     bld.recurse (i18n_children)