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