root/trunk/libffado/SConstruct

Revision 1897, 22.5 kB (checked in by arnonym, 11 years ago)

Fix #214: Replace Options by Variables and thus remove the deprecation warnings. I think it is save to do this now. Packagers for distros where scons is to old "simply" need to apply the reverse of this patch. but I don't think there are that many distros/distro-versions using that old scons and still maintaining current copies of ffado...

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