root/trunk/libffado/SConstruct

Revision 1816, 22.3 kB (checked in by arnonym, 11 years ago)

Support more minimalistic installations:

When the dbus-devel-stuff is not found, the dbus-server is not built. Of course this stops the mixer (if it can be built) from being usable. But when you don't need that because the device doesn't need/have mixer control, this simplifies things for low-disk-space systems...

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