root/trunk/libffado/SConstruct

Revision 587, 8.9 kB (checked in by ppalmers, 15 years ago)

- moved all vendor id's to one include file
- introduced the framework for the ECHO FireWorks? platform

Line 
1 #! /usr/bin/env python
2
3 import os
4 import sys
5 sys.path.append( "./admin" )
6 from pkgconfig import *
7
8 build_dir = ARGUMENTS.get('BUILDDIR', "")
9 if build_dir:
10         build_base=build_dir+'/'
11         if not os.path.isdir( build_base ):
12                 os.makedirs( build_base )
13         print "Building into: " + build_base
14 else:
15         build_base=''
16
17 if not os.path.isdir( "cache" ):
18         os.makedirs( "cache" )
19
20 opts = Options( "cache/"+build_base+"options.cache" )
21
22 #
23 # If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong...
24 opts.Add( "BUILDDIR", "Path to place the built files in", "")
25
26 opts.AddOptions(
27         BoolOption( "DEBUG", """
28 Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use
29 \"-O2\" to optimise.""", True ),
30         PathOption( "PREFIX", "The prefix where ffado will be installed to.", "/usr/local" ),
31         BoolOption( "ENABLE_BEBOB", "Enable/Disable the bebob part.", True ),
32         BoolOption( "ENABLE_FIREWORKS", "Enable/Disable the ECHO Audio FireWorks avc part.", True ),
33         BoolOption( "ENABLE_MOTU", "Enable/Disable the Motu part.", False ),
34         BoolOption( "ENABLE_DICE", "Enable/Disable the DICE part.", False ),
35         BoolOption( "ENABLE_METRIC_HALO", "Enable/Disable the Metric Halo part.", False ),
36         BoolOption( "ENABLE_RME", "Enable/Disable the RME part.", False ),
37         BoolOption( "ENABLE_BOUNCE", "Enable/Disable the BOUNCE part.", False ),
38         BoolOption( "ENABLE_ALL", "Enable/Disable support for all devices.", False ),
39         BoolOption( "BUILD_TESTS", """
40 Build the tests in their directory. As some contain quite some functionality,
41 this is on by default.
42 If you just want to use ffado with jack without the tools, you can disable this.
43 """, True ),
44         )
45
46 ## Load the builders in config
47 buildenv={}
48 if os.environ.has_key('PATH'):
49         buildenv['PATH']=os.environ['PATH']
50 else:
51         buildenv['PATH']=''
52
53 if os.environ.has_key('PKG_CONFIG_PATH'):
54         buildenv['PKG_CONFIG_PATH']=os.environ['PKG_CONFIG_PATH']
55 else:
56         buildenv['PKG_CONFIG_PATH']=''
57
58 env = Environment( tools=['default','scanreplace','pyuic'], toolpath=['admin'], ENV = buildenv, options=opts )
59
60 Help( """
61 For building ffado you can set different options as listed below. You have to
62 specify them only once, scons will save the last value you used and re-use
63 that.
64 To really undo your settings and return to the factory defaults, remove the
65 "cache"-folder and the file ".sconsign.dblite" from this directory.
66 For example with: "rm -Rf .sconsign.dblite cache"
67
68 Currently it seems as if only the BEBOB is kind-of-working, thats why only BEBOB
69 is enabled by default.
70
71 Note that this is a development version! Don't complain if its not working!
72 See www.ffado.org for stable releases.
73 """ )
74 Help( opts.GenerateHelpText( env ) )
75
76 # make sure the necessary dirs exist
77 if not os.path.isdir( "cache/" + build_base ):
78         os.makedirs( "cache/" + build_base )
79 if not os.path.isdir( 'cache/objects' ):
80         os.makedirs( 'cache/objects' )
81
82 CacheDir( 'cache/objects' )
83
84 opts.Save( 'cache/' + build_base + "options.cache", env )
85
86 #
87 # Check for apps...
88 #
89 def CheckForApp( context, app ):
90         context.Message( "Checking if '%s' executes... " % app )
91         ret = context.TryAction( app )[0]
92         context.Result( ret )
93         return ret
94
95
96 if not env.GetOption('clean'):
97         conf = Configure( env,
98                 custom_tests={ 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG, 'CheckForApp' : CheckForApp },
99                 conf_dir="cache/" + build_base,
100                 log_file="cache/" + build_base + 'config.log' )
101
102         if not conf.CheckHeader( "stdio.h" ):
103                 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."
104                 Exit( 1 )
105
106         allpresent = 1;
107         allpresent &= conf.CheckForPKGConfig();
108         allpresent &= conf.CheckForPKG( 'libraw1394', "1.3.0" )
109         allpresent &= conf.CheckForPKG( 'libavc1394', "0.5.3" )
110         allpresent &= conf.CheckForPKG( 'libiec61883', "1.1.0" )
111         allpresent &= conf.CheckForPKG( 'alsa', "1.0.0" )
112         allpresent &= conf.CheckForPKG( 'libxml++-2.6', "2.13.0" )
113         allpresent &= conf.CheckForPKG( 'liblo', "0.22" )
114         allpresent &= conf.CheckForPKG( 'dbus-1', "1.0" )
115         allpresent &= conf.CheckHeader( "expat.h" )
116         allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
117        
118         if not allpresent:
119                 print """
120 (At least) One of the dependencies is missing. I can't go on without it, please
121 install the needed packages (remember to also install the *-devel packages)
122 """
123                 Exit( 1 )
124
125         #
126         # Checking wether "which pyuic" executes is clearly wrong. Nonetheless here
127         # on my system it seems to be the right thing, as checking for pyuic alone
128         # returns false. (Both pyuic and which are installed in the same dir.)
129         # - Strange :-/
130         env['HAVE_PYUIC'] = conf.CheckForApp( 'which pyuic' )
131
132         env = conf.Finish()
133
134 if env['DEBUG']:
135         print "Doing a DEBUG build"
136         # -Werror could be added to, which would force the devs to really remove all the warnings :-)
137         env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
138 else:
139         env.AppendUnique( CCFLAGS=["-O2"] )
140
141 # this is required to indicate that the DBUS version we use has support
142 # for platform dependent threading init functions
143 # this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is
144 # always true
145 env.AppendUnique( CCFLAGS=["-DDBUS_HAS_THREADS_INIT_DEFAULT"] )
146
147 if env['ENABLE_ALL']:
148         env['ENABLE_BEBOB'] = True
149         env['ENABLE_FIREWORKS'] = True
150         env['ENABLE_MOTU'] = True
151         env['ENABLE_DICE'] = True
152         env['ENABLE_METRIC_HALO'] = True
153         env['ENABLE_RME'] = True
154         env['ENABLE_BOUNCE'] = True
155
156 if build_base:
157         env['build_base']="#/"+build_base
158 else:
159         env['build_base']="#/"
160
161 #
162 # Create an environment for the externals-directory without all the fancy
163 # ffado-defines. Probably the ffado-defines should be gathered in a distinct
164 # ffadoenv...
165 externalenv = env.Copy()
166 Export( 'externalenv' )
167
168 #
169 # TODO: Probably this should be in the src/SConscript...
170 #
171 if env['ENABLE_BEBOB']:
172         env.AppendUnique( CCFLAGS=["-DENABLE_BEBOB"] )
173 if env['ENABLE_FIREWORKS']:
174         env.AppendUnique( CCFLAGS=["-DENABLE_FIREWORKS"] )
175 if env['ENABLE_MOTU']:
176         env.AppendUnique( CCFLAGS=["-DENABLE_MOTU"] )
177 if env['ENABLE_DICE']:
178         env.AppendUnique( CCFLAGS=["-DENABLE_DICE"] )
179 if env['ENABLE_METRIC_HALO']:
180         env.AppendUnique( CCFLAGS=["-DENABLE_METRIC_HALO"] )
181 if env['ENABLE_RME']:
182         env.AppendUnique( CCFLAGS=["-DENABLE_RME"] )
183 if env['ENABLE_BOUNCE']:
184         env.AppendUnique( CCFLAGS=["-DENABLE_BOUNCE"] )
185
186 # the GenericAVC code is used by these devices
187 if env['ENABLE_BEBOB'] or env['ENABLE_DICE'] or env['ENABLE_BOUNCE'] or env['ENABLE_FIREWORKS']:
188         env.AppendUnique( CCFLAGS=["-DENABLE_GENERICAVC"] )
189
190 #
191 # TODO: Most of these flags aren't needed for all the apps/libs compiled here.
192 # The relevant MergeFlags-calls should be moved to the SConscript-files where
193 # its needed...
194 if env.has_key('LIBRAW1394_FLAGS'):
195     env.MergeFlags( env['LIBRAW1394_FLAGS'] )
196 if env.has_key('LIBAVC1394_FLAGS'):
197     env.MergeFlags( env['LIBAVC1394_FLAGS'] )
198 if env.has_key('LIBIEC61883_FLAGS'):
199     env.MergeFlags( env['LIBIEC61883_FLAGS'] )
200 if env.has_key('ALSA_FLAGS'):
201     env.MergeFlags( env['ALSA_FLAGS'] )
202 if env.has_key('LIBXML26_FLAGS'):
203     env.MergeFlags( env['LIBXML26_FLAGS'] )
204 if env.has_key('LIBLO_FLAGS'):
205     env.MergeFlags( env['LIBLO_FLAGS'] )
206
207 #
208 # Some includes in src/*/ are full path (src/*), that should be fixed?
209 env.AppendUnique( CPPPATH=["#/"] )
210
211 env['bindir'] = os.path.join( env['PREFIX'], "bin" )
212 env['libdir'] = os.path.join( env['PREFIX'], "lib" )
213 env['includedir'] = os.path.join( env['PREFIX'], "include" )
214 env['sharedir'] = os.path.join( env['PREFIX'], "share/libffado" )
215 env['cachedir'] = os.path.join( env['PREFIX'], "var/cache/libffado" )
216
217 env.Alias( "install", env['libdir'] )
218 env.Alias( "install", env['includedir'] )
219
220 env['PACKAGE'] = "libffado"
221 env['VERSION'] = "1.999.5"
222 env['LIBVERSION'] = "1.0.0"
223
224 #
225 # Start building
226 #
227
228 env.Command( "config.h.in", "config.h.in.scons", "cp $SOURCE $TARGET" )
229
230 env.ScanReplace( "config.h.in" )
231 pkgconfig = env.ScanReplace( "libffado.pc.in" )
232 env.Alias( "install", env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) )
233
234 # build helper tools first
235 subdirs=['external']
236 if build_base:
237         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
238 else:
239         env.SConscript( dirs=subdirs, exports="env" )
240
241 if not env.GetOption('clean'):
242     Default( 'external' )
243
244 Import( 'dbusxx_xml2cpp_adaptor_builder' )
245 env.Append(BUILDERS = {'XML2CPP_ADAPTOR' : dbusxx_xml2cpp_adaptor_builder})
246
247 Import( 'dbusxx_xml2cpp_proxy_builder' )
248 env.Append(BUILDERS = {'XML2CPP_PROXY' : dbusxx_xml2cpp_proxy_builder})
249
250 # now build our own stuff, which can use the tools defined above
251 subdirs=['src','libffado','tests','support']
252 if build_base:
253         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
254 else:
255         env.SConscript( dirs=subdirs, exports="env" )
256
257
258 # By default only src is built but all is cleaned
259 if not env.GetOption('clean'):
260     Default( 'src' )
261     if env['BUILD_TESTS']:
262         Default( 'tests' )
263     #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) )
264     env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) )
Note: See TracBrowser for help on using the browser.