root/trunk/libffado/SConstruct

Revision 605, 7.4 kB (checked in by arnonym, 15 years ago)

Docs are back!

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
67 env = Environment( tools=['default','scanreplace','pyuic','dbus','doxygen'], toolpath=['admin'], ENV = buildenv, options=opts )
68
69
70 Help( """
71 For building ffado you can set different options as listed below. You have to
72 specify them only once, scons will save the last value you used and re-use
73 that.
74 To really undo your settings and return to the factory defaults, remove the
75 "cache"-folder and the file ".sconsign.dblite" from this directory.
76 For example with: "rm -Rf .sconsign.dblite cache"
77
78 Currently it seems as if only the BEBOB is kind-of-working, thats why only BEBOB
79 is enabled by default.
80
81 Note that this is a development version! Don't complain if its not working!
82 See www.ffado.org for stable releases.
83 """ )
84 Help( opts.GenerateHelpText( env ) )
85
86 # make sure the necessary dirs exist
87 if not os.path.isdir( "cache/" + build_base ):
88         os.makedirs( "cache/" + build_base )
89 if not os.path.isdir( 'cache/objects' ):
90         os.makedirs( 'cache/objects' )
91
92 CacheDir( 'cache/objects' )
93
94 opts.Save( 'cache/' + build_base + "options.cache", env )
95
96 #
97 # Check for apps...
98 #
99 def CheckForApp( context, app ):
100         context.Message( "Checking if '%s' executes... " % app )
101         ret = context.env.WhereIs( app )
102         if ret != "":
103                 context.Result( True )
104         else:
105                 context.Result( False )
106         return ret
107
108
109 if not env.GetOption('clean'):
110         conf = Configure( env,
111                 custom_tests={ 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG, 'GetPKGFlags' : GetPKGFlags, 'CheckForApp' : CheckForApp },
112                 conf_dir="cache/" + build_base,
113                 log_file="cache/" + build_base + 'config.log' )
114
115         if not conf.CheckHeader( "stdio.h" ):
116                 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."
117                 Exit( 1 )
118
119         allpresent = 1;
120         allpresent &= conf.CheckHeader( "expat.h" )
121         allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
122        
123         allpresent &= conf.CheckForPKGConfig();
124
125         pkgs = {
126                 'libraw1394' : '1.3.0',
127                 'libavc1394' : '0.5.3',
128                 'libiec61883' : '1.1.0',
129                 'alsa' : '1.0.0',
130                 'libxml++-2.6' : '2.13.0',
131                 'liblo' : '0.22',
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         env['PYUIC'] = conf.CheckForApp( 'pyuic' )
149
150         env = conf.Finish()
151
152 if env['DEBUG']:
153         print "Doing a DEBUG build"
154         # -Werror could be added to, which would force the devs to really remove all the warnings :-)
155         env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
156 else:
157         env.AppendUnique( CCFLAGS=["-O2"] )
158
159 # this is required to indicate that the DBUS version we use has support
160 # for platform dependent threading init functions
161 # this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is
162 # always true
163 env.AppendUnique( CCFLAGS=["-DDBUS_HAS_THREADS_INIT_DEFAULT"] )
164
165 if env['ENABLE_ALL']:
166         env['ENABLE_BEBOB'] = True
167         env['ENABLE_FIREWORKS'] = True
168         env['ENABLE_MOTU'] = True
169         env['ENABLE_DICE'] = True
170         env['ENABLE_METRIC_HALO'] = True
171         env['ENABLE_RME'] = True
172         env['ENABLE_BOUNCE'] = True
173
174 if env['ENABLE_BEBOB'] or env['ENABLE_DICE'] or env['ENABLE_BOUNCE'] or env['ENABLE_FIREWORKS']:
175         env['ENABLE_GENERICAVC'] = True
176
177 if build_base:
178         env['build_base']="#/"+build_base
179 else:
180         env['build_base']="#/"
181
182 #
183 # XXX: Maybe we can even drop these lower-case variables and only use the uppercase ones?
184 #
185 env['bindir'] = os.path.join( env['BINDIR'] )
186 env['libdir'] = os.path.join( env['LIBDIR'] )
187 env['includedir'] = os.path.join( env['INCLUDEDIR'] )
188 env['sharedir'] = os.path.join( env['SHAREDIR'] )
189 env['cachedir'] = os.path.join( env['PREFIX'], "var/cache/libffado" )
190
191 env.Alias( "install", env['libdir'] )
192 env.Alias( "install", env['includedir'] )
193
194 env['PACKAGE'] = "libffado"
195 env['VERSION'] = "1.999.6"
196 env['LIBVERSION'] = "1.0.0"
197
198 #
199 # To have the top_srcdir as the doxygen-script is used from auto*
200 #
201 env['top_srcdir'] = env.Dir( "." ).abspath
202
203 #
204 # Start building
205 #
206
207 env.ScanReplace( "config.h.in" )
208
209 pkgconfig = env.ScanReplace( "libffado.pc.in" )
210 env.Alias( "install", env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) )
211
212 subdirs=['external','src','libffado','tests','support','doc']
213 if build_base:
214         env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir )
215 else:
216         env.SConscript( dirs=subdirs, exports="env" )
217
218
219 # By default only src is built but all is cleaned
220 if not env.GetOption('clean'):
221     Default( 'external' )
222     Default( 'src' )
223     if env['BUILD_TESTS']:
224         Default( 'tests' )
225     # Cachedir has to be fixed...
226     #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) )
227     #env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) )
Note: See TracBrowser for help on using the browser.