root/trunk/libffado/SConstruct

Revision 2189, 27.1 kB (checked in by jwoithe, 8 years ago)

Check JACK version using "jackd --version" rather than relying on pkg-config. The latter will only work on most distributions if a jack-devel package is installed, and many users will not have this. If the new check fails, fall back to the old one even though it has little chance of success either. The new check should work equally well with jack1 and jack2, but it has only been tested explicitly with jack1.

Line 
1 #! /usr/bin/python
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright (C) 2007, 2008, 2010 Arnold Krille
5 # Copyright (C) 2007, 2008 Pieter Palmers
6 # Copyright (C) 2008, 2012 Jonathan Woithe
7 #
8 # This file is part of FFADO
9 # FFADO = Free Firewire (pro-)audio drivers for linux
10 #
11 # FFADO is based upon FreeBoB.
12 #
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 2 of the License, or
16 # (at your option) version 3 of the License.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
25 #
26
27 FFADO_API_VERSION = "9"
28 FFADO_VERSION="2.999.0"
29
30 from subprocess import Popen, PIPE
31 import os
32 import re
33 from string import Template
34 import imp
35 import distutils.sysconfig
36
37 if not os.path.isdir( "cache" ):
38         os.makedirs( "cache" )
39
40 opts = Variables( "cache/options.cache" )
41
42 opts.AddVariables(
43     BoolVariable( "DEBUG", """\
44 Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use
45   \"-O2\" to optimize.""", True ),
46     BoolVariable( "PROFILE", "Build with symbols and other profiling info", False ),
47     PathVariable( "PREFIX", "The prefix where ffado will be installed to.", "/usr/local", PathVariable.PathAccept ),
48     PathVariable( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathVariable.PathAccept ),
49     PathVariable( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathVariable.PathAccept ),
50     PathVariable( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathVariable.PathAccept ),
51     PathVariable( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathVariable.PathAccept ),
52     PathVariable( "MANDIR", "Overwrite the directory where manpages are installed", "$PREFIX/man", PathVariable.PathAccept ),
53     PathVariable( "PYPKGDIR", "The directory where the python modules get installed.",
54         distutils.sysconfig.get_python_lib( prefix="$PREFIX" ), PathVariable.PathAccept ),
55     PathVariable( "UDEVDIR", "Overwrite the directory where udev rules are installed to.", "/lib/udev/rules.d/", PathVariable.PathAccept ),
56     BoolVariable( "ENABLE_BEBOB", "Enable/Disable support for the BeBoB platform.", True ),
57     BoolVariable( "ENABLE_FIREWORKS", "Enable/Disable support for the ECHO Audio FireWorks platform.", True ),
58     BoolVariable( "ENABLE_OXFORD", "Enable/Disable support for the Oxford Semiconductor FW platform.", True ),
59     BoolVariable( "ENABLE_MOTU", "Enable/Disable support for the MOTU platform.", True ),
60     BoolVariable( "ENABLE_DICE", "Enable/Disable support for the TCAT DICE platform.", True ),
61     BoolVariable( "ENABLE_METRIC_HALO", "Enable/Disable support for the Metric Halo platform.", False ),
62     BoolVariable( "ENABLE_RME", "Enable/Disable support for the RME platform.", True ),
63     BoolVariable( "ENABLE_DIGIDESIGN", "Enable/Disable support for Digidesign interfaces.", False ),
64     BoolVariable( "ENABLE_MAUDIO", "Enable/Disable support for the M-Audio custom BeBoB devices.", False ),
65     BoolVariable( "ENABLE_BOUNCE", "Enable/Disable the BOUNCE device.", False ),
66     BoolVariable( "ENABLE_GENERICAVC", """\
67 Enable/Disable the the generic avc part (mainly used by apple).
68   Note that disabling this option might be overwritten by other devices needing
69   this code.""", False ),
70     BoolVariable( "ENABLE_ALL", "Enable/Disable support for all devices.", False ),
71     BoolVariable( "SERIALIZE_USE_EXPAT", "Use libexpat for XML serialization.", False ),
72     BoolVariable( "BUILD_TESTS", """\
73 Build the tests in their directory. As some contain quite some functionality,
74   this is on by default.
75   If you just want to use ffado with jack without the tools, you can disable this.\
76 """, True ),
77     BoolVariable( "BUILD_STATIC_TOOLS", "Build a statically linked version of the FFADO tools.", False ),
78     EnumVariable('DIST_TARGET', 'Build target for cross compiling packagers', 'auto', allowed_values=('auto', 'i386', 'i686', 'x86_64', 'powerpc', 'powerpc64', 'none' ), ignorecase=2),
79     BoolVariable( "ENABLE_OPTIMIZATIONS", "Enable optimizations and the use of processor specific extentions (MMX/SSE/...).", False ),
80     BoolVariable( "PEDANTIC", "Enable -Werror and more pedantic options during compile.", False ),
81     ( "COMPILE_FLAGS", "Add additional flags to the environment.\nOnly meant for distributors and gentoo-users who want to over-optimize their built.\n Using this is not supported by the ffado-devs!" ),
82     EnumVariable( "ENABLE_SETBUFFERSIZE_API_VER", "Report API version at runtime which includes support for dynamic buffer resizing (requires recent jack).", 'auto', allowed_values=('auto', 'true', 'false', 'force'), ignorecase=2),
83
84     )
85
86 ## Load the builders in config
87 buildenv=os.environ
88
89 env = Environment( tools=['default','scanreplace','pyuic','pyuic4','dbus','doxygen','pkgconfig'], toolpath=['admin'], ENV = buildenv, options=opts )
90
91 if env.has_key('COMPILE_FLAGS') and len(env['COMPILE_FLAGS']) > 0:
92     print '''
93  * Usage of additional flags is not supported by the ffado-devs.
94  * Use at own risk!
95  *
96  * Currentl value is '%s'
97  ''' % env['COMPILE_FLAGS']
98     env.MergeFlags(env['COMPILE_FLAGS'])
99
100 Help( """
101 For building ffado you can set different options as listed below. You have to
102 specify them only once, scons will save the last value you used and re-use
103 that.
104 To really undo your settings and return to the factory defaults, remove the
105 "cache"-folder and the file ".sconsign.dblite" from this directory.
106 For example with: "rm -Rf .sconsign.dblite cache"
107
108 Note that this is a development version! Don't complain if its not working!
109 See www.ffado.org for stable releases.
110 """ )
111 Help( opts.GenerateHelpText( env ) )
112
113 # make sure the necessary dirs exist
114 if not os.path.isdir( "cache" ):
115         os.makedirs( "cache" )
116 if not os.path.isdir( 'cache/objects' ):
117     os.makedirs( 'cache/objects' )
118
119 CacheDir( 'cache/objects' )
120
121 opts.Save( 'cache/options.cache', env )
122
123 def ConfigGuess( context ):
124     context.Message( "Trying to find the system triple: " )
125     ret = os.popen( "admin/config.guess" ).read()[:-1]
126     context.Result( ret )
127     return ret
128
129 def CheckForApp( context, app ):
130     context.Message( "Checking whether '" + app + "' executes " )
131     ret = context.TryAction( app )
132     context.Result( ret[0] )
133     return ret[0]
134
135 def CheckForPyModule( context, module ):
136     context.Message( "Checking for the python module '" + module + "' " )
137     ret = context.TryAction( "python $SOURCE", "import %s" % module, ".py" )
138     context.Result( ret[0] )
139     return ret[0]
140
141 def CompilerCheck( context ):
142     context.Message( "Checking for a working C-compiler " )
143     ret = context.TryRun( """
144 #include <stdio.h>
145
146 int main() {
147     printf( "Hello World!" );
148     return 0;
149 }""", '.c' )[0]
150     context.Result( ret )
151     if ret == 0:
152         return False;
153     context.Message( "Checking for a working C++-compiler " )
154     ret = context.TryRun( """
155 #include <iostream>
156
157 int main() {
158     std::cout << "Hello World!" << std::endl;
159     return 0;
160 }""", ".cpp" )[0]
161     context.Result( ret )
162     return ret
163
164 def CheckPKG(context, name):
165     context.Message( 'Checking for %s... ' % name )
166     ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
167     context.Result( ret )
168     return ret
169
170 tests = {
171     "ConfigGuess" : ConfigGuess,
172     "CheckForApp" : CheckForApp,
173     "CheckForPyModule": CheckForPyModule,
174     "CompilerCheck" : CompilerCheck,
175     "CheckPKG" : CheckPKG,
176 }
177 tests.update( env['PKGCONFIG_TESTS'] )
178 tests.update( env['PYUIC_TESTS'] )
179 tests.update( env['PYUIC4_TESTS'] )
180
181 conf = Configure( env,
182     custom_tests = tests,
183     conf_dir = "cache/",
184     log_file = 'cache/config.log' )
185
186 version_re = re.compile(r'^(\d+)\.(\d+)\.(\d+)')
187
188 def VersionInt(vers):
189     match = version_re.match(vers)
190     if not match:
191         return -1
192     (maj, min, patch) = match.group(1, 2, 3)
193     # For now allow "min" to run up to 65535.  "maj" and "patch" are
194     # restricted to 0-255.
195     return (int(maj) << 24) | (int(min) << 8) | int(patch)
196
197 def CheckJackdVer():
198     print 'Checking jackd version...',
199     ret = Popen("which jackd >/dev/null 2>&1 && jackd --version | cut -d ' ' -f 3", shell=True, stdout=PIPE).stdout.read()[:-1]
200     if (ret == ""):
201         print "not installed"
202         return -1
203     else:
204         print ret
205     return VersionInt(ret)
206
207 if env['SERIALIZE_USE_EXPAT']:
208     env['SERIALIZE_USE_EXPAT']=1
209 else:
210     env['SERIALIZE_USE_EXPAT']=0
211
212 if env['ENABLE_BOUNCE'] or env['ENABLE_ALL']:
213     env['REQUIRE_LIBAVC']=1
214 else:
215     env['REQUIRE_LIBAVC']=0
216
217 if not env.GetOption('clean'):
218     #
219     # Check for working gcc and g++ compilers and their environment.
220     #
221     if not conf.CompilerCheck():
222         print "\nIt seems as if your system isn't even able to compile any C-/C++-programs. Probably you don't have gcc and g++ installed. Compiling a package from source without a working compiler is very hard to do, please install the needed packages.\nHint: on *ubuntu you need both gcc- and g++-packages installed, easiest solution is to install build-essential which depends on gcc and g++."
223         Exit( 1 )
224
225     # Check for pkg-config before using pkg-config to check for other dependencies.
226     if not conf.CheckForPKGConfig():
227         print "\nThe program 'pkg-config' could not be found.\nEither you have to install the corresponding package first or make sure that PATH points to the right directions."
228         Exit( 1 )
229
230     #
231     # The following checks are for headers and libs and packages we need.
232     #
233     allpresent = 1;
234     # for cache-serialization.
235     if env['SERIALIZE_USE_EXPAT']:
236         allpresent &= conf.CheckHeader( "expat.h" )
237         allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
238
239     pkgs = {
240         'libraw1394' : '1.3.0',
241         'libiec61883' : '1.1.0',
242         'libconfig++' : '0'
243         }
244
245     if env['REQUIRE_LIBAVC']:
246         pkgs['libavc1394'] = '0.5.3'
247
248     if not env['SERIALIZE_USE_EXPAT']:
249         pkgs['libxml++-2.6'] = '2.13.0'
250
251     # Provide a way for users to compile newer libffado which will work
252     # against older jack installations which will not accept the new API
253     # version reported at runtime.
254     jackd_ver = CheckJackdVer()
255     if (jackd_ver != -1):
256         # If jackd is available, use the version number reported by it.  This
257         # means users don't have to have jack development files present on
258         # their system for this to work.
259         have_jack = (jackd_ver >= VersionInt('0.0.0'))
260         good_jack1 = (jackd_ver < VersionInt('1.9.0')) and (jackd_ver >= VersionInt('0.122.0'))
261         good_jack2 = (jackd_ver >= VersionInt('1.9.9'))
262     else:
263         # Jackd is not runnable.  Attempt to identify a version from
264         # pkgconfig on the off-chance jack details are available from there.
265         print "Will retry jack detection using pkg-config"
266         have_jack = conf.CheckPKG('jack >= 0.0.0')
267         good_jack1 = conf.CheckPKG('jack < 1.9.0') and conf.CheckPKG('jack >= 0.122.0')
268         good_jack2 = conf.CheckPKG('jack >= 1.9.9')
269     if env['ENABLE_SETBUFFERSIZE_API_VER'] == 'auto':
270         if not(have_jack):
271             print """
272 No Jack Audio Connection Kit (JACK) installed: assuming a FFADO
273 setbuffersize-compatible version will be used.
274 """
275         elif not(good_jack1 or good_jack2):
276             FFADO_API_VERSION="8"
277             print """
278 Installed Jack Audio Connection Kit (JACK) jack does not support FFADO
279 setbuffersize API: will report earlier API version at runtime.  Consider
280 upgrading to jack1 >=0.122.0 or jack2 >=1.9.9 at some point, and then
281 recompile ffado to gain access to this added feature.
282 """
283         else:
284             print "Installed Jack Audio Connection Kit (JACK) supports FFADO setbuffersize API"
285     elif env['ENABLE_SETBUFFERSIZE_API_VER'] == 'true':
286         if (have_jack and not(good_jack1) and not(good_jack2)):
287             print """
288 SetBufferSize API version is enabled but no suitable version of Jack Audio
289 Connection Kit (JACK) has been found.  The resulting FFADO would cause your
290 jackd to abort with "incompatible FFADO version".  Please upgrade to
291 jack1 >=0.122.0 or jack2 >=1.9.9, or set ENABLE_SETBUFFERSIZE_API_VER to "auto"
292 or "false".
293 """
294             # Although it's not strictly an error, in almost every case that
295             # this occurs the user will want to know about it and fix the
296             # problem, so we exit so they're guaranteed of seeing the above
297             # message.
298             Exit( 1 )
299         else:
300             print "Will report SetBufferSize API version at runtime"
301     elif env['ENABLE_SETBUFFERSIZE_API_VER'] == 'force':
302         print "Will report SetBufferSize API version at runtime"
303     else:
304         FFADO_API_VERSION="8"
305         print "Will not report SetBufferSize API version at runtime"
306
307     for pkg in pkgs:
308         name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
309         env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
310         #print '%s_FLAGS' % name2
311         if env['%s_FLAGS'%name2] == 0:
312             allpresent &= 0
313
314     if not allpresent:
315         print """
316 (At least) One of the dependencies is missing. I can't go on without it, please
317 install the needed packages for each of the lines saying "no".
318 (Remember to also install the *-devel packages!)
319
320 And remember to remove the cache with "rm -Rf .sconsign.dblite cache" so the
321 results above get rechecked.
322 """
323         Exit( 1 )
324
325     # Check for C99 lrint() and lrintf() functions used to convert from
326     # float to integer more efficiently via float_cast.h.  If not
327     # present the standard slower methods will be used instead.  This
328     # might not be the best way of testing for these but it's the only
329     # way which seems to work properly.  CheckFunc() fails due to
330     # argument count problems.
331     if env.has_key( 'CFLAGS' ):
332         oldcf = env['CFLAGS']
333     else:
334         oldcf = ""
335     oldcf = env.Append(CFLAGS = '-std=c99')
336     if conf.CheckLibWithHeader( "m", "math.h", "c", "lrint(3.2);" ):
337         HAVE_LRINT = 1
338     else:
339         HAVE_LRINT = 0
340     if conf.CheckLibWithHeader( "m", "math.h", "c", "lrintf(3.2);" ):
341         HAVE_LRINTF = 1
342     else:
343         HAVE_LRINTF = 0
344     env['HAVE_LRINT'] = HAVE_LRINT;
345     env['HAVE_LRINTF'] = HAVE_LRINTF;
346     env.Replace(CFLAGS=oldcf)
347
348 #
349 # Optional checks follow:
350 #
351
352 # PyQT checks
353 build_mixer = False
354 if conf.CheckForApp( 'which pyuic4' ) and conf.CheckForPyModule( 'dbus' ) and conf.CheckForPyModule( 'PyQt4' ) and conf.CheckForPyModule( 'dbus.mainloop.qt' ):
355     env['PYUIC4'] = True
356     build_mixer = True
357
358 if conf.CheckForApp( 'xdg-desktop-menu --help' ):
359     env['XDG_TOOLS'] = True
360 else:
361     print """
362 I couldn't find the program 'xdg-desktop-menu'. Together with xdg-icon-resource
363 this is needed to add the fancy entry to your menu. But if the mixer will be
364 installed, you can start it by executing "ffado-mixer".
365 """
366
367 if not build_mixer and not env.GetOption('clean'):
368     print """
369 I couldn't find all the prerequisites ('pyuic4' and the python-modules 'dbus'
370 and 'PyQt4', the packages could be named like dbus-python and PyQt) to build the
371 mixer.
372 Therefor the qt4 mixer will not get installed.
373 """
374
375 #
376 # Optional pkg-config
377 #
378 pkgs = {
379     'alsa': '0',
380     'dbus-1': '1.0',
381     'dbus-c++-1' : '0',
382     }
383 for pkg in pkgs:
384     name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
385     env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
386
387 if not env['DBUS1_FLAGS'] or not env['DBUSC1_FLAGS'] or not conf.CheckForApp('which dbusxx-xml2cpp'):
388     env['DBUS1_FLAGS'] = ""
389     env['DBUSC1_FLAGS'] = ""
390     print """
391 One of the dbus-headers, the dbus-c++-headers and/or the application
392 'dbusxx-xml2cpp' where not found. The dbus-server for ffado will therefore not
393 be built.
394 """
395 else:
396     # Get the directory where dbus stores the service-files
397     env['dbus_service_dir'] = conf.GetPKGVariable( 'dbus-1', 'session_bus_services_dir' ).strip()
398     # this is required to indicate that the DBUS version we use has support
399     # for platform dependent threading init functions
400     # this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is
401     # always true
402     env['DBUS1_FLAGS'] += " -DDBUS_HAS_THREADS_INIT_DEFAULT"
403
404
405 config_guess = conf.ConfigGuess()
406
407 env = conf.Finish()
408
409 if env['DEBUG']:
410     print "Doing a DEBUG build"
411     env.MergeFlags( "-DDEBUG -Wall -g" )
412 else:
413     env.MergeFlags( "-O2 -DNDEBUG" )
414
415 if env['PROFILE']:
416     print "Doing a PROFILE build"
417     env.MergeFlags( "-Wall -g" )
418
419 if env['PEDANTIC']:
420     env.MergeFlags( "-Werror" )
421
422
423 if env['ENABLE_ALL']:
424     env['ENABLE_BEBOB'] = True
425     env['ENABLE_FIREWORKS'] = True
426     env['ENABLE_OXFORD'] = True
427     env['ENABLE_MOTU'] = True
428     env['ENABLE_DICE'] = True
429     env['ENABLE_METRIC_HALO'] = True
430     env['ENABLE_RME'] = True
431     env['ENABLE_DIGIDESIGN'] = True
432     env['ENABLE_BOUNCE'] = True
433     env['ENABLE_MAUDIO'] = True
434
435
436 env['BUILD_STATIC_LIB'] = False
437 if env['BUILD_STATIC_TOOLS']:
438     print "Building static versions of the tools..."
439     env['BUILD_STATIC_LIB'] = True
440
441 env['build_base']="#/"
442
443 #
444 # Get the DESTDIR (if wanted) from the commandline
445 #
446 env.destdir = ARGUMENTS.get( 'DESTDIR', "" )
447
448 #
449 # Uppercase variables are for usage in code, lowercase versions for usage in
450 # scons-files for installing.
451 #
452 env['BINDIR'] = Template( env['BINDIR'] ).safe_substitute( env )
453 env['LIBDIR'] = Template( env['LIBDIR'] ).safe_substitute( env )
454 env['INCLUDEDIR'] = Template( env['INCLUDEDIR'] ).safe_substitute( env )
455 env['SHAREDIR'] = Template( env['SHAREDIR'] ).safe_substitute( env )
456 env['UDEVDIR'] = Template( env['UDEVDIR'] ).safe_substitute( env )
457 env['prefix'] = Template( env.destdir + env['PREFIX'] ).safe_substitute( env )
458 env['bindir'] = Template( env.destdir + env['BINDIR'] ).safe_substitute( env )
459 env['libdir'] = Template( env.destdir + env['LIBDIR'] ).safe_substitute( env )
460 env['includedir'] = Template( env.destdir + env['INCLUDEDIR'] ).safe_substitute( env )
461 env['sharedir'] = Template( env.destdir + env['SHAREDIR'] ).safe_substitute( env )
462 env['mandir'] = Template( env.destdir + env['MANDIR'] ).safe_substitute( env )
463 env['pypkgdir'] = Template( env.destdir + env['PYPKGDIR'] ).safe_substitute( env )
464 env['udevdir'] = Template( env.destdir + env['UDEVDIR'] ).safe_substitute( env )
465 env['PYPKGDIR'] = Template( env['PYPKGDIR'] ).safe_substitute( env )
466
467 env.Command( target=env['sharedir'], source="", action=Mkdir( env['sharedir'] ) )
468
469 env.Alias( "install", env['libdir'] )
470 env.Alias( "install", env['includedir'] )
471 env.Alias( "install", env['sharedir'] )
472 env.Alias( "install", env['bindir'] )
473 env.Alias( "install", env['mandir'] )
474 if build_mixer:
475     env.Alias( "install", env['pypkgdir'] )
476
477 #
478 # shamelessly copied from the Ardour scons file
479 #
480
481 opt_flags = []
482 env['USE_SSE'] = 0
483
484 # guess at the platform, used to define compiler flags
485
486 config_cpu = 0
487 config_arch = 1
488 config_kernel = 2
489 config_os = 3
490 config = config_guess.split ("-")
491
492 needs_fPIC = False
493
494 # Autodetect
495 if env['DIST_TARGET'] == 'auto':
496     if re.search ("x86_64", config[config_cpu]) != None:
497         env['DIST_TARGET'] = 'x86_64'
498     elif re.search("i[0-5]86", config[config_cpu]) != None:
499         env['DIST_TARGET'] = 'i386'
500     elif re.search("i686", config[config_cpu]) != None:
501         env['DIST_TARGET'] = 'i686'
502     elif re.search("powerpc64", config[config_cpu]) != None:
503         env['DIST_TARGET'] = 'powerpc64'
504     elif re.search("powerpc", config[config_cpu]) != None:
505         env['DIST_TARGET'] = 'powerpc'
506     else:
507         env['DIST_TARGET'] = config[config_cpu]
508     print "Detected DIST_TARGET = " + env['DIST_TARGET']
509
510 if ((re.search ("i[0-9]86", config[config_cpu]) != None) or (re.search ("x86_64", config[config_cpu]) != None) or (re.search ("powerpc", config[config_cpu]) != None)):
511    
512     build_host_supports_sse = 0
513     build_host_supports_sse2 = 0
514     build_host_supports_sse3 = 0
515
516     if config[config_kernel] == 'linux' :
517        
518         if (env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64'):
519            
520             flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
521             x86_flags = flag_line.split (": ")[1:][0].split ()
522            
523             if "mmx" in x86_flags:
524                 opt_flags.append ("-mmmx")
525             if "sse" in x86_flags:
526                 build_host_supports_sse = 1
527             if "sse2" in x86_flags:
528                 build_host_supports_sse2 = 1
529             #if "sse3" in x86_flags:
530                 #build_host_supports_sse3 = 1
531             if "3dnow" in x86_flags:
532                 opt_flags.append ("-m3dnow")
533            
534             if config[config_cpu] == "i586":
535                 opt_flags.append ("-march=i586")
536             elif config[config_cpu] == "i686":
537                 opt_flags.append ("-march=i686")
538
539         elif (env['DIST_TARGET'] == 'powerpc') or (env['DIST_TARGET'] == 'powerpc64'):
540
541             cpu_line = os.popen ("cat /proc/cpuinfo | grep '^cpu'").read()[:-1]
542
543             ppc_type = cpu_line.split (": ")[1]
544             if re.search ("altivec", ppc_type) != None:
545                 opt_flags.append ("-maltivec")
546                 opt_flags.append ("-mabi=altivec")
547
548             ppc_type = ppc_type.split (", ")[0]
549             if re.match ("74[0145][0578]A?", ppc_type) != None:
550                 opt_flags.append ("-mcpu=7400")
551                 opt_flags.append ("-mtune=7400")
552             elif re.match ("750", ppc_type) != None:
553                 opt_flags.append ("-mcpu=750")
554                 opt_flags.append ("-mtune=750")
555             elif re.match ("PPC970", ppc_type) != None:
556                 opt_flags.append ("-mcpu=970")
557                 opt_flags.append ("-mtune=970")
558             elif re.match ("Cell Broadband Engine", ppc_type) != None:
559                 opt_flags.append ("-mcpu=cell")
560                 opt_flags.append ("-mtune=cell")
561
562     if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
563        and build_host_supports_sse and env['ENABLE_OPTIMIZATIONS']:
564         opt_flags.extend (["-msse", "-mfpmath=sse"])
565         env['USE_SSE'] = 1
566
567     if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
568        and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']:
569         opt_flags.extend (["-msse2"])
570         env['USE_SSE2'] = 1
571
572     #if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
573        #and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']:
574         #opt_flags.extend (["-msse3"])
575         #env['USE_SSE3'] = 1
576
577     # build for 64-bit userland?
578     if env['DIST_TARGET'] == "powerpc64":
579         print "Doing a 64-bit PowerPC build"
580         env.MergeFlags( "-m64" )
581     elif env['DIST_TARGET'] == "x86_64":
582         print "Doing a 64-bit x86 build"
583         env.MergeFlags( "-m64" )
584         needs_fPIC = True
585     else:
586         print "Doing a 32-bit build"
587         env.MergeFlags( "-m32" )
588
589 if needs_fPIC or ( env.has_key('COMPILE_FLAGS') and '-fPIC' in env['COMPILE_FLAGS'] ):
590     env.MergeFlags( "-fPIC" )
591
592 # end of processor-specific section
593 if env['ENABLE_OPTIMIZATIONS']:
594     opt_flags.extend (["-fomit-frame-pointer","-ffast-math","-funroll-loops"])
595     env.MergeFlags( opt_flags )
596     print "Doing an optimized build..."
597
598 env['REVISION'] = os.popen('svnversion .').read()[:-1]
599 # This may be as simple as '89' or as complex as '4123:4184M'.
600 # We'll just use the last bit.
601 env['REVISION'] = env['REVISION'].split(':')[-1]
602
603 # try to circumvent localized versions
604 if len(env['REVISION']) >= 5 and env['REVISION'][0:6] == 'export':
605     env['REVISION'] = ''
606
607 # avoid the 1.999.41- type of version for exported versions
608 if env['REVISION'] != '':
609         env['REVISIONSTRING'] = '-' + env['REVISION']
610 else:
611         env['REVISIONSTRING'] = ''
612
613 env['FFADO_API_VERSION'] = FFADO_API_VERSION
614
615 env['PACKAGE'] = "libffado"
616 env['VERSION'] = FFADO_VERSION
617 env['LIBVERSION'] = "1.0.0"
618
619 env['CONFIGDIR'] = "~/.ffado"
620 env['CACHEDIR'] = "~/.ffado"
621
622 env['USER_CONFIG_FILE'] = env['CONFIGDIR'] + "/configuration"
623 env['SYSTEM_CONFIG_FILE'] = env['SHAREDIR'] + "/configuration"
624
625 env['REGISTRATION_URL'] = "http://ffado.org/deviceregistration/register.php?action=register"
626
627 #
628 # To have the top_srcdir as the doxygen-script is used from auto*
629 #
630 env['top_srcdir'] = env.Dir( "." ).abspath
631
632 #
633 # Start building
634 #
635 env.ScanReplace( "config.h.in" )
636 env.ScanReplace( "config_debug.h.in" )
637 env.ScanReplace( "version.h.in" )
638
639 # ensure that the config.h is updated
640 env.Depends( "config.h", "SConstruct" )
641 env.Depends( "config.h", 'cache/options.cache' )
642
643 # update version.h whenever the version or SVN revision changes
644 env.Depends( "version.h", env.Value(env['REVISION']))
645 env.Depends( "version.h", env.Value(env['VERSION']))
646
647 env.Depends( "libffado.pc", "SConstruct" )
648 pkgconfig = env.ScanReplace( "libffado.pc.in" )
649 env.Install( env['libdir'] + '/pkgconfig', pkgconfig )
650
651 env.Install( env['sharedir'], 'configuration' )
652
653 subdirs=['src','libffado','support','doc']
654 if env['BUILD_TESTS']:
655     subdirs.append('tests')
656
657 env.SConscript( dirs=subdirs, exports="env" )
658
659 if 'debian' in COMMAND_LINE_TARGETS:
660     env.SConscript("deb/SConscript", exports="env")
661
662 # By default only src is built but all is cleaned
663 if not env.GetOption('clean'):
664     Default( 'src' )
665     Default( 'support' )
666     if env['BUILD_TESTS']:
667         Default( 'tests' )
668
669 #
670 # Deal with the DESTDIR vs. xdg-tools conflict (which is basicely that the
671 # xdg-tools can't deal with DESTDIR, so the packagers have to deal with this
672 # their own :-/
673 #
674 if len(env.destdir) > 0:
675     if not len( ARGUMENTS.get( "WILL_DEAL_WITH_XDG_MYSELF", "" ) ) > 0:
676         print """
677 WARNING!
678 You are using the (packagers) option DESTDIR to install this package to a
679 different place than the real prefix. As the xdg-tools can't cope with
680 that, the .desktop-files are not installed by this build, you have to
681 deal with them your own.
682 (And you have to look into the SConstruct to learn how to disable this
683 message.)
684 """
685 else:
686
687     def CleanAction( action ):
688         if env.GetOption( "clean" ):
689             env.Execute( action )
690
691     if env.has_key( 'XDG_TOOLS' ) and env.has_key( 'PYUIC4' ):
692         if not env.GetOption("clean"):
693             action = "install"
694         else:
695             action = "uninstall"
696         mixerdesktopaction = env.Action( "-xdg-desktop-menu %s support/xdg/ffado.org-ffadomixer.desktop" % action )
697         mixericonaction = env.Action( "-xdg-icon-resource %s --size 64 --novendor --context apps support/xdg/hi64-apps-ffado.png ffado" % action )
698         env.Command( "__xdgstuff1", None, mixerdesktopaction )
699         env.Command( "__xdgstuff2", None, mixericonaction )
700         env.Alias( "install", ["__xdgstuff1", "__xdgstuff2" ] )
701         CleanAction( mixerdesktopaction )
702         CleanAction( mixericonaction )
703
704 #
705 # Create a tags-file for easier emacs/vim-source-browsing
706 #  I don't know if the dependency is right...
707 #
708 findcommand = "find . \( -path \"*.h\" -o -path \"*.cpp\" -o -path \"*.c\" \) \! -path \"*.svn*\" \! -path \"./doc*\" \! -path \"./cache*\""
709 env.Command( "tags", "", findcommand + " |xargs ctags" )
710 env.Command( "TAGS", "", findcommand + " |xargs etags" )
711 env.AlwaysBuild( "tags", "TAGS" )
712 if 'NoCache' in dir(env):
713     env.NoCache( "tags", "TAGS" )
714
715 # Another convinience target
716 if env.GetOption( "clean" ):
717     env.Execute( "rm cache/objects -Rf" )
718
719 #
720 # vim: ts=4 sw=4 et
Note: See TracBrowser for help on using the browser.