[5c411dc] | 1 | #! /usr/bin/python |
---|
[110ac90] | 2 | # |
---|
[21ee709] | 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 |
---|
[ee36175] | 11 | # - doc: add doxygen |
---|
[110ac90] | 12 | # - tests: move to new unit test system |
---|
[000b090] | 13 | |
---|
| 14 | APPNAME = 'aubio' |
---|
[5820107] | 15 | |
---|
| 16 | # read from VERSION |
---|
| 17 | for l in open('VERSION').readlines(): exec (l.strip()) |
---|
| 18 | |
---|
| 19 | VERSION = '.'.join \ |
---|
| 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]]) |
---|
[e565c649] | 24 | |
---|
| 25 | import os.path, sys |
---|
| 26 | if os.path.exists('src/config.h') or os.path.exists('Makefile'): |
---|
[7684ff2] | 27 | print "Please run 'make distclean' to clean-up autotools files before using waf" |
---|
[e565c649] | 28 | sys.exit(1) |
---|
| 29 | |
---|
[46378b3] | 30 | top = '.' |
---|
| 31 | out = 'build' |
---|
[000b090] | 32 | |
---|
| 33 | def init(opt): |
---|
| 34 | pass |
---|
| 35 | |
---|
[46378b3] | 36 | def options(opt): |
---|
[06d30f9] | 37 | opt.add_option('--enable-double', action='store_true', default=False, |
---|
| 38 | help='compile aubio in double precision mode') |
---|
[dda6ba6] | 39 | opt.add_option('--enable-fftw', action='store_true', default=False, |
---|
[729a3c0] | 40 | help='compile with ooura instead of fftw') |
---|
[dda6ba6] | 41 | opt.add_option('--enable-fftw3f', action='store_true', default=False, |
---|
[000b090] | 42 | help='compile with fftw3 instead of fftw3f') |
---|
[62b8ab2] | 43 | opt.add_option('--enable-complex', action='store_true', default=False, |
---|
| 44 | help='compile with C99 complex') |
---|
[46378b3] | 45 | opt.add_option('--enable-jack', action='store_true', default=False, |
---|
[2a6e672] | 46 | help='compile with jack support') |
---|
[46378b3] | 47 | opt.add_option('--enable-lash', action='store_true', default=False, |
---|
[2a6e672] | 48 | help='compile with lash support') |
---|
[110ac90] | 49 | opt.add_option('--enable-sndfile', action='store_true', default=False, |
---|
| 50 | help='compile with libsndfile support') |
---|
[ad7c710] | 51 | opt.add_option('--enable-samplerate', action='store_true', default=False, |
---|
[2a6e672] | 52 | help='compile with libsamplerate support') |
---|
[dda6ba6] | 53 | opt.add_option('--enable-swig', action='store_true', default=False, |
---|
| 54 | help='compile with swig support (obsolete)') |
---|
[5c411dc] | 55 | opt.add_option('--with-target-platform', type='string', |
---|
| 56 | help='set target platform for cross-compilation', dest='target_platform') |
---|
[dda6ba6] | 57 | opt.load('compiler_c') |
---|
[46378b3] | 58 | opt.load('compiler_cxx') |
---|
| 59 | opt.load('gnu_dirs') |
---|
| 60 | opt.load('waf_unit_test') |
---|
[000b090] | 61 | |
---|
| 62 | def configure(conf): |
---|
| 63 | import Options |
---|
[dda6ba6] | 64 | conf.check_tool('compiler_c') |
---|
[000b090] | 65 | conf.check_tool('compiler_cxx') |
---|
| 66 | conf.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation |
---|
[110ac90] | 67 | #conf.check_tool('misc') # needed for subst |
---|
[46378b3] | 68 | conf.load('waf_unit_test') |
---|
[000b090] | 69 | |
---|
[5c411dc] | 70 | if Options.options.target_platform: |
---|
| 71 | Options.platform = Options.options.target_platform |
---|
| 72 | |
---|
| 73 | if Options.platform == 'win32': |
---|
| 74 | conf.env['shlib_PATTERN'] = 'lib%s.dll' |
---|
| 75 | |
---|
[000b090] | 76 | # check for required headers |
---|
| 77 | conf.check(header_name='stdlib.h') |
---|
| 78 | conf.check(header_name='stdio.h') |
---|
| 79 | conf.check(header_name='math.h') |
---|
| 80 | conf.check(header_name='string.h') |
---|
[10a5413] | 81 | conf.check(header_name='limits.h') |
---|
[000b090] | 82 | |
---|
| 83 | # optionally use complex.h |
---|
[62b8ab2] | 84 | if (Options.options.enable_complex == True): |
---|
[000b090] | 85 | conf.check(header_name='complex.h') |
---|
| 86 | |
---|
[2e4fb04] | 87 | # check dependencies |
---|
[110ac90] | 88 | if (Options.options.enable_sndfile == True): |
---|
| 89 | conf.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
| 90 | args = '--cflags --libs') |
---|
[82335b7] | 91 | if (Options.options.enable_samplerate == True): |
---|
[46378b3] | 92 | conf.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
[2e4fb04] | 93 | args = '--cflags --libs') |
---|
[000b090] | 94 | |
---|
[06d30f9] | 95 | # double precision mode |
---|
| 96 | if (Options.options.enable_double == True): |
---|
| 97 | conf.define('HAVE_AUBIO_DOUBLE', 1) |
---|
| 98 | else: |
---|
| 99 | conf.define('HAVE_AUBIO_DOUBLE', 0) |
---|
| 100 | |
---|
[110ac90] | 101 | # check if pkg-config is installed, optional |
---|
| 102 | try: |
---|
| 103 | conf.find_program('pkg-config', var='PKGCONFIG') |
---|
| 104 | except conf.errors.ConfigurationError: |
---|
[acb2ac9] | 105 | conf.msg('Could not find pkg-config', 'disabling fftw, jack, and lash') |
---|
| 106 | conf.msg('Could not find fftw', 'using ooura') |
---|
[110ac90] | 107 | |
---|
[36f954a] | 108 | # optional dependancies using pkg-config |
---|
| 109 | if conf.env['PKGCONFIG']: |
---|
| 110 | |
---|
[dda6ba6] | 111 | if (Options.options.enable_fftw == True or Options.options.enable_fftw3f == True): |
---|
[36f954a] | 112 | # one of fftwf or fftw3f |
---|
[dda6ba6] | 113 | if (Options.options.enable_fftw3f == True): |
---|
| 114 | conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
[729a3c0] | 115 | args = '--cflags --libs') |
---|
[dda6ba6] | 116 | if (Options.options.enable_double == True): |
---|
| 117 | conf.msg('Warning', 'fftw3f enabled, but aubio compiled in double precision!') |
---|
[729a3c0] | 118 | else: |
---|
[dda6ba6] | 119 | # fftw3f not enabled, take most sensible one according to enable_double |
---|
[36f954a] | 120 | if (Options.options.enable_double == True): |
---|
| 121 | conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
| 122 | args = '--cflags --libs') |
---|
| 123 | else: |
---|
| 124 | conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 125 | args = '--cflags --libs') |
---|
| 126 | conf.define('HAVE_FFTW3', 1) |
---|
| 127 | else: |
---|
| 128 | # fftw disabled, use ooura |
---|
[acb2ac9] | 129 | conf.msg('Fftw disabled', 'using ooura') |
---|
[36f954a] | 130 | pass |
---|
| 131 | |
---|
| 132 | if (Options.options.enable_jack == True): |
---|
| 133 | conf.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
| 134 | args = '--cflags --libs') |
---|
| 135 | |
---|
| 136 | if (Options.options.enable_lash == True): |
---|
| 137 | conf.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
| 138 | args = '--cflags --libs', uselib_store = 'LASH') |
---|
[000b090] | 139 | |
---|
| 140 | # swig |
---|
[dda6ba6] | 141 | if (Options.options.enable_swig == True): |
---|
| 142 | try: |
---|
| 143 | conf.find_program('swig', var='SWIG') |
---|
| 144 | except conf.errors.ConfigurationError: |
---|
| 145 | conf.to_log('swig was not found, not looking for (ignoring)') |
---|
| 146 | |
---|
| 147 | if conf.env['SWIG']: |
---|
| 148 | conf.check_tool('swig') |
---|
| 149 | conf.check_swig_version() |
---|
| 150 | |
---|
| 151 | # python |
---|
| 152 | if conf.find_program('python'): |
---|
| 153 | conf.check_tool('python') |
---|
| 154 | conf.check_python_version((2,4,2)) |
---|
| 155 | conf.check_python_headers() |
---|
[000b090] | 156 | |
---|
| 157 | # check support for C99 __VA_ARGS__ macros |
---|
| 158 | check_c99_varargs = ''' |
---|
| 159 | #include <stdio.h> |
---|
| 160 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 161 | ''' |
---|
[110ac90] | 162 | if conf.check_cc(fragment = check_c99_varargs, |
---|
[46378b3] | 163 | type='cstlib', |
---|
[000b090] | 164 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
| 165 | conf.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
| 166 | |
---|
| 167 | # write configuration header |
---|
| 168 | conf.write_config_header('src/config.h') |
---|
| 169 | |
---|
[110ac90] | 170 | # add some defines used in examples |
---|
[000b090] | 171 | conf.define('AUBIO_PREFIX', conf.env['PREFIX']) |
---|
| 172 | conf.define('PACKAGE', APPNAME) |
---|
| 173 | |
---|
| 174 | # check if docbook-to-man is installed, optional |
---|
[110ac90] | 175 | try: |
---|
| 176 | conf.find_program('docbook-to-man', var='DOCBOOKTOMAN') |
---|
| 177 | except conf.errors.ConfigurationError: |
---|
| 178 | conf.to_log('docbook-to-man was not found (ignoring)') |
---|
[000b090] | 179 | |
---|
| 180 | def build(bld): |
---|
[110ac90] | 181 | bld.env['VERSION'] = VERSION |
---|
| 182 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
[000b090] | 183 | |
---|
| 184 | # add sub directories |
---|
[e460e60] | 185 | bld.add_subdirs('src examples') |
---|
[000b090] | 186 | if bld.env['SWIG']: |
---|
| 187 | if bld.env['PYTHON']: |
---|
[dda6ba6] | 188 | bld.add_subdirs('python') |
---|
[000b090] | 189 | |
---|
| 190 | # create the aubio.pc file for pkg-config |
---|
[110ac90] | 191 | if bld.env['TARGET_PLATFORM'] == 'linux': |
---|
| 192 | aubiopc = bld.new_task_gen('subst') |
---|
| 193 | aubiopc.source = 'aubio.pc.in' |
---|
| 194 | aubiopc.target = 'aubio.pc' |
---|
| 195 | aubiopc.install_path = '${PREFIX}/lib/pkgconfig' |
---|
[000b090] | 196 | |
---|
| 197 | # build manpages from sgml files |
---|
| 198 | if bld.env['DOCBOOKTOMAN']: |
---|
| 199 | import TaskGen |
---|
| 200 | TaskGen.declare_chain( |
---|
| 201 | name = 'docbooktoman', |
---|
| 202 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
| 203 | ext_in = '.sgml', |
---|
| 204 | ext_out = '.1', |
---|
| 205 | reentrant = 0, |
---|
| 206 | ) |
---|
[110ac90] | 207 | manpages = bld.new_task_gen(name = 'docbooktoman', |
---|
[000b090] | 208 | source=bld.path.ant_glob('doc/*.sgml')) |
---|
| 209 | bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1')) |
---|
| 210 | |
---|
| 211 | # install woodblock sound |
---|
[110ac90] | 212 | bld.install_files('${PREFIX}/share/sounds/aubio/', |
---|
[000b090] | 213 | 'sounds/woodblock.aiff') |
---|
| 214 | |
---|
[f11d78d] | 215 | # build and run the unit tests |
---|
| 216 | build_tests(bld) |
---|
| 217 | |
---|
[000b090] | 218 | def shutdown(bld): |
---|
| 219 | pass |
---|
| 220 | |
---|
[f11d78d] | 221 | # loop over all *.c filenames in tests/src to build them all |
---|
| 222 | # target name is filename.c without the .c |
---|
| 223 | def build_tests(bld): |
---|
[46378b3] | 224 | for target_name in bld.path.ant_glob('tests/src/**/*.c'): |
---|
[110ac90] | 225 | includes = ['src'] |
---|
| 226 | uselib = [] |
---|
| 227 | if not str(target_name).endswith('-jack.c'): |
---|
| 228 | includes = [] |
---|
| 229 | uselib = [] |
---|
| 230 | extra_source = [] |
---|
| 231 | else: |
---|
| 232 | # phasevoc-jack needs jack |
---|
| 233 | if bld.env['JACK']: |
---|
| 234 | includes = ['examples'] |
---|
| 235 | uselib = ['JACK'] |
---|
| 236 | extra_source = ['examples/jackio.c'] |
---|
| 237 | else: |
---|
| 238 | continue |
---|
| 239 | |
---|
[f11d78d] | 240 | this_target = bld.new_task_gen( |
---|
[46378b3] | 241 | features = 'c cprogram test', |
---|
[110ac90] | 242 | uselib = uselib, |
---|
| 243 | source = [target_name] + extra_source, |
---|
[46378b3] | 244 | target = str(target_name).split('.')[0], |
---|
[110ac90] | 245 | includes = ['src'] + includes, |
---|
[740f06b] | 246 | defines = 'AUBIO_UNSTABLE_API=1', |
---|
[46378b3] | 247 | use = 'aubio') |
---|