3 # waf build script, see http://code.google.com/p/waf/
5 # $ waf distclean configure build
7 # $ svn co http://waf.googlecode.com/svn/trunk /path/to/waf
8 # $ alias waf=/path/to/waf/waf-light
12 # - tests: move to new unit test system
17 for l in open('VERSION').readlines(): exec (l.strip())
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]])
26 if os.path.exists('src/config.h') or os.path.exists('Makefile'):
27 print "Please run 'make distclean' using waf"
37 opt.add_option('--enable-double', action='store_true', default=False,
38 help='compile aubio in double precision mode')
39 opt.add_option('--disable-fftw', action='store_true', default=False,
40 help='compile with ooura instead of fftw')
41 opt.add_option('--disable-fftw3f', action='store_true', default=False,
42 help='compile with fftw3 instead of fftw3f')
43 opt.add_option('--enable-complex', action='store_true', default=False,
44 help='compile with C99 complex')
45 opt.add_option('--enable-jack', action='store_true', default=False,
46 help='compile with jack support')
47 opt.add_option('--enable-lash', action='store_true', default=False,
48 help='compile with lash support')
49 opt.add_option('--enable-samplerate', action='store_true', default=False,
50 help='compile with libsamplerate support')
51 opt.add_option('--with-target-platform', type='string',
52 help='set target platform for cross-compilation', dest='target_platform')
53 opt.load('compiler_cc')
54 opt.load('compiler_cxx')
56 opt.load('waf_unit_test')
60 conf.check_tool('compiler_cc')
61 conf.check_tool('compiler_cxx')
62 conf.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation
63 conf.check_tool('misc') # needed for subst
64 conf.load('waf_unit_test')
66 if Options.options.target_platform:
67 Options.platform = Options.options.target_platform
69 if Options.platform == 'win32':
70 conf.env['shlib_PATTERN'] = 'lib%s.dll'
72 # check for required headers
73 conf.check(header_name='stdlib.h')
74 conf.check(header_name='stdio.h')
75 conf.check(header_name='math.h')
76 conf.check(header_name='string.h')
77 conf.check(header_name='limits.h')
79 # optionally use complex.h
80 if (Options.options.enable_complex == True):
81 conf.check(header_name='complex.h')
84 conf.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
85 args = '--cflags --libs')
86 if (Options.options.enable_samplerate == True):
87 conf.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
88 args = '--cflags --libs')
90 # double precision mode
91 if (Options.options.enable_double == True):
92 conf.define('HAVE_AUBIO_DOUBLE', 1)
94 conf.define('HAVE_AUBIO_DOUBLE', 0)
96 if (Options.options.disable_fftw == False):
97 # one of fftwf or fftw3f
98 if (Options.options.disable_fftw3f == True):
99 conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
100 args = '--cflags --libs')
102 # fftw3f not disabled, take most sensible one according to enable_double
103 if (Options.options.enable_double == True):
104 conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
105 args = '--cflags --libs')
107 conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
108 args = '--cflags --libs')
109 conf.define('HAVE_FFTW3', 1)
111 # fftw disabled, use ooura
114 # optional dependancies
115 if (Options.options.enable_jack == True):
116 conf.check_cfg(package = 'jack', atleast_version = '0.15.0',
117 args = '--cflags --libs')
118 if (Options.options.enable_lash == True):
119 conf.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
120 args = '--cflags --libs', uselib_store = 'LASH')
123 if 0: #conf.find_program('swig', var='SWIG', mandatory = False):
124 conf.check_tool('swig', tooldir='swig')
125 conf.check_swig_version('1.3.27')
128 if conf.find_program('python', mandatory = False):
129 conf.check_tool('python')
130 conf.check_python_version((2,4,2))
131 conf.check_python_headers()
133 # check support for C99 __VA_ARGS__ macros
134 check_c99_varargs = '''
136 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
138 if conf.check_cc(fragment = check_c99_varargs,
140 msg = 'Checking for C99 __VA_ARGS__ macro'):
141 conf.define('HAVE_C99_VARARGS_MACROS', 1)
143 # write configuration header
144 conf.write_config_header('src/config.h')
146 # add some defines used in examples
147 conf.define('AUBIO_PREFIX', conf.env['PREFIX'])
148 conf.define('PACKAGE', APPNAME)
150 # check if docbook-to-man is installed, optional
151 conf.find_program('docbook-to-man', var='DOCBOOKTOMAN', mandatory=False)
154 bld.env['VERSION'] = VERSION
155 bld.env['LIB_VERSION'] = LIB_VERSION
157 # add sub directories
158 bld.add_subdirs('src examples')
160 if bld.env['PYTHON']:
161 bld.add_subdirs('python/aubio python')
163 # create the aubio.pc file for pkg-config
164 aubiopc = bld.new_task_gen('subst')
165 aubiopc.source = 'aubio.pc.in'
166 aubiopc.target = 'aubio.pc'
167 aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
169 # build manpages from sgml files
170 if bld.env['DOCBOOKTOMAN']:
172 TaskGen.declare_chain(
173 name = 'docbooktoman',
174 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
179 manpages = bld.new_task_gen(name = 'docbooktoman',
180 source=bld.path.ant_glob('doc/*.sgml'))
181 bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1'))
183 # install woodblock sound
184 bld.install_files('${PREFIX}/share/sounds/aubio/',
185 'sounds/woodblock.aiff')
187 # build and run the unit tests
193 # loop over all *.c filenames in tests/src to build them all
194 # target name is filename.c without the .c
195 def build_tests(bld):
196 for target_name in bld.path.ant_glob('tests/src/**/*.c'):
197 this_target = bld.new_task_gen(
198 features = 'c cprogram test',
199 source = target_name,
200 target = str(target_name).split('.')[0],
202 defines = 'AUBIO_UNSTABLE_API=1',
204 # phasevoc-jack also needs jack
205 if str(target_name).endswith('test-phasevoc-jack.c'):
206 this_target.includes = ['src', 'examples']
207 this_target.uselib = ['JACK']
208 this_target.target += ' examples/jackio.c'