1 |
#! /usr/bin/python |
---|
2 |
# |
---|
3 |
# Copyright (C) 2007-2008 Arnold Krille |
---|
4 |
# Copyright (C) 2007-2008 Pieter Palmers |
---|
5 |
# Copyright (C) 2008 Jonathan Woithe |
---|
6 |
# |
---|
7 |
# This file is part of FFADO |
---|
8 |
# FFADO = Free Firewire (pro-)audio drivers for linux |
---|
9 |
# |
---|
10 |
# FFADO is based upon FreeBoB. |
---|
11 |
# |
---|
12 |
# This program is free software: you can redistribute it and/or modify |
---|
13 |
# it under the terms of the GNU General Public License as published by |
---|
14 |
# the Free Software Foundation, either version 2 of the License, or |
---|
15 |
# (at your option) version 3 of the License. |
---|
16 |
# |
---|
17 |
# This program is distributed in the hope that it will be useful, |
---|
18 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
19 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
20 |
# GNU General Public License for more details. |
---|
21 |
# |
---|
22 |
# You should have received a copy of the GNU General Public License |
---|
23 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
24 |
# |
---|
25 |
|
---|
26 |
FFADO_API_VERSION="8" |
---|
27 |
FFADO_VERSION="1.999.41" |
---|
28 |
|
---|
29 |
import os |
---|
30 |
import re |
---|
31 |
from string import Template |
---|
32 |
import imp |
---|
33 |
|
---|
34 |
build_dir = ARGUMENTS.get('BUILDDIR', "") |
---|
35 |
if build_dir: |
---|
36 |
build_base=build_dir+'/' |
---|
37 |
if not os.path.isdir( build_base ): |
---|
38 |
os.makedirs( build_base ) |
---|
39 |
print "Building into: " + build_base |
---|
40 |
else: |
---|
41 |
build_base='' |
---|
42 |
|
---|
43 |
if not os.path.isdir( "cache" ): |
---|
44 |
os.makedirs( "cache" ) |
---|
45 |
|
---|
46 |
opts = Options( "cache/"+build_base+"options.cache" ) |
---|
47 |
|
---|
48 |
# |
---|
49 |
# If this is just to display a help-text for the variable used via ARGUMENTS, then its wrong... |
---|
50 |
opts.Add( "BUILDDIR", "Path to place the built files in", "") |
---|
51 |
|
---|
52 |
opts.AddOptions( |
---|
53 |
BoolOption( "DEBUG", """\ |
---|
54 |
Toggle debug-build. DEBUG means \"-g -Wall\" and more, otherwise we will use |
---|
55 |
\"-O2\" to optimize.""", True ), |
---|
56 |
BoolOption( "PROFILE", "Build with symbols and other profiling info", False ), |
---|
57 |
PathOption( "PREFIX", "The prefix where ffado will be installed to.", "/usr/local", PathOption.PathAccept ), |
---|
58 |
PathOption( "BINDIR", "Overwrite the directory where apps are installed to.", "$PREFIX/bin", PathOption.PathAccept ), |
---|
59 |
PathOption( "LIBDIR", "Overwrite the directory where libs are installed to.", "$PREFIX/lib", PathOption.PathAccept ), |
---|
60 |
PathOption( "INCLUDEDIR", "Overwrite the directory where headers are installed to.", "$PREFIX/include", PathOption.PathAccept ), |
---|
61 |
PathOption( "SHAREDIR", "Overwrite the directory where misc shared files are installed to.", "$PREFIX/share/libffado", PathOption.PathAccept ), |
---|
62 |
BoolOption( "ENABLE_BEBOB", "Enable/Disable the bebob part.", True ), |
---|
63 |
BoolOption( "ENABLE_FIREWORKS", "Enable/Disable the ECHO Audio FireWorks AV/C part.", True ), |
---|
64 |
BoolOption( "ENABLE_MOTU", "Enable/Disable the MOTU part.", True ), |
---|
65 |
BoolOption( "ENABLE_GENERICAVC", """\ |
---|
66 |
Enable/Disable the the generic avc part (mainly used by apple). |
---|
67 |
Note that disabling this option might be overwritten by other devices needing |
---|
68 |
this code.""", False ), |
---|
69 |
BoolOption( "ENABLE_ALL", "Enable/Disable support for all devices.", False ), |
---|
70 |
BoolOption( "SERIALIZE_USE_EXPAT", "Use libexpat for XML serialization.", False ), |
---|
71 |
BoolOption( "BUILD_TESTS", """\ |
---|
72 |
Build the tests in their directory. As some contain quite some functionality, |
---|
73 |
this is on by default. |
---|
74 |
If you just want to use ffado with jack without the tools, you can disable this.\ |
---|
75 |
""", True ), |
---|
76 |
BoolOption( "BUILD_STATIC_TOOLS", "Build a statically linked version of the FFADO tools.", False ), |
---|
77 |
EnumOption('DIST_TARGET', 'Build target for cross compiling packagers', 'auto', allowed_values=('auto', 'i386', 'i686', 'x86_64', 'powerpc', 'powerpc64', 'none' ), ignorecase=2), |
---|
78 |
BoolOption( "ENABLE_OPTIMIZATIONS", "Enable optimizations and the use of processor specific extentions (MMX/SSE/...).", False ), |
---|
79 |
|
---|
80 |
) |
---|
81 |
|
---|
82 |
## Load the builders in config |
---|
83 |
buildenv=os.environ |
---|
84 |
vars_to_check = [ |
---|
85 |
'PATH', |
---|
86 |
'PKG_CONFIG_PATH', |
---|
87 |
'LD_LIBRARY_PATH', |
---|
88 |
'XDG_CONFIG_DIRS', |
---|
89 |
'XDG_DATA_DIRS', |
---|
90 |
'HOME', |
---|
91 |
'CC', |
---|
92 |
'CFLAGS', |
---|
93 |
'CXX', |
---|
94 |
'CXXFLAGS', |
---|
95 |
'CPPFLAGS', |
---|
96 |
] |
---|
97 |
for var in vars_to_check: |
---|
98 |
if os.environ.has_key(var): |
---|
99 |
buildenv[var]=os.environ[var] |
---|
100 |
else: |
---|
101 |
buildenv[var]='' |
---|
102 |
|
---|
103 |
env = Environment( tools=['default','scanreplace','pyuic','pyuic4','dbus','doxygen','pkgconfig'], toolpath=['admin'], ENV = buildenv, options=opts ) |
---|
104 |
|
---|
105 |
if os.environ.has_key('LDFLAGS'): |
---|
106 |
env['LINKFLAGS'] = os.environ['LDFLAGS'] |
---|
107 |
|
---|
108 |
# grab OS CFLAGS / CCFLAGS |
---|
109 |
env['OS_CFLAGS']=[] |
---|
110 |
if os.environ.has_key('CFLAGS'): |
---|
111 |
env['OS_CFLAGS'] = os.environ['CFLAGS'] |
---|
112 |
env['OS_CCFLAGS']=[] |
---|
113 |
if os.environ.has_key('CCFLAGS'): |
---|
114 |
env['OS_CCFLAGS'] = os.environ['CCFLAGS'] |
---|
115 |
|
---|
116 |
Help( """ |
---|
117 |
For building ffado you can set different options as listed below. You have to |
---|
118 |
specify them only once, scons will save the last value you used and re-use |
---|
119 |
that. |
---|
120 |
To really undo your settings and return to the factory defaults, remove the |
---|
121 |
"cache"-folder and the file ".sconsign.dblite" from this directory. |
---|
122 |
For example with: "rm -Rf .sconsign.dblite cache" |
---|
123 |
|
---|
124 |
Note that this is a development version! Don't complain if its not working! |
---|
125 |
See www.ffado.org for stable releases. |
---|
126 |
""" ) |
---|
127 |
Help( opts.GenerateHelpText( env ) ) |
---|
128 |
|
---|
129 |
# make sure the necessary dirs exist |
---|
130 |
if not os.path.isdir( "cache/" + build_base ): |
---|
131 |
os.makedirs( "cache/" + build_base ) |
---|
132 |
if not os.path.isdir( 'cache/objects' ): |
---|
133 |
os.makedirs( 'cache/objects' ) |
---|
134 |
|
---|
135 |
CacheDir( 'cache/objects' ) |
---|
136 |
|
---|
137 |
opts.Save( 'cache/' + build_base + "options.cache", env ) |
---|
138 |
|
---|
139 |
def ConfigGuess( context ): |
---|
140 |
context.Message( "Trying to find the system triple: " ) |
---|
141 |
ret = os.popen( "admin/config.guess" ).read()[:-1] |
---|
142 |
context.Result( ret ) |
---|
143 |
return ret |
---|
144 |
|
---|
145 |
def CheckForApp( context, app ): |
---|
146 |
context.Message( "Checking whether '" + app + "' executes " ) |
---|
147 |
ret = context.TryAction( app ) |
---|
148 |
context.Result( ret[0] ) |
---|
149 |
return ret[0] |
---|
150 |
|
---|
151 |
def CheckForPyModule( context, module ): |
---|
152 |
context.Message( "Checking for the python module '" + module + "' " ) |
---|
153 |
ret = context.TryAction( "python $SOURCE", "import %s" % module, ".py" ) |
---|
154 |
context.Result( ret[0] ) |
---|
155 |
return ret[0] |
---|
156 |
|
---|
157 |
def CompilerCheck( context ): |
---|
158 |
context.Message( "Checking for a working C-compiler " ) |
---|
159 |
ret = context.TryRun( """ |
---|
160 |
#include <stdlib.h> |
---|
161 |
|
---|
162 |
int main() { |
---|
163 |
printf( "Hello World!" ); |
---|
164 |
return 0; |
---|
165 |
}""", '.c' )[0] |
---|
166 |
context.Result( ret ) |
---|
167 |
if ret == 0: |
---|
168 |
return False; |
---|
169 |
context.Message( "Checking for a working C++-compiler " ) |
---|
170 |
ret = context.TryRun( """ |
---|
171 |
#include <iostream> |
---|
172 |
|
---|
173 |
int main() { |
---|
174 |
std::cout << "Hello World!" << std::endl; |
---|
175 |
return 0; |
---|
176 |
}""", ".cpp" )[0] |
---|
177 |
context.Result( ret ) |
---|
178 |
return ret |
---|
179 |
|
---|
180 |
tests = { |
---|
181 |
"ConfigGuess" : ConfigGuess, |
---|
182 |
"CheckForApp" : CheckForApp, |
---|
183 |
"CheckForPyModule": CheckForPyModule, |
---|
184 |
"CompilerCheck" : CompilerCheck, |
---|
185 |
} |
---|
186 |
tests.update( env['PKGCONFIG_TESTS'] ) |
---|
187 |
tests.update( env['PYUIC_TESTS'] ) |
---|
188 |
tests.update( env['PYUIC4_TESTS'] ) |
---|
189 |
|
---|
190 |
conf = Configure( env, |
---|
191 |
custom_tests = tests, |
---|
192 |
conf_dir = "cache/" + build_base, |
---|
193 |
log_file = "cache/" + build_base + 'config.log' ) |
---|
194 |
|
---|
195 |
if env['SERIALIZE_USE_EXPAT']: |
---|
196 |
env['SERIALIZE_USE_EXPAT']=1 |
---|
197 |
else: |
---|
198 |
env['SERIALIZE_USE_EXPAT']=0 |
---|
199 |
|
---|
200 |
if not env.GetOption('clean'): |
---|
201 |
# |
---|
202 |
# Check for working gcc and g++ compilers and their environment. |
---|
203 |
# |
---|
204 |
if not conf.CompilerCheck(): |
---|
205 |
print "\nIt seems as if your system isn't even able to compile any C-/C++-programs. Probably you don't have gcc and g++ installed. Compiling a package from source without a working compiler is very hard to do, please install the needed packages.\nHint: on *ubuntu you need both gcc- and g++-packages installed, easiest solution is to install build-essential which depends on gcc and g++." |
---|
206 |
Exit( 1 ) |
---|
207 |
|
---|
208 |
# Check for pkg-config before using pkg-config to check for other dependencies. |
---|
209 |
if not conf.CheckForPKGConfig(): |
---|
210 |
print "\nThe program 'pkg-config' could not be found.\nEither you have to install the corresponding package first or make sure that PATH points to the right directions." |
---|
211 |
Exit( 1 ) |
---|
212 |
|
---|
213 |
# |
---|
214 |
# The following checks are for headers and libs and packages we need. |
---|
215 |
# |
---|
216 |
allpresent = 1; |
---|
217 |
# for DBUS C++ bindings |
---|
218 |
allpresent &= conf.CheckHeader( "expat.h" ) |
---|
219 |
allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' ) |
---|
220 |
|
---|
221 |
pkgs = { |
---|
222 |
'libraw1394' : '1.3.0', |
---|
223 |
'libiec61883' : '1.1.0', |
---|
224 |
'dbus-1' : '1.0', |
---|
225 |
} |
---|
226 |
if not env['SERIALIZE_USE_EXPAT']: |
---|
227 |
pkgs['libxml++-2.6'] = '2.13.0' |
---|
228 |
|
---|
229 |
for pkg in pkgs: |
---|
230 |
name2 = pkg.replace("+","").replace(".","").replace("-","").upper() |
---|
231 |
env['%s_FLAGS' % name2] = conf.GetPKGFlags( pkg, pkgs[pkg] ) |
---|
232 |
if env['%s_FLAGS'%name2] == 0: |
---|
233 |
allpresent &= 0 |
---|
234 |
|
---|
235 |
if not allpresent: |
---|
236 |
print """ |
---|
237 |
(At least) One of the dependencies is missing. I can't go on without it, please |
---|
238 |
install the needed packages for each of the lines saying "no". |
---|
239 |
(Remember to also install the *-devel packages!) |
---|
240 |
|
---|
241 |
And remember to remove the cache with "rm -Rf .sconsign.dblite cache" so the |
---|
242 |
results above get rechecked. |
---|
243 |
""" |
---|
244 |
Exit( 1 ) |
---|
245 |
|
---|
246 |
# Check for C99 lrint() and lrintf() functions used to convert from |
---|
247 |
# float to integer more efficiently via float_cast.h. If not |
---|
248 |
# present the standard slower methods will be used instead. This |
---|
249 |
# might not be the best way of testing for these but it's the only |
---|
250 |
# way which seems to work properly. CheckFunc() fails due to |
---|
251 |
# argument count problems. |
---|
252 |
if env.has_key( 'CFLAGS' ): |
---|
253 |
oldcf = env['CFLAGS'] |
---|
254 |
else: |
---|
255 |
oldcf = "" |
---|
256 |
oldcf = env.Append(CFLAGS = '-std=c99') |
---|
257 |
if conf.CheckLibWithHeader( "m", "math.h", "c", "lrint(3.2);" ): |
---|
258 |
HAVE_LRINT = 1 |
---|
259 |
else: |
---|
260 |
HAVE_LRINT = 0 |
---|
261 |
if conf.CheckLibWithHeader( "m", "math.h", "c", "lrintf(3.2);" ): |
---|
262 |
HAVE_LRINTF = 1 |
---|
263 |
else: |
---|
264 |
HAVE_LRINTF = 0 |
---|
265 |
env['HAVE_LRINT'] = HAVE_LRINT; |
---|
266 |
env['HAVE_LRINTF'] = HAVE_LRINTF; |
---|
267 |
env.Replace(CFLAGS=oldcf) |
---|
268 |
|
---|
269 |
# |
---|
270 |
# Optional checks follow: |
---|
271 |
# |
---|
272 |
|
---|
273 |
# PyQT checks |
---|
274 |
build_mixer = False |
---|
275 |
if conf.CheckForApp( 'which pyuic4' ) and conf.CheckForPyModule( 'dbus' ) and conf.CheckForPyModule( 'PyQt4' ) and conf.CheckForPyModule( 'dbus.mainloop.qt' ): |
---|
276 |
env['PYUIC4'] = True |
---|
277 |
build_mixer = True |
---|
278 |
|
---|
279 |
if conf.CheckForApp( 'which pyuic' ) and conf.CheckForPyModule( 'dbus' ) and conf.CheckForPyModule( 'qt' ): |
---|
280 |
env['PYUIC'] = True |
---|
281 |
build_mixer = True |
---|
282 |
|
---|
283 |
if conf.CheckForApp( 'xdg-desktop-menu --help' ): |
---|
284 |
env['XDG_TOOLS'] = True |
---|
285 |
else: |
---|
286 |
print """ |
---|
287 |
I couldn't find the program 'xdg-desktop-menu'. Together with xdg-icon-resource |
---|
288 |
this is needed to add the fancy entry to your menu. But the mixer will be installed, you can start it by executing "ffado-mixer". |
---|
289 |
""" |
---|
290 |
|
---|
291 |
if not build_mixer and not env.GetOption('clean'): |
---|
292 |
print """ |
---|
293 |
I couldn't find all the prerequisites ('pyuic' / 'pyuic4' and the python-modules 'dbus' and |
---|
294 |
'qt' / 'PyQt4', the packages could be named like dbus-python and PyQt) to build the mixer. |
---|
295 |
Therefor neither the qt3 nor the qt4 mixer will get installed. |
---|
296 |
""" |
---|
297 |
|
---|
298 |
config_guess = conf.ConfigGuess() |
---|
299 |
|
---|
300 |
env = conf.Finish() |
---|
301 |
|
---|
302 |
if env['DEBUG']: |
---|
303 |
print "Doing a DEBUG build" |
---|
304 |
env.MergeFlags( "-DDEBUG -Wall -g" ) |
---|
305 |
else: |
---|
306 |
env.MergeFlags( "-O2 -DNDEBUG" ) |
---|
307 |
|
---|
308 |
if env['PROFILE']: |
---|
309 |
print "Doing a PROFILE build" |
---|
310 |
env.MergeFlags( "-Wall -g" ) |
---|
311 |
|
---|
312 |
|
---|
313 |
# this is required to indicate that the DBUS version we use has support |
---|
314 |
# for platform dependent threading init functions |
---|
315 |
# this is true for DBUS >= 0.96 or so. Since we require >= 1.0 it is |
---|
316 |
# always true |
---|
317 |
env.MergeFlags( "-DDBUS_HAS_THREADS_INIT_DEFAULT" ) |
---|
318 |
|
---|
319 |
if env['ENABLE_ALL']: |
---|
320 |
env['ENABLE_BEBOB'] = True |
---|
321 |
env['ENABLE_FIREWORKS'] = True |
---|
322 |
env['ENABLE_MOTU'] = True |
---|
323 |
|
---|
324 |
if env['ENABLE_BEBOB'] or env['ENABLE_FIREWORKS']: |
---|
325 |
env['ENABLE_GENERICAVC'] = True |
---|
326 |
|
---|
327 |
env['BUILD_STATIC_LIB'] = False |
---|
328 |
if env['BUILD_STATIC_TOOLS']: |
---|
329 |
print "Building static versions of the tools..." |
---|
330 |
env['BUILD_STATIC_LIB'] = True |
---|
331 |
|
---|
332 |
if build_base: |
---|
333 |
env['build_base']="#/"+build_base |
---|
334 |
else: |
---|
335 |
env['build_base']="#/" |
---|
336 |
|
---|
337 |
# |
---|
338 |
# Get the DESTDIR (if wanted) from the commandline |
---|
339 |
# |
---|
340 |
env.destdir = ARGUMENTS.get( 'DESTDIR', "" ) |
---|
341 |
|
---|
342 |
# |
---|
343 |
# Uppercase variables are for usage in code, lowercase versions for usage in |
---|
344 |
# scons-files for installing. |
---|
345 |
# |
---|
346 |
env['BINDIR'] = Template( env['BINDIR'] ).safe_substitute( env ) |
---|
347 |
env['LIBDIR'] = Template( env['LIBDIR'] ).safe_substitute( env ) |
---|
348 |
env['INCLUDEDIR'] = Template( env['INCLUDEDIR'] ).safe_substitute( env ) |
---|
349 |
env['SHAREDIR'] = Template( env['SHAREDIR'] ).safe_substitute( env ) |
---|
350 |
env['bindir'] = Template( env.destdir + env['BINDIR'] ).safe_substitute( env ) |
---|
351 |
env['libdir'] = Template( env.destdir + env['LIBDIR'] ).safe_substitute( env ) |
---|
352 |
env['includedir'] = Template( env.destdir + env['INCLUDEDIR'] ).safe_substitute( env ) |
---|
353 |
env['sharedir'] = Template( env.destdir + env['SHAREDIR'] ).safe_substitute( env ) |
---|
354 |
|
---|
355 |
env.Command( target=env['sharedir'], source="", action=Mkdir( env['sharedir'] ) ) |
---|
356 |
|
---|
357 |
env.Alias( "install", env['libdir'] ) |
---|
358 |
env.Alias( "install", env['includedir'] ) |
---|
359 |
env.Alias( "install", env['sharedir'] ) |
---|
360 |
env.Alias( "install", env['bindir'] ) |
---|
361 |
|
---|
362 |
# |
---|
363 |
# shamelessly copied from the Ardour scons file |
---|
364 |
# |
---|
365 |
|
---|
366 |
opt_flags = [] |
---|
367 |
env['USE_SSE'] = 0 |
---|
368 |
|
---|
369 |
# guess at the platform, used to define compiler flags |
---|
370 |
|
---|
371 |
config_cpu = 0 |
---|
372 |
config_arch = 1 |
---|
373 |
config_kernel = 2 |
---|
374 |
config_os = 3 |
---|
375 |
config = config_guess.split ("-") |
---|
376 |
|
---|
377 |
needs_fPIC = False |
---|
378 |
|
---|
379 |
# Autodetect |
---|
380 |
if env['DIST_TARGET'] == 'auto': |
---|
381 |
if re.search ("x86_64", config[config_cpu]) != None: |
---|
382 |
env['DIST_TARGET'] = 'x86_64' |
---|
383 |
elif re.search("i[0-5]86", config[config_cpu]) != None: |
---|
384 |
env['DIST_TARGET'] = 'i386' |
---|
385 |
elif re.search("powerpc64", config[config_cpu]) != None: |
---|
386 |
env['DIST_TARGET'] = 'powerpc64' |
---|
387 |
elif re.search("powerpc", config[config_cpu]) != None: |
---|
388 |
env['DIST_TARGET'] = 'powerpc' |
---|
389 |
else: |
---|
390 |
env['DIST_TARGET'] = 'i686' |
---|
391 |
print "Detected DIST_TARGET = " + env['DIST_TARGET'] |
---|
392 |
|
---|
393 |
if ((re.search ("i[0-9]86", config[config_cpu]) != None) or (re.search ("x86_64", config[config_cpu]) != None) or (re.search ("powerpc", config[config_cpu]) != None)): |
---|
394 |
|
---|
395 |
build_host_supports_sse = 0 |
---|
396 |
build_host_supports_sse2 = 0 |
---|
397 |
build_host_supports_sse3 = 0 |
---|
398 |
|
---|
399 |
if config[config_kernel] == 'linux' : |
---|
400 |
|
---|
401 |
if (env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64'): |
---|
402 |
|
---|
403 |
flag_line = os.popen ("cat /proc/cpuinfo | grep '^flags'").read()[:-1] |
---|
404 |
x86_flags = flag_line.split (": ")[1:][0].split () |
---|
405 |
|
---|
406 |
if "mmx" in x86_flags: |
---|
407 |
opt_flags.append ("-mmmx") |
---|
408 |
if "sse" in x86_flags: |
---|
409 |
build_host_supports_sse = 1 |
---|
410 |
if "sse2" in x86_flags: |
---|
411 |
build_host_supports_sse2 = 1 |
---|
412 |
#if "sse3" in x86_flags: |
---|
413 |
#build_host_supports_sse3 = 1 |
---|
414 |
if "3dnow" in x86_flags: |
---|
415 |
opt_flags.append ("-m3dnow") |
---|
416 |
|
---|
417 |
if config[config_cpu] == "i586": |
---|
418 |
opt_flags.append ("-march=i586") |
---|
419 |
elif config[config_cpu] == "i686": |
---|
420 |
opt_flags.append ("-march=i686") |
---|
421 |
|
---|
422 |
elif (env['DIST_TARGET'] == 'powerpc') or (env['DIST_TARGET'] == 'powerpc64'): |
---|
423 |
|
---|
424 |
cpu_line = os.popen ("cat /proc/cpuinfo | grep '^cpu'").read()[:-1] |
---|
425 |
|
---|
426 |
ppc_type = cpu_line.split (": ")[1] |
---|
427 |
if re.search ("altivec", ppc_type) != None: |
---|
428 |
opt_flags.append ("-maltivec") |
---|
429 |
opt_flags.append ("-mabi=altivec") |
---|
430 |
|
---|
431 |
ppc_type = ppc_type.split (", ")[0] |
---|
432 |
if re.match ("74[0145][0578]A?", ppc_type) != None: |
---|
433 |
opt_flags.append ("-mcpu=7400") |
---|
434 |
opt_flags.append ("-mtune=7400") |
---|
435 |
elif re.match ("750", ppc_type) != None: |
---|
436 |
opt_flags.append ("-mcpu=750") |
---|
437 |
opt_flags.append ("-mtune=750") |
---|
438 |
elif re.match ("PPC970", ppc_type) != None: |
---|
439 |
opt_flags.append ("-mcpu=970") |
---|
440 |
opt_flags.append ("-mtune=970") |
---|
441 |
elif re.match ("Cell Broadband Engine", ppc_type) != None: |
---|
442 |
opt_flags.append ("-mcpu=cell") |
---|
443 |
opt_flags.append ("-mtune=cell") |
---|
444 |
|
---|
445 |
if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \ |
---|
446 |
and build_host_supports_sse and env['ENABLE_OPTIMIZATIONS']: |
---|
447 |
opt_flags.extend (["-msse", "-mfpmath=sse"]) |
---|
448 |
env['USE_SSE'] = 1 |
---|
449 |
|
---|
450 |
if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \ |
---|
451 |
and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']: |
---|
452 |
opt_flags.extend (["-msse2"]) |
---|
453 |
env['USE_SSE2'] = 1 |
---|
454 |
|
---|
455 |
#if ((env['DIST_TARGET'] == 'i686') or (env['DIST_TARGET'] == 'x86_64')) \ |
---|
456 |
#and build_host_supports_sse2 and env['ENABLE_OPTIMIZATIONS']: |
---|
457 |
#opt_flags.extend (["-msse3"]) |
---|
458 |
#env['USE_SSE3'] = 1 |
---|
459 |
|
---|
460 |
# build for 64-bit userland? |
---|
461 |
if env['DIST_TARGET'] == "powerpc64": |
---|
462 |
print "Doing a 64-bit PowerPC build" |
---|
463 |
env.MergeFlags( "-m64" ) |
---|
464 |
elif env['DIST_TARGET'] == "x86_64": |
---|
465 |
print "Doing a 64-bit x86 build" |
---|
466 |
env.MergeFlags( "-m64" ) |
---|
467 |
needs_fPIC = True |
---|
468 |
else: |
---|
469 |
print "Doing a 32-bit build" |
---|
470 |
env.MergeFlags( "-m32" ) |
---|
471 |
|
---|
472 |
if needs_fPIC or '-fPIC' in env['OS_CFLAGS'] or "-fPIC" in env['OS_CCFLAGS']: |
---|
473 |
env.MergeFlags( "-fPIC" ) |
---|
474 |
|
---|
475 |
# end of processor-specific section |
---|
476 |
if env['ENABLE_OPTIMIZATIONS']: |
---|
477 |
opt_flags.extend (["-fomit-frame-pointer","-ffast-math","-funroll-loops"]) |
---|
478 |
env.MergeFlags( opt_flags ) |
---|
479 |
print "Doing an optimized build..." |
---|
480 |
|
---|
481 |
env['REVISION'] = os.popen('svnversion .').read()[:-1] |
---|
482 |
# This may be as simple as '89' or as complex as '4123:4184M'. |
---|
483 |
# We'll just use the last bit. |
---|
484 |
env['REVISION'] = env['REVISION'].split(':')[-1] |
---|
485 |
|
---|
486 |
# try to circumvent localized versions |
---|
487 |
if len(env['REVISION']) >= 5 and env['REVISION'][0:6] == 'export': |
---|
488 |
env['REVISION'] = '' |
---|
489 |
|
---|
490 |
env['FFADO_API_VERSION']=FFADO_API_VERSION |
---|
491 |
|
---|
492 |
env['PACKAGE'] = "libffado" |
---|
493 |
env['VERSION'] = FFADO_VERSION |
---|
494 |
env['LIBVERSION'] = "1.0.0" |
---|
495 |
|
---|
496 |
env['CONFIGDIR'] = "~/.ffado" |
---|
497 |
env['CACHEDIR'] = "~/.ffado" |
---|
498 |
|
---|
499 |
env['USER_CONFIG_FILE'] = env['CONFIGDIR'] + "/configuration" |
---|
500 |
env['SYSTEM_CONFIG_FILE'] = env['SHAREDIR'] + "/configuration" |
---|
501 |
|
---|
502 |
env['REGISTRATION_URL'] = "http://ffado.org/deviceregistration/register.php?action=register" |
---|
503 |
|
---|
504 |
# |
---|
505 |
# To have the top_srcdir as the doxygen-script is used from auto* |
---|
506 |
# |
---|
507 |
env['top_srcdir'] = env.Dir( "." ).abspath |
---|
508 |
|
---|
509 |
# |
---|
510 |
# Start building |
---|
511 |
# |
---|
512 |
env.ScanReplace( "config.h.in" ) |
---|
513 |
# ensure that the config.h is updated with the version |
---|
514 |
|
---|
515 |
env.Depends( "config.h", "SConstruct" ) |
---|
516 |
env.Depends( "config.h", 'cache/' + build_base + "options.cache" ) |
---|
517 |
|
---|
518 |
# update config.h whenever the SVN revision changes |
---|
519 |
env.Depends( "config.h", env.Value(env['REVISION'])) |
---|
520 |
|
---|
521 |
env.Depends( "libffado.pc", "SConstruct" ) |
---|
522 |
pkgconfig = env.ScanReplace( "libffado.pc.in" ) |
---|
523 |
env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) |
---|
524 |
|
---|
525 |
env.Install( env['sharedir'], 'configuration' ) |
---|
526 |
|
---|
527 |
subdirs=['external','src','libffado','support','doc'] |
---|
528 |
if env['BUILD_TESTS']: |
---|
529 |
subdirs.append('tests') |
---|
530 |
|
---|
531 |
if build_base: |
---|
532 |
env.SConscript( dirs=subdirs, exports="env", build_dir=build_base+subdir ) |
---|
533 |
else: |
---|
534 |
env.SConscript( dirs=subdirs, exports="env" ) |
---|
535 |
|
---|
536 |
# By default only src is built but all is cleaned |
---|
537 |
if not env.GetOption('clean'): |
---|
538 |
Default( 'src' ) |
---|
539 |
Default( 'support' ) |
---|
540 |
if env['BUILD_TESTS']: |
---|
541 |
Default( 'tests' ) |
---|
542 |
|
---|
543 |
# |
---|
544 |
# Deal with the DESTDIR vs. xdg-tools conflict (which is basicely that the |
---|
545 |
# xdg-tools can't deal with DESTDIR, so the packagers have to deal with this |
---|
546 |
# their own :-/ |
---|
547 |
# |
---|
548 |
if len(env.destdir) > 0: |
---|
549 |
if not len( ARGUMENTS.get( "WILL_DEAL_WITH_XDG_MYSELF", "" ) ) > 0: |
---|
550 |
print """ |
---|
551 |
WARNING! |
---|
552 |
You are using the (packagers) option DESTDIR to install this package to a |
---|
553 |
different place than the real prefix. As the xdg-tools can't cope with |
---|
554 |
that, the .desktop-files are not installed by this build, you have to |
---|
555 |
deal with them your own. |
---|
556 |
(And you have to look into the SConstruct to learn how to disable this |
---|
557 |
message.) |
---|
558 |
""" |
---|
559 |
else: |
---|
560 |
|
---|
561 |
def CleanAction( action ): |
---|
562 |
if env.GetOption( "clean" ): |
---|
563 |
env.Execute( action ) |
---|
564 |
|
---|
565 |
if env.has_key( 'XDG_TOOLS' ) and env.has_key( 'PYUIC4' ): |
---|
566 |
if not env.GetOption("clean"): |
---|
567 |
action = "install" |
---|
568 |
else: |
---|
569 |
action = "uninstall" |
---|
570 |
mixerdesktopaction = env.Action( "xdg-desktop-menu %s support/xdg/ffado.org-ffadomixer.desktop" % action ) |
---|
571 |
mixericonaction = env.Action( "xdg-icon-resource %s --size 64 --novendor --context apps support/xdg/hi64-apps-ffado.png ffado" % action ) |
---|
572 |
env.Command( "__xdgstuff1", None, mixerdesktopaction ) |
---|
573 |
env.Command( "__xdgstuff2", None, mixericonaction ) |
---|
574 |
env.Alias( "install", ["__xdgstuff1", "__xdgstuff2" ] ) |
---|
575 |
CleanAction( mixerdesktopaction ) |
---|
576 |
CleanAction( mixericonaction ) |
---|
577 |
|
---|
578 |
# |
---|
579 |
# Create a tags-file for easier emacs/vim-source-browsing |
---|
580 |
# I don't know if the dependency is right... |
---|
581 |
# |
---|
582 |
findcommand = "find . \( -path \"*.h\" -o -path \"*.cpp\" -o -path \"*.c\" \) \! -path \"*.svn*\" \! -path \"./doc*\" \! -path \"./cache*\"" |
---|
583 |
env.Command( "tags", "", findcommand + " |xargs ctags" ) |
---|
584 |
env.Command( "TAGS", "", findcommand + " |xargs etags" ) |
---|
585 |
env.AlwaysBuild( "tags", "TAGS" ) |
---|
586 |
if 'NoCache' in dir(env): |
---|
587 |
env.NoCache( "tags", "TAGS" ) |
---|
588 |
|
---|
589 |
# Another convinience target |
---|
590 |
if env.GetOption( "clean" ): |
---|
591 |
env.Execute( "rm cache/objects -Rf" ) |
---|
592 |
|
---|