root/trunk/libffado/SConstruct

Revision 576, 8.7 kB (checked in by arnonym, 16 years ago)

Some cleanup

I created an externalenv which is a copy of env without all the ffado-defines to be used by the externals. That way there is no need for code-duplication in external/dbus/SConscript.

And the DBUS-Builders should probably go into an own file in admin/...

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_GENERICAVC", "Enable/Disable the generic avc part (apple).", 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_GENERICAVC'] = 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_GENERICAVC']:
174         env.AppendUnique( CCFLAGS=["-DENABLE_GENERICAVC"] )
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 #
187 # TODO: Most of these flags aren't needed for all the apps/libs compiled here.
188 # The relevant MergeFlags-calls should be moved to the SConscript-files where
189 # its needed...
190 if env.has_key('LIBRAW1394_FLAGS'):
191     env.MergeFlags( env['LIBRAW1394_FLAGS'] )
192 if env.has_key('LIBAVC1394_FLAGS'):
193     env.MergeFlags( env['LIBAVC1394_FLAGS'] )
194 if env.has_key('LIBIEC61883_FLAGS'):
195     env.MergeFlags( env['LIBIEC61883_FLAGS'] )
196 if env.has_key('ALSA_FLAGS'):
197     env.MergeFlags( env['ALSA_FLAGS'] )
198 if env.has_key('LIBXML26_FLAGS'):
199     env.MergeFlags( env['LIBXML26_FLAGS'] )
200 if env.has_key('LIBLO_FLAGS'):
201     env.MergeFlags( env['LIBLO_FLAGS'] )
202
203 #
204 # Some includes in src/*/ are full path (src/*), that should be fixed?
205 env.AppendUnique( CPPPATH=["#/"] )
206
207 env['bindir'] = os.path.join( env['PREFIX'], "bin" )
208 env['libdir'] = os.path.join( env['PREFIX'], "lib" )
209 env['includedir'] = os.path.join( env['PREFIX'], "include" )
210 env['sharedir'] = os.path.join( env['PREFIX'], "share/libffado" )
211 env['cachedir'] = os.path.join( env['PREFIX'], "var/cache/libffado" )
212
213 env.Alias( "install", env['libdir'] )
214 env.Alias( "install", env['includedir'] )
215
216 env['PACKAGE'] = "libffado"
217 env['VERSION'] = "1.999.5"
218 env['LIBVERSION'] = "1.0.0"
219
220 #
221 # Start building
222 #
223
224 env.Command( "config.h.in", "config.h.in.scons", "cp $SOURCE $TARGET" )
225
226 env.ScanReplace( "config.h.in" )
227 pkgconfig = env.ScanReplace( "libffado.pc.in" )
228 env.Alias( "install", env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) )
229
230 # build helper tools first
231 subdirs=['external']
232 if build_base:
233         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
234 else:
235         env.SConscript( dirs=subdirs, exports="env" )
236
237 if not env.GetOption('clean'):
238     Default( 'external' )
239
240 Import( 'dbusxx_xml2cpp_adaptor_builder' )
241 env.Append(BUILDERS = {'XML2CPP_ADAPTOR' : dbusxx_xml2cpp_adaptor_builder})
242
243 Import( 'dbusxx_xml2cpp_proxy_builder' )
244 env.Append(BUILDERS = {'XML2CPP_PROXY' : dbusxx_xml2cpp_proxy_builder})
245
246 # now build our own stuff, which can use the tools defined above
247 subdirs=['src','libffado','tests','support']
248 if build_base:
249         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
250 else:
251         env.SConscript( dirs=subdirs, exports="env" )
252
253
254 # By default only src is built but all is cleaned
255 if not env.GetOption('clean'):
256     Default( 'src' )
257     if env['BUILD_TESTS']:
258         Default( 'tests' )
259     #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) )
260     env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) )
Note: See TracBrowser for help on using the browser.