root/branches/ppalmers-streaming/SConstruct

Revision 730, 8.0 kB (checked in by ppalmers, 13 years ago)

- Remove OSC related code
- create DBus server application
- add "scons debian" target that builds a debian package

Line 
1 #! /usr/bin/env python
2
3 import os
4 from string import Template
5
6 build_dir = ARGUMENTS.get('BUILDDIR', "")
7 if build_dir:
8         build_base=build_dir+'/'
9         if not os.path.isdir( build_base ):
10                 os.makedirs( build_base )
11         print "Building into: " + build_base
12 else:
13         build_base=''
14
15 if not os.path.isdir( "cache" ):
16         os.makedirs( "cache" )
17
18 opts = Options( "cache/"+build_base+"options.cache" )
19
20 #
21 # If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong...
22 opts.Add( "BUILDDIR", "Path to place the built files in", "")
23
24 opts.AddOptions(
25         BoolOption( "DEBUG", """\
26 Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use
27   \"-O2\" to optimise.""", True ),
28         PathOption( "PREFIX", "The prefix where ffado will be installed to.", "/usr/local", PathOption.PathAccept ),
29         PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathOption.PathAccept ),
30         PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathOption.PathAccept ),
31         PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathOption.PathAccept ),
32         PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathOption.PathAccept ),
33         BoolOption( "ENABLE_BEBOB", "Enable/Disable the bebob part.", True ),
34         BoolOption( "ENABLE_FIREWORKS", "Enable/Disable the ECHO Audio FireWorks avc part.", True ),
35         BoolOption( "ENABLE_MOTU", "Enable/Disable the Motu part.", False ),
36         BoolOption( "ENABLE_DICE", "Enable/Disable the DICE part.", False ),
37         BoolOption( "ENABLE_METRIC_HALO", "Enable/Disable the Metric Halo part.", False ),
38         BoolOption( "ENABLE_RME", "Enable/Disable the RME part.", False ),
39         BoolOption( "ENABLE_BOUNCE", "Enable/Disable the BOUNCE part.", False ),
40         BoolOption( "ENABLE_GENERICAVC", """\
41 Enable/Disable the the generic avc part (mainly used by apple).
42   Note that disabling this option might be overwritten by other devices needing
43   this code.""", False ),
44         BoolOption( "ENABLE_ALL", "Enable/Disable support for all devices.", False ),
45         BoolOption( "BUILD_TESTS", """\
46 Build the tests in their directory. As some contain quite some functionality,
47   this is on by default.
48   If you just want to use ffado with jack without the tools, you can disable this.\
49 """, True ),
50         )
51
52 ## Load the builders in config
53 buildenv={}
54 if os.environ.has_key('PATH'):
55         buildenv['PATH']=os.environ['PATH']
56 else:
57         buildenv['PATH']=''
58
59 if os.environ.has_key('PKG_CONFIG_PATH'):
60         buildenv['PKG_CONFIG_PATH']=os.environ['PKG_CONFIG_PATH']
61 else:
62         buildenv['PKG_CONFIG_PATH']=''
63
64
65 env = Environment( tools=['default','scanreplace','pyuic','dbus','doxygen','pkgconfig'], toolpath=['admin'], ENV = buildenv, options=opts )
66
67
68 Help( """
69 For building ffado you can set different options as listed below. You have to
70 specify them only once, scons will save the last value you used and re-use
71 that.
72 To really undo your settings and return to the factory defaults, remove the
73 "cache"-folder and the file ".sconsign.dblite" from this directory.
74 For example with: "rm -Rf .sconsign.dblite cache"
75
76 Currently it seems as if only the BEBOB is kind-of-working, thats why only BEBOB
77 is enabled by default.
78
79 Note that this is a development version! Don't complain if its not working!
80 See www.ffado.org for stable releases.
81 """ )
82 Help( opts.GenerateHelpText( env ) )
83
84 # make sure the necessary dirs exist
85 if not os.path.isdir( "cache/" + build_base ):
86         os.makedirs( "cache/" + build_base )
87 if not os.path.isdir( 'cache/objects' ):
88         os.makedirs( 'cache/objects' )
89
90 CacheDir( 'cache/objects' )
91
92 opts.Save( 'cache/' + build_base + "options.cache", env )
93
94 #
95 # Check for apps...
96 #
97 def CheckForApp( context, app ):
98         context.Message( "Checking if '%s' executes... " % app )
99         ret = context.env.WhereIs( app )
100         if ret != "":
101                 context.Result( True )
102         else:
103                 context.Result( False )
104         return ret
105
106 tests = { 'CheckForApp' : CheckForApp }
107 tests.update( env['PKGCONFIG_TESTS'] )
108
109 if not env.GetOption('clean'):
110         conf = Configure( env,
111                 custom_tests = tests,
112                 conf_dir = "cache/" + build_base,
113                 log_file = "cache/" + build_base + 'config.log' )
114
115         #
116         # Check if the environment can actually compile c-files by checking for a
117         # header shipped with gcc.
118         #
119         if not conf.CheckHeader( "stdio.h" ):
120                 print "It seems as if stdio.h is missing. This probably means that your build environment is broken, please make sure you have a working c-compiler and libstdc installed and usable."
121                 Exit( 1 )
122
123         #
124         # The following checks are for headers and libs and packages we need.
125         #
126         allpresent = 1;
127         allpresent &= conf.CheckHeader( "expat.h" )
128         allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
129        
130         allpresent &= conf.CheckForPKGConfig();
131
132         pkgs = {
133                 'libraw1394' : '1.3.0',
134                 'libavc1394' : '0.5.3',
135                 'libiec61883' : '1.1.0',
136                 'alsa' : '1.0.0',
137                 'libxml++-2.6' : '2.13.0',
138                 'dbus-1' : '1.0',
139                 }
140         for pkg in pkgs:
141                 name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
142                 env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
143                 if env['%s_FLAGS'%name2] == 0:
144                         allpresent &= 0
145
146         if not allpresent:
147                 print """
148 (At least) One of the dependencies is missing. I can't go on without it, please
149 install the needed packages (remember to also install the *-devel packages)
150 """
151                 Exit( 1 )
152
153         #
154         # Optional checks follow:
155         #
156         env['PYUIC'] = conf.CheckForApp( 'pyuic' )
157         env['ALSA_SEQ_OUTPUT'] = conf.CheckLib( 'asound', symbol='snd_seq_event_output_direct', autoadd=0 )
158
159         env = conf.Finish()
160
161 if env['DEBUG']:
162         print "Doing a DEBUG build"
163         # -Werror could be added to, which would force the devs to really remove all the warnings :-)
164         env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
165 else:
166         env.AppendUnique( CCFLAGS=["-O2","-DNDEBUG"] )
167
168 # this is required to indicate that the DBUS version we use has support
169 # for platform dependent threading init functions
170 # this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is
171 # always true
172 env.AppendUnique( CCFLAGS=["-DDBUS_HAS_THREADS_INIT_DEFAULT"] )
173
174 if env['ENABLE_ALL']:
175         env['ENABLE_BEBOB'] = True
176         env['ENABLE_FIREWORKS'] = True
177         env['ENABLE_MOTU'] = True
178         env['ENABLE_DICE'] = True
179         env['ENABLE_METRIC_HALO'] = True
180         env['ENABLE_RME'] = True
181         env['ENABLE_BOUNCE'] = True
182
183 if env['ENABLE_BEBOB'] or env['ENABLE_DICE'] or env['ENABLE_BOUNCE'] or env['ENABLE_FIREWORKS']:
184         env['ENABLE_GENERICAVC'] = True
185
186 if build_base:
187         env['build_base']="#/"+build_base
188 else:
189         env['build_base']="#/"
190
191 #
192 # XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones?
193 #
194 env['bindir'] = Template( os.path.join( env['BINDIR'] ) ).safe_substitute( env )
195 env['libdir'] = Template( os.path.join( env['LIBDIR'] ) ).safe_substitute( env )
196 env['includedir'] = Template( os.path.join( env['INCLUDEDIR'] ) ).safe_substitute( env )
197 env['sharedir'] = Template( os.path.join( env['SHAREDIR'] ) ).safe_substitute( env )
198
199 env.Alias( "install", env['libdir'] )
200 env.Alias( "install", env['includedir'] )
201 env.Alias( "install", env['sharedir'] )
202 env.Alias( "install", env['bindir'] )
203
204
205 env['REVISION'] = os.popen('svnversion .').read()[:-1]
206 # This may be as simple as '89' or as complex as '4123:4184M'.
207 # We'll just use the last bit.
208 env['REVISION'] = env['REVISION'].split(':')[-1]
209
210 if env['REVISION'] == 'exported':
211         env['REVISION'] = ''
212
213 env['PACKAGE'] = "libffado"
214 env['VERSION'] = "1.999.7"
215 env['LIBVERSION'] = "1.0.0"
216
217 #
218 # To have the top_srcdir as the doxygen-script is used from auto*
219 #
220 env['top_srcdir'] = env.Dir( "." ).abspath
221
222 #
223 # Start building
224 #
225 env.ScanReplace( "config.h.in" )
226
227 pkgconfig = env.ScanReplace( "libffado.pc.in" )
228 env.Install( env['libdir'] + '/pkgconfig', pkgconfig )
229
230 subdirs=['external','src','libffado','tests','support','doc']
231 if build_base:
232         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
233 else:
234         env.SConscript( dirs=subdirs, exports="env" )
235
236 if 'debian' in COMMAND_LINE_TARGETS:
237         env.SConscript("deb/SConscript", exports="env")
238
239 # By default only src is built but all is cleaned
240 if not env.GetOption('clean'):
241     Default( 'external' )
242     Default( 'src' )
243     Default( 'support' )
244     if env['BUILD_TESTS']:
245         Default( 'tests' )
246
Note: See TracBrowser for help on using the browser.