2 from waflib.extras import autowaf as autowaf
3 from waflib import Options
9 import platform as PLATFORM
10 from waflib.Tools import winres
11 from waflib.Build import Context
12 from waflib.Build import BuildContext
14 class i18n(BuildContext):
18 class i18n_pot(BuildContext):
22 class i18n_po(BuildContext):
26 class i18n_mo(BuildContext):
30 def is_tracks_build(self, *k, **kw):
31 return self.env['PROGRAM_NAME'] == 'Tracks Live'
33 Context.Context.is_tracks_build = is_tracks_build
35 compiler_flags_dictionaries= {
37 # Flags required when building a debug build
38 'debuggable' : [ '-g' ],
39 # Flags required for the linker (if any) when building a debug build
40 'linker-debuggable' : '',
41 # Flags required when building a non-debug optimized build
42 'nondebuggable' : '-DNDEBUG',
43 # Flags required to enable profiling at runtime with optimized builds
44 'profile' : [ '-fno-omit-frame-pointer' ],
45 # Flags required to enable gprofile profiling
47 # Flags required to disable warnings about unused arguments to function calls
48 'silence-unused-arguments' : '',
49 # Flags required to use SSE unit for general math
51 # Flags required to use SSE unit for floating point math
52 'fpmath-sse' : '-mfpmath=sse',
53 # Flags required to use XMM Intrinsics
54 'xmmintrinsics' : '-DUSE_XMMINTRIN',
55 # Flags to use posix pipes between compiler stages
57 # Flags for maximally optimized build
58 'full-optimization' : [ '-O3', '-fomit-frame-pointer', '-ffast-math', '-fstrength-reduce', ],
59 # Flag to ensure that compiler error output includes column/line numbers
60 'show-column' : '-fshow-column',
61 # Flags required to build for x86 only (OS X feature)
63 # Flags required to build for PowerPC only (OS X feature)
65 # All flags required to get basic warnings to be generated by the compiler
66 'basic-warnings' : [ '-Wall', '-Wpointer-arith', '-Wcast-qual', '-Wcast-align', '-Wno-unused-parameter' ],
67 # Any additional flags for warnings that are specific to C (not C++)
68 'extra-c-warnings' : [ '-Wstrict-prototypes', '-Wmissing-prototypes' ],
69 # Any additional flags for warnings that are specific to C++ (not C)
70 'extra-cxx-warnings' : [ '-Woverloaded-virtual', '-Wno-unused-local-typedefs' ],
71 # Flags used for "strict" compilation, C and C++ (i.e. compiler will warn about language issues)
72 'strict' : ['-Wall', '-Wcast-align', '-Wextra', '-Wwrite-strings', '-Wunsafe-loop-optimizations', '-Wlogical-op' ],
73 # Flags used for "strict" compilation, C only (i.e. compiler will warn about language issues)
74 'c-strict' : ['-std=c99', '-pedantic', '-Wshadow'],
75 # Flags used for "strict" compilation, C++ only (i.e. compiler will warn about language issues)
76 'cxx-strict' : [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual', '-fstrict-overflow' ],
77 # Flags required for whatever consider the strictest possible compilation
78 'ultra-strict' : ['-Wredundant-decls', '-Wstrict-prototypes', '-Wmissing-prototypes'],
79 # Flag to turn on C99 compliance by itself
81 # Flag to enable AT&T assembler syntax
82 'attasm': '-masm=att',
83 # Flags to make AVX instructions/intrinsics available
85 # Flags to generate position independent code, when needed to build a shared object
87 # Flags required to compile C code with anonymous unions (only part of C11)
88 'c-anonymous-union': '-fms-extensions',
91 'debuggable' : ['/DDEBUG', '/Od', '/Zi', '/MDd', '/Gd', '/EHsc'],
92 'linker-debuggable' : ['/DEBUG', '/INCREMENTAL' ],
93 'nondebuggable' : ['/DNDEBUG', '/Ob1', '/MD', '/Gd', '/EHsc'],
96 'silence-unused-arguments' : '',
101 'full-optimization' : '/O2',
102 'no-frame-pointer' : '',
104 'strength-reduce' : '',
108 'basic-warnings' : '',
109 'extra-c-warnings' : '',
110 'extra-cxx-warnings' : '',
119 'c-anonymous-union': '',
123 # Copy, edit and insert variants on gcc dict for gcc-darwin and clang
125 gcc_darwin_dict = compiler_flags_dictionaries['gcc'].copy()
126 gcc_darwin_dict['extra-cxx-warnings'] = [ '-Woverloaded-virtual' ]
127 gcc_darwin_dict['cxx-strict'] = [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual' ]
128 gcc_darwin_dict['strict'] = ['-Wall', '-Wcast-align', '-Wextra', '-Wwrite-strings' ]
129 gcc_darwin_dict['generic-x86'] = [ '-arch', 'i386' ]
130 gcc_darwin_dict['generic-ppc'] = [ '-arch', 'ppc' ]
131 compiler_flags_dictionaries['gcc-darwin'] = gcc_darwin_dict;
133 clang_dict = compiler_flags_dictionaries['gcc'].copy();
134 clang_dict['sse'] = ''
135 clang_dict['fpmath-sse'] = ''
136 clang_dict['xmmintrinsics'] = ''
137 clang_dict['silence-unused-arguments'] = '-Qunused-arguments'
138 clang_dict['extra-cxx-warnings'] = [ '-Woverloaded-virtual', '-Wno-mismatched-tags', '-Wno-cast-align', '-Wno-unused-local-typedefs', '-Wunneeded-internal-declaration' ]
139 clang_dict['cxx-strict'] = [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual', '-fstrict-overflow' ]
140 clang_dict['strict'] = ['-Wall', '-Wcast-align', '-Wextra', '-Wwrite-strings' ]
141 clang_dict['generic-x86'] = [ '-arch', 'i386' ]
142 clang_dict['full-optimization'] = [ '-O3', '-fomit-frame-pointer', '-ffast-math', ]
143 compiler_flags_dictionaries['clang'] = clang_dict;
145 clang_darwin_dict = compiler_flags_dictionaries['clang'].copy();
146 clang_darwin_dict['cxx-strict'] = [ '-ansi', '-Wnon-virtual-dtor', '-Woverloaded-virtual', ]
147 clang_darwin_dict['full-optimization'] = [ '-O3', '-ffast-math']
148 compiler_flags_dictionaries['clang-darwin'] = clang_darwin_dict;
150 def fetch_git_revision_date ():
151 cmd = ["git", "describe", "HEAD"]
152 output = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
153 rev = re.sub(r"^[A-Za-z0-9]*\+", "", output[0].decode('utf-8'))
155 cmd = ["git", "log", "-1", "--pretty=format:%ci", "HEAD"]
156 output = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
157 date = output[0].decode('utf-8').split(None, 2)[0]
161 def fetch_tarball_revision_date():
162 if not os.path.exists ('libs/ardour/revision.cc'):
163 print ('This tarball was not created correctly - it is missing libs/ardour/revision.cc')
165 with open('libs/ardour/revision.cc', 'rb') as f:
166 content = f.readlines()
167 remove_punctuation_map = dict((ord(char), None) for char in '";')
169 raw_line_tokens = content[1].decode('utf-8').strip().split(' ')
170 rev = raw_line_tokens[7].translate(remove_punctuation_map)
171 date = raw_line_tokens[12].translate(remove_punctuation_map)
175 if os.path.isdir (os.path.join(os.getcwd(), '.git')):
176 rev, rev_date = fetch_git_revision_date()
178 rev, rev_date = fetch_tarball_revision_date()
181 # rev is now of the form MAJOR.MINOR[-rcX]-rev-commit
182 # or, if right at the same rev as a release, MAJOR.MINOR[-rcX]
185 parts = rev.split ('.', 1)
187 other = parts[1].split('-', 1)
190 MICRO = other[1].rsplit('-',1)[0].replace('-','.')
194 V = MAJOR + '.' + MINOR + '.' + MICRO
197 # round-trip to remove anything in the string that is not encodable in
198 # ASCII, yet still keep a real (utf8-encoded internally) string.
199 s = s.encode ('ascii', 'ignore').decode ("utf-8")
200 # In Python3, bytes is the class of binary content and encode() returns
201 # bytes to transform a string according to a text encoding; str is the
202 # class of normal strings (utf8-encoded internally) and decode() returns
204 # Python 2 did not initially cater for encoding problems and can use str
205 # for both binary content and for (decoded) strings. The Unicode type was
206 # added to correspond to Python 3 str, and the Python 2 str type should
207 # only correspond to bytes. Alas, almost everything in the Python 2
208 # ecosystem has been written with str in mind and doesn't handle Unicode
209 # objects correctly. If Python 2 is in use, s will be a Unicode object and
210 # to avoid strange problems later we convert back to str, but in utf-8
212 if not isinstance(s, str):
213 s = s.encode("utf-8")
215 VERSION = sanitize(V)
216 PROGRAM_VERSION = sanitize(MAJOR)
219 if len (sys.argv) > 1 and sys.argv[1] == 'dist':
220 if not 'APPNAME' in os.environ:
221 print ("You must define APPNAME in the environment when running ./waf dist")
223 APPNAME = os.environ['APPNAME'];
225 # Mandatory variables
230 # optionally external libraries
238 'libs/zita-resampler',
239 # core ardour libraries
253 'libs/plugins/reasonablesynth.lv2',
254 'libs/plugins/a-comp.lv2',
255 'libs/plugins/a-exp.lv2',
256 'libs/plugins/a-delay.lv2',
257 'libs/plugins/a-eq.lv2',
258 'libs/plugins/a-reverb.lv2',
259 'libs/plugins/a-fluidsynth.lv2',
270 # shared helper binaries (plugin-scanner, exec-wrapper)
273 'libs/ardouralsautil',
285 def fetch_gcc_version (CC):
286 cmd = "%s --version" % CC
287 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
288 o = output[0].decode('utf-8')
289 version = o.split(' ')[2].split('.')
292 def create_stored_revision():
294 if os.path.exists('.git'):
295 rev, rev_date = fetch_git_revision_date();
296 print("Git version: " + rev + "\n")
297 elif os.path.exists('libs/ardour/revision.cc'):
298 print("Using packaged revision")
301 print("Missing libs/ardour/revision.cc. Blame the packager.")
306 # if you change the format of this, be sure to fix fetch_tarball_revision_date()
307 # above so that it still works.
309 text = '#include "ardour/revision.h"\n'
311 'namespace ARDOUR { const char* revision = \"%s\"; '
312 'const char* date = \"%s\"; }\n'
314 print('Writing revision info to libs/ardour/revision.cc using ' + rev + ', ' + rev_date)
315 o = open('libs/ardour/revision.cc', 'w')
319 print('Could not open libs/ardour/revision.cc for writing\n')
322 def get_depstack_rev(depstack_root):
324 with open(depstack_root + '/../.vers', 'r') as f:
325 return f.readline().decode('utf-8').strip()[:7]
329 def set_compiler_flags (conf,opt):
331 # Compiler flags and other system-dependent stuff
333 build_host_supports_sse = False
335 # Flags necessary for building
336 compiler_flags = [] # generic
337 c_flags = [] # C-specific
338 cxx_flags = [] # C++-specific
341 # Optimization flags (overridable)
342 optimization_flags = []
347 u = PLATFORM.uname ()
349 platform = u[0].lower()
352 # waf adds -O0 -g itself. thanks waf!
353 is_clang = conf.check_cxx(fragment = '''
357 int main() { return 0; }''',
361 msg = 'Checking for clang')
364 if platform == 'darwin':
365 compiler_name = 'clang-darwin'
367 compiler_name = 'clang'
368 elif conf.env['MSVC_COMPILER']:
369 compiler_name = 'msvc'
371 if platform == 'darwin':
372 compiler_name = 'gcc-darwin'
374 compiler_name = 'gcc'
376 flags_dict = compiler_flags_dictionaries[compiler_name]
377 # Save the compiler flags because we need them at build time
378 # when we need to add compiler specific flags in certain
380 conf.env['compiler_flags_dict'] = flags_dict;
382 autowaf.set_basic_compiler_flags (conf,flags_dict)
384 if conf.options.asan:
385 conf.check_cxx(cxxflags=["-fsanitize=address", "-fno-omit-frame-pointer"], linkflags=["-fsanitize=address"])
386 cxx_flags.append('-fsanitize=address')
387 cxx_flags.append('-fno-omit-frame-pointer')
388 linker_flags.append('-fsanitize=address')
391 debug_flags = [ flags_dict['gprofile'] ]
394 if platform == 'darwin':
395 if re.search ("^13[.]", version) != None:
396 conf.env['build_host'] = 'mavericks'
397 elif re.search ("^14[.]", version) != None:
398 conf.env['build_host'] = 'yosemite'
399 elif re.search ("^15[.]", version) != None:
400 conf.env['build_host'] = 'el_capitan'
401 elif re.search ("^16[.]", version) != None:
402 conf.env['build_host'] = 'sierra'
403 elif re.search ("^17[.]", version) != None:
404 conf.env['build_host'] = 'high_sierra'
406 conf.env['build_host'] = 'irrelevant'
409 if opt.dist_target == 'auto':
410 if platform == 'darwin':
411 # The [.] matches to the dot after the major version, "." would match any character
412 if re.search ("^[0-7][.]", version) != None:
413 conf.env['build_target'] = 'panther'
414 elif re.search ("^8[.]", version) != None:
415 conf.env['build_target'] = 'tiger'
416 elif re.search ("^9[.]", version) != None:
417 conf.env['build_target'] = 'leopard'
418 elif re.search ("^10[.]", version) != None:
419 conf.env['build_target'] = 'snowleopard'
420 elif re.search ("^11[.]", version) != None:
421 conf.env['build_target'] = 'lion'
422 elif re.search ("^12[.]", version) != None:
423 conf.env['build_target'] = 'mountainlion'
424 elif re.search ("^13[.]", version) != None:
425 conf.env['build_target'] = 'mavericks'
426 elif re.search ("^14[.]", version) != None:
427 conf.env['build_target'] = 'yosemite'
428 elif re.search ("^15[.]", version) != None:
429 conf.env['build_target'] = 'el_capitan'
430 elif re.search ("^16[.]", version) != None:
431 conf.env['build_target'] = 'sierra'
433 conf.env['build_target'] = 'high_sierra'
436 "(?P<cpu>i[0-6]86|x86_64|powerpc|ppc|ppc64|arm|s390x?)",
439 conf.env['build_target'] = match.group("cpu")
440 if re.search("i[0-5]86", conf.env['build_target']):
441 conf.env['build_target'] = "i386"
443 conf.env['build_target'] = 'none'
445 conf.env['build_target'] = opt.dist_target
447 if conf.env['build_target'] == 'snowleopard':
449 # stupid OS X 10.6 has a bug in math.h that prevents llrint and friends
450 # from being visible.
452 compiler_flags.append ('-U__STRICT_ANSI__')
454 if opt.use_libcpp or conf.env['build_host'] in [ 'el_capitan', 'sierra', 'high_sierra' ]:
455 cxx_flags.append('--stdlib=libc++')
456 linker_flags.append('--stdlib=libc++')
458 if conf.options.cxx11 or conf.env['build_host'] in [ 'mavericks', 'yosemite', 'el_capitan', 'sierra', 'high_sierra' ]:
459 conf.check_cxx(cxxflags=["-std=c++11"])
460 cxx_flags.append('-std=c++11')
461 if platform == "darwin":
462 # Mavericks and later changed the syntax to be used when including Carbon headers,
463 # from requiring a full path to requiring just the header name.
464 cxx_flags.append('-DCARBON_FLAT_HEADERS')
466 if not opt.use_libcpp and not conf.env['build_host'] in [ 'el_capitan', 'sierra', 'high_sierra' ]:
467 cxx_flags.append('--stdlib=libstdc++')
468 linker_flags.append('--stdlib=libstdc++')
469 # Prevents visibility issues in standard headers
470 conf.define("_DARWIN_C_SOURCE", 1)
472 cxx_flags.append('-DBOOST_NO_AUTO_PTR')
475 if (is_clang and platform == "darwin") or conf.env['build_host'] in [ 'mavericks', 'yosemite', 'el_capitan', 'sierra', 'high_sierra' ]:
476 # Silence warnings about the non-existing osx clang compiler flags
477 # -compatibility_version and -current_version. These are Waf
478 # generated and not needed with clang
479 c_flags.append("-Qunused-arguments")
480 cxx_flags.append("-Qunused-arguments")
482 if (re.search ("(i[0-9]86|x86_64|AMD64)", cpu) != None) and conf.env['build_target'] != 'none':
485 # ARCH_X86 means anything in the x86 family from i386 to x86_64
486 # the compile-time presence of the macro _LP64 is used to
487 # distingush 32 and 64 bit assembler
490 compiler_flags.append ("-DARCH_X86")
492 if platform == 'linux' :
495 # determine processor flags via /proc/cpuinfo
498 if conf.env['build_target'] != 'i386':
500 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
501 x86_flags = flag_line.split (": ")[1:][0].split ()
503 if "mmx" in x86_flags:
504 compiler_flags.append ("-mmmx")
505 if "sse" in x86_flags:
506 build_host_supports_sse = True
507 if "3dnow" in x86_flags:
508 compiler_flags.append ("-m3dnow")
511 compiler_flags.append ("-march=i586")
513 compiler_flags.append ("-march=i686")
515 if not is_clang and ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
516 compiler_flags.extend ([ flags_dict['sse'], flags_dict['fpmath-sse'], flags_dict['xmmintrinsics'] ])
518 if (conf.env['build_target'] == 'mingw'):
519 if (re.search ("(x86_64|AMD64)", cpu) != None):
520 # on Windows sse is supported by 64 bit platforms only
521 build_host_supports_sse = True
523 # mingw GCC compiler to uses at&t (Unix specific) assembler dialect by default
524 # compiler_flags.append (["--mmnemonic=att", "msyntax=att")
526 compiler_flags.extend ([ flags_dict['sse'], flags_dict['fpmath-sse'], flags_dict['xmmintrinsics'], flags_dict['attasm'] ])
528 # end of processor-specific section
530 # optimization section
531 if conf.env['FPU_OPTIMIZATION']:
532 if sys.platform == 'darwin':
533 compiler_flags.append("-DBUILD_VECLIB_OPTIMIZATIONS");
534 conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'Accelerate'])
535 elif conf.env['build_target'] == 'i686' or conf.env['build_target'] == 'x86_64':
536 compiler_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
537 elif conf.env['build_target'] == 'mingw':
538 # usability of the 64 bit windows assembler depends on the compiler target,
539 # not the build host, which in turn can only be inferred from the name
541 if re.search ('x86_64-w64', str(conf.env['CC'])) != None:
542 compiler_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
543 if not build_host_supports_sse:
544 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)")
546 # end optimization section
552 if conf.env['build_target'] == 'x86_64' and opt.windows_vst:
553 print("\n\n==================================================")
554 print("64bit Windows VST support on 64bit Linux is experimental.")
555 print("(This version of ardour will not load 32bit VSTs)")
556 print("==================================================\n\n")
558 if conf.env['LXVST_SUPPORT'] == True:
559 if conf.env['build_target'] == 'x86_64':
560 compiler_flags.append("-DLXVST_64BIT")
562 compiler_flags.append("-DLXVST_32BIT")
565 # a single way to test if we're on OS X
568 if conf.env['build_target'] in ['panther', 'tiger', 'leopard' ]:
569 # force tiger or later, to avoid issues on PPC which defaults
570 # back to 10.1 if we don't tell it otherwise.
572 compiler_flags.extend(
573 ("-DMAC_OS_X_VERSION_MIN_REQUIRED=1040",
574 '-mmacosx-version-min=10.4'))
576 elif conf.env['build_target'] in [ 'snowleopard' ]:
577 compiler_flags.extend(
578 ("-DMAC_OS_X_VERSION_MIN_REQUIRED=1060",
579 '-mmacosx-version-min=10.6'))
581 elif conf.env['build_target'] in [ 'lion', 'mountainlion' ]:
582 compiler_flags.extend(
583 ("-DMAC_OS_X_VERSION_MIN_REQUIRED=1070",
584 '-mmacosx-version-min=10.7'))
586 elif conf.env['build_target'] in [ 'mavericks', 'yosemite' ]:
587 compiler_flags.extend(
588 ("-DMAC_OS_X_VERSION_MAX_ALLOWED=1090",
589 "-mmacosx-version-min=10.8"))
591 elif conf.env['build_target'] in ['el_capitan', 'sierra', 'high_sierra' ]:
592 compiler_flags.extend(
593 ("-DMAC_OS_X_VERSION_MAX_ALLOWED=1090",
594 "-mmacosx-version-min=10.9"))
597 # save off CPU element in an env
599 conf.define ('CONFIG_ARCH', cpu)
602 # ARCH="..." overrides all
606 optimization_flags = opt.arch.split()
609 # prepend boiler plate optimization flags that work on all architectures
612 optimization_flags[:0] = [flags_dict['pipe']]
614 # don't prepend optimization flags if "-O<something>" is present
615 prepend_opt_flags = True
616 for flag in optimization_flags:
617 if flag.startswith("-O"):
618 prepend_opt_flags = False
621 if prepend_opt_flags:
622 optimization_flags[:0] = flags_dict['full-optimization']
624 if opt.debug_symbols:
625 optimization_flags += flags_dict['debuggable']
628 optimization_flags += flags_dict['profile']
631 cxx_flags.append("-D_GLIBCXX_DEBUG")
633 if re.search ("freebsd", sys.platform) != None or re.search ("openbsd", sys.platform) != None:
634 linker_flags.append('-lexecinfo')
636 if conf.env['DEBUG_RT_ALLOC']:
637 compiler_flags.append('-DDEBUG_RT_ALLOC')
638 linker_flags.append('-ldl')
640 if conf.env['DEBUG_DENORMAL_EXCEPTION']:
641 compiler_flags.append('-DDEBUG_DENORMAL_EXCEPTION')
644 compiler_flags.extend(flags_dict['generic-x86'])
645 linker_flags.extend(flags_dict['generic-x86'])
648 compiler_flags.extend(flags_dict['generic-ppc'])
649 linker_flags.extend(flags_dict['generic-ppc'])
655 compiler_flags.extend(flags_dict['basic-warnings'])
657 c_flags.extend(flags_dict['extra-c-warnings'])
658 cxx_flags.extend (flags_dict['extra-cxx-warnings'])
664 # need ISOC9X for llabs()
665 compiler_flags.extend(
666 ('-DBOOST_SYSTEM_NO_DEPRECATED', '-D_ISOC9X_SOURCE',
667 '-D_LARGEFILE64_SOURCE', '-D_FILE_OFFSET_BITS=64'))
669 ('-D__STDC_LIMIT_MACROS', '-D__STDC_FORMAT_MACROS',
670 '-DCANVAS_COMPATIBILITY', '-DCANVAS_DEBUG'))
673 compiler_flags.append('-DENABLE_NLS')
675 # use sparingly, prefer runtime profile
676 if Options.options.program_name.lower() == "mixbus":
677 compiler_flags.append ('-DMIXBUS')
679 if Options.options.program_name.lower() == "mixbus32c":
680 compiler_flags.append ('-DMIXBUS')
681 compiler_flags.append ('-DMIXBUS32C')
683 compiler_flags.append ('-DPROGRAM_NAME="' + Options.options.program_name + '"')
684 compiler_flags.append ('-DPROGRAM_VERSION="' + PROGRAM_VERSION + '"')
686 conf.env['PROGRAM_NAME'] = Options.options.program_name
689 conf.env.append_value('CFLAGS', debug_flags)
690 conf.env.append_value('CXXFLAGS', debug_flags)
692 conf.env.append_value('CFLAGS', optimization_flags)
693 conf.env.append_value('CXXFLAGS', optimization_flags)
696 if platform != 'darwin' and not is_clang and not Options.options.dist_target == 'mingw':
697 linker_flags += [ '-rdynamic' ]
699 conf.env.append_value('CFLAGS', compiler_flags)
700 conf.env.append_value('CFLAGS', c_flags)
701 conf.env.append_value('CXXFLAGS', compiler_flags)
702 conf.env.append_value('CXXFLAGS', cxx_flags)
703 conf.env.append_value('LINKFLAGS', linker_flags)
705 def create_resource_file(icon):
707 text = 'IDI_ICON1 ICON DISCARDABLE "icons/' + icon + '.ico"\n'
708 o = open('gtk2_ardour/windows_icon.rc', 'w')
712 print('Could not open gtk2_ardour/windows_icon.rc for writing\n')
715 def is_tracks_build (conf):
716 return conf.env['PROGRAM_NAME'] == 'Tracks Live'
718 #----------------------------------------------------------------
723 opt.load('compiler_c')
724 opt.load('compiler_cxx')
725 autowaf.set_options(opt, debug_by_default=True)
726 opt.add_option('--program-name', type='string', action='store', default='Ardour', dest='program_name',
727 help='The user-visible name of the program being built')
728 opt.add_option('--arch', type='string', action='store', dest='arch',
729 help='Architecture-specific compiler FLAGS')
730 opt.add_option('--with-backends', type='string', action='store', default='jack', dest='with_backends',
731 help='Specify which backend modules are to be included(jack,alsa,dummy,portaudio,coreaudio)')
732 opt.add_option('--backtrace', action='store_true', default=False, dest='backtrace',
733 help='Compile with -rdynamic -- allow obtaining backtraces from within Ardour')
734 opt.add_option('--no-carbon', action='store_true', default=False, dest='nocarbon',
735 help='Compile without support for AU Plugins with only CARBON UI (needed for 64bit)')
736 opt.add_option('--boost-sp-debug', action='store_true', default=False, dest='boost_sp_debug',
737 help='Compile with Boost shared pointer debugging')
738 opt.add_option('--debug-symbols', action='store_true', default=False, dest='debug_symbols',
739 help='Add debug-symbols to optimized builds')
740 opt.add_option('--depstack-root', type='string', default='~', dest='depstack_root',
741 help='Directory/folder where dependency stack trees (gtk, a3) can be found (defaults to ~)')
742 opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
743 help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,tiger,leopard,mingw,msvc]')
744 opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
745 help='Build runtime checked assembler code (default)')
746 opt.add_option('--no-fpu-optimization', action='store_false', dest='fpu_optimization')
747 opt.add_option('--exports-hidden', action='store_true', default=False, dest='exports_hidden')
748 opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
749 help='Build MIME type and .desktop files as per freedesktop.org standards (will be placed in build/gtk2_ardour)')
750 opt.add_option('--freebie', action='store_true', default=False, dest='freebie',
751 help='Build a version suitable for distribution as a zero-cost binary')
752 opt.add_option('--profile', action='store_true', default=False, dest='profile',
753 help='Compile for use with profiling tools requiring a frame pointer')
754 opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
755 help='Compile for use with gprofile')
756 opt.add_option('--libjack', type='string', default="auto", dest='libjack_link',
757 help='libjack link mode [auto|link|weak]')
758 opt.add_option('--internal-shared-libs', action='store_true', default=True, dest='internal_shared_libs',
759 help='Build internal libs as shared libraries')
760 opt.add_option('--internal-static-libs', action='store_false', dest='internal_shared_libs',
761 help='Build internal libs as static libraries')
762 opt.add_option('--use-external-libs', action='store_true', default=False, dest='use_external_libs',
763 help='Use external/system versions of some bundled libraries')
764 opt.add_option('--keepflags', action='store_true', default=False, dest='keepflags',
765 help='Do not ignore CFLAGS/CXXFLAGS environment vars')
766 opt.add_option('--luadoc', action='store_true', default=False, dest='luadoc',
767 help='Compile Tool to dump LuaBindings (needs C++11)')
768 opt.add_option('--canvasui', action='store_true', default=False, dest='canvasui',
769 help='Compile libcanvas test GUI')
770 opt.add_option('--beatbox', action='store_true', default=False, dest='beatbox',
771 help='Compile beatbox test app')
772 opt.add_option('--lv2', action='store_true', default=True, dest='lv2',
773 help='Compile with support for LV2 (if Lilv+Suil is available)')
774 opt.add_option('--no-lv2', action='store_false', dest='lv2',
775 help='Do not compile with support for LV2')
776 opt.add_option('--lv2dir', type='string', help="install destination for builtin LV2 bundles [Default: LIBDIR/lv2]")
777 opt.add_option('--lxvst', action='store_true', default=True, dest='lxvst',
778 help='Compile with support for linuxVST plugins')
779 opt.add_option('--no-lxvst', action='store_false', dest='lxvst',
780 help='Compile without support for linuxVST plugins')
781 opt.add_option('--no-lrdf', action='store_true', dest='no_lrdf',
782 help='Compile without support for LRDF LADSPA data even if present')
783 opt.add_option('--nls', action='store_true', default=True, dest='nls',
784 help='Enable i18n (native language support) (default)')
785 opt.add_option('--no-nls', action='store_false', dest='nls')
786 opt.add_option('--phone-home', action='store_true', default=True, dest='phone_home',
787 help='Contact ardour.org at startup for new announcements')
788 opt.add_option('--no-phone-home', action='store_false', dest='phone_home',
789 help='Do not contact ardour.org at startup for new announcements')
790 opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
791 help='Build with debugging for the STL')
792 opt.add_option('--rt-alloc-debug', action='store_true', default=False, dest='rt_alloc_debug',
793 help='Build with debugging for memory allocation in the real-time thread')
794 opt.add_option('--pt-timing', action='store_true', default=False, dest='pt_timing',
795 help='Build with logging of timing in the process thread(s)')
796 opt.add_option('--denormal-exception', action='store_true', default=False, dest='denormal_exception',
797 help='Raise a floating point exception if a denormal is detected')
798 opt.add_option('--test', action='store_true', default=False, dest='build_tests',
799 help="Build unit tests")
800 opt.add_option('--run-tests', action='store_true', default=False, dest='run_tests',
801 help="Run tests after build")
802 opt.add_option('--single-tests', action='store_true', default=False, dest='single_tests',
803 help="Build a single executable for each unit test")
804 #opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
805 # help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
806 opt.add_option('--maschine', action='store_true', default=False, dest='maschine',
807 help='Compile with support for NI-Maschine')
808 opt.add_option('--generic', action='store_true', default=False, dest='generic',
809 help='Compile with -arch i386 (OS X ONLY)')
810 opt.add_option('--ppc', action='store_true', default=False, dest='ppc',
811 help='Compile with -arch ppc (OS X ONLY)')
812 opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
813 help='Add revision information to executable name inside the build directory')
814 opt.add_option('--windows-vst', action='store_true', default=False, dest='windows_vst',
815 help='Compile with support for Windows VST')
816 opt.add_option('--windows-key', type='string', action='store', dest='windows_key', default='Mod4><Super',
817 help='X Modifier(s) (Mod1,Mod2, etc) for the Windows key (X11 builds only). ' +
818 'Multiple modifiers must be separated by \'><\'')
819 opt.add_option('--boost-include', type='string', action='store', dest='boost_include', default='',
820 help='directory where Boost header files can be found')
821 opt.add_option('--also-include', type='string', action='store', dest='also_include', default='',
822 help='additional include directory where header files can be found (split multiples with commas)')
823 opt.add_option('--also-libdir', type='string', action='store', dest='also_libdir', default='',
824 help='additional include directory where shared libraries can be found (split multiples with commas)')
825 opt.add_option('--wine-include', type='string', action='store', dest='wine_include', default='/usr/include/wine/windows',
826 help='directory where Wine\'s Windows header files can be found')
827 opt.add_option('--noconfirm', action='store_true', default=False, dest='noconfirm',
828 help='Do not ask questions that require confirmation during the build')
829 opt.add_option('--cxx11', action='store_true', default=False, dest='cxx11',
830 help='Turn on c++11 compiler flags (-std=c++11)')
831 opt.add_option('--use-libc++', action='store_true', default=False, dest='use_libcpp',
832 help='use libc++ instead of default or auto-detected stdlib')
833 opt.add_option('--address-sanitizer', action='store_true', default=False, dest='asan',
834 help='Turn on AddressSanitizer (requires GCC >= 4.8 or clang >= 3.1)')
835 opt.add_option('--ptformat', action='store_true', default=False, dest='ptformat',
836 help='Turn on PT session import option')
837 opt.add_option('--no-threaded-waveviews', action='store_true', default=False, dest='no_threaded_waveviews',
838 help='Disable threaded waveview rendering')
840 '--qm-dsp-include', type='string', action='store',
841 dest='qm_dsp_include', default='/usr/include/qm-dsp',
842 help='directory where the header files of qm-dsp can be found')
847 def sub_config_and_use(conf, name, has_objects = True):
849 autowaf.set_local_lib(conf, name, has_objects)
852 conf.load('compiler_c')
853 conf.load('compiler_cxx')
854 if Options.options.dist_target == 'mingw':
857 if Options.options.dist_target == 'msvc':
858 conf.env['MSVC_VERSIONS'] = ['msvc 10.0', 'msvc 9.0', 'msvc 8.0', 'msvc 7.1', 'msvc 7.0', 'msvc 6.0', ]
859 conf.env['MSVC_TARGETS'] = ['x64']
862 if Options.options.debug and not Options.options.keepflags:
863 # Nuke user CFLAGS/CXXFLAGS if debug is set (they likely contain -O3, NDEBUG, etc)
864 conf.env['CFLAGS'] = []
865 conf.env['CXXFLAGS'] = []
867 # freedesktop translations needs itstool > 1.0.3 (-j option)
868 if Options.options.freedesktop:
869 output = subprocess.Popen("itstool --version", shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
870 o = output[0].decode('utf-8')
871 itstool = o.split(' ')[0]
872 version = o.split(' ')[1].split('.')
873 # use distutils.version.StrictVersion or something python to check >= 1.0.4
874 # but first make sure that all build-hosts (incl. OSX-10.5/PPC) have that python lib.
875 # lazy approach: just use major version 2.X.X
876 if itstool != "itstool" or version[0] < "2":
877 print("--freedesktop requires itstool > 2.0.0 to translate files.")
880 conf.env['VERSION'] = VERSION
881 conf.env['MAJOR'] = MAJOR
882 conf.env['MINOR'] = MINOR
883 conf.env['MICRO'] = MICRO
885 autowaf.set_recursive()
886 autowaf.configure(conf)
887 autowaf.display_header('Ardour Configuration')
889 # systems with glibc have libintl builtin. systems without require explicit
890 # linkage against libintl.
893 pkg_config_path = os.getenv('PKG_CONFIG_PATH')
894 user_gtk_root = os.path.expanduser (Options.options.depstack_root + '/gtk/inst')
896 if os.getenv('DEPSTACK_ROOT') is not None and os.path.exists (os.getenv('DEPSTACK_ROOT') + '/lib'):
897 conf.env['DEPSTACK_REV'] = get_depstack_rev (os.getenv('DEPSTACK_ROOT') + '/lib')
898 elif pkg_config_path is not None and pkg_config_path.find (user_gtk_root) >= 0:
899 # told to search user_gtk_root
900 prefinclude = ''.join ([ '-I', user_gtk_root + '/include'])
901 preflib = ''.join ([ '-L', user_gtk_root + '/lib'])
902 conf.env.append_value('CFLAGS', [ prefinclude ])
903 conf.env.append_value('CXXFLAGS', [prefinclude ])
904 conf.env.append_value('LINKFLAGS', [ preflib ])
905 autowaf.display_msg(conf, 'Will build against private GTK dependency stack in ' + user_gtk_root, 'yes')
906 conf.env['DEPSTACK_REV'] = get_depstack_rev (user_gtk_root)
908 autowaf.display_msg(conf, 'Will build against private GTK dependency stack', 'no')
909 conf.env['DEPSTACK_REV'] = '-system-'
911 if sys.platform == 'darwin':
912 conf.define ('NEED_INTL', 1)
913 autowaf.display_msg(conf, 'Will use explicit linkage against libintl in ' + user_gtk_root, 'yes')
915 # libintl is part of the system, so use it
916 autowaf.display_msg(conf, 'Will rely on libintl built into libc', 'yes')
918 user_ardour_root = os.path.expanduser (Options.options.depstack_root + '/a3/inst')
919 if pkg_config_path is not None and pkg_config_path.find (user_ardour_root) >= 0:
920 # told to search user_ardour_root
921 prefinclude = ''.join ([ '-I', user_ardour_root + '/include'])
922 preflib = ''.join ([ '-L', user_ardour_root + '/lib'])
923 conf.env.append_value('CFLAGS', [ prefinclude ])
924 conf.env.append_value('CXXFLAGS', [prefinclude ])
925 conf.env.append_value('LINKFLAGS', [ preflib ])
926 autowaf.display_msg(conf, 'Will build against private Ardour dependency stack in ' + user_ardour_root, 'yes')
928 autowaf.display_msg(conf, 'Will build against private Ardour dependency stack', 'no')
930 if Options.options.freebie:
931 conf.env.append_value ('CFLAGS', '-DSILENCE_AFTER')
932 conf.env.append_value ('CXXFLAGS', '-DSILENCE_AFTER')
933 conf.define ('FREEBIE', 1)
935 if Options.options.lv2dir:
936 conf.env['LV2DIR'] = Options.options.lv2dir
938 conf.env['LV2DIR'] = os.path.join(conf.env['LIBDIR'], 'ardour' + str(conf.env['MAJOR']), 'LV2')
940 conf.env['LV2DIR'] = os.path.normpath(conf.env['LV2DIR'])
942 if sys.platform == 'darwin':
944 # this is required, potentially, for anything we link and then relocate into a bundle
945 conf.env.append_value('LINKFLAGS', [ '-Xlinker', '-headerpad_max_install_names' ])
947 conf.define ('HAVE_COREAUDIO', 1)
948 conf.define ('AUDIOUNIT_SUPPORT', 1)
950 if not Options.options.ppc:
951 conf.define('MACVST_SUPPORT', 1)
953 conf.define ('TOP_MENUBAR',1)
955 # It would be nice to be able to use this to force back-compatibility with 10.4
956 # but even by the time of 11, the 10.4 SDK is no longer available in any normal
959 #conf.env.append_value('CXXFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
960 #conf.env.append_value('CFLAGS_OSX', "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
961 #conf.env.append_value('LINKFLAGS_OSX', "-sysroot /Developer/SDKs/MacOSX10.4u.sdk")
962 #conf.env.append_value('LINKFLAGS_OSX', "-sysroot /Developer/SDKs/MacOSX10.4u.sdk")
964 conf.env.append_value('CXXFLAGS_OSX', "-msse")
965 conf.env.append_value('CFLAGS_OSX', "-msse")
966 conf.env.append_value('CXXFLAGS_OSX', "-msse2")
967 conf.env.append_value('CFLAGS_OSX', "-msse2")
969 # TODO: The previous sse flags NEED to be based
970 # off processor type. Need to add in a check
973 conf.env.append_value('CXXFLAGS_OSX', '-F/System/Library/Frameworks')
974 conf.env.append_value('CXXFLAGS_OSX', '-F/Library/Frameworks')
976 conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'AppKit'])
977 conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreAudio'])
978 conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreAudioKit'])
979 conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreFoundation'])
980 conf.env.append_value('LINKFLAGS_OSX', ['-framework', 'CoreServices'])
982 conf.env.append_value('LINKFLAGS_OSX', ['-undefined', 'dynamic_lookup' ])
983 conf.env.append_value('LINKFLAGS_OSX', ['-flat_namespace'])
985 conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DAUDIOUNIT_SUPPORT")
986 conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'AudioToolbox', '-framework', 'AudioUnit'])
987 conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'Cocoa'])
990 # osx up to and including 10.6 (uname 10.X.X)
991 (re.search ("^[1-9][0-9]\.", os.uname()[2]) == None or not re.search ("^10\.", os.uname()[2]) == None)
992 and (Options.options.generic or Options.options.ppc)
993 and not Options.options.nocarbon
995 conf.env.append_value('CXXFLAGS_AUDIOUNITS', "-DWITH_CARBON")
996 conf.env.append_value('LINKFLAGS_AUDIOUNITS', ['-framework', 'Carbon'])
998 print ('No Carbon support available for this build\n')
1001 if Options.options.canvasui:
1002 conf.env['CANVASTESTUI'] = True
1003 conf.define ('CANVASTESTUI', 1)
1005 if Options.options.beatbox:
1006 conf.env['BEATBOX'] = True
1007 conf.define ('BEATBOX', 1)
1009 if Options.options.luadoc:
1010 conf.env['LUABINDINGDOC'] = True
1011 conf.define ('LUABINDINGDOC', 1)
1013 if Options.options.internal_shared_libs:
1014 conf.define('INTERNAL_SHARED_LIBS', 1)
1016 if Options.options.use_external_libs:
1017 conf.define('USE_EXTERNAL_LIBS', 1)
1018 conf.env.append_value(
1019 'CXXFLAGS', '-I' + Options.options.qm_dsp_include)
1021 if Options.options.boost_include != '':
1022 conf.env.append_value('CXXFLAGS', '-I' + Options.options.boost_include)
1024 if Options.options.also_include != '':
1025 conf.env.append_value('CXXFLAGS', '-I' + Options.options.also_include)
1026 conf.env.append_value('CFLAGS', '-I' + Options.options.also_include)
1028 if Options.options.also_libdir != '':
1029 conf.env.append_value('LDFLAGS', '-L' + Options.options.also_libdir)
1031 if Options.options.boost_sp_debug:
1032 conf.env.append_value('CXXFLAGS', '-DBOOST_SP_ENABLE_DEBUG_HOOKS')
1034 # executing a test program is n/a when cross-compiling
1035 if Options.options.dist_target != 'mingw':
1036 if Options.options.dist_target != 'msvc' and re.search ("openbsd", sys.platform) == None:
1037 if re.search ("freebsd", sys.platform) != None:
1038 conf.check_cc(function_name='dlopen', header_name='dlfcn.h', uselib_store='DL')
1040 conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL')
1042 conf.check_cxx(fragment = "#include <boost/version.hpp>\n#if !defined (BOOST_VERSION) || BOOST_VERSION < 103900\n#error boost >= 1.39 is not available\n#endif\nint main(void) { return 0; }\n",
1045 msg = 'Checking for boost library >= 1.39',
1047 errmsg = 'too old\nPlease install boost version 1.39 or higher.')
1049 if re.search ("linux", sys.platform) != None and Options.options.dist_target != 'mingw':
1050 autowaf.check_pkg(conf, 'alsa', uselib_store='ALSA')
1052 if re.search ("openbsd", sys.platform) != None:
1053 conf.env.append_value('LDFLAGS', '-L/usr/X11R6/lib')
1055 autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.28', mandatory=True)
1056 autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2', mandatory=True)
1057 autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True)
1058 autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18', mandatory=True)
1059 autowaf.check_pkg(conf, 'giomm-2.4', uselib_store='GIOMM', atleast_version='2.2', mandatory=True)
1060 autowaf.check_pkg(conf, 'libcurl', uselib_store='CURL', atleast_version='7.0.0', mandatory=True)
1061 autowaf.check_pkg(conf, 'libarchive', uselib_store='ARCHIVE', atleast_version='3.0.0', mandatory=True)
1062 autowaf.check_pkg(conf, 'liblo', uselib_store='LO', atleast_version='0.26', mandatory=True)
1063 autowaf.check_pkg(conf, 'taglib', uselib_store='TAGLIB', atleast_version='1.6', mandatory=True)
1064 autowaf.check_pkg(conf, 'vamp-sdk', uselib_store='VAMPSDK', atleast_version='2.1', mandatory=True)
1065 autowaf.check_pkg(conf, 'vamp-hostsdk', uselib_store='VAMPHOSTSDK', atleast_version='2.1', mandatory=True)
1066 autowaf.check_pkg(conf, 'rubberband', uselib_store='RUBBERBAND', mandatory=True)
1068 have_rf64_riff_support = conf.check_cc(fragment = '''
1069 #include <sndfile.h>
1070 int main () { int x = SFC_RF64_AUTO_DOWNGRADE; return 0; }
1076 msg = 'Checking for sndfile RF64=>RIFF support',
1078 errmsg = 'Not found, no RF64-to-WAV support')
1080 if have_rf64_riff_support:
1081 conf.env.append_value('CXXFLAGS', "-DHAVE_RF64_RIFF")
1082 conf.env.append_value('CFLAGS', "-DHAVE_RF64_RIFF")
1084 if Options.options.dist_target == 'mingw':
1085 Options.options.fpu_optimization = True
1086 conf.env.append_value('CFLAGS', '-DPLATFORM_WINDOWS')
1087 conf.env.append_value('CFLAGS', '-DCOMPILER_MINGW')
1088 conf.env.append_value('CXXFLAGS', '-DPLATFORM_WINDOWS')
1089 conf.env.append_value('CXXFLAGS', '-DCOMPILER_MINGW')
1090 if conf.options.cxx11:
1091 conf.env.append_value('CFLAGS', '-D_USE_MATH_DEFINES')
1092 conf.env.append_value('CXXFLAGS', '-D_USE_MATH_DEFINES')
1093 conf.env.append_value('CFLAGS', '-DWIN32')
1094 conf.env.append_value('CXXFLAGS', '-DWIN32')
1095 conf.env.append_value('LIB', 'pthread')
1096 # needed for at least libsmf
1097 conf.check_cc(function_name='htonl', header_name='winsock2.h', lib='ws2_32')
1098 conf.env.append_value('LIB', 'ws2_32')
1099 conf.env.append_value('LIB', 'winmm')
1100 # needed for mingw64 packages, not harmful on normal mingw build
1101 conf.env.append_value('LIB', 'intl')
1102 conf.check_cc(function_name='regcomp', header_name='regex.h',
1103 lib='regex', uselib_store="REGEX", define_name='HAVE_REGEX_H')
1104 # TODO put this only where it is needed
1105 conf.env.append_value('LIB', 'regex')
1106 # TODO this should only be necessary for a debug build
1107 conf.env.append_value('LIB', 'dbghelp')
1109 # work around GdkDrawable BitBlt performance issue on windows
1110 # see http://gareus.org/wiki/ardour_windows_gdk_and_cairo
1111 conf.env.append_value('CFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
1112 conf.env.append_value('CXXFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
1113 conf.define ('WINDOWS', 1)
1115 have_ptw_semaphore = conf.check_cc(fragment = '''
1116 #include <pthread.h>
1117 #include <semaphore.h>
1118 int main () { return 0; }
1123 msg = 'Checking for pthread posix semaphore',
1125 errmsg = 'Not found, falling back to Windows Semaphore.')
1127 #if have_ptw_semaphore:
1128 # conf.define('USE_PTW32_SEMAPHORE', 1)
1129 # conf.env.append_value('CFLAGS', '-DUSE_PTW32_SEMAPHORE')
1130 # conf.env.append_value('CXXFLAGS', '-DUSE_PTW32_SEMAPHORE')
1132 if Options.options.dist_target == 'msvc':
1133 conf.env.append_value('CFLAGS', '-DPLATFORM_WINDOWS')
1134 conf.env.append_value('CFLAGS', '-DCOMPILER_MSVC')
1135 conf.env.append_value('CXXFLAGS', '-DPLATFORM_WINDOWS')
1136 conf.env.append_value('CXXFLAGS', '-DCOMPILER_MSVC')
1137 # work around GdkDrawable BitBlt performance issue on windows
1138 # see http://gareus.org/wiki/ardour_windows_gdk_and_cairo
1139 conf.env.append_value('CFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
1140 conf.env.append_value('CXXFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
1141 # MORE STUFF PROBABLY NEEDED HERE
1142 conf.define ('WINDOWS', 1)
1144 # Tell everyone that this is a waf build
1146 conf.env.append_value('CFLAGS', '-DWAF_BUILD')
1147 conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
1149 opts = Options.options
1151 # (optionally) Adopt Microsoft-like convention that makes all non-explicitly exported
1152 # symbols invisible (rather than doing this all over the wscripts in the src tree)
1154 # This won't apply to MSVC but that hasn't been added as a target yet
1156 # We can't do this till all tests are complete, since some fail if this is et.
1157 if opts.exports_hidden:
1158 conf.define ('EXPORT_VISIBILITY_HIDDEN', True)
1159 if opts.internal_shared_libs:
1160 conf.env.append_value ('CXXFLAGS', '-fvisibility=hidden')
1161 conf.env.append_value ('CFLAGS', '-fvisibility=hidden')
1163 conf.define ('EXPORT_VISIBILITY_HIDDEN', False)
1165 # Set up waf environment and C defines
1167 conf.define('PHONE_HOME', 1)
1168 conf.env['PHONE_HOME'] = True
1169 if opts.fpu_optimization:
1170 conf.env['FPU_OPTIMIZATION'] = True
1171 if opts.freedesktop:
1172 conf.env['FREEDESKTOP'] = True
1174 conf.define('ENABLE_NLS', 1)
1175 conf.env['ENABLE_NLS'] = True
1176 if opts.build_tests:
1177 conf.env['BUILD_TESTS'] = True
1178 conf.env['RUN_TESTS'] = opts.run_tests
1179 if opts.single_tests:
1180 conf.env['SINGLE_TESTS'] = opts.single_tests
1182 # conf.env['TRANZPORT'] = 1
1183 if opts.windows_vst:
1184 conf.define('WINDOWS_VST_SUPPORT', 1)
1185 conf.env['WINDOWS_VST_SUPPORT'] = True
1186 if not Options.options.dist_target == 'mingw':
1187 conf.env.append_value('CFLAGS', '-I' + Options.options.wine_include)
1188 conf.env.append_value('CXXFLAGS', '-I' + Options.options.wine_include)
1189 autowaf.check_header(conf, 'cxx', 'windows.h', mandatory = True)
1191 if sys.platform == 'darwin':
1192 conf.env['LXVST_SUPPORT'] = False
1193 elif Options.options.dist_target == 'mingw':
1194 conf.env['LXVST_SUPPORT'] = False
1196 conf.define('LXVST_SUPPORT', 1)
1197 conf.env['LXVST_SUPPORT'] = True
1198 conf.env['WINDOWS_KEY'] = opts.windows_key
1199 if opts.rt_alloc_debug:
1200 conf.define('DEBUG_RT_ALLOC', 1)
1201 conf.env['DEBUG_RT_ALLOC'] = True
1203 conf.define('PT_TIMING', 1)
1204 conf.env['PT_TIMING'] = True
1205 if opts.denormal_exception:
1206 conf.define('DEBUG_DENORMAL_EXCEPTION', 1)
1207 conf.env['DEBUG_DENORMAL_EXCEPTION'] = True
1208 if opts.build_tests:
1209 autowaf.check_pkg(conf, 'cppunit', uselib_store='CPPUNIT', atleast_version='1.12.0', mandatory=True)
1211 conf.define('PTFORMAT', 1)
1212 conf.env['PTFORMAT'] = True
1213 if opts.no_threaded_waveviews:
1214 conf.define('NO_THREADED_WAVEVIEWS', 1)
1215 conf.env['NO_THREADED_WAVEVIEWS'] = True
1217 backends = opts.with_backends.split(',')
1218 if opts.build_tests and 'dummy' not in backends:
1219 backends += ['dummy']
1222 print("Must configure and build at least one backend")
1225 conf.env['BACKENDS'] = backends
1226 conf.env['BUILD_JACKBACKEND'] = any('jack' in b for b in backends)
1227 conf.env['BUILD_ALSABACKEND'] = any('alsa' in b for b in backends)
1228 conf.env['BUILD_DUMMYBACKEND'] = any('dummy' in b for b in backends)
1229 conf.env['BUILD_PABACKEND'] = any('portaudio' in b for b in backends)
1230 conf.env['BUILD_CORECRAPPITA'] = any('coreaudio' in b for b in backends)
1232 if re.search ("linux", sys.platform) != None and Options.options.dist_target != 'mingw' and conf.env['BUILD_PABACKEND']:
1233 print("PortAudio Backend is not for Linux")
1236 if sys.platform != 'darwin' and conf.env['BUILD_CORECRAPPITA']:
1237 print("Coreaudio backend is only available for OSX")
1240 if re.search ("linux", sys.platform) == None and conf.env['BUILD_ALSABACKEND']:
1241 print("ALSA Backend is only available on Linux")
1244 set_compiler_flags (conf, Options.options)
1246 if sys.platform == 'darwin':
1247 sub_config_and_use(conf, 'libs/appleutility')
1248 elif re.search ("openbsd", sys.platform) != None:
1250 elif Options.options.dist_target != 'mingw':
1251 sub_config_and_use(conf, 'tools/sanity_check')
1252 sub_config_and_use(conf, 'tools/gccabicheck')
1254 sub_config_and_use(conf, 'libs/clearlooks-newer')
1257 sub_config_and_use(conf, i)
1259 # Fix utterly braindead FLAC include path to not smash assert.h
1260 conf.env['INCLUDES_FLAC'] = []
1262 config_text = open('libs/ardour/config_text.cc', "w")
1263 config_text.write('''#include "ardour/ardour.h"
1265 const char* const ardour_config_info = "\\n\\
1268 def write_config_text(title, val):
1269 autowaf.display_msg(conf, title, val)
1270 config_text.write(title + ': ')
1271 config_text.write(str(val).replace ('"', '\\"'))
1272 config_text.write("\\n\\\n")
1274 write_config_text('Build documentation', conf.env['DOCS'])
1275 write_config_text('Debuggable build', conf.env['DEBUG'])
1276 write_config_text('Export all symbols (backtrace)', opts.backtrace)
1277 write_config_text('Install prefix', conf.env['PREFIX'])
1278 write_config_text('Strict compiler flags', conf.env['STRICT'])
1279 write_config_text('Internal Shared Libraries', conf.is_defined('INTERNAL_SHARED_LIBS'))
1280 write_config_text('Use External Libraries', conf.is_defined('USE_EXTERNAL_LIBS'))
1281 write_config_text('Library exports hidden', conf.is_defined('EXPORT_VISIBILITY_HIDDEN'))
1282 write_config_text('Free/Demo copy', conf.is_defined('FREEBIE'))
1283 config_text.write("\\n\\\n")
1284 write_config_text('ALSA DBus Reservation', conf.is_defined('HAVE_DBUS'))
1285 write_config_text('Architecture flags', opts.arch)
1286 write_config_text('Aubio', conf.is_defined('HAVE_AUBIO'))
1287 write_config_text('AudioUnits', conf.is_defined('AUDIOUNIT_SUPPORT'))
1288 write_config_text('Build target', conf.env['build_target'])
1289 write_config_text('Canvas Test UI', conf.is_defined('CANVASTESTUI'))
1290 write_config_text('Beatbox test app', conf.is_defined('BEATBOX'))
1291 write_config_text('CoreAudio', conf.is_defined('HAVE_COREAUDIO'))
1292 write_config_text('CoreAudio 10.5 compat', conf.is_defined('COREAUDIO105'))
1293 write_config_text('Debug RT allocations', conf.is_defined('DEBUG_RT_ALLOC'))
1294 write_config_text('Debug Symbols', conf.is_defined('debug_symbols') or conf.env['DEBUG'])
1295 write_config_text('Denormal exceptions', conf.is_defined('DEBUG_DENORMAL_EXCEPTION'))
1296 write_config_text('FLAC', conf.is_defined('HAVE_FLAC'))
1297 write_config_text('FPU optimization', opts.fpu_optimization)
1298 write_config_text('Freedesktop files', opts.freedesktop)
1299 write_config_text('Libjack linking', conf.env['libjack_link'])
1300 write_config_text('Libjack metadata', conf.is_defined ('HAVE_JACK_METADATA'))
1301 write_config_text('Lua Binding Doc', conf.is_defined('LUABINDINGDOC'))
1302 write_config_text('LV2 UI embedding', conf.is_defined('HAVE_SUIL'))
1303 write_config_text('LV2 support', conf.is_defined('LV2_SUPPORT'))
1304 write_config_text('LV2 extensions', conf.is_defined('LV2_EXTENDED'))
1305 write_config_text('LXVST support', conf.is_defined('LXVST_SUPPORT'))
1306 write_config_text('Mac VST support', conf.is_defined('MACVST_SUPPORT'))
1307 write_config_text('NI-Maschine', opts.maschine)
1308 write_config_text('OGG', conf.is_defined('HAVE_OGG'))
1309 write_config_text('Phone home', conf.is_defined('PHONE_HOME'))
1310 write_config_text('Process thread timing', conf.is_defined('PT_TIMING'))
1311 write_config_text('Program name', opts.program_name)
1312 write_config_text('Samplerate', conf.is_defined('HAVE_SAMPLERATE'))
1313 write_config_text('PT format', conf.is_defined('PTFORMAT'))
1314 write_config_text('PTW32 Semaphore', conf.is_defined('USE_PTW32_SEMAPHORE'))
1315 # write_config_text('Soundtouch', conf.is_defined('HAVE_SOUNDTOUCH'))
1316 write_config_text('Threaded WaveViews', not opts.no_threaded_waveviews)
1317 write_config_text('Translation', opts.nls)
1318 # write_config_text('Tranzport', opts.tranzport)
1319 write_config_text('Unit tests', conf.env['BUILD_TESTS'])
1320 write_config_text('Windows VST support', opts.windows_vst)
1321 write_config_text('Wiimote support', conf.is_defined('BUILD_WIIMOTE'))
1322 write_config_text('Windows key', opts.windows_key)
1323 config_text.write("\\n\\\n")
1324 write_config_text('PortAudio Backend', conf.env['BUILD_PABACKEND'])
1325 write_config_text('CoreAudio/Midi Backend',conf.env['BUILD_CORECRAPPITA'])
1326 write_config_text('ALSA Backend', conf.env['BUILD_ALSABACKEND'])
1327 write_config_text('Dummy backend', conf.env['BUILD_DUMMYBACKEND'])
1328 write_config_text('JACK Backend', conf.env['BUILD_JACKBACKEND'])
1329 config_text.write("\\n\\\n")
1330 write_config_text('Buildstack', conf.env['DEPSTACK_REV'])
1331 write_config_text('Mac i386 Architecture', opts.generic)
1332 write_config_text('Mac ppc Architecture', opts.ppc)
1333 config_text.write("\\n\\\n")
1334 write_config_text('C compiler flags', conf.env['CFLAGS'])
1335 write_config_text('C++ compiler flags', conf.env['CXXFLAGS'])
1336 write_config_text('Linker flags', conf.env['LINKFLAGS'])
1338 config_text.write ('";\n}\n')
1339 config_text.close ()
1342 if Options.options.dist_target == 'mingw' or Options.options.dist_target == 'msvc':
1343 create_resource_file(Options.options.program_name)
1346 create_stored_revision()
1348 bld.env['DATE'] = rev_date
1350 # add directories that contain only headers, to workaround an issue with waf
1352 if not bld.is_defined('USE_EXTERNAL_LIBS'):
1353 bld.path.find_dir ('libs/libltc/ltc')
1354 bld.path.find_dir ('libs/evoral/evoral')
1355 bld.path.find_dir ('libs/surfaces/control_protocol/control_protocol')
1356 bld.path.find_dir ('libs/temporal/temporal')
1357 bld.path.find_dir ('libs/gtkmm2ext/gtkmm2ext')
1358 bld.path.find_dir ('libs/ardour/ardour')
1359 bld.path.find_dir ('libs/pbd/pbd')
1361 # set up target directories
1362 lwrcase_dirname = 'ardour' + bld.env['MAJOR']
1364 if bld.is_tracks_build():
1365 bld.env.append_value ('CXXFLAGS', '-DUSE_TRACKS_CODE_FEATURES')
1366 bld.env.append_value ('CFLAGS', '-DUSE_TRACKS_CODE_FEATURES')
1367 lwrcase_dirname = 'trx'
1369 # configuration files go here
1370 bld.env['CONFDIR'] = os.path.join(bld.env['SYSCONFDIR'], lwrcase_dirname)
1371 # data files loaded at run time go here
1372 bld.env['DATADIR'] = os.path.join(bld.env['DATADIR'], lwrcase_dirname)
1373 # shared objects loaded at runtime go here (two aliases)
1374 bld.env['DLLDIR'] = os.path.join(bld.env['LIBDIR'], lwrcase_dirname)
1375 bld.env['LIBDIR'] = bld.env['DLLDIR']
1376 bld.env['LOCALEDIR'] = os.path.join(bld.env['DATADIR'], 'locale')
1377 bld.env['lwrcase_dirname'] = lwrcase_dirname;
1379 autowaf.set_recursive()
1381 if sys.platform == 'darwin':
1382 bld.recurse('libs/appleutility')
1383 elif re.search ("openbsd", sys.platform) != None:
1385 elif bld.env['build_target'] != 'mingw':
1386 bld.recurse('tools/sanity_check')
1387 bld.recurse('tools/gccabicheck')
1389 bld.recurse('libs/clearlooks-newer')
1394 if bld.is_defined ('BEATBOX'):
1395 bld.recurse('tools/bb')
1397 bld.install_files (bld.env['CONFDIR'], 'system_config')
1399 bld.install_files (os.path.join (bld.env['DATADIR'], 'templates'), bld.path.ant_glob ('templates/**'), cwd=bld.path.find_dir ('templates'), relative_trick=True)
1401 if bld.env['RUN_TESTS']:
1402 bld.add_post_fun(test)
1406 bld.recurse (i18n_children)
1409 bld.recurse (i18n_children)
1412 bld.recurse (i18n_children)
1415 bld.recurse (i18n_children)
1418 create_stored_revision()
1421 subprocess.call("gtk2_ardour/artest")
1424 cmd = "help2man -s 1 -N -o ardour.1 -n Ardour --version-string='Ardour %s' gtk2_ardour/ardev" % PROGRAM_VERSION
1425 subprocess.call(cmd, shell=True)