root/trunk/libffado/SConstruct

Revision 565, 6.6 kB (checked in by ppalmers, 15 years ago)

add support for out-of-tree building using 'scons BUILDDIR=target_build_dir'

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 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" ),
29         BoolOption( "ENABLE_BEBOB", "Enable/Disable the bebob part.", True ),
30         BoolOption( "ENABLE_GENERIC_AVC", "Enable/Disable the generic avc part (apple).", True ),
31         BoolOption( "ENABLE_MOTU", "Enable/Disable the Motu part.", False ),
32         BoolOption( "ENABLE_DICE", "Enable/Disable the DICE part.", False ),
33         BoolOption( "ENABLE_METRIC_HALO", "Enable/Disable the Metric Halo part.", False ),
34         BoolOption( "ENABLE_RME", "Enable/Disable the RME part.", False ),
35         BoolOption( "ENABLE_BOUNCE", "Enable/Disable the BOUNCE part.", False ),
36         BoolOption( "ENABLE_ALL", "Enable/Disable support for all devices.", False ),
37         BoolOption( "BUILD_TESTS", """
38 Build the tests in their directory. As some contain quite some functionality,
39 this is on by default.
40 If you just want to use ffado with jack without the tools, you can disable this.
41 """, True ),
42         )
43
44 ## Load the builders in config
45 env = Environment( tools=['default','scanreplace','pyuic'], toolpath=['admin'], ENV = { 'PATH' : os.environ['PATH'], 'PKG_CONFIG_PATH' : os.environ['PKG_CONFIG_PATH'] }, options=opts )
46
47 Help( """
48 For building ffado you can set different options as listed below. You have to
49 specify them only once, scons will save the last value you used and re-use
50 that.
51 To really undo your settings and return to the factory defaults, remove the
52 "cache"-folder and the file ".sconsign.dblite" from this directory.
53 For example with: "rm -Rf .sconsign.dblite cache"
54
55 Currently it seems as if only the BEBOB is kind-of-working, thats why only BEBOB
56 is enabled by default.
57
58 Note that this is a development version! Don't complain if its not working!
59 See www.ffado.org for stable releases.
60 """ )
61 Help( opts.GenerateHelpText( env ) )
62
63 # make sure the necessary dirs exist
64 if not os.path.isdir( "cache/" + build_base ):
65         os.makedirs( "cache/" + build_base )
66 if not os.path.isdir( "cache/" + build_base + 'objects' ):
67         os.makedirs( "cache/" + build_base + 'objects' )
68
69 CacheDir( 'cache/' + build_base + 'objects' )
70
71 opts.Save( 'cache/' + build_base + "options.cache", env )
72
73 if not env.GetOption('clean'):
74         conf = Configure( env, custom_tests={ 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG }, conf_dir="cache/" + build_base, log_file="cache/" + build_base + 'config.log' )
75
76         if not conf.CheckHeader( "stdio.h" ):
77                 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."
78                 Exit( 1 )
79
80         allpresent = 1;
81         allpresent &= conf.CheckForPKGConfig();
82         allpresent &= conf.CheckForPKG( 'libraw1394', "1.3.0" )
83         allpresent &= conf.CheckForPKG( 'libavc1394', "0.5.3" )
84         allpresent &= conf.CheckForPKG( 'libiec61883', "1.1.0" )
85         allpresent &= conf.CheckForPKG( 'alsa', "1.0.0" )
86         allpresent &= conf.CheckForPKG( 'libxml++-2.6', "2.13.0" )
87         allpresent &= conf.CheckForPKG( 'liblo', "0.22" )
88         allpresent &= conf.CheckForPKG( 'dbus-1', "1.0" )
89         allpresent &= conf.CheckHeader( "expat.h" )
90         allpresent &= conf.CheckLib( 'expat', 'XML_ExpatVersion', '#include <expat.h>' )
91        
92         if not allpresent:
93                 print """
94 (At least) One of the dependencies is missing. I can't go on without it, please
95 install the needed packages (remember to also install the *-devel packages)
96 """
97                 Exit( 1 )
98
99         env = conf.Finish()
100
101
102 if env['DEBUG']:
103         print "Doing a debug build"
104         # -Werror could be added to, which would force the devs to really remove all the warnings :-)
105         env.AppendUnique( CCFLAGS=["-DDEBUG","-Wall","-g"] )
106 else:
107         env.AppendUnique( CCFLAGS=["-O2"] )
108
109 if env['ENABLE_ALL']:
110         env['ENABLE_BEBOB'] = True
111         env['ENABLE_GENERIC_AVC'] = True
112         env['ENABLE_MOTU'] = True
113         env['ENABLE_DICE'] = True
114         env['ENABLE_METRIC_HALO'] = True
115         env['ENABLE_RME'] = True
116         env['ENABLE_BOUNCE'] = True
117
118 if env['ENABLE_BEBOB']:
119         env.AppendUnique( CCFLAGS=["-DENABLE_BEBOB"] )
120 if env['ENABLE_GENERIC_AVC']:
121         env.AppendUnique( CCFLAGS=["-DENABLE_GENERIC_AVC"] )
122 if env['ENABLE_MOTU']:
123         env.AppendUnique( CCFLAGS=["-DENABLE_MOTU"] )
124 if env['ENABLE_DICE']:
125         env.AppendUnique( CCFLAGS=["-DENABLE_DICE"] )
126 if env['ENABLE_METRIC_HALO']:
127         env.AppendUnique( CCFLAGS=["-DENABLE_METRIC_HALO"] )
128 if env['ENABLE_RME']:
129         env.AppendUnique( CCFLAGS=["-DENABLE_RME"] )
130 if env['ENABLE_BOUNCE']:
131         env.AppendUnique( CCFLAGS=["-DENABLE_BOUNCE"] )
132
133 env.MergeFlags( ["!pkg-config --cflags --libs libraw1394"] )
134 env.MergeFlags( ["!pkg-config --cflags --libs libavc1394"] )
135 env.MergeFlags( ["!pkg-config --cflags --libs libiec61883"] )
136 env.MergeFlags( ["!pkg-config --cflags --libs alsa"] )
137 env.MergeFlags( ["!pkg-config --cflags --libs libxml++-2.6"] )
138 env.MergeFlags( ["!pkg-config --cflags --libs liblo"] )
139
140
141 #
142 # Some includes in src/*/ are full path (src/*), that should be fixed?
143 env.AppendUnique( CPPPATH=["#/"] )
144
145 env['bindir'] = os.path.join( env['PREFIX'], "bin" )
146 env['libdir'] = os.path.join( env['PREFIX'], "lib" )
147 env['includedir'] = os.path.join( env['PREFIX'], "include" )
148 env['sharedir'] = os.path.join( env['PREFIX'], "share/libffado" )
149 env['cachedir'] = os.path.join( env['PREFIX'], "var/cache/libffado" )
150
151 env.Alias( "install", env['libdir'] )
152 env.Alias( "install", env['includedir'] )
153
154 env['PACKAGE'] = "libffado"
155 env['VERSION'] = "1.999.5"
156 env['LIBVERSION'] = "1.0.0"
157
158 #
159 # Start building
160 #
161
162 env.Command( "config.h.in", "config.h.in.scons", "cp $SOURCE $TARGET" )
163
164 env.ScanReplace( "config.h.in" )
165 pkgconfig = env.ScanReplace( "libffado.pc.in" )
166 env.Alias( "install", env.Install( env['libdir'] + '/pkgconfig', pkgconfig ) )
167
168
169 subdirs=['src','libffado','tests','support','external']
170 if build_base:
171         env['build_base']="#/"+build_base
172         for subdir in subdirs:
173                 env.SConscript( dirs=subdir, exports="env", build_dir=build_base+subdir )
174 else:
175         env['build_base']="#/"
176         env.SConscript( dirs=subdirs, exports="env" )
177
178
179 # By default only src is built but all is cleaned
180 if not env.GetOption('clean'):
181         Default( 'external' )
182         Default( 'src' )
183         if env['BUILD_TESTS']:
184                 Default( 'tests' )
185         #env.Alias( "install", env["cachedir"], os.makedirs( env["cachedir"] ) )
186         env.Alias( "install", env.Install( env["cachedir"], "" ) ) #os.makedirs( env["cachedir"] ) )
Note: See TracBrowser for help on using the browser.