root/trunk/libffado/SConstruct

Revision 2106, 25.2 kB (checked in by jwoithe, 9 years ago)

If ffado is compiled on a machine without jack, permit compilation and default to the setbuffersize-compatible API version return when ENABLE_SETBUFFERSIZE_API_VER is set to auto (the default). Having jackd on the system should not be a prerequisite for compiling, but r2104 effectively made it so. Also note that the commit message for r2105 wrongly referred to r2104 as 2014.

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