1 | #! /usr/bin/python |
---|
2 | # |
---|
3 | # waf build script, see http://code.google.com/p/waf/ |
---|
4 | # usage: |
---|
5 | # $ waf distclean configure build |
---|
6 | # get it: |
---|
7 | # $ svn co http://waf.googlecode.com/svn/trunk /path/to/waf |
---|
8 | # $ alias waf=/path/to/waf/waf-light |
---|
9 | # |
---|
10 | # TODO |
---|
11 | # - doc: add doxygen |
---|
12 | # - tests: move to new unit test system |
---|
13 | |
---|
14 | APPNAME = 'aubio' |
---|
15 | |
---|
16 | # read from VERSION |
---|
17 | for l in open('VERSION').readlines(): exec (l.strip()) |
---|
18 | |
---|
19 | VERSION = '.'.join \ |
---|
20 | ([str(x) for x in [AUBIO_MAJOR_VERSION, AUBIO_MINOR_VERSION, AUBIO_PATCH_VERSION]]) \ |
---|
21 | + AUBIO_VERSION_STATUS |
---|
22 | LIB_VERSION = '.'.join \ |
---|
23 | ([str(x) for x in [LIBAUBIO_LT_CUR, LIBAUBIO_LT_REV, LIBAUBIO_LT_AGE]]) |
---|
24 | |
---|
25 | import os.path, sys |
---|
26 | if os.path.exists('src/config.h') or os.path.exists('Makefile'): |
---|
27 | print "Please run 'make distclean' to clean-up autotools files before using waf" |
---|
28 | sys.exit(1) |
---|
29 | |
---|
30 | top = '.' |
---|
31 | out = 'build' |
---|
32 | |
---|
33 | def add_option_enable_disable(ctx, name, default = None, help_str = None, help_disable_str = None): |
---|
34 | if help_str == None: |
---|
35 | help_str = 'enable ' + name + ' support' |
---|
36 | if help_disable_str == None: |
---|
37 | help_disable_str = 'do not ' + help_str |
---|
38 | ctx.add_option('--enable-' + name, action = 'store_true', default = default, |
---|
39 | dest = 'enable_' + name, |
---|
40 | help = help_str) |
---|
41 | ctx.add_option('--disable-' + name, action = 'store_false', |
---|
42 | #default = default, |
---|
43 | dest = 'enable_' + name, |
---|
44 | help = help_disable_str ) |
---|
45 | |
---|
46 | def options(ctx): |
---|
47 | add_option_enable_disable(ctx, 'double', default = False, |
---|
48 | help_str = 'compile aubio in double precision mode') |
---|
49 | add_option_enable_disable(ctx, 'fftw3f', default = False, |
---|
50 | help_str = 'compile with fftw3f instead of ooura (recommended)', help_disable_str = 'do not compile with fftw3f') |
---|
51 | add_option_enable_disable(ctx, 'fftw3', default = False, |
---|
52 | help_str = 'compile with fftw3 instead of ooura', help_disable_str = 'do not compile with fftw3') |
---|
53 | add_option_enable_disable(ctx, 'complex', default = False, |
---|
54 | help_str ='compile with C99 complex', help_disable_str = 'do not use C99 complex (default)' ) |
---|
55 | add_option_enable_disable(ctx, 'jack', default = None, |
---|
56 | help_str = 'compile with jack (auto)', help_disable_str = 'disable jack support') |
---|
57 | add_option_enable_disable(ctx, 'lash', default = None, |
---|
58 | help_str = 'compile with LASH (auto)', help_disable_str = 'disable LASH' ) |
---|
59 | add_option_enable_disable(ctx, 'sndfile', default = None, |
---|
60 | help_str = 'compile with sndfile (auto)', help_disable_str = 'disable sndfile') |
---|
61 | add_option_enable_disable(ctx, 'samplerate', default = None, |
---|
62 | help_str = 'compile with samplerate (auto)', help_disable_str = 'disable samplerate') |
---|
63 | |
---|
64 | ctx.add_option('--with-target-platform', type='string', |
---|
65 | help='set target platform for cross-compilation', dest='target_platform') |
---|
66 | ctx.load('compiler_c') |
---|
67 | ctx.load('waf_unit_test') |
---|
68 | ctx.load('gnu_dirs') |
---|
69 | |
---|
70 | def configure(ctx): |
---|
71 | from waflib import Options |
---|
72 | ctx.load('compiler_c') |
---|
73 | ctx.load('waf_unit_test') |
---|
74 | ctx.load('gnu_dirs') |
---|
75 | ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra'] |
---|
76 | |
---|
77 | if Options.options.target_platform: |
---|
78 | Options.platform = Options.options.target_platform |
---|
79 | ctx.env['DEST_OS'] = Options.platform |
---|
80 | |
---|
81 | if Options.platform == 'win32': |
---|
82 | ctx.env['shlib_PATTERN'] = 'lib%s.dll' |
---|
83 | |
---|
84 | if Options.platform == 'darwin': |
---|
85 | ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
86 | ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
87 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
88 | ctx.define('HAVE_ACCELERATE', 1) |
---|
89 | |
---|
90 | if Options.platform in [ 'ios', 'iosimulator' ]: |
---|
91 | ctx.define('HAVE_ACCELERATE', 1) |
---|
92 | ctx.define('TARGET_OS_IPHONE', 1) |
---|
93 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
94 | SDKVER="7.0" |
---|
95 | MINSDKVER="6.1" |
---|
96 | ctx.env.CFLAGS += ['-std=c99'] |
---|
97 | if Options.platform == 'ios': |
---|
98 | DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
99 | SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals() |
---|
100 | ctx.env.CFLAGS += [ '-arch', 'armv7' ] |
---|
101 | ctx.env.CFLAGS += [ '-arch', 'armv7s' ] |
---|
102 | ctx.env.LINKFLAGS += ['-arch', 'armv7'] |
---|
103 | ctx.env.LINKFLAGS += ['-arch', 'armv7s'] |
---|
104 | ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
105 | ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ] |
---|
106 | else: |
---|
107 | DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer" |
---|
108 | SDKROOT="%(DEVROOT)s/SDKs/iPhoneSimulator%(SDKVER)s.sdk" % locals() |
---|
109 | ctx.env.CFLAGS += [ '-arch', 'i386' ] |
---|
110 | ctx.env.LINKFLAGS += ['-arch', 'i386'] |
---|
111 | ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
112 | ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ] |
---|
113 | ctx.env.CFLAGS += [ '-isysroot' , SDKROOT] |
---|
114 | ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT] |
---|
115 | |
---|
116 | # check for required headers |
---|
117 | ctx.check(header_name='stdlib.h') |
---|
118 | ctx.check(header_name='stdio.h') |
---|
119 | ctx.check(header_name='math.h') |
---|
120 | ctx.check(header_name='string.h') |
---|
121 | ctx.check(header_name='limits.h') |
---|
122 | |
---|
123 | # check support for C99 __VA_ARGS__ macros |
---|
124 | check_c99_varargs = ''' |
---|
125 | #include <stdio.h> |
---|
126 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
127 | ''' |
---|
128 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
129 | type='cstlib', |
---|
130 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
131 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
132 | |
---|
133 | # optionally use complex.h |
---|
134 | if (Options.options.enable_complex == True): |
---|
135 | ctx.check(header_name='complex.h') |
---|
136 | |
---|
137 | # check dependencies |
---|
138 | if (Options.options.enable_sndfile != False): |
---|
139 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
140 | args = '--cflags --libs', mandatory = False) |
---|
141 | if (Options.options.enable_samplerate != False): |
---|
142 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
143 | args = '--cflags --libs', mandatory = False) |
---|
144 | |
---|
145 | # double precision mode |
---|
146 | if (Options.options.enable_double == True): |
---|
147 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
148 | else: |
---|
149 | ctx.define('HAVE_AUBIO_DOUBLE', 0) |
---|
150 | |
---|
151 | # optional dependancies using pkg-config |
---|
152 | if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False): |
---|
153 | # one of fftwf or fftw3f |
---|
154 | if (Options.options.enable_fftw3f != False): |
---|
155 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
156 | args = '--cflags --libs', mandatory = False) |
---|
157 | if (Options.options.enable_double == True): |
---|
158 | ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!') |
---|
159 | else: |
---|
160 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
161 | if (Options.options.enable_double == True): |
---|
162 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
163 | args = '--cflags --libs', mandatory = False) |
---|
164 | else: |
---|
165 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
166 | args = '--cflags --libs', mandatory = False) |
---|
167 | ctx.define('HAVE_FFTW3', 1) |
---|
168 | |
---|
169 | # fftw disabled, use ooura |
---|
170 | if 'HAVE_FFTW3F' in ctx.env.define_key: |
---|
171 | ctx.msg('Checking for FFT implementation', 'fftw3f') |
---|
172 | elif 'HAVE_FFTW3' in ctx.env.define_key: |
---|
173 | ctx.msg('Checking for FFT implementation', 'fftw3') |
---|
174 | elif 'HAVE_ACCELERATE' in ctx.env.define_key: |
---|
175 | ctx.msg('Checking for FFT implementation', 'vDSP') |
---|
176 | else: |
---|
177 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
178 | |
---|
179 | if (Options.options.enable_jack != False): |
---|
180 | ctx.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
181 | args = '--cflags --libs', mandatory = False) |
---|
182 | |
---|
183 | if (Options.options.enable_lash != False): |
---|
184 | ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
185 | args = '--cflags --libs', uselib_store = 'LASH', mandatory = False) |
---|
186 | |
---|
187 | # write configuration header |
---|
188 | ctx.write_config_header('src/config.h') |
---|
189 | |
---|
190 | # add some defines used in examples |
---|
191 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
192 | ctx.define('PACKAGE', APPNAME) |
---|
193 | |
---|
194 | # check if docbook-to-man is installed, optional |
---|
195 | try: |
---|
196 | ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN') |
---|
197 | except ctx.errors.ConfigurationError: |
---|
198 | ctx.to_log('docbook-to-man was not found (ignoring)') |
---|
199 | |
---|
200 | def build(bld): |
---|
201 | bld.env['VERSION'] = VERSION |
---|
202 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
203 | |
---|
204 | # add sub directories |
---|
205 | bld.recurse('src') |
---|
206 | if bld.env['DEST_OS'] not in ['ios', 'iosimulator']: |
---|
207 | bld.recurse('examples') |
---|
208 | bld.recurse('tests') |
---|
209 | |
---|
210 | """ |
---|
211 | # install woodblock sound |
---|
212 | bld.install_files('${PREFIX}/share/sounds/aubio/', |
---|
213 | 'sounds/woodblock.aiff') |
---|
214 | """ |
---|
215 | |
---|
216 | bld( source = 'aubio.pc.in' ) |
---|
217 | |
---|
218 | # build manpages from sgml files |
---|
219 | if bld.env['DOCBOOKTOMAN']: |
---|
220 | from waflib import TaskGen |
---|
221 | if 'MANDIR' not in bld.env: |
---|
222 | bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man' |
---|
223 | TaskGen.declare_chain( |
---|
224 | name = 'docbooktoman', |
---|
225 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
226 | ext_in = '.sgml', |
---|
227 | ext_out = '.1', |
---|
228 | reentrant = False, |
---|
229 | install_path = '${MANDIR}/man1', |
---|
230 | ) |
---|
231 | bld( source = bld.path.ant_glob('doc/*.sgml') ) |
---|
232 | |
---|
233 | """ |
---|
234 | bld(rule = 'doxygen ${SRC}', source = 'web.cfg') #, target = 'doc/web/index.html') |
---|
235 | """ |
---|
236 | |
---|
237 | |
---|
238 | def shutdown(bld): |
---|
239 | from waflib import Options, Logs |
---|
240 | if Options.platform in ['ios', 'iosimulator']: |
---|
241 | msg ='aubio built for ios, contact the author for a commercial license' |
---|
242 | Logs.pprint('RED', msg) |
---|
243 | msg =' Paul Brossier <piem@aubio.org>' |
---|
244 | Logs.pprint('RED', msg) |
---|
245 | |
---|
246 | |
---|
247 | def dist(ctx): |
---|
248 | ctx.excl = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git*' |
---|
249 | ctx.excl += ' **/build/*' |
---|
250 | ctx.excl += ' **/python/gen **/python/build **/python/dist' |
---|
251 | ctx.excl += ' **/**.zip **/**.tar.bz2' |
---|
252 | ctx.excl += ' **/doc/full/*' |
---|
253 | ctx.excl += ' **/python/*.db' |
---|
254 | ctx.excl += ' **/python.old/*' |
---|