root/trunk/libffado/SConstruct

Revision 736, 8.0 kB (checked in by ppalmers, 16 years ago)

fix some stuff that was not merged correctly

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