root/trunk/libffado/SConstruct

Revision 1853, 22.2 kB (checked in by arnonym, 14 years ago)

Make it easier for distributions to define their own additional built-flags. (Importing all the various shell-variables is a pain in the a** with scons as the gcc-tools of scons overwrite half of them.)

See #278

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 = Options( "cache/options.cache" )
40
41 opts.AddOptions(
42     BoolOption( "DEBUG", """\
43 Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use
44   \"-O2\" to optimize.""", True ),
45     BoolOption( "PROFILE", "Build with symbols and other profiling info", False ),
46     PathOption( "PREFIX", "The prefix where ffado will be installed to.", "/usr/local", PathOption.PathAccept ),
47     PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathOption.PathAccept ),
48     PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathOption.PathAccept ),
49     PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathOption.PathAccept ),
50     PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathOption.PathAccept ),
51     PathOption( "PYPKGDIR", "The directory where the python modules get installed.",
52         distutils.sysconfig.get_python_lib( prefix="$PREFIX" ), PathOption.PathAccept ),
53     BoolOption( "ENABLE_BEBOB", "Enable/Disable support for the BeBoB platform.", True ),
54     BoolOption( "ENABLE_FIREWORKS", "Enable/Disable support for the ECHO Audio FireWorks platform.", True ),
55     BoolOption( "ENABLE_OXFORD", "Enable/Disable support for the Oxford Semiconductor FW platform.", True ),
56     BoolOption( "ENABLE_MOTU", "Enable/Disable support for the MOTU platform.", True ),
57     BoolOption( "ENABLE_DICE", "Enable/Disable support for the TCAT DICE platform.", True ),
58     BoolOption( "ENABLE_METRIC_HALO", "Enable/Disable support for the Metric Halo platform.", False ),
59     BoolOption( "ENABLE_RME", "Enable/Disable support for the RME platform.", False ),
60     BoolOption( "ENABLE_MAUDIO", "Enable/Disable support for the M-Audio custom BeBoB devices.", False ),
61     BoolOption( "ENABLE_BOUNCE", "Enable/Disable the BOUNCE device.", False ),
62     BoolOption( "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     BoolOption( "ENABLE_ALL", "Enable/Disable support for all devices.", False ),
67     BoolOption( "SERIALIZE_USE_EXPAT", "Use libexpat for XML serialization.", False ),
68     BoolOption( "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     BoolOption( "BUILD_STATIC_TOOLS", "Build a statically linked version of the FFADO tools.", False ),
74     EnumOption('DIST_TARGET', 'Build target for cross compiling packagers', 'auto', allowed_values=('auto', 'i386', 'i686', 'x86_64', 'powerpc', 'powerpc64', 'none' ), ignorecase=2),
75     BoolOption( "ENABLE_OPTIMIZATIONS", "Enable optimizations and the use of processor specific extentions (MMX/SSE/...).", False ),
76     BoolOption( "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 DBUS C++ bindings and cache-serialization.
202     allpresent &= conf.CheckHeader( "expat.h" )
203     allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
204
205     pkgs = {
206         'libraw1394' : '1.3.0',
207         'libiec61883' : '1.1.0',
208         }
209
210     if env['REQUIRE_LIBAVC']:
211         pkgs['libavc1394'] = '0.5.3'
212
213     if not env['SERIALIZE_USE_EXPAT']:
214         pkgs['libxml++-2.6'] = '2.13.0'
215
216     for pkg in pkgs:
217         name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
218         env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
219         #print '%s_FLAGS' % name2
220         if env['%s_FLAGS'%name2] == 0:
221             allpresent &= 0
222
223     if not allpresent:
224         print """
225 (At least) One of the dependencies is missing. I can't go on without it, please
226 install the needed packages for each of the lines saying "no".
227 (Remember to also install the *-devel packages!)
228
229 And remember to remove the cache with "rm -Rf .sconsign.dblite cache" so the
230 results above get rechecked.
231 """
232         Exit( 1 )
233
234     # Check for C99 lrint() and lrintf() functions used to convert from
235     # float to integer more efficiently via float_cast.h.  If not
236     # present the standard slower methods will be used instead.  This
237     # might not be the best way of testing for these but it's the only
238     # way which seems to work properly.  CheckFunc() fails due to
239     # argument count problems.
240     if env.has_key( 'CFLAGS' ):
241         oldcf = env['CFLAGS']
242     else:
243         oldcf = ""
244     oldcf = env.Append(CFLAGS = '-std=c99')
245     if conf.CheckLibWithHeader( "m", "math.h", "c", "lrint(3.2);" ):
246         HAVE_LRINT = 1
247     else:
248         HAVE_LRINT = 0
249     if conf.CheckLibWithHeader( "m", "math.h", "c", "lrintf(3.2);" ):
250         HAVE_LRINTF = 1
251     else:
252         HAVE_LRINTF = 0
253     env['HAVE_LRINT'] = HAVE_LRINT;
254     env['HAVE_LRINTF'] = HAVE_LRINTF;
255     env.Replace(CFLAGS=oldcf)
256
257 #
258 # Optional checks follow:
259 #
260
261 # PyQT checks
262 build_mixer = False
263 if conf.CheckForApp( 'which pyuic4' ) and conf.CheckForPyModule( 'dbus' ) and conf.CheckForPyModule( 'PyQt4' ) and conf.CheckForPyModule( 'dbus.mainloop.qt' ):
264     env['PYUIC4'] = True
265     build_mixer = True
266
267 if conf.CheckForApp( 'xdg-desktop-menu --help' ):
268     env['XDG_TOOLS'] = True
269 else:
270     print """
271 I couldn't find the program 'xdg-desktop-menu'. Together with xdg-icon-resource
272 this is needed to add the fancy entry to your menu. But if the mixer will be
273 installed, you can start it by executing "ffado-mixer".
274 """
275
276 if not build_mixer and not env.GetOption('clean'):
277     print """
278 I couldn't find all the prerequisites ('pyuic4' and the python-modules 'dbus'
279 and 'PyQt4', the packages could be named like dbus-python and PyQt) to build the
280 mixer.
281 Therefor the qt4 mixer will not get installed.
282 """
283
284 #
285 # Optional pkg-config
286 #
287 pkgs = {
288     'alsa': '0',
289     'dbus-1': '1.0',
290     }
291 for pkg in pkgs:
292     name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
293     env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
294
295 #
296 # Get the directory where dbus stores the service-files
297 #
298 if env['DBUS1_FLAGS']:
299     env['dbus_service_dir'] = conf.GetPKGVariable( 'dbus-1', 'session_bus_services_dir' ).strip()
300     # this is required to indicate that the DBUS version we use has support
301     # for platform dependent threading init functions
302     # this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is
303     # always true
304     env.MergeFlags( "-DDBUS_HAS_THREADS_INIT_DEFAULT" )
305 else:
306     print """
307 The dbus-headers where not found. The dbus-server for ffado will therefor not be built.
308 """
309
310 config_guess = conf.ConfigGuess()
311
312 env = conf.Finish()
313
314 if env['DEBUG']:
315     print "Doing a DEBUG build"
316     env.MergeFlags( "-DDEBUG -Wall -g" )
317 else:
318     env.MergeFlags( "-O2 -DNDEBUG" )
319
320 if env['PROFILE']:
321     print "Doing a PROFILE build"
322     env.MergeFlags( "-Wall -g" )
323
324 if env['PEDANTIC']:
325     env.MergeFlags( "-Werror" )
326
327
328 if env['ENABLE_ALL']:
329     env['ENABLE_BEBOB'] = True
330     env['ENABLE_FIREWORKS'] = True
331     env['ENABLE_OXFORD'] = True
332     env['ENABLE_MOTU'] = True
333     env['ENABLE_DICE'] = True
334     env['ENABLE_METRIC_HALO'] = True
335     env['ENABLE_RME'] = True
336     env['ENABLE_BOUNCE'] = True
337     env['ENABLE_MAUDIO'] = True
338
339
340 env['BUILD_STATIC_LIB'] = False
341 if env['BUILD_STATIC_TOOLS']:
342     print "Building static versions of the tools..."
343     env['BUILD_STATIC_LIB'] = True
344
345 env['build_base']="#/"
346
347 #
348 # Get the DESTDIR (if wanted) from the commandline
349 #
350 env.destdir = ARGUMENTS.get( 'DESTDIR', "" )
351
352 #
353 # Uppercase variables are for usage in code, lowercase versions for usage in
354 # scons-files for installing.
355 #
356 env['BINDIR'] = Template( env['BINDIR'] ).safe_substitute( env )
357 env['LIBDIR'] = Template( env['LIBDIR'] ).safe_substitute( env )
358 env['INCLUDEDIR'] = Template( env['INCLUDEDIR'] ).safe_substitute( env )
359 env['SHAREDIR'] = Template( env['SHAREDIR'] ).safe_substitute( env )
360 env['prefix'] = Template( env.destdir + env['PREFIX'] ).safe_substitute( env )
361 env['bindir'] = Template( env.destdir + env['BINDIR'] ).safe_substitute( env )
362 env['libdir'] = Template( env.destdir + env['LIBDIR'] ).safe_substitute( env )
363 env['includedir'] = Template( env.destdir + env['INCLUDEDIR'] ).safe_substitute( env )
364 env['sharedir'] = Template( env.destdir + env['SHAREDIR'] ).safe_substitute( env )
365 env['pypkgdir'] = Template( env.destdir + env['PYPKGDIR'] ).safe_substitute( env )
366 env['PYPKGDIR'] = Template( env['PYPKGDIR'] ).safe_substitute( env )
367
368 env.Command( target=env['sharedir'], source="", action=Mkdir( env['sharedir'] ) )
369
370 env.Alias( "install", env['libdir'] )
371 env.Alias( "install", env['includedir'] )
372 env.Alias( "install", env['sharedir'] )
373 env.Alias( "install", env['bindir'] )
374 if build_mixer:
375     env.Alias( "install", env['pypkgdir'] )
376
377 #
378 # shamelessly copied from the Ardour scons file
379 #
380
381 opt_flags = []
382 env['USE_SSE'] = 0
383
384 # guess at the platform, used to define compiler flags
385
386 config_cpu = 0
387 config_arch = 1
388 config_kernel = 2
389 config_os = 3
390 config = config_guess.split ("-")
391
392 needs_fPIC = False
393
394 # Autodetect
395 if env['DIST_TARGET'] == 'auto':
396     if re.search ("x86_64", config[config_cpu]) != None:
397         env['DIST_TARGET'] = 'x86_64'
398     elif re.search("i[0-5]86", config[config_cpu]) != None:
399         env['DIST_TARGET'] = 'i386'
400     elif re.search("i686", config[config_cpu]) != None:
401         env['DIST_TARGET'] = 'i686'
402     elif re.search("powerpc64", config[config_cpu]) != None:
403         env['DIST_TARGET'] = 'powerpc64'
404     elif re.search("powerpc", config[config_cpu]) != None:
405         env['DIST_TARGET'] = 'powerpc'
406     else:
407         env['DIST_TARGET'] = config[config_cpu]
408     print "Detected DIST_TARGET = " + env['DIST_TARGET']
409
410 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)):
411    
412     build_host_supports_sse = 0
413     build_host_supports_sse2 = 0
414     build_host_supports_sse3 = 0
415
416     if config[config_kernel] == 'linux' :
417        
418         if (env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64'):
419            
420             flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
421             x86_flags = flag_line.split (": ")[1:][0].split ()
422            
423             if "mmx" in x86_flags:
424                 opt_flags.append ("-mmmx")
425             if "sse" in x86_flags:
426                 build_host_supports_sse = 1
427             if "sse2" in x86_flags:
428                 build_host_supports_sse2 = 1
429             #if "sse3" in x86_flags:
430                 #build_host_supports_sse3 = 1
431             if "3dnow" in x86_flags:
432                 opt_flags.append ("-m3dnow")
433            
434             if config[config_cpu] == "i586":
435                 opt_flags.append ("-march=i586")
436             elif config[config_cpu] == "i686":
437                 opt_flags.append ("-march=i686")
438
439         elif (env['DIST_TARGET'] == 'powerpc') or (env['DIST_TARGET'] == 'powerpc64'):
440
441             cpu_line = os.popen ("cat /proc/cpuinfo | grep '^cpu'").read()[:-1]
442
443             ppc_type = cpu_line.split (": ")[1]
444             if re.search ("altivec", ppc_type) != None:
445                 opt_flags.append ("-maltivec")
446                 opt_flags.append ("-mabi=altivec")
447
448             ppc_type = ppc_type.split (", ")[0]
449             if re.match ("74[0145][0578]A?", ppc_type) != None:
450                 opt_flags.append ("-mcpu=7400")
451                 opt_flags.append ("-mtune=7400")
452             elif re.match ("750", ppc_type) != None:
453                 opt_flags.append ("-mcpu=750")
454                 opt_flags.append ("-mtune=750")
455             elif re.match ("PPC970", ppc_type) != None:
456                 opt_flags.append ("-mcpu=970")
457                 opt_flags.append ("-mtune=970")
458             elif re.match ("Cell Broadband Engine", ppc_type) != None:
459                 opt_flags.append ("-mcpu=cell")
460                 opt_flags.append ("-mtune=cell")
461
462     if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
463        and build_host_supports_sse and env['ENABLE_OPTIMIZATIONS']:
464         opt_flags.extend (["-msse", "-mfpmath=sse"])
465         env['USE_SSE'] = 1
466
467     if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
468        and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']:
469         opt_flags.extend (["-msse2"])
470         env['USE_SSE2'] = 1
471
472     #if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
473        #and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']:
474         #opt_flags.extend (["-msse3"])
475         #env['USE_SSE3'] = 1
476
477     # build for 64-bit userland?
478     if env['DIST_TARGET'] == "powerpc64":
479         print "Doing a 64-bit PowerPC build"
480         env.MergeFlags( "-m64" )
481     elif env['DIST_TARGET'] == "x86_64":
482         print "Doing a 64-bit x86 build"
483         env.MergeFlags( "-m64" )
484         needs_fPIC = True
485     else:
486         print "Doing a 32-bit build"
487         env.MergeFlags( "-m32" )
488
489 if needs_fPIC or ( env.has_key('COMPILE_FLAGS') and '-fPIC' in env['COMPILE_FLAGS'] ):
490     env.MergeFlags( "-fPIC" )
491
492 # end of processor-specific section
493 if env['ENABLE_OPTIMIZATIONS']:
494     opt_flags.extend (["-fomit-frame-pointer","-ffast-math","-funroll-loops"])
495     env.MergeFlags( opt_flags )
496     print "Doing an optimized build..."
497
498 env['REVISION'] = os.popen('svnversion .').read()[:-1]
499 # This may be as simple as '89' or as complex as '4123:4184M'.
500 # We'll just use the last bit.
501 env['REVISION'] = env['REVISION'].split(':')[-1]
502
503 # try to circumvent localized versions
504 if len(env['REVISION']) >= 5 and env['REVISION'][0:6] == 'export':
505     env['REVISION'] = ''
506
507 # avoid the 1.999.41- type of version for exported versions
508 if env['REVISION'] != '':
509         env['REVISIONSTRING'] = '-' + env['REVISION']
510 else:
511         env['REVISIONSTRING'] = ''
512
513 env['FFADO_API_VERSION'] = FFADO_API_VERSION
514
515 env['PACKAGE'] = "libffado"
516 env['VERSION'] = FFADO_VERSION
517 env['LIBVERSION'] = "1.0.0"
518
519 env['CONFIGDIR'] = "~/.ffado"
520 env['CACHEDIR'] = "~/.ffado"
521
522 env['USER_CONFIG_FILE'] = env['CONFIGDIR'] + "/configuration"
523 env['SYSTEM_CONFIG_FILE'] = env['SHAREDIR'] + "/configuration"
524
525 env['REGISTRATION_URL'] = "http://ffado.org/deviceregistration/register.php?action=register"
526
527 #
528 # To have the top_srcdir as the doxygen-script is used from auto*
529 #
530 env['top_srcdir'] = env.Dir( "." ).abspath
531
532 #
533 # Start building
534 #
535 env.ScanReplace( "config.h.in" )
536 env.ScanReplace( "config_debug.h.in" )
537 env.ScanReplace( "version.h.in" )
538
539 # ensure that the config.h is updated
540 env.Depends( "config.h", "SConstruct" )
541 env.Depends( "config.h", 'cache/options.cache' )
542
543 # update version.h whenever the version or SVN revision changes
544 env.Depends( "version.h", env.Value(env['REVISION']))
545 env.Depends( "version.h", env.Value(env['VERSION']))
546
547 env.Depends( "libffado.pc", "SConstruct" )
548 pkgconfig = env.ScanReplace( "libffado.pc.in" )
549 env.Install( env['libdir'] + '/pkgconfig', pkgconfig )
550
551 env.Install( env['sharedir'], 'configuration' )
552
553 subdirs=['external','src','libffado','support','doc']
554 if env['BUILD_TESTS']:
555     subdirs.append('tests')
556
557 env.SConscript( dirs=subdirs, exports="env" )
558
559 if 'debian' in COMMAND_LINE_TARGETS:
560     env.SConscript("deb/SConscript", exports="env")
561
562 # By default only src is built but all is cleaned
563 if not env.GetOption('clean'):
564     Default( 'src' )
565     Default( 'support' )
566     if env['BUILD_TESTS']:
567         Default( 'tests' )
568
569 #
570 # Deal with the DESTDIR vs. xdg-tools conflict (which is basicely that the
571 # xdg-tools can't deal with DESTDIR, so the packagers have to deal with this
572 # their own :-/
573 #
574 if len(env.destdir) > 0:
575     if not len( ARGUMENTS.get( "WILL_DEAL_WITH_XDG_MYSELF", "" ) ) > 0:
576         print """
577 WARNING!
578 You are using the (packagers) option DESTDIR to install this package to a
579 different place than the real prefix. As the xdg-tools can't cope with
580 that, the .desktop-files are not installed by this build, you have to
581 deal with them your own.
582 (And you have to look into the SConstruct to learn how to disable this
583 message.)
584 """
585 else:
586
587     def CleanAction( action ):
588         if env.GetOption( "clean" ):
589             env.Execute( action )
590
591     if env.has_key( 'XDG_TOOLS' ) and env.has_key( 'PYUIC4' ):
592         if not env.GetOption("clean"):
593             action = "install"
594         else:
595             action = "uninstall"
596         mixerdesktopaction = env.Action( "-xdg-desktop-menu %s support/xdg/ffado.org-ffadomixer.desktop" % action )
597         mixericonaction = env.Action( "-xdg-icon-resource %s --size 64 --novendor --context apps support/xdg/hi64-apps-ffado.png ffado" % action )
598         env.Command( "__xdgstuff1", None, mixerdesktopaction )
599         env.Command( "__xdgstuff2", None, mixericonaction )
600         env.Alias( "install", ["__xdgstuff1", "__xdgstuff2" ] )
601         CleanAction( mixerdesktopaction )
602         CleanAction( mixericonaction )
603
604 #
605 # Create a tags-file for easier emacs/vim-source-browsing
606 #  I don't know if the dependency is right...
607 #
608 findcommand = "find . \( -path \"*.h\" -o -path \"*.cpp\" -o -path \"*.c\" \) \! -path \"*.svn*\" \! -path \"./doc*\" \! -path \"./cache*\""
609 env.Command( "tags", "", findcommand + " |xargs ctags" )
610 env.Command( "TAGS", "", findcommand + " |xargs etags" )
611 env.AlwaysBuild( "tags", "TAGS" )
612 if 'NoCache' in dir(env):
613     env.NoCache( "tags", "TAGS" )
614
615 # Another convinience target
616 if env.GetOption( "clean" ):
617     env.Execute( "rm cache/objects -Rf" )
618
619 #
620 # vim: ts=4 sw=4 et
Note: See TracBrowser for help on using the browser.