root/trunk/libffado/SConstruct

Revision 1963, 22.7 kB (checked in by jwoithe, 13 years ago)

digidesign: integrate into build system

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