root/trunk/libffado/SConstruct

Revision 570, 6.9 kB (checked in by arnonym, 15 years ago)

Make use of the exported FLAGS from the CheckForPkg?.

And I don't think the object-cache needs to be devided as scons is rather good at identifying not be file-descriptor but by a hash of filename and content and compile-flags...

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