root/trunk/libffado/SConstruct

Revision 1437, 22.3 kB (checked in by arnonym, 15 years ago)

Forward-port r1421 and r1428

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