root/trunk/libffado/SConstruct

Revision 1747, 22.7 kB (checked in by arnonym, 12 years ago)

Some buildsystem stuff:

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