10 # Variables for 'waf dist'
40 def fetch_svn_revision (path):
41 cmd = "LANG= svn info " + path + " | awk '/^Revision:/ { print $2}'"
42 return commands.getoutput(cmd)
44 def fetch_git_revision (path):
45 cmd = "LANG= git log --abbrev HEAD^..HEAD " + path
46 output = commands.getoutput(cmd).splitlines()
47 rev = output[0].replace ("commit", "git")[0:10]
50 if "git-svn-id" in line:
51 line = line.split('@')[1].split(' ')
57 def fetch_bzr_revision (path):
58 cmd = subprocess.Popen("LANG= bzr log -l 1 " + path, stdout=subprocess.PIPE, shell=True)
59 out = cmd.communicate()[0]
60 svn = re.search('^svn revno: [0-9]*', out, re.MULTILINE)
63 return string.lstrip(str, chars)
65 def create_stored_revision():
67 if os.path.exists('.svn'):
68 rev = fetch_svn_revision('.');
69 elif os.path.exists('.git'):
70 rev = fetch_git_revision('.');
71 elif os.path.exists('.bzr'):
72 rev = fetch_bzr_revision('.');
73 print "Revision: " + rev;
74 elif os.path.exists('libs/ardour/svn_revision.cc'):
75 print "Using packaged svn revision"
78 print "Missing libs/ardour/svn_revision.cc. Blame the packager."
82 text = '#include <ardour/svn_revision.h>\n'
83 text += 'namespace ARDOUR { extern const char* svn_revision = \"' + rev + '\"; }\n'
84 print 'Writing svn revision info to libs/ardour/svn_revision.cc'
85 o = file('libs/ardour/svn_revision.cc', 'w')
89 print 'Could not open libs/ardour/svn_revision.cc for writing\n'
93 def set_compiler_flags (conf,opt):
95 # Compiler flags and other system-dependent stuff
98 build_host_supports_sse = 0
99 optimization_flags = []
101 debug_flags = [ '-pg' ]
103 debug_flags = [ ] # waf adds -O0 -g itself. thanks waf!
105 # guess at the platform, used to define compiler flags
107 config_guess = os.popen("tools/config.guess").read()[:-1]
113 config = config_guess.split ("-")
115 print "system triple: " + config_guess
118 if opt.dist_target == 'auto':
119 if config[config_arch] == 'apple':
120 # The [.] matches to the dot after the major version, "." would match any character
121 if re.search ("darwin[0-7][.]", config[config_kernel]) != None:
122 conf.define ('build_target', 'panther')
123 if re.search ("darwin8[.]", config[config_kernel]) != None:
124 conf.define ('build_target', 'tiger')
126 conf.define ('build_target', 'leopard')
128 if re.search ("x86_64", config[config_cpu]) != None:
129 conf.define ('build_target', 'x86_64')
130 elif re.search("i[0-5]86", config[config_cpu]) != None:
131 conf.define ('build_target', 'i386')
132 elif re.search("powerpc", config[config_cpu]) != None:
133 conf.define ('build_target', 'powerpc')
135 conf.define ('build_target', 'i686')
137 conf.define ('build_target', opt.dist_target)
139 if config[config_cpu] == 'powerpc' and conf.env['build_target'] != 'none':
141 # Apple/PowerPC optimization options
143 # -mcpu=7450 does not reliably work with gcc 3.*
145 if opt.dist_target == 'panther' or opt.dist_target == 'tiger':
146 if config[config_arch] == 'apple':
147 # optimization_flags.extend ([ "-mcpu=7450", "-faltivec"])
148 # to support g3s but still have some optimization for above
149 optimization_flags.extend ([ "-mcpu=G3", "-mtune=7450"])
151 optimization_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
153 optimization_flags.extend([ "-mcpu=750", "-mmultiple" ])
154 optimization_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
155 optimization_flags.extend (["-Os"])
157 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':
161 # ARCH_X86 means anything in the x86 family from i386 to x86_64
162 # USE_X86_64_ASM is used to distingush 32 and 64 bit assembler
165 if (re.search ("(i[0-9]86|x86_64)", config[config_cpu]) != None):
166 debug_flags.append ("-DARCH_X86")
167 optimization_flags.append ("-DARCH_X86")
169 if config[config_kernel] == 'linux' :
172 # determine processor flags via /proc/cpuinfo
175 if conf.env['build_target'] != 'i386':
177 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
178 x86_flags = flag_line.split (": ")[1:][0].split ()
180 if "mmx" in x86_flags:
181 optimization_flags.append ("-mmmx")
182 if "sse" in x86_flags:
183 build_host_supports_sse = 1
184 if "3dnow" in x86_flags:
185 optimization_flags.append ("-m3dnow")
187 if config[config_cpu] == "i586":
188 optimization_flags.append ("-march=i586")
189 elif config[config_cpu] == "i686":
190 optimization_flags.append ("-march=i686")
192 if ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
193 optimization_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
194 debug_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
196 # end of processor-specific section
198 # optimization section
199 if conf.env['FPU_OPTIMIZATION']:
200 if conf.env['build_target'] == 'tiger' or conf.env['build_target'] == 'leopard':
201 optimization_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
202 debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
203 libraries['core'].Append(LINKFLAGS= '-framework Accelerate')
204 elif conf.env['build_target'] == 'i686' or conf.env['build_target'] == 'x86_64':
205 optimization_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
206 debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
207 if conf.env['build_target'] == 'x86_64':
208 optimization_flags.append ("-DUSE_X86_64_ASM")
209 debug_flags.append ("-DUSE_X86_64_ASM")
210 if build_host_supports_sse != 1:
211 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 # end optimization section
219 if conf.env['build_target'] == 'x86_64' and opt.vst:
220 print "\n\n=================================================="
221 print "You cannot use VST plugins with a 64 bit host. Please run waf with --vst=0"
222 print "\nIt is theoretically possible to build a 32 bit host on a 64 bit system."
223 print "However, this is tricky and not recommended for beginners."
227 # a single way to test if we're on OS X
230 if conf.env['build_target'] in ['panther', 'tiger', 'leopard' ]:
231 conf.define ('IS_OSX', 1)
232 # force tiger or later, to avoid issues on PPC which defaults
233 # back to 10.1 if we don't tell it otherwise.
234 conf.env.append_value (CCFLAGS="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
236 if conf.env['build_target'] == 'leopard':
237 # need this to force build against the 10.4 SDK when building on later versions of OS X
238 # ideally this would be configurable, but lets just do that later when we need it
239 conf.env.append_value(CCFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
240 conf.env.append_value(LINKFLAGS="-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk")
243 conf.define ('IS_OSX', 0)
246 # save off guessed arch element in an env
248 conf.define ('CONFIG_ARCH', config[config_arch])
251 # ARCH="..." overrides all
255 optimization_flags = opt.arch.split()
258 # prepend boiler plate optimization flags that work on all architectures
261 optimization_flags[:0] = [
263 "-fomit-frame-pointer",
270 conf.env.append_value('CCFLAGS', debug_flags)
271 conf.env.append_value('CXXFLAGS', debug_flags)
272 conf.env.append_value('LINKFLAGS', debug_flags)
274 conf.env.append_value('CCFLAGS', optimization_flags)
275 conf.env.append_value('CXXFLAGS', optimization_flags)
276 conf.env.append_value('LINKFLAGS', optimization_flags)
279 conf.env.append_value('CXXFLAGS', "-D_GLIBCXX_DEBUG")
282 conf.env.append_value('CCFLAGS', "-arch i386 -arch ppc")
283 conf.env.append_value('CXXFLAGS', "-arch i386 -arch ppc")
284 conf.env.append_value('LINKFLAGS', "-arch i386 -arch ppc")
290 conf.env.append_value('CCFLAGS', "-Wall")
291 conf.env.append_value('CXXFLAGS', [ '-Wall', '-Woverloaded-virtual'])
294 conf.env.append_value('CCFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
295 conf.env.append_value('CXXFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
296 #conf.env.append_value('CFLAGS', "-iso")
303 conf.env.append_value('CCFLAGS', [ '-D_LARGEFILE64_SOURCE', '-D_LARGEFILE_SOURCE' ])
304 conf.env.append_value('CXXFLAGS', [ '-D_LARGEFILE64_SOURCE', '-D_LARGEFILE_SOURCE' ])
306 conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
307 conf.env.append_value('CCFLAGS', '-DENABLE_NLS')
310 #----------------------------------------------------------------
314 def set_options(opt):
315 autowaf.set_options(opt)
316 opt.add_option('--arch', type='string', action='store', dest='arch',
317 help='Architecture-specific compiler flags')
318 opt.add_option('--aubio', action='store_true', default=True, dest='aubio',
319 help="Use Paul Brossier's aubio library for feature detection (if available)")
320 opt.add_option('--audiounits', action='store_true', default=False, dest='audiounits',
321 help='Compile with Apple\'s AudioUnit library (experimental)')
322 opt.add_option('--coreaudio', action='store_true', default=False, dest='coreaudio',
323 help='Compile with Apple\'s CoreAudio library')
324 opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
325 help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]')
326 opt.add_option('--extra-warn', action='store_true', default=False, dest='extra_warn',
327 help='Build with even more compiler warning flags')
328 opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
329 help='Build runtime checked assembler code')
330 opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
331 help='Install MIME type, icons and .desktop file as per freedesktop.org standards')
332 opt.add_option('--freesound', action='store_true', default=False, dest='freesound',
333 help='Include Freesound database lookup')
334 opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
335 help='Compile for use with gprofile')
336 opt.add_option('--gtkosx', action='store_true', default=False, dest='gtkosx',
337 help='Compile for use with GTK-OSX, not GTK-X11')
338 opt.add_option('--lv2', action='store_true', default=False, dest='lv2',
339 help='Compile with support for LV2 (if slv2 is available)')
340 opt.add_option('--nls', action='store_true', default=True, dest='nls',
341 help='Enable i18n (native language support)')
342 opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
343 help='Build with debugging for the STL')
344 opt.add_option('--syslibs', action='store_true', default=True, dest='syslibs',
345 help='Use existing system versions of various libraries instead of internal ones')
346 opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
347 help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
348 opt.add_option('--universal', action='store_true', default=False, dest='universal',
349 help='Compile as universal binary (requires that external libraries are universal)')
350 opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
351 help='Add revision information to executable name inside the build directory')
352 opt.add_option('--vst', action='store_true', default=False, dest='vst',
353 help='Compile with support for VST')
354 opt.add_option('--wiimote', action='store_true', default=False, dest='wiimote',
355 help='Build the wiimote control surface')
356 opt.add_option('--windows-key', type='string', dest='windows_key',
357 help='Set X Modifier (Mod1,Mod2,Mod3,Mod4,Mod5) for "Windows" key [Default: Mod4]', default='Mod4><Super')
361 def sub_config_and_use(conf, name, has_objects = True):
362 conf.sub_config(name)
363 autowaf.set_local_lib(conf, name, has_objects)
366 create_stored_revision()
367 autowaf.set_recursive()
368 autowaf.configure(conf)
369 autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.2')
370 autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.14.0')
372 sub_config_and_use(conf, i)
374 # Fix utterly braindead FLAC include path to not smash assert.h
375 conf.env['CPPPATH_FLAC'] = []
377 # Tell everyone that this is a waf build
379 conf.env.append_value('CCFLAGS', '-DWAF_BUILD')
380 conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
382 autowaf.print_summary(conf)
383 opts = Options.options
384 autowaf.display_header('Ardour Configuration')
385 autowaf.display_msg(conf, 'Build Target', conf.env['build_target'])
386 autowaf.display_msg(conf, 'Architecture flags', opts.arch)
387 autowaf.display_msg(conf, 'Aubio', bool(conf.env['HAVE_AUBIO']))
388 autowaf.display_msg(conf, 'AudioUnits', opts.audiounits)
390 conf.define('AUDIOUNITS',1)
391 autowaf.display_msg(conf, 'FPU Optimization', opts.fpu_optimization)
392 if opts.fpu_optimization:
393 conf.define('FPU_OPTIMIZATION', 1)
394 autowaf.display_msg(conf, 'Freedesktop Files', opts.freedesktop)
395 autowaf.display_msg(conf, 'Freesound', opts.freesound)
397 conf.define('FREESOUND',1)
398 autowaf.display_msg(conf, 'GtkOSX', opts.gtkosx)
400 conf.define ('GTKOSX', 1)
401 autowaf.display_msg(conf, 'LV2 Support', bool(conf.env['HAVE_SLV2']))
402 autowaf.display_msg(conf, 'Rubberband', bool(conf.env['HAVE_RUBBERBAND']))
403 autowaf.display_msg(conf, 'Samplerate', bool(conf.env['HAVE_SAMPLERATE']))
404 autowaf.display_msg(conf, 'Soundtouch', bool(conf.env['HAVE_SOUNDTOUCH']))
405 autowaf.display_msg(conf, 'Translation', opts.nls)
407 conf.define ('ENABLE_NLS', 1)
408 autowaf.display_msg(conf, 'System Libraries', opts.syslibs)
409 autowaf.display_msg(conf, 'Tranzport', opts.tranzport)
411 conf.define('TRANZPORT', 1)
412 autowaf.display_msg(conf, 'Universal Binary', opts.universal)
413 autowaf.display_msg(conf, 'VST Support', opts.vst)
415 conf.define('VST_SUPPORT', 1)
416 autowaf.display_msg(conf, 'Wiimote Support', opts.wiimote)
418 conf.define('WIIMOTE',1)
419 autowaf.display_msg(conf, 'Windows Key', opts.windows_key)
421 conf.define('WINDOWS_KEY', opts.windows_key)
423 set_compiler_flags (conf, Options.options)
425 autowaf.display_msg(conf, 'C Compiler flags', conf.env['CCFLAGS'])
426 autowaf.display_msg(conf, 'C++ Compiler flags', conf.env['CXXFLAGS'])
429 autowaf.set_recursive()
434 bld.recurse (i18n_children)