source: wscript @ 7fd1831

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

wscript: move double towards the end, improve help

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