root/trunk/libffado/SConstruct

Revision 604, 7.3 kB (checked in by arnonym, 15 years ago)

A global include #/ is no longer needed...

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         PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin" ),
32         PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib" ),
33         PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include" ),
34         PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado" ),
35         BoolOption( "ENABLE_BEBOB", "Enable/Disable the bebob part.", True ),
36         BoolOption( "ENABLE_FIREWORKS", "Enable/Disable the ECHO Audio FireWorks avc part.", True ),
37         BoolOption( "ENABLE_MOTU", "Enable/Disable the Motu part.", False ),
38         BoolOption( "ENABLE_DICE", "Enable/Disable the DICE part.", False ),
39         BoolOption( "ENABLE_METRIC_HALO", "Enable/Disable the Metric Halo part.", False ),
40         BoolOption( "ENABLE_RME", "Enable/Disable the RME part.", False ),
41         BoolOption( "ENABLE_BOUNCE", "Enable/Disable the BOUNCE part.", False ),
42         BoolOption( "ENABLE_GENERICAVC", """\
43 Enable/Disable the the generic avc part (mainly used by apple).
44   Note that disabling this option might be overwritten by other devices needing
45   this code.""", False ),
46         BoolOption( "ENABLE_ALL", "Enable/Disable support for all devices.", False ),
47         BoolOption( "BUILD_TESTS", """\
48 Build the tests in their directory. As some contain quite some functionality,
49   this is on by default.
50   If you just want to use ffado with jack without the tools, you can disable this.\
51 """, True ),
52         )
53
54 ## Load the builders in config
55 buildenv={}
56 if os.environ.has_key('PATH'):
57         buildenv['PATH']=os.environ['PATH']
58 else:
59         buildenv['PATH']=''
60
61 if os.environ.has_key('PKG_CONFIG_PATH'):
62         buildenv['PKG_CONFIG_PATH']=os.environ['PKG_CONFIG_PATH']
63 else:
64         buildenv['PKG_CONFIG_PATH']=''
65
66 env = Environment( tools=['default','scanreplace','pyuic','dbus'], toolpath=['admin'], ENV = buildenv, options=opts )
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
107 if not env.GetOption('clean'):
108         conf = Configure( env,
109                 custom_tests={ 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG, 'GetPKGFlags' : GetPKGFlags, 'CheckForApp' : CheckForApp },
110                 conf_dir="cache/" + build_base,
111                 log_file="cache/" + build_base + 'config.log' )
112
113         if not conf.CheckHeader( "stdio.h" ):
114                 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."
115                 Exit( 1 )
116
117         allpresent = 1;
118         allpresent &= conf.CheckHeader( "expat.h" )
119         allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
120        
121         allpresent &= conf.CheckForPKGConfig();
122
123         pkgs = {
124                 'libraw1394' : '1.3.0',
125                 'libavc1394' : '0.5.3',
126                 'libiec61883' : '1.1.0',
127                 'alsa' : '1.0.0',
128                 'libxml++-2.6' : '2.13.0',
129                 'liblo' : '0.22',
130                 'dbus-1' : '1.0',
131                 }
132         for pkg in pkgs:
133                 name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
134                 env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
135                 if env['%s_FLAGS'%name2] == 0:
136                         allpresent &= 0
137
138         if not allpresent:
139                 print """
140 (At least) One of the dependencies is missing. I can't go on without it, please
141 install the needed packages (remember to also install the *-devel packages)
142 """
143                 Exit( 1 )
144
145         #
146         env['PYUIC'] = conf.CheckForApp( 'pyuic' )
147
148         env = conf.Finish()
149
150 if env['DEBUG']:
151         print "Doing a DEBUG build"
152         # -Werror could be added to, which would force the devs to really remove all the warnings :-)
153         env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
154 else:
155         env.AppendUnique( CCFLAGS=["-O2"] )
156
157 # this is required to indicate that the DBUS version we use has support
158 # for platform dependent threading init functions
159 # this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is
160 # always true
161 env.AppendUnique( CCFLAGS=["-DDBUS_HAS_THREADS_INIT_DEFAULT"] )
162
163 if env['ENABLE_ALL']:
164         env['ENABLE_BEBOB'] = True
165         env['ENABLE_FIREWORKS'] = True
166         env['ENABLE_MOTU'] = True
167         env['ENABLE_DICE'] = True
168         env['ENABLE_METRIC_HALO'] = True
169         env['ENABLE_RME'] = True
170         env['ENABLE_BOUNCE'] = True
171
172 if env['ENABLE_BEBOB'] or env['ENABLE_DICE'] or env['ENABLE_BOUNCE'] or env['ENABLE_FIREWORKS']:
173         env['ENABLE_GENERICAVC'] = True
174
175 if build_base:
176         env['build_base']="#/"+build_base
177 else:
178         env['build_base']="#/"
179
180 #
181 # XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones?
182 #
183 env['bindir'] = os.path.join( env['BINDIR'] )
184 env['libdir'] = os.path.join( env['LIBDIR'] )
185 env['includedir'] = os.path.join( env['INCLUDEDIR'] )
186 env['sharedir'] = os.path.join( env['SHAREDIR'] )
187 env['cachedir'] = os.path.join( env['PREFIX'], "var/cache/libffado" )
188
189 env.Alias( "install", env['libdir'] )
190 env.Alias( "install", env['includedir'] )
191
192 env['PACKAGE'] = "libffado"
193 env['VERSION'] = "1.999.6"
194 env['LIBVERSION'] = "1.0.0"
195
196 #
197 # Start building
198 #
199
200 env.ScanReplace( "config.h.in" )
201
202 pkgconfig = env.ScanReplace( "libffado.pc.in" )
203 env.Alias( "install", env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) )
204
205 subdirs=['external','src','libffado','tests','support']
206 if build_base:
207         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
208 else:
209         env.SConscript( dirs=subdirs, exports="env" )
210
211
212 # By default only src is built but all is cleaned
213 if not env.GetOption('clean'):
214     Default( 'external' )
215     Default( 'src' )
216     if env['BUILD_TESTS']:
217         Default( 'tests' )
218     # Cachedir has to be fixed...
219     #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) )
220     #env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) )
Note: See TracBrowser for help on using the browser.