root/trunk/libffado/SConstruct

Revision 571, 7.4 kB (checked in by arnonym, 17 years ago)

Add a first check for pyuic and compile the mixer ui's only if it was successful.

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_GENERIC_AVC", "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 if env['ENABLE_ALL']:
142         env['ENABLE_BEBOB'] = True
143         env['ENABLE_GENERIC_AVC'] = True
144         env['ENABLE_MOTU'] = True
145         env['ENABLE_DICE'] = True
146         env['ENABLE_METRIC_HALO'] = True
147         env['ENABLE_RME'] = True
148         env['ENABLE_BOUNCE'] = True
149
150 if env['ENABLE_BEBOB']:
151         env.AppendUnique( CCFLAGS=["-DENABLE_BEBOB"] )
152 if env['ENABLE_GENERIC_AVC']:
153         env.AppendUnique( CCFLAGS=["-DENABLE_GENERIC_AVC"] )
154 if env['ENABLE_MOTU']:
155         env.AppendUnique( CCFLAGS=["-DENABLE_MOTU"] )
156 if env['ENABLE_DICE']:
157         env.AppendUnique( CCFLAGS=["-DENABLE_DICE"] )
158 if env['ENABLE_METRIC_HALO']:
159         env.AppendUnique( CCFLAGS=["-DENABLE_METRIC_HALO"] )
160 if env['ENABLE_RME']:
161         env.AppendUnique( CCFLAGS=["-DENABLE_RME"] )
162 if env['ENABLE_BOUNCE']:
163         env.AppendUnique( CCFLAGS=["-DENABLE_BOUNCE"] )
164
165 #
166 # TODO: Most of these flags aren't needed for all the apps/libs compiled here.
167 # The relevant MergeFlags-calls should be moved to the SConscript-files where
168 # its needed...
169 env.MergeFlags( env['LIBRAW1394_FLAGS'] )
170 env.MergeFlags( env['LIBAVC1394_FLAGS'] )
171 env.MergeFlags( env['LIBIEC61883_FLAGS'] )
172 env.MergeFlags( env['ALSA_FLAGS'] )
173 env.MergeFlags( env['LIBXML26_FLAGS'] )
174 env.MergeFlags( env['LIBLO_FLAGS'] )
175
176 #
177 # Some includes in src/*/ are full path (src/*), that should be fixed?
178 env.AppendUnique( CPPPATH=["#/"] )
179
180 env['bindir'] = os.path.join( env['PREFIX'], "bin" )
181 env['libdir'] = os.path.join( env['PREFIX'], "lib" )
182 env['includedir'] = os.path.join( env['PREFIX'], "include" )
183 env['sharedir'] = os.path.join( env['PREFIX'], "share/libffado" )
184 env['cachedir'] = os.path.join( env['PREFIX'], "var/cache/libffado" )
185
186 env.Alias( "install", env['libdir'] )
187 env.Alias( "install", env['includedir'] )
188
189 env['PACKAGE'] = "libffado"
190 env['VERSION'] = "1.999.5"
191 env['LIBVERSION'] = "1.0.0"
192
193 #
194 # Start building
195 #
196
197 env.Command( "config.h.in", "config.h.in.scons", "cp $SOURCE $TARGET" )
198
199 env.ScanReplace( "config.h.in" )
200 pkgconfig = env.ScanReplace( "libffado.pc.in" )
201 env.Alias( "install", env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) )
202
203
204 subdirs=['src','libffado','tests','support','external']
205 if build_base:
206         env['build_base']="#/"+build_base
207         for subdir in subdirs:
208                 env.SConscript( dirs=subdir, exports="env", build_dir=build_base+subdir )
209 else:
210         env['build_base']="#/"
211         env.SConscript( dirs=subdirs, exports="env" )
212
213
214 # By default only src is built but all is cleaned
215 if not env.GetOption('clean'):
216         Default( 'external' )
217         Default( 'src' )
218         if env['BUILD_TESTS']:
219                 Default( 'tests' )
220         #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) )
221         env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) )
Note: See TracBrowser for help on using the browser.