source: wscript @ 5e1c04f

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

wscript: define TARGET_OS_IPHONE 1 and add armv7s to ios

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