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'
95 def set_compiler_flags (conf,opt):
97 # Compiler flags and other system-dependent stuff
100 build_host_supports_sse = 0
101 optimization_flags = []
103 debug_flags = [ '-pg' ]
105 debug_flags = [ ] # waf adds -O0 -g itself. thanks waf!
107 # guess at the platform, used to define compiler flags
109 config_guess = os.popen("tools/config.guess").read()[:-1]
115 config = config_guess.split ("-")
117 print "system triple: " + config_guess
120 if opt.dist_target == 'auto':
121 if config[config_arch] == 'apple':
122 # The [.] matches to the dot after the major version, "." would match any character
123 if re.search ("darwin[0-7][.]", config[config_kernel]) != None:
124 conf.define ('build_target', 'panther')
125 if re.search ("darwin8[.]", config[config_kernel]) != None:
126 conf.define ('build_target', 'tiger')
128 conf.define ('build_target', 'leopard')
130 if re.search ("x86_64", config[config_cpu]) != None:
131 conf.define ('build_target', 'x86_64')
132 elif re.search("i[0-5]86", config[config_cpu]) != None:
133 conf.define ('build_target', 'i386')
134 elif re.search("powerpc", config[config_cpu]) != None:
135 conf.define ('build_target', 'powerpc')
137 conf.define ('build_target', 'i686')
139 conf.define ('build_target', opt.dist_target)
141 if config[config_cpu] == 'powerpc' and conf.env['build_target'] != 'none':
143 # Apple/PowerPC optimization options
145 # -mcpu=7450 does not reliably work with gcc 3.*
147 if opt.dist_target == 'panther' or opt.dist_target == 'tiger':
148 if config[config_arch] == 'apple':
149 # optimization_flags.extend ([ "-mcpu=7450", "-faltivec"])
150 # to support g3s but still have some optimization for above
151 optimization_flags.extend ([ "-mcpu=G3", "-mtune=7450"])
153 optimization_flags.extend ([ "-mcpu=7400", "-maltivec", "-mabi=altivec"])
155 optimization_flags.extend([ "-mcpu=750", "-mmultiple" ])
156 optimization_flags.extend (["-mhard-float", "-mpowerpc-gfxopt"])
157 optimization_flags.extend (["-Os"])
159 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':
163 # ARCH_X86 means anything in the x86 family from i386 to x86_64
164 # USE_X86_64_ASM is used to distingush 32 and 64 bit assembler
167 if (re.search ("(i[0-9]86|x86_64)", config[config_cpu]) != None):
168 debug_flags.append ("-DARCH_X86")
169 optimization_flags.append ("-DARCH_X86")
171 if config[config_kernel] == 'linux' :
174 # determine processor flags via /proc/cpuinfo
177 if conf.env['build_target'] != 'i386':
179 flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
180 x86_flags = flag_line.split (": ")[1:][0].split ()
182 if "mmx" in x86_flags:
183 optimization_flags.append ("-mmmx")
184 if "sse" in x86_flags:
185 build_host_supports_sse = 1
186 if "3dnow" in x86_flags:
187 optimization_flags.append ("-m3dnow")
189 if config[config_cpu] == "i586":
190 optimization_flags.append ("-march=i586")
191 elif config[config_cpu] == "i686":
192 optimization_flags.append ("-march=i686")
194 if ((conf.env['build_target'] == 'i686') or (conf.env['build_target'] == 'x86_64')) and build_host_supports_sse:
195 optimization_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
196 debug_flags.extend (["-msse", "-mfpmath=sse", "-DUSE_XMMINTRIN"])
198 # end of processor-specific section
200 # optimization section
201 if conf.env['FPU_OPTIMIZATION']:
202 if conf.env['build_target'] == 'tiger' or conf.env['build_target'] == 'leopard':
203 optimization_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
204 debug_flags.append ("-DBUILD_VECLIB_OPTIMIZATIONS");
205 conf.env.append_value('LINKFLAGS', "-framework Accelerate")
206 elif conf.env['build_target'] == 'i686' or conf.env['build_target'] == 'x86_64':
207 optimization_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
208 debug_flags.append ("-DBUILD_SSE_OPTIMIZATIONS")
209 if conf.env['build_target'] == 'x86_64':
210 optimization_flags.append ("-DUSE_X86_64_ASM")
211 debug_flags.append ("-DUSE_X86_64_ASM")
212 if build_host_supports_sse != 1:
213 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)"
214 if conf.check_cc(function_name='posix_memalign', header_name='stdlib.h', ccflags='-D_XOPEN_SOURCE=600') == False:
215 optimization_flags.append("-DNO_POSIX_MEMALIGN")
217 # end optimization section
223 if conf.env['build_target'] == 'x86_64' and opt.vst:
224 print "\n\n=================================================="
225 print "You cannot use VST plugins with a 64 bit host. Please run waf with --vst=0"
226 print "\nIt is theoretically possible to build a 32 bit host on a 64 bit system."
227 print "However, this is tricky and not recommended for beginners."
231 # a single way to test if we're on OS X
234 if conf.env['build_target'] in ['panther', 'tiger', 'leopard' ]:
235 conf.define ('IS_OSX', 1)
236 # force tiger or later, to avoid issues on PPC which defaults
237 # back to 10.1 if we don't tell it otherwise.
238 conf.env.append_value('CCFLAGS', "-DMAC_OS_X_VERSION_MIN_REQUIRED=1040")
241 conf.define ('IS_OSX', 0)
244 # save off guessed arch element in an env
246 conf.define ('CONFIG_ARCH', config[config_arch])
249 # ARCH="..." overrides all
253 optimization_flags = opt.arch.split()
256 # prepend boiler plate optimization flags that work on all architectures
259 optimization_flags[:0] = [
261 "-fomit-frame-pointer",
268 conf.env.append_value('CCFLAGS', debug_flags)
269 conf.env.append_value('CXXFLAGS', debug_flags)
270 conf.env.append_value('LINKFLAGS', debug_flags)
272 conf.env.append_value('CCFLAGS', optimization_flags)
273 conf.env.append_value('CXXFLAGS', optimization_flags)
274 conf.env.append_value('LINKFLAGS', optimization_flags)
277 conf.env.append_value('CXXFLAGS', "-D_GLIBCXX_DEBUG")
280 conf.env.append_value('CCFLAGS', "-arch i386 -arch ppc")
281 conf.env.append_value('CXXFLAGS', "-arch i386 -arch ppc")
282 conf.env.append_value('LINKFLAGS', "-arch i386 -arch ppc")
288 conf.env.append_value('CCFLAGS', "-Wall")
289 conf.env.append_value('CXXFLAGS', [ '-Wall', '-Woverloaded-virtual'])
292 conf.env.append_value('CCFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
293 conf.env.append_value('CXXFLAGS', [ '-Wextra', '-pedantic', '-ansi' ])
294 #conf.env.append_value('CFLAGS', "-iso")
301 conf.env.append_value('CCFLAGS', [ '-D_LARGEFILE64_SOURCE', '-D_LARGEFILE_SOURCE' ])
302 conf.env.append_value('CXXFLAGS', [ '-D_LARGEFILE64_SOURCE', '-D_LARGEFILE_SOURCE' ])
304 conf.env.append_value('CXXFLAGS', '-DENABLE_NLS')
305 conf.env.append_value('CCFLAGS', '-DENABLE_NLS')
308 #----------------------------------------------------------------
312 def set_options(opt):
313 autowaf.set_options(opt)
314 opt.add_option('--arch', type='string', action='store', dest='arch',
315 help='Architecture-specific compiler flags')
316 opt.add_option('--aubio', action='store_true', default=True, dest='aubio',
317 help="Use Paul Brossier's aubio library for feature detection (if available)")
318 opt.add_option('--audiounits', action='store_true', default=False, dest='audiounits',
319 help='Compile with Apple\'s AudioUnit library (experimental)')
320 opt.add_option('--coreaudio', action='store_true', default=False, dest='coreaudio',
321 help='Compile with Apple\'s CoreAudio library')
322 opt.add_option('--dist-target', type='string', default='auto', dest='dist_target',
323 help='Specify the target for cross-compiling [auto,none,x86,i386,i686,x86_64,powerpc,tiger,leopard]')
324 opt.add_option('--extra-warn', action='store_true', default=False, dest='extra_warn',
325 help='Build with even more compiler warning flags')
326 opt.add_option('--fpu-optimization', action='store_true', default=True, dest='fpu_optimization',
327 help='Build runtime checked assembler code')
328 opt.add_option('--freedesktop', action='store_true', default=False, dest='freedesktop',
329 help='Install MIME type, icons and .desktop file as per freedesktop.org standards')
330 opt.add_option('--freesound', action='store_true', default=False, dest='freesound',
331 help='Include Freesound database lookup')
332 opt.add_option('--gprofile', action='store_true', default=False, dest='gprofile',
333 help='Compile for use with gprofile')
334 opt.add_option('--gtkosx', action='store_true', default=False, dest='gtkosx',
335 help='Compile for use with GTK-OSX, not GTK-X11')
336 opt.add_option('--lv2', action='store_true', default=False, dest='lv2',
337 help='Compile with support for LV2 (if slv2 is available)')
338 opt.add_option('--nls', action='store_true', default=True, dest='nls',
339 help='Enable i18n (native language support)')
340 opt.add_option('--stl-debug', action='store_true', default=False, dest='stl_debug',
341 help='Build with debugging for the STL')
342 opt.add_option('--syslibs', action='store_true', default=True, dest='syslibs',
343 help='Use existing system versions of various libraries instead of internal ones')
344 opt.add_option('--tranzport', action='store_true', default=False, dest='tranzport',
345 help='Compile with support for Frontier Designs Tranzport (if libusb is available)')
346 opt.add_option('--universal', action='store_true', default=False, dest='universal',
347 help='Compile as universal binary (requires that external libraries are universal)')
348 opt.add_option('--versioned', action='store_true', default=False, dest='versioned',
349 help='Add revision information to executable name inside the build directory')
350 opt.add_option('--vst', action='store_true', default=False, dest='vst',
351 help='Compile with support for VST')
352 opt.add_option('--wiimote', action='store_true', default=False, dest='wiimote',
353 help='Build the wiimote control surface')
354 opt.add_option('--windows-key', type='string', action='store', dest='windows_key', default='Mod4><Super',
355 help='X Modifier(s) (Mod1,Mod2, etc) for the Windows key (X11 builds only). ' +
356 'Multiple modifiers must be separated by \'><\'')
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')
371 if sys.platform == 'darwin':
372 sub_config_and_use(conf, 'libs/appleutility')
374 sub_config_and_use(conf, i)
376 # Fix utterly braindead FLAC include path to not smash assert.h
377 conf.env['CPPPATH_FLAC'] = []
379 # Tell everyone that this is a waf build
381 conf.env.append_value('CCFLAGS', '-DWAF_BUILD')
382 conf.env.append_value('CXXFLAGS', '-DWAF_BUILD')
384 autowaf.print_summary(conf)
385 opts = Options.options
386 autowaf.display_header('Ardour Configuration')
387 autowaf.display_msg(conf, 'Build Target', conf.env['build_target'])
388 autowaf.display_msg(conf, 'Architecture flags', opts.arch)
389 autowaf.display_msg(conf, 'Aubio', bool(conf.env['HAVE_AUBIO']))
390 autowaf.display_msg(conf, 'AudioUnits', opts.audiounits)
392 conf.define('AUDIOUNITS',1)
393 autowaf.display_msg(conf, 'FPU Optimization', opts.fpu_optimization)
394 if opts.fpu_optimization:
395 conf.define('FPU_OPTIMIZATION', 1)
396 autowaf.display_msg(conf, 'Freedesktop Files', opts.freedesktop)
397 autowaf.display_msg(conf, 'Freesound', opts.freesound)
399 conf.define('FREESOUND',1)
400 autowaf.display_msg(conf, 'GtkOSX', opts.gtkosx)
402 conf.define ('GTKOSX', 1)
404 conf.define ('COREAUDIO', 1)
405 autowaf.display_msg(conf, 'LV2 Support', bool(conf.env['HAVE_SLV2']))
406 autowaf.display_msg(conf, 'Rubberband', bool(conf.env['HAVE_RUBBERBAND']))
407 autowaf.display_msg(conf, 'Samplerate', bool(conf.env['HAVE_SAMPLERATE']))
408 autowaf.display_msg(conf, 'Soundtouch', bool(conf.env['HAVE_SOUNDTOUCH']))
409 autowaf.display_msg(conf, 'Translation', opts.nls)
411 conf.define ('ENABLE_NLS', 1)
412 autowaf.display_msg(conf, 'System Libraries', opts.syslibs)
413 autowaf.display_msg(conf, 'Tranzport', opts.tranzport)
415 conf.define('TRANZPORT', 1)
416 autowaf.display_msg(conf, 'Universal Binary', opts.universal)
417 autowaf.display_msg(conf, 'VST Support', opts.vst)
419 conf.define('VST_SUPPORT', 1)
420 autowaf.display_msg(conf, 'Wiimote Support', opts.wiimote)
422 conf.define('WIIMOTE',1)
424 conf.define('WINDOWS_KEY', opts.windows_key)
425 autowaf.display_msg(conf, 'Windows Key', opts.windows_key)
427 set_compiler_flags (conf, Options.options)
429 autowaf.display_msg(conf, 'C Compiler flags', conf.env['CCFLAGS'])
430 autowaf.display_msg(conf, 'C++ Compiler flags', conf.env['CXXFLAGS'])
433 autowaf.set_recursive()
434 if sys.platform == 'darwin':
435 bld.add_subdirs('libs/appleutility')
440 bld.recurse (i18n_children)