source: wscript @ 917d4c1

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

wscript: add arm64

  • Property mode set to 100644
File size: 9.5 KB
RevLine 
[5c411dc]1#! /usr/bin/python
[110ac90]2#
[21ee709]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
[ee36175]11#  - doc: add doxygen
[110ac90]12#  - tests: move to new unit test system
[000b090]13
14APPNAME = 'aubio'
[5820107]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]])
[e565c649]24
25import os.path, sys
26if os.path.exists('src/config.h') or os.path.exists('Makefile'):
[7684ff2]27    print "Please run 'make distclean' to clean-up autotools files before using waf"
[e565c649]28    sys.exit(1)
29
[46378b3]30top = '.'
31out = 'build'
[000b090]32
[3819aca]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,
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
[d41bc4d]46def options(ctx):
[3819aca]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
[d41bc4d]64  ctx.add_option('--with-target-platform', type='string',
[5c411dc]65      help='set target platform for cross-compilation', dest='target_platform')
[d41bc4d]66  ctx.load('compiler_c')
67  ctx.load('waf_unit_test')
[f4aa258]68  ctx.load('gnu_dirs')
[000b090]69
[d41bc4d]70def configure(ctx):
[6ed0f4e]71  from waflib import Options
72  ctx.load('compiler_c')
[d41bc4d]73  ctx.load('waf_unit_test')
[f4aa258]74  ctx.load('gnu_dirs')
[c57ecd9]75  ctx.env.CFLAGS += ['-g', '-Wall', '-Wextra']
[000b090]76
[5c411dc]77  if Options.options.target_platform:
78    Options.platform = Options.options.target_platform
[19ddbf3]79    ctx.env['DEST_OS'] = Options.platform
[5c411dc]80
81  if Options.platform == 'win32':
[d41bc4d]82    ctx.env['shlib_PATTERN'] = 'lib%s.dll'
[5c411dc]83
[956e113]84  if Options.platform == 'darwin':
[d6001bf]85    ctx.env.CFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
86    ctx.env.LINKFLAGS += ['-arch', 'i386', '-arch', 'x86_64']
[54dd945]87    ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
88    ctx.define('HAVE_ACCELERATE', 1)
[d6001bf]89
[4084cd8]90  if Options.platform in [ 'ios', 'iosimulator' ]:
[54dd945]91    ctx.define('HAVE_ACCELERATE', 1)
[5e1c04f]92    ctx.define('TARGET_OS_IPHONE', 1)
[4084cd8]93    ctx.env.FRAMEWORK = ['CoreFoundation', 'AudioToolbox', 'Accelerate']
94    SDKVER="7.0"
95    MINSDKVER="6.1"
[19ddbf3]96    ctx.env.CFLAGS += ['-std=c99']
[4084cd8]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()
[917d4c1]100        ctx.env.CFLAGS += [ '-arch', 'arm64' ]
[4084cd8]101        ctx.env.CFLAGS += [ '-arch', 'armv7' ]
102        ctx.env.CFLAGS += [ '-arch', 'armv7s' ]
[917d4c1]103        ctx.env.LINKFLAGS += [ '-arch', 'arm64' ]
[4084cd8]104        ctx.env.LINKFLAGS += ['-arch', 'armv7']
105        ctx.env.LINKFLAGS += ['-arch', 'armv7s']
[19ddbf3]106        ctx.env.CFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
107        ctx.env.LINKFLAGS += [ '-miphoneos-version-min=' + MINSDKVER ]
[4084cd8]108    else:
109        DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer"
110        SDKROOT="%(DEVROOT)s/SDKs/iPhoneSimulator%(SDKVER)s.sdk" % locals()
111        ctx.env.CFLAGS += [ '-arch', 'i386' ]
[0c11dfa]112        ctx.env.CFLAGS += [ '-arch', 'x86_64' ]
[917d4c1]113        ctx.env.LINKFLAGS += ['-arch', 'i386']
[0c11dfa]114        ctx.env.LINKFLAGS += ['-arch', 'x86_64']
[19ddbf3]115        ctx.env.CFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
116        ctx.env.LINKFLAGS += [ '-mios-simulator-version-min=' + MINSDKVER ]
117    ctx.env.CFLAGS += [ '-isysroot' , SDKROOT]
118    ctx.env.LINKFLAGS += [ '-isysroot' , SDKROOT]
[a1da37f]119
[000b090]120  # check for required headers
[d41bc4d]121  ctx.check(header_name='stdlib.h')
122  ctx.check(header_name='stdio.h')
123  ctx.check(header_name='math.h')
124  ctx.check(header_name='string.h')
125  ctx.check(header_name='limits.h')
[000b090]126
[0318cc1]127  # check support for C99 __VA_ARGS__ macros
128  check_c99_varargs = '''
129#include <stdio.h>
130#define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
131'''
132  if ctx.check_cc(fragment = check_c99_varargs,
133      type='cstlib',
134      msg = 'Checking for C99 __VA_ARGS__ macro'):
135    ctx.define('HAVE_C99_VARARGS_MACROS', 1)
136
[000b090]137  # optionally use complex.h
[62b8ab2]138  if (Options.options.enable_complex == True):
[d41bc4d]139    ctx.check(header_name='complex.h')
[000b090]140
[2e4fb04]141  # check dependencies
[0318cc1]142  if (Options.options.enable_sndfile != False):
143      ctx.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
144        args = '--cflags --libs', mandatory = False)
145  if (Options.options.enable_samplerate != False):
[d41bc4d]146      ctx.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
[0318cc1]147        args = '--cflags --libs', mandatory = False)
[000b090]148
[06d30f9]149  # double precision mode
150  if (Options.options.enable_double == True):
[d41bc4d]151    ctx.define('HAVE_AUBIO_DOUBLE', 1)
[06d30f9]152  else:
[d41bc4d]153    ctx.define('HAVE_AUBIO_DOUBLE', 0)
[06d30f9]154
[36f954a]155  # optional dependancies using pkg-config
[002563f]156  if (Options.options.enable_fftw3 != False or Options.options.enable_fftw3f != False):
[0318cc1]157    # one of fftwf or fftw3f
158    if (Options.options.enable_fftw3f != False):
159      ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
160          args = '--cflags --libs', mandatory = False)
161      if (Options.options.enable_double == True):
162        ctx.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!')
[36f954a]163    else:
[0318cc1]164      # fftw3f not enabled, take most sensible one according to enable_double
165      if (Options.options.enable_double == True):
166        ctx.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
167            args = '--cflags --libs', mandatory = False)
168      else:
169        ctx.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
170            args = '--cflags --libs', mandatory = False)
171    ctx.define('HAVE_FFTW3', 1)
[5dc9f33]172
173  # fftw disabled, use ooura
174  if 'HAVE_FFTW3F' in ctx.env.define_key:
175    ctx.msg('Checking for FFT implementation', 'fftw3f')
176  elif 'HAVE_FFTW3' in ctx.env.define_key:
177    ctx.msg('Checking for FFT implementation', 'fftw3')
178  elif 'HAVE_ACCELERATE' in ctx.env.define_key:
179    ctx.msg('Checking for FFT implementation', 'vDSP')
[0318cc1]180  else:
[5dc9f33]181    ctx.msg('Checking for FFT implementation', 'ooura')
[000b090]182
[0318cc1]183  if (Options.options.enable_jack != False):
184    ctx.check_cfg(package = 'jack', atleast_version = '0.15.0',
185    args = '--cflags --libs', mandatory = False)
186
187  if (Options.options.enable_lash != False):
188    ctx.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
189    args = '--cflags --libs', uselib_store = 'LASH', mandatory = False)
[000b090]190
191  # write configuration header
[d41bc4d]192  ctx.write_config_header('src/config.h')
[000b090]193
[110ac90]194  # add some defines used in examples
[d41bc4d]195  ctx.define('AUBIO_PREFIX', ctx.env['PREFIX'])
196  ctx.define('PACKAGE', APPNAME)
[000b090]197
198  # check if docbook-to-man is installed, optional
[110ac90]199  try:
[d41bc4d]200    ctx.find_program('docbook-to-man', var='DOCBOOKTOMAN')
201  except ctx.errors.ConfigurationError:
202    ctx.to_log('docbook-to-man was not found (ignoring)')
[000b090]203
[6ed0f4e]204def build(bld):
205  bld.env['VERSION'] = VERSION
206  bld.env['LIB_VERSION'] = LIB_VERSION
[000b090]207
208  # add sub directories
[81fe3273]209  bld.recurse('src')
[19ddbf3]210  if bld.env['DEST_OS'] not in ['ios', 'iosimulator']:
[81fe3273]211      bld.recurse('examples')
212      bld.recurse('tests')
[000b090]213
[e57859f]214  bld( source = 'aubio.pc.in' )
215
[000b090]216  # build manpages from sgml files
[65860ff]217  if bld.env['DOCBOOKTOMAN']:
218    from waflib import TaskGen
[733aea2]219    if 'MANDIR' not in bld.env:
220      bld.env['MANDIR'] = bld.env['PREFIX'] + '/share/man'
[000b090]221    TaskGen.declare_chain(
[733aea2]222        name      = 'docbooktoman',
223        rule      = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
224        ext_in    = '.sgml',
225        ext_out   = '.1',
226        reentrant = False,
227        install_path =  '${MANDIR}/man1',
[000b090]228    )
[733aea2]229    bld( source = bld.path.ant_glob('doc/*.sgml') )
[30250de]230
[50d56cc]231  """
232  bld(rule = 'doxygen ${SRC}', source = 'web.cfg') #, target = 'doc/web/index.html')
233  """
234
235
[30250de]236def shutdown(bld):
237    from waflib import Options, Logs
[4084cd8]238    if Options.platform in ['ios', 'iosimulator']:
[30250de]239          msg ='aubio built for ios, contact the author for a commercial license'
240          Logs.pprint('RED', msg)
241          msg ='   Paul Brossier <piem@aubio.org>'
242          Logs.pprint('RED', msg)
[b4d1ba1]243
244
245def dist(ctx):
246    ctx.excl  = ' **/.waf-1* **/*~ **/*.pyc **/*.swp **/.lock-w* **/.git*'
247    ctx.excl += ' **/build/*'
[22dd9dc]248    ctx.excl += ' **/python/gen **/python/build **/python/dist'
249    ctx.excl += ' **/**.zip **/**.tar.bz2'
[b4d1ba1]250    ctx.excl += ' **/doc/full/*'
251    ctx.excl += ' **/python/*.db'
252    ctx.excl += ' **/python.old/*'
Note: See TracBrowser for help on using the repository browser.