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
24 opt.add_option('--enable-double', action='store_true', default=False,
25 help='compile aubio in double precision mode')
26 opt.add_option('--disable-fftw3f', action='store_true', default=False,
27 help='compile with fftw3 instead of fftw3f')
28 opt.add_option('--enable-complex', action='store_true', default=False,
29 help='compile with C99 complex')
30 opt.add_option('--enable-jack', action='store_true', default=False,
31 help='compile with jack support')
32 opt.add_option('--enable-lash', action='store_true', default=False,
33 help='compile with lash support')
34 opt.add_option('--enable-libsamplerate', action='store_true', default=False,
35 help='compile with libsamplerate support')
36 opt.add_option('--with-target-platform', type='string',
37 help='set target platform for cross-compilation', dest='target_platform')
38 opt.load('compiler_cc')
39 opt.load('compiler_cxx')
41 opt.load('waf_unit_test')
45 conf.check_tool('compiler_cc')
46 conf.check_tool('compiler_cxx')
47 conf.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation
48 conf.check_tool('misc') # needed for subst
49 conf.load('waf_unit_test')
51 if Options.options.target_platform:
52 Options.platform = Options.options.target_platform
54 if Options.platform == 'win32':
55 conf.env['shlib_PATTERN'] = 'lib%s.dll'
57 # check for required headers
58 conf.check(header_name='stdlib.h')
59 conf.check(header_name='stdio.h')
60 conf.check(header_name='math.h')
61 conf.check(header_name='string.h')
62 conf.check(header_name='limits.h')
64 # optionally use complex.h
65 if (Options.options.enable_complex == True):
66 conf.check(header_name='complex.h')
69 conf.check_cfg(package = 'sndfile', atleast_version = '1.0.4',
70 args = '--cflags --libs')
71 if (Options.options.enable_libsamplerate == True):
72 conf.check_cfg(package = 'samplerate', atleast_version = '0.0.15',
73 args = '--cflags --libs')
75 # double precision mode
76 if (Options.options.enable_double == True):
77 conf.define('HAVE_AUBIO_DOUBLE', 1)
79 conf.define('HAVE_AUBIO_DOUBLE', 0)
81 # one of fftwf or fftw3f
82 if (Options.options.disable_fftw3f == True):
83 conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
84 args = '--cflags --libs')
86 # fftw3f not disabled, take most sensible one according to enable_double
87 if (Options.options.enable_double == True):
88 conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0',
89 args = '--cflags --libs')
91 conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0',
92 args = '--cflags --libs')
94 # optional dependancies
95 if (Options.options.enable_jack == True):
96 conf.check_cfg(package = 'jack', atleast_version = '0.15.0',
97 args = '--cflags --libs')
98 if (Options.options.enable_lash == True):
99 conf.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0',
100 args = '--cflags --libs', uselib_store = 'LASH')
103 if 0: #conf.find_program('swig', var='SWIG', mandatory = False):
104 conf.check_tool('swig', tooldir='swig')
105 conf.check_swig_version('1.3.27')
108 if conf.find_program('python', mandatory = False):
109 conf.check_tool('python')
110 conf.check_python_version((2,4,2))
111 conf.check_python_headers()
113 # check support for C99 __VA_ARGS__ macros
114 check_c99_varargs = '''
116 #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__)
118 if conf.check_cc(fragment = check_c99_varargs,
120 msg = 'Checking for C99 __VA_ARGS__ macro'):
121 conf.define('HAVE_C99_VARARGS_MACROS', 1)
123 # write configuration header
124 conf.write_config_header('src/config.h')
126 # add some defines used in examples
127 conf.define('AUBIO_PREFIX', conf.env['PREFIX'])
128 conf.define('PACKAGE', APPNAME)
130 # check if docbook-to-man is installed, optional
131 conf.find_program('docbook-to-man', var='DOCBOOKTOMAN', mandatory=False)
134 bld.env['VERSION'] = VERSION
135 bld.env['LIB_VERSION'] = LIB_VERSION
137 # add sub directories
138 bld.add_subdirs('src examples')
140 if bld.env['PYTHON']:
141 bld.add_subdirs('python/aubio python')
143 # create the aubio.pc file for pkg-config
144 aubiopc = bld.new_task_gen('subst')
145 aubiopc.source = 'aubio.pc.in'
146 aubiopc.target = 'aubio.pc'
147 aubiopc.install_path = '${PREFIX}/lib/pkgconfig'
149 # build manpages from sgml files
150 if bld.env['DOCBOOKTOMAN']:
152 TaskGen.declare_chain(
153 name = 'docbooktoman',
154 rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}',
159 manpages = bld.new_task_gen(name = 'docbooktoman',
160 source=bld.path.ant_glob('doc/*.sgml'))
161 bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1'))
163 # install woodblock sound
164 bld.install_files('${PREFIX}/share/sounds/aubio/',
165 'sounds/woodblock.aiff')
167 # build and run the unit tests
173 # loop over all *.c filenames in tests/src to build them all
174 # target name is filename.c without the .c
175 def build_tests(bld):
176 for target_name in bld.path.ant_glob('tests/src/**/*.c'):
177 this_target = bld.new_task_gen(
178 features = 'c cprogram test',
179 source = target_name,
180 target = str(target_name).split('.')[0],
182 defines = 'AUBIO_UNSTABLE_API=1',
184 # phasevoc-jack also needs jack
185 if str(target_name).endswith('test-phasevoc-jack.c'):
186 this_target.includes = ['src', 'examples']
187 this_target.use = ['aubio']
188 this_target.uselib = ['JACK']
189 this_target.target += ' examples/jackio.c'