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 options(ctx): |
---|
34 | ctx.add_option('--enable-double', action='store_true', default=False, |
---|
35 | help='compile aubio in double precision mode') |
---|
36 | ctx.add_option('--enable-fftw3f', action='store_true', default=False, |
---|
37 | help='compile with fftw3f instead of ooura (recommended)') |
---|
38 | ctx.add_option('--enable-fftw3', action='store_true', default=False, |
---|
39 | help='compile with fftw3 instead of ooura (recommended in double precision)') |
---|
40 | ctx.add_option('--enable-complex', action='store_true', default=False, |
---|
41 | help='compile with C99 complex') |
---|
42 | ctx.add_option('--enable-jack', action='store_true', default=None, |
---|
43 | help='compile with jack support') |
---|
44 | ctx.add_option('--enable-lash', action='store_true', default=None, |
---|
45 | help='compile with lash support') |
---|
46 | ctx.add_option('--enable-sndfile', action='store_true', default=None, |
---|
47 | help='compile with libsndfile support') |
---|
48 | ctx.add_option('--enable-samplerate', action='store_true', default=None, |
---|
49 | help='compile with libsamplerate support') |
---|
50 | ctx.add_option('--with-target-platform', type='string', |
---|
51 | help='set target platform for cross-compilation', dest='target_platform') |
---|
52 | ctx.load('compiler_c') |
---|
53 | ctx.load('waf_unit_test') |
---|
54 | |
---|
55 | def configure(ctx): |
---|
56 | from waflib import Options |
---|
57 | ctx.load('compiler_c') |
---|
58 | ctx.load('waf_unit_test') |
---|
59 | ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra'] |
---|
60 | |
---|
61 | if Options.options.target_platform: |
---|
62 | Options.platform = Options.options.target_platform |
---|
63 | |
---|
64 | if Options.platform == 'win32': |
---|
65 | ctx.env['shlib_PATTERN'] = 'lib%s.dll' |
---|
66 | |
---|
67 | if Options.platform == 'darwin': |
---|
68 | ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
69 | ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64'] |
---|
70 | ctx.env.CC = 'llvm-gcc-4.2' |
---|
71 | ctx.env.LINK_CC = 'llvm-gcc-4.2' |
---|
72 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
73 | ctx.define('HAVE_ACCELERATE', 1) |
---|
74 | |
---|
75 | if Options.platform == 'ios': |
---|
76 | ctx.env.CC = 'clang' |
---|
77 | ctx.env.LD = 'clang' |
---|
78 | ctx.env.LINK_CC = 'clang' |
---|
79 | SDKVER="6.1" |
---|
80 | DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer" |
---|
81 | SDKROOT="%(DEVROOT)s/SDKs/iPhoneOS%(SDKVER)s.sdk" % locals() |
---|
82 | ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate'] |
---|
83 | ctx.define('HAVE_ACCELERATE', 1) |
---|
84 | ctx.env.CFLAGS += [ '-miphoneos-version-min=6.1', '-arch', 'armv7', |
---|
85 | '--sysroot=%s' % SDKROOT] |
---|
86 | ctx.env.LINKFLAGS += ['-std=c99', '-arch', 'armv7', '--sysroot=%s' % |
---|
87 | SDKROOT] |
---|
88 | |
---|
89 | # check for required headers |
---|
90 | ctx.check(header_name='stdlib.h') |
---|
91 | ctx.check(header_name='stdio.h') |
---|
92 | ctx.check(header_name='math.h') |
---|
93 | ctx.check(header_name='string.h') |
---|
94 | ctx.check(header_name='limits.h') |
---|
95 | |
---|
96 | # check support for C99 __VA_ARGS__ macros |
---|
97 | check_c99_varargs = ''' |
---|
98 | #include <stdio.h> |
---|
99 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
100 | ''' |
---|
101 | if ctx.check_cc(fragment = check_c99_varargs, |
---|
102 | type='cstlib', |
---|
103 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
104 | ctx.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
105 | |
---|
106 | # optionally use complex.h |
---|
107 | if (Options.options.enable_complex == True): |
---|
108 | ctx.check(header_name='complex.h') |
---|
109 | |
---|
110 | # check dependencies |
---|
111 | if (Options.options.enable_sndfile != False): |
---|
112 | ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
113 | args = '--cflags --libs', mandatory = False) |
---|
114 | if (Options.options.enable_samplerate != False): |
---|
115 | ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
116 | args = '--cflags --libs', mandatory = False) |
---|
117 | |
---|
118 | # double precision mode |
---|
119 | if (Options.options.enable_double == True): |
---|
120 | ctx.define('HAVE_AUBIO_DOUBLE', 1) |
---|
121 | else: |
---|
122 | ctx.define('HAVE_AUBIO_DOUBLE', 0) |
---|
123 | |
---|
124 | # optional dependancies using pkg-config |
---|
125 | if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False): |
---|
126 | # one of fftwf or fftw3f |
---|
127 | if (Options.options.enable_fftw3f != False): |
---|
128 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
129 | args = '--cflags --libs', mandatory = False) |
---|
130 | if (Options.options.enable_double == True): |
---|
131 | ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!') |
---|
132 | else: |
---|
133 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
134 | if (Options.options.enable_double == True): |
---|
135 | ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
136 | args = '--cflags --libs', mandatory = False) |
---|
137 | else: |
---|
138 | ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
139 | args = '--cflags --libs', mandatory = False) |
---|
140 | ctx.define('HAVE_FFTW3', 1) |
---|
141 | else: |
---|
142 | # fftw disabled, use ooura |
---|
143 | if 'HAVE_ACCELERATE' in ctx.env.define_key: |
---|
144 | ctx.msg('Checking for FFT implementation', 'vDSP') |
---|
145 | else: |
---|
146 | ctx.msg('Checking for FFT implementation', 'ooura') |
---|
147 | pass |
---|
148 | |
---|
149 | if (Options.options.enable_jack != False): |
---|
150 | ctx.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
151 | args = '--cflags --libs', mandatory = False) |
---|
152 | |
---|
153 | if (Options.options.enable_lash != False): |
---|
154 | ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
155 | args = '--cflags --libs', uselib_store = 'LASH', mandatory = False) |
---|
156 | |
---|
157 | # write configuration header |
---|
158 | ctx.write_config_header('src/config.h') |
---|
159 | |
---|
160 | # add some defines used in examples |
---|
161 | ctx.define('AUBIO_PREFIX', ctx.env['PREFIX']) |
---|
162 | ctx.define('PACKAGE', APPNAME) |
---|
163 | |
---|
164 | # check if docbook-to-man is installed, optional |
---|
165 | try: |
---|
166 | ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN') |
---|
167 | except ctx.errors.ConfigurationError: |
---|
168 | ctx.to_log('docbook-to-man was not found (ignoring)') |
---|
169 | |
---|
170 | def build(bld): |
---|
171 | bld.env['VERSION'] = VERSION |
---|
172 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
173 | |
---|
174 | # add sub directories |
---|
175 | bld.recurse('src') |
---|
176 | from waflib import Options |
---|
177 | if Options.platform != 'ios': |
---|
178 | bld.recurse('examples') |
---|
179 | bld.recurse('tests') |
---|
180 | |
---|
181 | """ |
---|
182 | # create the aubio.pc file for pkg-config |
---|
183 | if ctx.env['TARGET_PLATFORM'] == 'linux': |
---|
184 | aubiopc = ctx.new_task_gen('subst') |
---|
185 | aubiopc.source = 'aubio.pc.in' |
---|
186 | aubiopc.target = 'aubio.pc' |
---|
187 | aubiopc.install_path = '${PREFIX}/lib/pkgconfig' |
---|
188 | |
---|
189 | # build manpages from sgml files |
---|
190 | if ctx.env['DOCBOOKTOMAN']: |
---|
191 | import TaskGen |
---|
192 | TaskGen.declare_chain( |
---|
193 | name = 'docbooktoman', |
---|
194 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
195 | ext_in = '.sgml', |
---|
196 | ext_out = '.1', |
---|
197 | reentrant = 0, |
---|
198 | ) |
---|
199 | manpages = ctx.new_task_gen(name = 'docbooktoman', |
---|
200 | source=ctx.path.ant_glob('doc/*.sgml')) |
---|
201 | ctx.install_files('${MANDIR}/man1', ctx.path.ant_glob('doc/*.1')) |
---|
202 | |
---|
203 | # install woodblock sound |
---|
204 | bld.install_files('${PREFIX}/share/sounds/aubio/', |
---|
205 | 'sounds/woodblock.aiff') |
---|
206 | """ |
---|
207 | |
---|
208 | def shutdown(bld): |
---|
209 | from waflib import Options, Logs |
---|
210 | if Options.platform == 'ios': |
---|
211 | msg ='aubio built for ios, contact the author for a commercial license' |
---|
212 | Logs.pprint('RED', msg) |
---|
213 | msg =' Paul Brossier <piem@aubio.org>' |
---|
214 | Logs.pprint('RED', msg) |
---|