root/trunk/libffado/SConstruct

Revision 606, 7.6 kB (checked in by ppalmers, 17 years ago)

proposed fix for ticket #30

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