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-sndfile', action='store_true', default=False,
50 help='compile with libsndfile support')
51 opt.add_option('--enable-samplerate', action='store_true', default=False,
52 help='compile with libsamplerate support')
53 opt.add_option('--with-target-platform', type='string',
54 help='set target platform for cross-compilation', dest='target_platform')
55 opt.load('compiler_cc')
56 opt.load('compiler_cxx')
58 opt.load('waf_unit_test')
62 conf.check_tool('compiler_cc')
63 conf.check_tool('compiler_cxx')
64 conf.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation
65 #conf.check_tool('misc') # needed for subst
66 conf.load('waf_unit_test')
68 if Options.options.target_platform:
69 Options.platform = Options.options.target_platform
71 if Options.platform == 'win32':
72 conf.env['shlib_PATTERN'] = 'lib%s.dll'
74 # check for required headers
75 conf.check(header_name='stdlib.h')
76 conf.check(header_name='stdio.h')
77 conf.check(header_name='math.h')
78 conf.check(header_name='string.h')
79 conf.check(header_name='limits.h')
81 # optionally use complex.h
82 if (Options.options.enable_complex == True):
83 conf.check(header_name='complex.h')
86 if (Options.options.enable_sndfile == True):
87 conf.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
88 args = '--cflags --libs')
89 if (Options.options.enable_samplerate == True):
90 conf.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
91 args = '--cflags --libs')
93 # double precision mode
94 if (Options.options.enable_double == True):
95 conf.define('HAVE_AUBIO_DOUBLE', 1)
97 conf.define('HAVE_AUBIO_DOUBLE', 0)
99 # check if pkg-config is installed, optional
101 conf.find_program('pkg-config', var='PKGCONFIG')
102 except conf.errors.ConfigurationError:
103 conf.to_log('pkg-config was not found, not looking for (ignoring)')
106 print Options.options.directories
108 if (Options.options.disable_fftw == False) or not conf.env['PKGCONFIG']:
109 # one of fftwf or fftw3f
110 if (Options.options.disable_fftw3f == True):
111 conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
112 args = '--cflags --libs')
114 # fftw3f not disabled, take most sensible one according to enable_double
115 if (Options.options.enable_double == True):
116 conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
117 args = '--cflags --libs')
119 conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
120 args = '--cflags --libs')
121 conf.define('HAVE_FFTW3', 1)
123 # fftw disabled, use ooura
126 # optional dependancies
127 if (Options.options.enable_jack == True):
128 conf.check_cfg(package = 'jack', atleast_version = '0.15.0',
129 args = '--cflags --libs')
130 if (Options.options.enable_lash == True):
131 conf.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
132 args = '--cflags --libs', uselib_store = 'LASH')
136 conf.find_program('swig', var='SWIG')
137 except conf.errors.ConfigurationError:
138 conf.to_log('swig was not found, not looking for (ignoring)')
140 conf.check_tool('swig', tooldir='swig')
141 conf.check_swig_version('1.3.27')
144 if conf.find_program('python'):
145 conf.check_tool('python')
146 conf.check_python_version((2,4,2))
147 conf.check_python_headers()
149 # check support for C99 __VA_ARGS__ macros
150 check_c99_varargs = '''
152 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
154 if conf.check_cc(fragment = check_c99_varargs,
156 msg = 'Checking for C99 __VA_ARGS__ macro'):
157 conf.define('HAVE_C99_VARARGS_MACROS', 1)
159 # write configuration header
160 conf.write_config_header('src/config.h')
162 # add some defines used in examples
163 conf.define('AUBIO_PREFIX', conf.env['PREFIX'])
164 conf.define('PACKAGE', APPNAME)
166 # check if docbook-to-man is installed, optional
168 conf.find_program('docbook-to-man', var='DOCBOOKTOMAN')
169 except conf.errors.ConfigurationError:
170 conf.to_log('docbook-to-man was not found (ignoring)')
173 bld.env['VERSION'] = VERSION
174 bld.env['LIB_VERSION'] = LIB_VERSION
176 # add sub directories
177 bld.add_subdirs('src examples')
179 if bld.env['PYTHON']:
180 bld.add_subdirs('python/aubio python')
182 # create the aubio.pc file for pkg-config
183 if bld.env['TARGET_PLATFORM'] == 'linux':
184 aubiopc = bld.new_task_gen('subst')
185 aubiopc.source = 'aubio.pc.in'
186 aubiopc.target = 'aubio.pc'
187 aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
189 # build manpages from sgml files
190 if bld.env['DOCBOOKTOMAN']:
192 TaskGen.declare_chain(
193 name = 'docbooktoman',
194 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
199 manpages = bld.new_task_gen(name = 'docbooktoman',
200 source=bld.path.ant_glob('doc/*.sgml'))
201 bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1'))
203 # install woodblock sound
204 bld.install_files('${PREFIX}/share/sounds/aubio/',
205 'sounds/woodblock.aiff')
207 # build and run the unit tests
213 # loop over all *.c filenames in tests/src to build them all
214 # target name is filename.c without the .c
215 def build_tests(bld):
216 for target_name in bld.path.ant_glob('tests/src/**/*.c'):
219 if not str(target_name).endswith('-jack.c'):
224 # phasevoc-jack needs jack
226 includes = ['examples']
228 extra_source = ['examples/jackio.c']
232 this_target = bld.new_task_gen(
233 features = 'c cprogram test',
235 source = [target_name] + extra_source,
236 target = str(target_name).split('.')[0],
237 includes = ['src'] + includes,
238 defines = 'AUBIO_UNSTABLE_API=1',