source: wscript @ 3da8187

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 3da8187 was 1b25a70, checked in by Paul Brossier <piem@piem.org>, 11 years ago

examples/: move parse_args to parse_args.h, clean up, remove lash and old frames_delay

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