Fix saving sessions on windows by using g_rename instead of ::rename
[ardour.git] / wscript
1 #!/usr/bin/env python
2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
4 import os
5 import re
6 import string
7 import subprocess
8 import sys
9
10 MAJOR = '3'
11 MINOR = '2'
12 VERSION = MAJOR + '.' + MINOR
13
14 APPNAME = 'Ardour' + MAJOR
15
16 # Mandatory variables
17 top = '.'
18 out = 'build'
19
20 children = [
21         'libs/pbd',
22         'libs/midi++2',
23         'libs/evoral',
24         'libs/vamp-sdk',
25         'libs/qm-dsp',
26         'libs/vamp-plugins',
27         'libs/taglib',
28         'libs/libltc',
29         'libs/rubberband',
30         'libs/surfaces',
31         'libs/panners',
32         'libs/timecode',
33         'libs/ardour',
34         'libs/gtkmm2ext',
35         'libs/clearlooks-newer',
36         'libs/audiographer',
37         'gtk2_ardour',
38         'export',
39         'midi_maps',
40         'mcp',
41         'patchfiles'
42 ]
43
44 i18n_children = [
45         'gtk2_ardour',
46         'libs/ardour',
47         'libs/gtkmm2ext',
48 ]
49
50 if sys.platform == 'linux2':
51     children += [ 'tools/sanity_check' ]
52     lxvst_default = True
53 elif sys.platform == 'darwin':
54     children += [ 'libs/appleutility' ]
55     lxvst_default = False
56 else:
57     lxvst_default = False
58
59 # Version stuff
60
61 def fetch_gcc_version (CC):
62     cmd = "LANG= %s --version" % CC
63     output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
64     o = output[0].decode('utf-8')
65     version = o.split(' ')[2].split('.')
66     return version
67
68 def fetch_git_revision ():
69     cmd = "LANG= git describe --tags HEAD"
70     output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
71     rev = output[0].decode('utf-8')
72     return rev
73
74 def create_stored_revision():
75     rev = ""
76     if os.path.exists('.git'):
77         rev = fetch_git_revision();
78         print("ardour.git version: " + rev + "\n")
79     elif os.path.exists('libs/ardour/revision.cc'):
80         print("Using packaged revision")
81         return
82     else:
83         print("Missing libs/ardour/revision.cc.  Blame the packager.")
84         sys.exit(-1)
85
86     try:
87         text =  '#include "ardour/revision.h"\n'
88         text += 'namespace ARDOUR { const char* revision = \"%s\"; }\n' % rev
89         print('Writing revision info to libs/ardour/revision.cc using ' + rev)
90         o = open('libs/ardour/revision.cc', 'w')
91         o.write(text)
92         o.close()
93     except IOError:
94         print('Could not open libs/ardour/revision.cc for writing\n')
95         sys.exit(-1)
96
97 def set_compiler_flags (conf,opt):
98     #
99     # Compiler flags and other system-dependent stuff
100     #
101
102     build_host_supports_sse = False
103     optimization_flags = []
104     debug_flags = []
105
106     u = os.uname ()
107     cpu = u[4]
108     platform = u[0].lower()
109     version = u[2]
110
111     # waf adds -O0 -g itself. thanks waf!
112     is_clang = conf.env['CXX'][0].endswith('clang++')
113     if opt.gprofile:
114         debug_flags = [ '-pg' ]
115
116     if opt.backtrace:
117         if platform != 'darwin' and not is_clang:
118             debug_flags = [ '-rdynamic' ]
119
120     # Autodetect
121     if opt.dist_target == 'auto':
122         if platform == 'darwin':
123             # The [.] matches to the dot after the major version, "." would match any character
124             if re.search ("^[0-7][.]", version) != None:
125                 conf.env['build_target'] = 'panther'
126             elif re.search ("^8[.]", version) != None:
127                 conf.env['build_target'] = 'tiger'
128             elif re.search ("^9[.]", version) != None:
129                 conf.env['build_target'] = 'leopard'
130             elif re.search ("^10[.]", version) != None:
131                 conf.env['build_target'] = 'snowleopard'
132             elif re.search ("^11[.]", version) != None:
133                 conf.env['build_target'] = 'lion'
134             else:
135                 conf.env['build_target'] = 'mountainlion'
136         else:
137             if re.search ("x86_64", cpu) != None:
138                 conf.env['build_target'] = 'x86_64'
139             elif re.search("i[0-5]86", cpu) != None:
140                 conf.env['build_target'] = 'i386'
141             elif re.search("powerpc", cpu) != None:
142                 conf.env['build_target'] = 'powerpc'
143             else:
144                 conf.env['build_target'] = 'i686'
145     else:
146         conf.env['build_target'] = opt.dist_target
147
148     if conf.env['build_target'] == 'snowleopard':
149         #
150         # stupid OS X 10.6 has a bug in math.h that prevents llrint and friends
151         # from being visible.
152         # 
153         debug_flags.append ('-U__STRICT_ANSI__')
154         optimization_flags.append ('-U__STRICT_ANSI__')
155
156     if cpu == 'powerpc' and conf.env['build_target'] != 'none':
157         #
158         # Apple/PowerPC optimization options
159         #
160         # -mcpu=7450 does not reliably work with gcc 3.*
161         #
162         if opt.dist_target == 'panther' or opt.dist_target == 'tiger':
163             if platform == 'darwin':
164                 # optimization_flags.extend ([ "-mcpu=7450", "-faltivec"])
165                 # to support g3s but still have some optimization for above
166                 optimization_flags.extend ([ "-mcpu=G3", "-mtune=7450"])
167             else:
168                 optimization_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
169         else:
170             optimization_flags.extend([ "-mcpu=750", "-mmultiple" ])
171         optimization_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
172         optimization_flags.extend (["-Os"])
173
174     elif ((re.search ("i[0-9]86", cpu) != None) or (re.search ("x86_64", cpu) != None)) and conf.env['build_target'] != 'none':
175
176
177         #
178         # ARCH_X86 means anything in the x86 family from i386 to x86_64
179         # the compile-time presence of the macro _LP64 is used to 
180         # distingush 32 and 64 bit assembler
181         #
182
183         if (re.search ("(i[0-9]86|x86_64)", cpu) != None):
184             debug_flags.append ("-DARCH_X86")
185             optimization_flags.append ("-DARCH_X86")
186
187         if platform == 'linux' :
188
189             #
190             # determine processor flags via /proc/cpuinfo
191             #
192
193             if conf.env['build_target'] != 'i386':
194
195                 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
196                 x86_flags = flag_line.split (": ")[1:][0].split ()
197
198                 if "mmx" in x86_flags:
199                     optimization_flags.append ("-mmmx")
200                 if "sse" in x86_flags:
201                     build_host_supports_sse = True
202                 if "3dnow" in x86_flags:
203                     optimization_flags.append ("-m3dnow")
204
205             if cpu == "i586":
206                 optimization_flags.append ("-march=i586")
207             elif cpu == "i686":
208                 optimization_flags.append ("-march=i686")
209
210         if not is_clang and ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
211             optimization_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
212             debug_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
213
214     # end of processor-specific section
215
216     # optimization section
217     if conf.env['FPU_OPTIMIZATION']:
218         if sys.platform == 'darwin':
219             optimization_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
220             debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
221             conf.env.append_value('LINKFLAGS', "-framework Accelerate")
222         elif conf.env['build_target'] == 'i686' or conf.env['build_target'] == 'x86_64':
223             optimization_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
224             debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
225         if not build_host_supports_sse:
226             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)")
227
228     # end optimization section
229
230     #
231     # no VST on x86_64
232     #
233
234     if conf.env['build_target'] == 'x86_64' and opt.windows_vst:
235         print("\n\n==================================================")
236         print("You cannot use VST plugins with a 64 bit host. Please run waf with --windows-vst=0")
237         print("\nIt is theoretically possible to build a 32 bit host on a 64 bit system.")
238         print("However, this is tricky and not recommended for beginners.")
239         sys.exit (-1)
240
241     if opt.lxvst:
242         if conf.env['build_target'] == 'x86_64':
243             conf.env.append_value('CXXFLAGS', "-DLXVST_64BIT")
244         else:
245             conf.env.append_value('CXXFLAGS', "-DLXVST_32BIT")
246
247     #
248     # a single way to test if we're on OS X
249     #
250
251     if conf.env['build_target'] in ['panther', 'tiger', 'leopard', 'snowleopard' ]:
252         conf.define ('IS_OSX', 1)
253         # force tiger or later, to avoid issues on PPC which defaults
254         # back to 10.1 if we don't tell it otherwise.
255         
256         conf.env.append_value('CFLAGS', "-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
257         conf.env.append_value('CXXFLAGS', "-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
258         conf.env.append_value('CXXFLAGS', '-mmacosx-version-min=10.4')
259         conf.env.append_value('CFLAGS', '-mmacosx-version-min=10.4')
260
261
262     elif conf.env['build_target'] in [ 'lion', 'mountainlion' ]:
263         conf.env.append_value('CFLAGS', "-DMAC_OS_X_VERSION_MIN_REQUIRED=1070")
264         conf.env.append_value('CXXFLAGS', "-DMAC_OS_X_VERSION_MIN_REQUIRED=1070")
265         conf.env.append_value('CXXFLAGS', '-mmacosx-version-min=10.7')
266         conf.env.append_value('CFLAGS', '-mmacosx-version-min=10.7')
267     else:
268         conf.define ('IS_OSX', 0)
269
270     #
271     # save off CPU element in an env
272     #
273     conf.define ('CONFIG_ARCH', cpu)
274
275     #
276     # ARCH="..." overrides all
277     #
278
279     if opt.arch != None:
280         optimization_flags = opt.arch.split()
281
282     #
283     # prepend boiler plate optimization flags that work on all architectures
284     #
285
286     optimization_flags[:0] = [
287             "-O3",
288             "-fomit-frame-pointer",
289             "-ffast-math",
290             "-fstrength-reduce",
291             "-pipe"
292             ]
293
294     if opt.debug:
295         conf.env.append_value('CFLAGS', debug_flags)
296         conf.env.append_value('CXXFLAGS', debug_flags)
297         conf.env.append_value('LINKFLAGS', debug_flags)
298     else:
299         conf.env.append_value('CFLAGS', optimization_flags)
300         conf.env.append_value('CXXFLAGS', optimization_flags)
301         conf.env.append_value('LINKFLAGS', optimization_flags)
302
303     if opt.stl_debug:
304         conf.env.append_value('CXXFLAGS', "-D_GLIBCXX_DEBUG")
305
306     if conf.env['DEBUG_RT_ALLOC']:
307         conf.env.append_value('CFLAGS', '-DDEBUG_RT_ALLOC')
308         conf.env.append_value('CXXFLAGS', '-DDEBUG_RT_ALLOC')
309         conf.env.append_value('LINKFLAGS', '-ldl')
310
311     if conf.env['DEBUG_DENORMAL_EXCEPTION']:
312         conf.env.append_value('CFLAGS', '-DDEBUG_DENORMAL_EXCEPTION')
313         conf.env.append_value('CXXFLAGS', '-DDEBUG_DENORMAL_EXCEPTION')
314
315     if opt.universal:
316         if opt.generic:
317             print ('Specifying Universal and Generic builds at the same time is not supported')
318             sys.exit (1)
319         else:
320             if not Options.options.nocarbon:
321                 conf.env.append_value('CFLAGS', ["-arch", "i386", "-arch", "ppc"])
322                 conf.env.append_value('CXXFLAGS', ["-arch", "i386", "-arch", "ppc"])
323                 conf.env.append_value('LINKFLAGS', ["-arch", "i386", "-arch", "ppc"])
324             else:
325                 conf.env.append_value('CFLAGS', ["-arch", "x86_64", "-arch", "i386", "-arch", "ppc"])
326                 conf.env.append_value('CXXFLAGS', ["-arch", "x86_64", "-arch", "i386", "-arch", "ppc"])
327                 conf.env.append_value('LINKFLAGS', ["-arch", "x86_64", "-arch", "i386", "-arch", "ppc"])
328     else:
329         if opt.generic:
330             conf.env.append_value('CFLAGS', ['-arch', 'i386'])
331             conf.env.append_value('CXXFLAGS', ['-arch', 'i386'])
332             conf.env.append_value('LINKFLAGS', ['-arch', 'i386'])
333
334     #
335     # warnings flags
336     #
337
338     conf.env.append_value('CFLAGS', [ '-Wall',
339                                       '-Wpointer-arith',
340                                       '-Wcast-qual',
341                                       '-Wcast-align',
342                                       '-Wstrict-prototypes',
343                                       '-Wmissing-prototypes'
344                                       ])
345
346     conf.env.append_value('CXXFLAGS', [ '-Wall', 
347                                         '-Wpointer-arith',
348                                         '-Wcast-qual',
349                                         '-Wcast-align', 
350                                         '-Woverloaded-virtual'
351                                         ])
352
353
354     #
355     # more boilerplate
356     #
357
358     conf.env.append_value('CFLAGS', '-DBOOST_SYSTEM_NO_DEPRECATED')
359     conf.env.append_value('CXXFLAGS', '-DBOOST_SYSTEM_NO_DEPRECATED')
360     conf.env.append_value('CFLAGS', '-D_LARGEFILE64_SOURCE')
361     conf.env.append_value('CFLAGS', '-D_FILE_OFFSET_BITS=64')
362     conf.env.append_value('CXXFLAGS', '-D_LARGEFILE64_SOURCE')
363     conf.env.append_value('CXXFLAGS', '-D_FILE_OFFSET_BITS=64')
364
365     conf.env.append_value('CXXFLAGS', '-D__STDC_LIMIT_MACROS')
366     conf.env.append_value('CXXFLAGS', '-D__STDC_FORMAT_MACROS')
367
368     if opt.nls:
369         conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
370         conf.env.append_value('CFLAGS', '-DENABLE_NLS')
371
372 #----------------------------------------------------------------
373
374 # Waf stages
375
376 def options(opt):
377     opt.load('compiler_c')
378     opt.load('compiler_cxx')
379     autowaf.set_options(opt, debug_by_default=True)
380     opt.add_option('--program-name', type='string', action='store', default='Ardour', dest='program_name',
381                     help='The user-visible name of the program being built')
382     opt.add_option('--arch', type='string', action='store', dest='arch',
383                     help='Architecture-specific compiler flags')
384     opt.add_option('--backtrace', action='store_true', default=False, dest='backtrace',
385                     help='Compile with -rdynamic -- allow obtaining backtraces from within Ardour')
386     opt.add_option('--no-carbon', action='store_true', default=False, dest='nocarbon',
387                     help='Compile without support for AU Plugins with only CARBON UI (needed for 64bit)')
388     opt.add_option('--boost-sp-debug', action='store_true', default=False, dest='boost_sp_debug',
389                     help='Compile with Boost shared pointer debugging')
390     opt.add_option('--depstack-root', type='string', default='~', dest='depstack_root',
391                     help='Directory/folder where dependency stack trees (gtk, a3) can be found (defaults to ~)')
392     opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
393                     help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]')
394     opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
395                     help='Build runtime checked assembler code (default)')
396     opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization')
397     opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
398                     help='Install MIME type, icons and .desktop file as per freedesktop.org standards')
399     opt.add_option('--freebie', action='store_true', default=False, dest='freebie',
400                     help='Build a version suitable for distribution as a zero-cost binary')
401     opt.add_option('--no-freesound', action='store_false', default=True, dest='freesound',
402                     help='Do not build with Freesound database support')
403     opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
404                     help='Compile for use with gprofile')
405     opt.add_option('--internal-shared-libs', action='store_true', default=True, dest='internal_shared_libs',
406                    help='Build internal libs as shared libraries')
407     opt.add_option('--internal-static-libs', action='store_false', dest='internal_shared_libs',
408                    help='Build internal libs as static libraries')
409     opt.add_option('--lv2', action='store_true', default=True, dest='lv2',
410                     help='Compile with support for LV2 (if Lilv+Suil is available)')
411     opt.add_option('--no-lv2', action='store_false', dest='lv2',
412                     help='Do not compile with support for LV2')
413     opt.add_option('--lxvst', action='store_true', default=lxvst_default, dest='lxvst',
414                     help='Compile with support for linuxVST plugins')
415     opt.add_option('--nls', action='store_true', default=True, dest='nls',
416                     help='Enable i18n (native language support) (default)')
417     opt.add_option('--no-nls', action='store_false', dest='nls')
418     opt.add_option('--phone-home', action='store_true', default=True, dest='phone_home',
419                    help='Contact ardour.org at startup for new announcements')
420     opt.add_option('--no-phone-home', action='store_false', dest='phone_home',
421                    help='Do not contact ardour.org at startup for new announcements')
422     opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
423                     help='Build with debugging for the STL')
424     opt.add_option('--rt-alloc-debug', action='store_true', default=False, dest='rt_alloc_debug',
425                     help='Build with debugging for memory allocation in the real-time thread')
426     opt.add_option('--pt-timing', action='store_true', default=False, dest='pt_timing',
427                     help='Build with logging of timing in the process thread(s)')
428     opt.add_option('--denormal-exception', action='store_true', default=False, dest='denormal_exception',
429                     help='Raise a floating point exception if a denormal is detected')
430     opt.add_option('--test', action='store_true', default=False, dest='build_tests',
431                     help="Build unit tests")
432     opt.add_option('--single-tests', action='store_true', default=False, dest='single_tests',
433                     help="Build a single executable for each unit test")
434     #opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
435     # help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
436     opt.add_option('--universal', action='store_true', default=False, dest='universal',
437                     help='Compile as universal binary (OS X ONLY, requires that external libraries are universal)')
438     opt.add_option('--generic', action='store_true', default=False, dest='generic',
439                     help='Compile with -arch i386 (OS X ONLY)')
440     opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
441                     help='Add revision information to executable name inside the build directory')
442     opt.add_option('--windows-vst', action='store_true', default=False, dest='windows_vst',
443                     help='Compile with support for Windows VST')
444     opt.add_option('--windows-key', type='string', action='store', dest='windows_key', default='Mod4><Super',
445                     help='X Modifier(s) (Mod1,Mod2, etc) for the Windows key (X11 builds only). ' +
446                     'Multiple modifiers must be separated by \'><\'')
447     opt.add_option('--boost-include', type='string', action='store', dest='boost_include', default='',
448                     help='directory where Boost header files can be found')
449     opt.add_option('--also-include', type='string', action='store', dest='also_include', default='',
450                     help='additional include directory where header files can be found (split multiples with commas)')
451     opt.add_option('--also-libdir', type='string', action='store', dest='also_libdir', default='',
452                     help='additional include directory where shared libraries can be found (split multiples with commas)')
453     opt.add_option('--wine-include', type='string', action='store', dest='wine_include', default='/usr/include/wine/windows',
454                     help='directory where Wine\'s Windows header files can be found')
455     opt.add_option('--noconfirm', action='store_true', default=False, dest='noconfirm',
456                     help='Do not ask questions that require confirmation during the build')
457     for i in children:
458         opt.recurse(i)
459
460 def sub_config_and_use(conf, name, has_objects = True):
461     conf.recurse(name)
462     autowaf.set_local_lib(conf, name, has_objects)
463
464 def configure(conf):
465     conf.load('compiler_c')
466     conf.load('compiler_cxx')
467     conf.env['VERSION'] = VERSION
468     conf.env['MAJOR'] = MAJOR
469     conf.env['MINOR'] = MINOR
470     conf.line_just = 52
471     autowaf.set_recursive()
472     autowaf.configure(conf)
473     autowaf.display_header('Ardour Configuration')
474
475     gcc_versions = fetch_gcc_version(str(conf.env['CC']))
476     if not Options.options.debug and gcc_versions[0] == '4' and gcc_versions[1] > '4':
477         print('Version 4.5 of gcc is not ready for use when compiling Ardour with optimization.')
478         print('Please use a different version or re-configure with --debug')
479         exit (1)
480
481     # systems with glibc have libintl builtin. systems without require explicit
482     # linkage against libintl.
483     #
484
485     pkg_config_path = os.getenv('PKG_CONFIG_PATH')
486     user_gtk_root = os.path.expanduser (Options.options.depstack_root + '/gtk/inst')
487
488     if pkg_config_path is not None and pkg_config_path.find (user_gtk_root) >= 0:
489         # told to search user_gtk_root
490         prefinclude = ''.join ([ '-I', user_gtk_root + '/include'])
491         preflib = ''.join ([ '-L', user_gtk_root + '/lib'])
492         conf.env.append_value('CFLAGS', [ prefinclude ])
493         conf.env.append_value('CXXFLAGS',  [prefinclude ])
494         conf.env.append_value('LINKFLAGS', [ preflib ])
495         autowaf.display_msg(conf, 'Will build against private GTK dependency stack in ' + user_gtk_root, 'yes')
496     else:
497         autowaf.display_msg(conf, 'Will build against private GTK dependency stack', 'no')
498
499     if sys.platform == 'darwin':
500         conf.define ('NEED_INTL', 1)
501         autowaf.display_msg(conf, 'Will use explicit linkage against libintl in ' + user_gtk_root, 'yes')
502     else:
503         # libintl is part of the system, so use it
504         autowaf.display_msg(conf, 'Will rely on libintl built into libc', 'yes')
505             
506     user_ardour_root = os.path.expanduser (Options.options.depstack_root + '/a3/inst')
507     if pkg_config_path is not None and pkg_config_path.find (user_ardour_root) >= 0:
508         # told to search user_ardour_root
509         prefinclude = ''.join ([ '-I', user_ardour_root + '/include'])
510         preflib = ''.join ([ '-L', user_ardour_root + '/lib'])
511         conf.env.append_value('CFLAGS', [ prefinclude ])
512         conf.env.append_value('CXXFLAGS',  [prefinclude ])
513         conf.env.append_value('LINKFLAGS', [ preflib ])
514         autowaf.display_msg(conf, 'Will build against private Ardour dependency stack in ' + user_ardour_root, 'yes')
515     else:
516         autowaf.display_msg(conf, 'Will build against private Ardour dependency stack', 'no')
517         
518     if Options.options.freebie:
519         conf.env.append_value ('CFLAGS', '-DNO_PLUGIN_STATE')
520         conf.env.append_value ('CXXFLAGS', '-DNO_PLUGIN_STATE')
521         conf.define ('NO_PLUGIN_STATE', 1)
522
523     if sys.platform == 'darwin':
524
525         # this is required, potentially, for anything we link and then relocate into a bundle
526         conf.env.append_value('LINKFLAGS', [ '-Xlinker', '-headerpad_max_install_names' ])
527
528         conf.define ('HAVE_COREAUDIO', 1)
529         conf.define ('AUDIOUNIT_SUPPORT', 1)
530
531         conf.define ('GTKOSX', 1)
532         conf.define ('TOP_MENUBAR',1)
533         conf.define ('GTKOSX',1)
534
535         # It would be nice to be able to use this to force back-compatibility with 10.4
536         # but even by the time of 11, the 10.4 SDK is no longer available in any normal
537         # way.
538         #
539         #conf.env.append_value('CXXFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
540         #conf.env.append_value('CFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
541         #conf.env.append_value('LINKFLAGS_OSX', "-sysroot /Developer/SDKs/MacOSX10.4u.sdk")
542         #conf.env.append_value('LINKFLAGS_OSX', "-sysroot /Developer/SDKs/MacOSX10.4u.sdk")
543
544         conf.env.append_value('CXXFLAGS_OSX', "-msse")
545         conf.env.append_value('CFLAGS_OSX', "-msse")
546         conf.env.append_value('CXXFLAGS_OSX', "-msse2")
547         conf.env.append_value('CFLAGS_OSX', "-msse2")
548         #
549         #       TODO: The previous sse flags NEED to be based
550         #       off processor type.  Need to add in a check
551         #       for that.
552         #
553         conf.env.append_value('CXXFLAGS_OSX', '-F/System/Library/Frameworks')
554         conf.env.append_value('CXXFLAGS_OSX', '-F/Library/Frameworks')
555
556         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'AppKit'])
557         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreAudio'])
558         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreAudioKit'])
559         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreFoundation'])
560         conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreServices'])
561
562         conf.env.append_value('LINKFLAGS_OSX', ['-undefined', 'dynamic_lookup' ])
563         conf.env.append_value('LINKFLAGS_OSX', ['-flat_namespace'])
564
565         conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DAUDIOUNIT_SUPPORT")
566         conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'AudioToolbox', '-framework', 'AudioUnit'])
567         conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'Cocoa'])
568
569         if re.search ("^[1-9][0-9]\.", os.uname()[2]) == None and not Options.options.nocarbon:
570             conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DWITH_CARBON")
571             conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'Carbon'])
572         else:
573             print ('No Carbon support available for this build\n')
574
575
576     if Options.options.internal_shared_libs: 
577         conf.define('INTERNAL_SHARED_LIBS', 1)
578
579     if Options.options.boost_include != '':
580         conf.env.append_value('CXXFLAGS', '-I' + Options.options.boost_include)
581
582     if Options.options.also_include != '':
583         conf.env.append_value('CXXFLAGS', '-I' + Options.options.also_include)
584         conf.env.append_value('CFLAGS', '-I' + Options.options.also_include)
585
586     if Options.options.also_libdir != '':
587         conf.env.append_value('LDFLAGS', '-L' + Options.options.also_libdir)
588
589     if Options.options.boost_sp_debug:
590         conf.env.append_value('CXXFLAGS', '-DBOOST_SP_ENABLE_DEBUG_HOOKS')
591
592     autowaf.check_header(conf, 'cxx', 'jack/session.h', define="JACK_SESSION", mandatory = False)
593
594     conf.check_cxx(fragment = "#include <boost/version.hpp>\nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n",
595                   execute = "1",
596                   mandatory = True,
597                   msg = 'Checking for boost library >= 1.39',
598                   okmsg = 'ok',
599                   errmsg = 'too old\nPlease install boost version 1.39 or higher.')
600
601     autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')
602     autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2')
603     autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0')
604     autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18')
605     autowaf.check_pkg(conf, 'giomm-2.4', uselib_store='GIOMM', atleast_version='2.2')
606     autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0')
607     autowaf.check_pkg(conf, 'liblo', uselib_store='LO', atleast_version='0.26')
608
609     conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL')
610
611     # Tell everyone that this is a waf build
612
613     conf.env.append_value('CFLAGS', '-DWAF_BUILD')
614     conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
615
616     # Set up waf environment and C defines
617     opts = Options.options
618     if opts.phone_home:
619         conf.define('PHONE_HOME', 1)
620         conf.env['PHONE_HOME'] = True
621     if opts.fpu_optimization:
622         conf.env['FPU_OPTIMIZATION'] = True
623     if opts.freesound:
624         conf.define('FREESOUND',1)
625         conf.env['FREESOUND'] = True
626     if opts.nls:
627         conf.define('ENABLE_NLS', 1)
628         conf.env['ENABLE_NLS'] = True
629     if opts.build_tests:
630         conf.env['BUILD_TESTS'] = opts.build_tests
631     if opts.single_tests:
632         conf.env['SINGLE_TESTS'] = opts.single_tests
633     #if opts.tranzport:
634     #    conf.env['TRANZPORT'] = 1
635     if opts.windows_vst:
636         conf.define('WINDOWS_VST_SUPPORT', 1)
637         conf.env['WINDOWS_VST_SUPPORT'] = True
638         conf.env.append_value('CFLAGS', '-I' + Options.options.wine_include)
639         conf.env.append_value('CXXFLAGS', '-I' + Options.options.wine_include)
640         autowaf.check_header(conf, 'cxx', 'windows.h', mandatory = True)
641     if opts.lxvst:
642         conf.define('LXVST_SUPPORT', 1)
643         conf.env['LXVST_SUPPORT'] = True
644     if bool(conf.env['JACK_SESSION']):
645         conf.define('HAVE_JACK_SESSION', 1)
646     conf.define('WINDOWS_KEY', opts.windows_key)
647     conf.env['PROGRAM_NAME'] = opts.program_name
648     if opts.rt_alloc_debug:
649         conf.define('DEBUG_RT_ALLOC', 1)
650         conf.env['DEBUG_RT_ALLOC'] = True
651     if opts.pt_timing:
652         conf.define('PT_TIMING', 1)
653         conf.env['PT_TIMING'] = True
654     if opts.denormal_exception:
655         conf.define('DEBUG_DENORMAL_EXCEPTION', 1)
656         conf.env['DEBUG_DENORMAL_EXCEPTION'] = True
657     if opts.build_tests:
658         autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=True)
659
660     set_compiler_flags (conf, Options.options)
661
662     for i in children:
663         sub_config_and_use(conf, i)
664
665     # Fix utterly braindead FLAC include path to not smash assert.h
666     conf.env['INCLUDES_FLAC'] = []
667
668     config_text = open('libs/ardour/config_text.cc', "w")
669     config_text.write('''#include "ardour/ardour.h"
670 namespace ARDOUR {
671 const char* const ardour_config_info = "\\n\\
672 ''')
673
674     def write_config_text(title, val):
675         autowaf.display_msg(conf, title, val)
676         config_text.write(title + ': ')
677         config_text.write(str(val))
678         config_text.write("\\n\\\n")
679
680     write_config_text('Build documentation',   conf.env['DOCS'])
681     write_config_text('Debuggable build',      conf.env['DEBUG'])
682     write_config_text('Export all symbols (backtrace)', opts.backtrace)
683     write_config_text('Install prefix',        conf.env['PREFIX'])
684     write_config_text('Strict compiler flags', conf.env['STRICT'])
685     write_config_text('Internal Shared Libraries', conf.is_defined('INTERNAL_SHARED_LIBS'))
686
687     write_config_text('Architecture flags',    opts.arch)
688     write_config_text('Aubio',                 conf.is_defined('HAVE_AUBIO'))
689     write_config_text('AudioUnits',            conf.is_defined('AUDIOUNIT_SUPPORT'))
690     write_config_text('No plugin state',       conf.is_defined('NO_PLUGIN_STATE'))
691     write_config_text('Build target',          conf.env['build_target'])
692     write_config_text('CoreAudio',             conf.is_defined('HAVE_COREAUDIO'))
693     write_config_text('Debug RT allocations',  conf.is_defined('DEBUG_RT_ALLOC'))
694     write_config_text('Process thread timing', conf.is_defined('PT_TIMING'))
695     write_config_text('Denormal exceptions',   conf.is_defined('DEBUG_DENORMAL_EXCEPTION'))
696     write_config_text('FLAC',                  conf.is_defined('HAVE_FLAC'))
697     write_config_text('FPU optimization',      opts.fpu_optimization)
698     write_config_text('Freedesktop files',     opts.freedesktop)
699     write_config_text('Freesound',             opts.freesound)
700     write_config_text('JACK session support',  conf.is_defined('JACK_SESSION'))
701     write_config_text('LV2 UI embedding',      conf.is_defined('HAVE_SUIL'))
702     write_config_text('LV2 support',           conf.is_defined('LV2_SUPPORT'))
703     write_config_text('LXVST support',         conf.is_defined('LXVST_SUPPORT'))
704     write_config_text('OGG',                   conf.is_defined('HAVE_OGG'))
705     write_config_text('Phone home',            conf.is_defined('PHONE_HOME'))
706     write_config_text('Program name',          opts.program_name)
707     write_config_text('Rubberband',            conf.is_defined('HAVE_RUBBERBAND'))
708     write_config_text('Samplerate',            conf.is_defined('HAVE_SAMPLERATE'))
709 #    write_config_text('Soundtouch',            conf.is_defined('HAVE_SOUNDTOUCH'))
710     write_config_text('Translation',           opts.nls)
711 #    write_config_text('Tranzport',             opts.tranzport)
712     write_config_text('Unit tests',            conf.env['BUILD_TESTS'])
713     write_config_text('Universal binary',      opts.universal)
714     write_config_text('Generic x86 CPU',       opts.generic)
715     write_config_text('Windows VST support',   opts.windows_vst)
716     write_config_text('Wiimote support',       conf.is_defined('BUILD_WIIMOTE'))
717     write_config_text('Windows key',           opts.windows_key)
718
719     write_config_text('C compiler flags',      conf.env['CFLAGS'])
720     write_config_text('C++ compiler flags',    conf.env['CXXFLAGS'])
721     write_config_text('Linker flags',           conf.env['LINKFLAGS'])
722
723     config_text.write ('";\n}\n')
724     config_text.close ()
725     print('')
726
727 def build(bld):
728     create_stored_revision()
729
730     # add directories that contain only headers, to workaround an issue with waf
731
732     bld.path.find_dir ('libs/evoral/evoral')
733     bld.path.find_dir ('libs/vamp-sdk/vamp-sdk')
734     bld.path.find_dir ('libs/surfaces/control_protocol/control_protocol')
735     bld.path.find_dir ('libs/timecode/timecode')
736     bld.path.find_dir ('libs/libltc/ltc')
737     bld.path.find_dir ('libs/rubberband/rubberband')
738     bld.path.find_dir ('libs/gtkmm2ext/gtkmm2ext')
739     bld.path.find_dir ('libs/ardour/ardour')
740     bld.path.find_dir ('libs/taglib/taglib')
741     bld.path.find_dir ('libs/pbd/pbd')
742
743     autowaf.set_recursive()
744
745     for i in children:
746         bld.recurse(i)
747
748     bld.install_files (os.path.join(bld.env['SYSCONFDIR'], 'ardour3', ), 'ardour_system.rc')
749
750 def i18n(bld):
751     bld.recurse (i18n_children)
752
753 def i18n_pot(bld):
754     bld.recurse (i18n_children)
755
756 def i18n_po(bld):
757     bld.recurse (i18n_children)
758
759 def i18n_mo(bld):
760     bld.recurse (i18n_children)
761
762 def tarball(bld):
763     create_stored_revision()