root/trunk/libffado/SConstruct

Revision 717, 7.9 kB (checked in by arnonym, 15 years ago)

This should fix redeemans problem with dbus and other libs in a non-standard place.

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 # Check for apps...
101 #
102 def CheckForApp( context, app ):
103         context.Message( "Checking if '%s' executes... " % app )
104         ret = context.env.WhereIs( app )
105         if ret != "":
106                 context.Result( True )
107         else:
108                 context.Result( False )
109         return ret
110
111 tests = { 'CheckForApp' : CheckForApp }
112 tests.update( env['PKGCONFIG_TESTS'] )
113
114 if not env.GetOption('clean'):
115         conf = Configure( env,
116                 custom_tests = tests,
117                 conf_dir = "cache/" + build_base,
118                 log_file = "cache/" + build_base + 'config.log' )
119
120         #
121         # Check if the environment can actually compile c-files by checking for a
122         # header shipped with gcc.
123         #
124         if not conf.CheckHeader( "stdio.h" ):
125                 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."
126                 Exit( 1 )
127
128         #
129         # The following checks are for headers and libs and packages we need.
130         #
131         allpresent = 1;
132         allpresent &= conf.CheckHeader( "expat.h" )
133         allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
134        
135         allpresent &= conf.CheckForPKGConfig();
136
137         pkgs = {
138                 'libraw1394' : '1.3.0',
139                 'libavc1394' : '0.5.3',
140                 'libiec61883' : '1.1.0',
141                 'alsa' : '1.0.0',
142                 'libxml++-2.6' : '2.13.0',
143                 'liblo' : '0.22',
144                 'dbus-1' : '1.0',
145                 }
146         for pkg in pkgs:
147                 name2 = pkg.replace("+","").replace(".","").replace("-","").upper()
148                 env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] )
149                 if env['%s_FLAGS'%name2] == 0:
150                         allpresent &= 0
151
152         if not allpresent:
153                 print """
154 (At least) One of the dependencies is missing. I can't go on without it, please
155 install the needed packages (remember to also install the *-devel packages)
156 """
157                 Exit( 1 )
158
159         #
160         # Optional checks follow:
161         #
162         env['PYUIC'] = conf.CheckForApp( 'pyuic' )
163         env['ALSA_SEQ_OUTPUT'] = conf.CheckLib( 'asound', symbol='snd_seq_event_output_direct', autoadd=0 )
164
165         env = conf.Finish()
166
167 if env['DEBUG']:
168         print "Doing a DEBUG build"
169         # -Werror could be added to, which would force the devs to really remove all the warnings :-)
170         env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
171 else:
172         env.AppendUnique( CCFLAGS=["-O2"] )
173
174 # this is required to indicate that the DBUS version we use has support
175 # for platform dependent threading init functions
176 # this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is
177 # always true
178 env.AppendUnique( CCFLAGS=["-DDBUS_HAS_THREADS_INIT_DEFAULT"] )
179
180 if env['ENABLE_ALL']:
181         env['ENABLE_BEBOB'] = True
182         env['ENABLE_FIREWORKS'] = True
183         env['ENABLE_MOTU'] = True
184         env['ENABLE_DICE'] = True
185         env['ENABLE_METRIC_HALO'] = True
186         env['ENABLE_RME'] = True
187         env['ENABLE_BOUNCE'] = True
188
189 if env['ENABLE_BEBOB'] or env['ENABLE_DICE'] or env['ENABLE_BOUNCE'] or env['ENABLE_FIREWORKS']:
190         env['ENABLE_GENERICAVC'] = True
191
192 if build_base:
193         env['build_base']="#/"+build_base
194 else:
195         env['build_base']="#/"
196
197 #
198 # XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones?
199 #
200 env['bindir'] = Template( os.path.join( env['BINDIR'] ) ).safe_substitute( env )
201 env['libdir'] = Template( os.path.join( env['LIBDIR'] ) ).safe_substitute( env )
202 env['includedir'] = Template( os.path.join( env['INCLUDEDIR'] ) ).safe_substitute( env )
203 env['sharedir'] = Template( os.path.join( env['SHAREDIR'] ) ).safe_substitute( env )
204
205 env.Alias( "install", env['libdir'] )
206 env.Alias( "install", env['includedir'] )
207 env.Alias( "install", env['sharedir'] )
208 env.Alias( "install", env['bindir'] )
209
210 env['PACKAGE'] = "libffado"
211 env['VERSION'] = "1.999.6"
212 env['LIBVERSION'] = "1.0.0"
213
214 #
215 # To have the top_srcdir as the doxygen-script is used from auto*
216 #
217 env['top_srcdir'] = env.Dir( "." ).abspath
218
219 #
220 # Start building
221 #
222
223 env.ScanReplace( "config.h.in" )
224
225 pkgconfig = env.ScanReplace( "libffado.pc.in" )
226 env.Install( env['libdir'] + '/pkgconfig', pkgconfig )
227
228 subdirs=['external','src','libffado','tests','support','doc']
229 if build_base:
230         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
231 else:
232         env.SConscript( dirs=subdirs, exports="env" )
233
234
235 # By default only src is built but all is cleaned
236 if not env.GetOption('clean'):
237     Default( 'external' )
238     Default( 'src' )
239     Default( 'support' )
240     if env['BUILD_TESTS']:
241         Default( 'tests' )
242
Note: See TracBrowser for help on using the browser.