root/trunk/libffado/SConstruct

Revision 1675, 22.9 kB (checked in by arnonym, 14 years ago)

Lets see how many setups this breaks. see #199

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