root/trunk/libffado/SConstruct

Revision 1645, 23.5 kB (checked in by arnonym, 15 years ago)

Something got lost on the way of times...

Don't add -m32 in 64bit builts.

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("powerpc64", config[config_cpu]) != None:
429         env['DIST_TARGET'] = 'powerpc64'
430     elif re.search("powerpc", config[config_cpu]) != None:
431         env['DIST_TARGET'] = 'powerpc'
432     else:
433         env['DIST_TARGET'] = 'i686'
434     print "Detected DIST_TARGET = " + env['DIST_TARGET']
435
436 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)):
437    
438     build_host_supports_sse = 0
439     build_host_supports_sse2 = 0
440     build_host_supports_sse3 = 0
441
442     if config[config_kernel] == 'linux' :
443        
444         if (env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64'):
445            
446             flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1]
447             x86_flags = flag_line.split (": ")[1:][0].split ()
448            
449             if "mmx" in x86_flags:
450                 opt_flags.append ("-mmmx")
451             if "sse" in x86_flags:
452                 build_host_supports_sse = 1
453             if "sse2" in x86_flags:
454                 build_host_supports_sse2 = 1
455             #if "sse3" in x86_flags:
456                 #build_host_supports_sse3 = 1
457             if "3dnow" in x86_flags:
458                 opt_flags.append ("-m3dnow")
459            
460             if config[config_cpu] == "i586":
461                 opt_flags.append ("-march=i586")
462             elif config[config_cpu] == "i686":
463                 opt_flags.append ("-march=i686")
464
465         elif (env['DIST_TARGET'] == 'powerpc') or (env['DIST_TARGET'] == 'powerpc64'):
466
467             cpu_line = os.popen ("cat /proc/cpuinfo | grep '^cpu'").read()[:-1]
468
469             ppc_type = cpu_line.split (": ")[1]
470             if re.search ("altivec", ppc_type) != None:
471                 opt_flags.append ("-maltivec")
472                 opt_flags.append ("-mabi=altivec")
473
474             ppc_type = ppc_type.split (", ")[0]
475             if re.match ("74[0145][0578]A?", ppc_type) != None:
476                 opt_flags.append ("-mcpu=7400")
477                 opt_flags.append ("-mtune=7400")
478             elif re.match ("750", ppc_type) != None:
479                 opt_flags.append ("-mcpu=750")
480                 opt_flags.append ("-mtune=750")
481             elif re.match ("PPC970", ppc_type) != None:
482                 opt_flags.append ("-mcpu=970")
483                 opt_flags.append ("-mtune=970")
484             elif re.match ("Cell Broadband Engine", ppc_type) != None:
485                 opt_flags.append ("-mcpu=cell")
486                 opt_flags.append ("-mtune=cell")
487
488     if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
489        and build_host_supports_sse and env['ENABLE_OPTIMIZATIONS']:
490         opt_flags.extend (["-msse", "-mfpmath=sse"])
491         env['USE_SSE'] = 1
492
493     if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
494        and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']:
495         opt_flags.extend (["-msse2"])
496         env['USE_SSE2'] = 1
497
498     #if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \
499        #and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']:
500         #opt_flags.extend (["-msse3"])
501         #env['USE_SSE3'] = 1
502
503     # build for 64-bit userland?
504     if env['DIST_TARGET'] == "powerpc64":
505         print "Doing a 64-bit PowerPC build"
506         env.MergeFlags( "-m64" )
507     elif env['DIST_TARGET'] == "x86_64":
508         print "Doing a 64-bit x86 build"
509         env.MergeFlags( "-m64" )
510         needs_fPIC = True
511     else:
512         print "Doing a 32-bit build"
513         env.MergeFlags( "-m32" )
514
515 if needs_fPIC or '-fPIC' in env['OS_CFLAGS'] or "-fPIC" in env['OS_CCFLAGS']:
516     env.MergeFlags( "-fPIC" )
517
518 # end of processor-specific section
519 if env['ENABLE_OPTIMIZATIONS']:
520     opt_flags.extend (["-fomit-frame-pointer","-ffast-math","-funroll-loops"])
521     env.MergeFlags( opt_flags )
522     print "Doing an optimized build..."
523
524 env['REVISION'] = os.popen('svnversion .').read()[:-1]
525 # This may be as simple as '89' or as complex as '4123:4184M'.
526 # We'll just use the last bit.
527 env['REVISION'] = env['REVISION'].split(':')[-1]
528
529 # try to circumvent localized versions
530 if len(env['REVISION']) >= 5 and env['REVISION'][0:6] == 'export':
531     env['REVISION'] = ''
532
533 env['FFADO_API_VERSION']=FFADO_API_VERSION
534
535 env['PACKAGE'] = "libffado"
536 env['VERSION'] = FFADO_VERSION
537 env['LIBVERSION'] = "1.0.0"
538
539 env['CONFIGDIR'] = "~/.ffado"
540 env['CACHEDIR'] = "~/.ffado"
541
542 env['USER_CONFIG_FILE'] = env['CONFIGDIR'] + "/configuration"
543 env['SYSTEM_CONFIG_FILE'] = env['SHAREDIR'] + "/configuration"
544
545 env['REGISTRATION_URL'] = "http://ffado.org/deviceregistration/register.php?action=register"
546
547 #
548 # To have the top_srcdir as the doxygen-script is used from auto*
549 #
550 env['top_srcdir'] = env.Dir( "." ).abspath
551
552 #
553 # Start building
554 #
555 env.ScanReplace( "config.h.in" )
556 env.ScanReplace( "config_debug.h.in" )
557 env.ScanReplace( "version.h.in" )
558
559 # ensure that the config.h is updated
560 env.Depends( "config.h", "SConstruct" )
561 env.Depends( "config.h", 'cache/' + build_base + "options.cache" )
562
563 # update version.h whenever the version or SVN revision changes
564 env.Depends( "version.h", env.Value(env['REVISION']))
565 env.Depends( "version.h", env.Value(env['VERSION']))
566
567 env.Depends( "libffado.pc", "SConstruct" )
568 pkgconfig = env.ScanReplace( "libffado.pc.in" )
569 env.Install( env['libdir'] + '/pkgconfig', pkgconfig )
570
571 env.Install( env['sharedir'], 'configuration' )
572
573 subdirs=['external','src','libffado','support','doc']
574 if env['BUILD_TESTS']:
575     subdirs.append('tests')
576
577 if build_base:
578     #env.SConscript( dirs=subdirs, exports="env", build_dir=build_base )
579     builddirs = list()
580     for dir in subdirs:
581         builddirs.append( build_base + dir )
582     env.SConscript( dirs=subdirs, exports="env", build_dir=builddirs )
583 else:
584     env.SConscript( dirs=subdirs, exports="env" )
585
586 if 'debian' in COMMAND_LINE_TARGETS:
587     env.SConscript("deb/SConscript", exports="env")
588
589 # By default only src is built but all is cleaned
590 if not env.GetOption('clean'):
591     Default( 'src' )
592     Default( 'support' )
593     if env['BUILD_TESTS']:
594         Default( 'tests' )
595
596 #
597 # Deal with the DESTDIR vs. xdg-tools conflict (which is basicely that the
598 # xdg-tools can't deal with DESTDIR, so the packagers have to deal with this
599 # their own :-/
600 #
601 if len(env.destdir) > 0:
602     if not len( ARGUMENTS.get( "WILL_DEAL_WITH_XDG_MYSELF", "" ) ) > 0:
603         print """
604 WARNING!
605 You are using the (packagers) option DESTDIR to install this package to a
606 different place than the real prefix. As the xdg-tools can't cope with
607 that, the .desktop-files are not installed by this build, you have to
608 deal with them your own.
609 (And you have to look into the SConstruct to learn how to disable this
610 message.)
611 """
612 else:
613
614     def CleanAction( action ):
615         if env.GetOption( "clean" ):
616             env.Execute( action )
617
618     if env.has_key( 'XDG_TOOLS' ) and env.has_key( 'PYUIC4' ):
619         if not env.GetOption("clean"):
620             action = "install"
621         else:
622             action = "uninstall"
623         mixerdesktopaction = env.Action( "xdg-desktop-menu %s support/xdg/ffado.org-ffadomixer.desktop" % action )
624         mixericonaction = env.Action( "xdg-icon-resource %s --size 64 --novendor --context apps support/xdg/hi64-apps-ffado.png ffado" % action )
625         env.Command( "__xdgstuff1", None, mixerdesktopaction )
626         env.Command( "__xdgstuff2", None, mixericonaction )
627         env.Alias( "install", ["__xdgstuff1", "__xdgstuff2" ] )
628         CleanAction( mixerdesktopaction )
629         CleanAction( mixericonaction )
630
631 #
632 # Create a tags-file for easier emacs/vim-source-browsing
633 #  I don't know if the dependency is right...
634 #
635 findcommand = "find . \( -path \"*.h\" -o -path \"*.cpp\" -o -path \"*.c\" \) \! -path \"*.svn*\" \! -path \"./doc*\" \! -path \"./cache*\""
636 env.Command( "tags", "", findcommand + " |xargs ctags" )
637 env.Command( "TAGS", "", findcommand + " |xargs etags" )
638 env.AlwaysBuild( "tags", "TAGS" )
639 if 'NoCache' in dir(env):
640     env.NoCache( "tags", "TAGS" )
641
642 # Another convinience target
643 if env.GetOption( "clean" ):
644     env.Execute( "rm cache/objects -Rf" )
645
646 #
647 # Temporary code to remove the installed qt3 mixer
648 #
649 import shutil
650 if os.path.exists( os.path.join( env['BINDIR'], "ffado-mixer-qt3" ) ):
651     print "Removing the old qt3-mixer from the installation..."
652     os.remove( os.path.join( env['BINDIR'], "ffado-mixer-qt3" ) )
653 if os.path.exists( os.path.join( env['SHAREDIR'], 'python-qt3' ) ):
654     print "Removing the old qt3-mixer files from the installation..."
655     shutil.rmtree( os.path.join( env['SHAREDIR'], 'python-qt3' ) )
656 if os.path.exists( os.path.join( env['SHAREDIR'], 'python' ) ):
657     print "Removing the old qt3-mixer files from the installation..."
658     shutil.rmtree( os.path.join( env['SHAREDIR'], 'python' ) )
659
660
661 #
662 # vim: ts=4 sw=4 et
Note: See TracBrowser for help on using the browser.