11 # Variables for 'waf dist'
30 'libs/clearlooks-newer',
42 def fetch_svn_revision (path):
43 cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'"
44 return commands.getoutput(cmd)
46 def fetch_git_revision (path):
47 cmd = "LANG= git log --abbrev HEAD^..HEAD " + path
48 output = commands.getoutput(cmd).splitlines()
49 rev = output[0].replace ("commit", "git")[0:10]
52 if "git-svn-id" in line:
53 line = line.split('@')[1].split(' ')
59 def fetch_bzr_revision (path):
60 cmd = subprocess.Popen("LANG= bzr log -l 1 " + path, stdout=subprocess.PIPE, shell=True)
61 out = cmd.communicate()[0]
62 svn = re.search('^svn revno: [0-9]*', out, re.MULTILINE)
65 return string.lstrip(str, chars)
67 def create_stored_revision():
69 if os.path.exists('.svn'):
70 rev = fetch_svn_revision('.');
71 elif os.path.exists('.git'):
72 rev = fetch_git_revision('.');
73 elif os.path.exists('.bzr'):
74 rev = fetch_bzr_revision('.');
75 print "Revision: " + rev;
76 elif os.path.exists('libs/ardour/svn_revision.cc'):
77 print "Using packaged svn revision"
80 print "Missing libs/ardour/svn_revision.cc. Blame the packager."
84 text = '#include <ardour/svn_revision.h>\n'
85 text += 'namespace ARDOUR { extern const char* svn_revision = \"' + rev + '\"; }\n'
86 print 'Writing svn revision info to libs/ardour/svn_revision.cc'
87 o = file('libs/ardour/svn_revision.cc', 'w')
91 print 'Could not open libs/ardour/svn_revision.cc for writing\n'
94 def set_compiler_flags (conf,opt):
96 # Compiler flags and other system-dependent stuff
99 build_host_supports_sse = 0
100 optimization_flags = []
102 debug_flags = [ '-pg' ]
104 debug_flags = [ ] # waf adds -O0 -g itself. thanks waf!
106 # guess at the platform, used to define compiler flags
108 config_guess = os.popen("tools/config.guess").read()[:-1]
114 config = config_guess.split ("-")
116 print "system triple: " + config_guess
119 if opt.dist_target == 'auto':
120 if config[config_arch] == 'apple':
121 # The [.] matches to the dot after the major version, "." would match any character
122 if re.search ("darwin[0-7][.]", config[config_kernel]) != None:
123 conf.define ('build_target', 'panther')
124 if re.search ("darwin8[.]", config[config_kernel]) != None:
125 conf.define ('build_target', 'tiger')
127 conf.define ('build_target', 'leopard')
129 if re.search ("x86_64", config[config_cpu]) != None:
130 conf.define ('build_target', 'x86_64')
131 elif re.search("i[0-5]86", config[config_cpu]) != None:
132 conf.define ('build_target', 'i386')
133 elif re.search("powerpc", config[config_cpu]) != None:
134 conf.define ('build_target', 'powerpc')
136 conf.define ('build_target', 'i686')
138 conf.define ('build_target', opt.dist_target)
140 if config[config_cpu] == 'powerpc' and conf.env['build_target'] != 'none':
142 # Apple/PowerPC optimization options
144 # -mcpu=7450 does not reliably work with gcc 3.*
146 if opt.dist_target == 'panther' or opt.dist_target == 'tiger':
147 if config[config_arch] == 'apple':
148 # optimization_flags.extend ([ "-mcpu=7450", "-faltivec"])
149 # to support g3s but still have some optimization for above
150 optimization_flags.extend ([ "-mcpu=G3", "-mtune=7450"])
152 optimization_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
154 optimization_flags.extend([ "-mcpu=750", "-mmultiple" ])
155 optimization_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
156 optimization_flags.extend (["-Os"])
158 elif ((re.search ("i[0-9]86", config[config_cpu]) != None) or (re.search ("x86_64", config[config_cpu]) != None)) and conf.env['build_target'] != 'none':
162 # ARCH_X86 means anything in the x86 family from i386 to x86_64
163 # USE_X86_64_ASM is used to distingush 32 and 64 bit assembler
166 if (re.search ("(i[0-9]86|x86_64)", config[config_cpu]) != None):
167 debug_flags.append ("-DARCH_X86")
168 optimization_flags.append ("-DARCH_X86")
170 if config[config_kernel] == 'linux' :
173 # determine processor flags via /proc/cpuinfo
176 if conf.env['build_target'] != 'i386':
178 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
179 x86_flags = flag_line.split (": ")[1:][0].split ()
181 if "mmx" in x86_flags:
182 optimization_flags.append ("-mmmx")
183 if "sse" in x86_flags:
184 build_host_supports_sse = 1
185 if "3dnow" in x86_flags:
186 optimization_flags.append ("-m3dnow")
188 if config[config_cpu] == "i586":
189 optimization_flags.append ("-march=i586")
190 elif config[config_cpu] == "i686":
191 optimization_flags.append ("-march=i686")
193 if ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
194 optimization_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
195 debug_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
197 # end of processor-specific section
199 # optimization section
200 if conf.env['FPU_OPTIMIZATION']:
201 if conf.env['build_target'] == 'tiger' or conf.env['build_target'] == 'leopard':
202 optimization_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
203 debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
204 conf.env.append_value('LINKFLAGS', "-framework Accelerate")
205 elif conf.env['build_target'] == 'i686' or conf.env['build_target'] == 'x86_64':
206 optimization_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
207 debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
208 if conf.env['build_target'] == 'x86_64':
209 optimization_flags.append ("-DUSE_X86_64_ASM")
210 debug_flags.append ("-DUSE_X86_64_ASM")
211 if build_host_supports_sse != 1:
212 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)"
213 if conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', ccflags='-D_XOPEN_SOURCE=600') == False:
214 optimization_flags.append("-DNO_POSIX_MEMALIGN")
216 # end optimization section
222 if conf.env['build_target'] == 'x86_64' and opt.vst:
223 print "\n\n=================================================="
224 print "You cannot use VST plugins with a 64 bit host. Please run waf with --vst=0"
225 print "\nIt is theoretically possible to build a 32 bit host on a 64 bit system."
226 print "However, this is tricky and not recommended for beginners."
230 # a single way to test if we're on OS X
233 if conf.env['build_target'] in ['panther', 'tiger', 'leopard' ]:
234 conf.define ('IS_OSX', 1)
235 # force tiger or later, to avoid issues on PPC which defaults
236 # back to 10.1 if we don't tell it otherwise.
237 conf.env.append_value('CCFLAGS', "-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
240 conf.define ('IS_OSX', 0)
243 # save off guessed arch element in an env
245 conf.define ('CONFIG_ARCH', config[config_arch])
248 # ARCH="..." overrides all
252 optimization_flags = opt.arch.split()
255 # prepend boiler plate optimization flags that work on all architectures
258 optimization_flags[:0] = [
260 "-fomit-frame-pointer",
267 conf.env.append_value('CCFLAGS', debug_flags)
268 conf.env.append_value('CXXFLAGS', debug_flags)
269 conf.env.append_value('LINKFLAGS', debug_flags)
271 conf.env.append_value('CCFLAGS', optimization_flags)
272 conf.env.append_value('CXXFLAGS', optimization_flags)
273 conf.env.append_value('LINKFLAGS', optimization_flags)
276 conf.env.append_value('CXXFLAGS', "-D_GLIBCXX_DEBUG")
279 conf.env.append_value('CCFLAGS', "-arch i386 -arch ppc")
280 conf.env.append_value('CXXFLAGS', "-arch i386 -arch ppc")
281 conf.env.append_value('LINKFLAGS', "-arch i386 -arch ppc")
287 conf.env.append_value('CCFLAGS', "-Wall")
288 conf.env.append_value('CXXFLAGS', [ '-Wall', '-Woverloaded-virtual'])
291 conf.env.append_value('CCFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
292 conf.env.append_value('CXXFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
293 #conf.env.append_value('CFLAGS', "-iso")
300 conf.env.append_value('CCFLAGS', [ '-D_LARGEFILE64_SOURCE', '-D_LARGEFILE_SOURCE' ])
301 conf.env.append_value('CXXFLAGS', [ '-D_LARGEFILE64_SOURCE', '-D_LARGEFILE_SOURCE' ])
303 conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
304 conf.env.append_value('CCFLAGS', '-DENABLE_NLS')
307 #----------------------------------------------------------------
311 def set_options(opt):
312 autowaf.set_options(opt)
313 opt.add_option('--arch', type='string', action='store', dest='arch',
314 help='Architecture-specific compiler flags')
315 opt.add_option('--aubio', action='store_true', default=True, dest='aubio',
316 help="Use Paul Brossier's aubio library for feature detection (if available)")
317 opt.add_option('--audiounits', action='store_true', default=False, dest='audiounits',
318 help='Compile with Apple\'s AudioUnit library (experimental)')
319 opt.add_option('--coreaudio', action='store_true', default=False, dest='coreaudio',
320 help='Compile with Apple\'s CoreAudio library')
321 opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
322 help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]')
323 opt.add_option('--extra-warn', action='store_true', default=False, dest='extra_warn',
324 help='Build with even more compiler warning flags')
325 opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
326 help='Build runtime checked assembler code')
327 opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
328 help='Install MIME type, icons and .desktop file as per freedesktop.org standards')
329 opt.add_option('--freesound', action='store_true', default=False, dest='freesound',
330 help='Include Freesound database lookup')
331 opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
332 help='Compile for use with gprofile')
333 opt.add_option('--gtkosx', action='store_true', default=False, dest='gtkosx',
334 help='Compile for use with GTK-OSX, not GTK-X11')
335 opt.add_option('--lv2', action='store_true', default=False, dest='lv2',
336 help='Compile with support for LV2 (if slv2 is available)')
337 opt.add_option('--nls', action='store_true', default=True, dest='nls',
338 help='Enable i18n (native language support)')
339 opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
340 help='Build with debugging for the STL')
341 opt.add_option('--syslibs', action='store_true', default=True, dest='syslibs',
342 help='Use existing system versions of various libraries instead of internal ones')
343 opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
344 help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
345 opt.add_option('--universal', action='store_true', default=False, dest='universal',
346 help='Compile as universal binary (requires that external libraries are universal)')
347 opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
348 help='Add revision information to executable name inside the build directory')
349 opt.add_option('--vst', action='store_true', default=False, dest='vst',
350 help='Compile with support for VST')
351 opt.add_option('--wiimote', action='store_true', default=False, dest='wiimote',
352 help='Build the wiimote control surface')
353 opt.add_option('--windows-key', type='string', action='store', dest='windows_key', default='Mod4><Super',
354 help='X Modifier(s) (Mod1,Mod2, etc) for the Windows key (X11 builds only). ' +
355 'Multiple modifiers must be separated by \'><\'')
360 def sub_config_and_use(conf, name, has_objects = True):
361 conf.sub_config(name)
362 autowaf.set_local_lib(conf, name, has_objects)
365 create_stored_revision()
366 autowaf.set_recursive()
367 autowaf.configure(conf)
368 autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')
369 autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0')
370 if sys.platform == 'darwin':
371 sub_config_and_use(conf, 'libs/appleutility')
373 sub_config_and_use(conf, i)
375 # Fix utterly braindead FLAC include path to not smash assert.h
376 conf.env['CPPPATH_FLAC'] = []
378 # Tell everyone that this is a waf build
380 conf.env.append_value('CCFLAGS', '-DWAF_BUILD')
381 conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
383 autowaf.print_summary(conf)
384 opts = Options.options
385 autowaf.display_header('Ardour Configuration')
386 autowaf.display_msg(conf, 'Build Target', conf.env['build_target'])
387 autowaf.display_msg(conf, 'Architecture flags', opts.arch)
388 autowaf.display_msg(conf, 'Aubio', bool(conf.env['HAVE_AUBIO']))
389 autowaf.display_msg(conf, 'AudioUnits', opts.audiounits)
391 conf.define('AUDIOUNITS',1)
392 autowaf.display_msg(conf, 'FPU Optimization', opts.fpu_optimization)
393 if opts.fpu_optimization:
394 conf.define('FPU_OPTIMIZATION', 1)
395 autowaf.display_msg(conf, 'Freedesktop Files', opts.freedesktop)
396 autowaf.display_msg(conf, 'Freesound', opts.freesound)
398 conf.define('FREESOUND',1)
399 autowaf.display_msg(conf, 'GtkOSX', opts.gtkosx)
401 conf.define ('GTKOSX', 1)
403 conf.define ('COREAUDIO', 1)
404 autowaf.display_msg(conf, 'LV2 Support', bool(conf.env['HAVE_SLV2']))
405 autowaf.display_msg(conf, 'Rubberband', bool(conf.env['HAVE_RUBBERBAND']))
406 autowaf.display_msg(conf, 'Samplerate', bool(conf.env['HAVE_SAMPLERATE']))
407 autowaf.display_msg(conf, 'Soundtouch', bool(conf.env['HAVE_SOUNDTOUCH']))
408 autowaf.display_msg(conf, 'Translation', opts.nls)
410 conf.define ('ENABLE_NLS', 1)
411 autowaf.display_msg(conf, 'System Libraries', opts.syslibs)
412 autowaf.display_msg(conf, 'Tranzport', opts.tranzport)
414 conf.define('TRANZPORT', 1)
415 autowaf.display_msg(conf, 'Universal Binary', opts.universal)
416 autowaf.display_msg(conf, 'VST Support', opts.vst)
418 conf.define('VST_SUPPORT', 1)
419 autowaf.display_msg(conf, 'Wiimote Support', opts.wiimote)
421 conf.define('WIIMOTE',1)
423 conf.define('WINDOWS_KEY', opts.windows_key)
424 autowaf.display_msg(conf, 'Windows Key', opts.windows_key)
426 set_compiler_flags (conf, Options.options)
428 autowaf.display_msg(conf, 'C Compiler flags', conf.env['CCFLAGS'])
429 autowaf.display_msg(conf, 'C++ Compiler flags', conf.env['CXXFLAGS'])
432 autowaf.set_recursive()
433 if sys.platform == 'darwin':
434 bld.add_subdirs('libs/appleutility')
439 'MIDITAG' : 'control',
441 'JACK_INPUT' : 'auditioner'
444 obj = bld.new_task_gen('subst')
445 obj.source = 'ardour.rc.in'
446 obj.target = 'ardour_system.rc'
447 obj.dict = rc_subst_dict
448 obj.install_path = '${CONFIGDIR}/ardour3'
451 bld.recurse (i18n_children)