[5c411dc] | 1 | #! /usr/bin/python |
---|
| 2 | # |
---|
[000b090] | 3 | # TODO |
---|
| 4 | # - plugins/puredata: add pd compilation |
---|
| 5 | # - java: add swig compilation |
---|
| 6 | # - doc: add docbook2html and doxygen |
---|
| 7 | # - tests: move to new unit test system |
---|
| 8 | |
---|
| 9 | APPNAME = 'aubio' |
---|
| 10 | VERSION = '0.3.3' |
---|
| 11 | LIB_VERSION = '2.1.1' |
---|
| 12 | srcdir = '.' |
---|
| 13 | blddir = 'build' |
---|
| 14 | |
---|
| 15 | import UnitTest |
---|
| 16 | |
---|
| 17 | def init(opt): |
---|
| 18 | pass |
---|
| 19 | |
---|
| 20 | def set_options(opt): |
---|
[06d30f9] | 21 | opt.add_option('--enable-double', action='store_true', default=False, |
---|
| 22 | help='compile aubio in double precision mode') |
---|
[000b090] | 23 | opt.add_option('--disable-fftw3f', action='store_true', default=False, |
---|
| 24 | help='compile with fftw3 instead of fftw3f') |
---|
| 25 | opt.add_option('--disable-complex', action='store_true', default=False, |
---|
| 26 | help='compile without C99 complex') |
---|
| 27 | opt.add_option('--disable-jack', action='store_true', default=False, |
---|
| 28 | help='compile without jack support') |
---|
| 29 | opt.add_option('--disable-alsa', action='store_true', default=False, |
---|
| 30 | help='compile without alsa support') |
---|
| 31 | opt.add_option('--disable-lash', action='store_true', default=False, |
---|
| 32 | help='compile without lash support') |
---|
| 33 | opt.add_option('--enable-java', action='store_true', default=False, |
---|
| 34 | help='compile with java support') |
---|
[5c411dc] | 35 | opt.add_option('--with-target-platform', type='string', |
---|
| 36 | help='set target platform for cross-compilation', dest='target_platform') |
---|
[000b090] | 37 | opt.tool_options('compiler_cc') |
---|
| 38 | opt.tool_options('compiler_cxx') |
---|
| 39 | opt.tool_options('gnu_dirs') |
---|
| 40 | #opt.tool_options('UnitTest') |
---|
| 41 | |
---|
| 42 | def configure(conf): |
---|
| 43 | import Options |
---|
| 44 | conf.check_tool('compiler_cc') |
---|
| 45 | conf.check_tool('compiler_cxx') |
---|
| 46 | conf.check_tool('gnu_dirs') # helpful for autotools transition and .pc generation |
---|
| 47 | conf.check_tool('misc') # needed for subst |
---|
| 48 | |
---|
[5c411dc] | 49 | if Options.options.target_platform: |
---|
| 50 | Options.platform = Options.options.target_platform |
---|
| 51 | |
---|
| 52 | if Options.platform == 'win32': |
---|
| 53 | conf.env['shlib_PATTERN'] = 'lib%s.dll' |
---|
| 54 | |
---|
[000b090] | 55 | # check for required headers |
---|
| 56 | conf.check(header_name='stdlib.h') |
---|
| 57 | conf.check(header_name='stdio.h') |
---|
| 58 | conf.check(header_name='math.h') |
---|
| 59 | conf.check(header_name='string.h') |
---|
| 60 | |
---|
| 61 | # optionally use complex.h |
---|
| 62 | if (Options.options.disable_complex == False): |
---|
| 63 | conf.check(header_name='complex.h') |
---|
| 64 | |
---|
| 65 | # required dependancies |
---|
| 66 | conf.check_cfg(package = 'sndfile', atleast_version = '1.0.4', |
---|
| 67 | args = '--cflags --libs') |
---|
| 68 | conf.check_cfg(package = 'samplerate', atleast_version = '0.0.15', |
---|
| 69 | args = '--cflags --libs') |
---|
| 70 | |
---|
[06d30f9] | 71 | # double precision mode |
---|
| 72 | if (Options.options.enable_double == True): |
---|
| 73 | conf.define('HAVE_AUBIO_DOUBLE', 1) |
---|
| 74 | else: |
---|
| 75 | conf.define('HAVE_AUBIO_DOUBLE', 0) |
---|
| 76 | |
---|
[000b090] | 77 | # one of fftwf or fftw3f |
---|
| 78 | if (Options.options.disable_fftw3f == True): |
---|
| 79 | conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
[06d30f9] | 80 | args = '--cflags --libs') |
---|
[000b090] | 81 | else: |
---|
[06d30f9] | 82 | # fftw3f not disabled, take most sensible one according to enable_double |
---|
| 83 | if (Options.options.enable_double == True): |
---|
| 84 | conf.check_cfg(package = 'fftw3', atleast_version = '3.0.0', |
---|
| 85 | args = '--cflags --libs') |
---|
| 86 | else: |
---|
| 87 | conf.check_cfg(package = 'fftw3f', atleast_version = '3.0.0', |
---|
| 88 | args = '--cflags --libs') |
---|
[000b090] | 89 | |
---|
| 90 | # optional dependancies |
---|
| 91 | if (Options.options.disable_jack == False): |
---|
| 92 | conf.check_cfg(package = 'jack', atleast_version = '0.15.0', |
---|
| 93 | args = '--cflags --libs') |
---|
| 94 | if (Options.options.disable_alsa == False): |
---|
| 95 | conf.check_cfg(package = 'alsa', atleast_version = '0.0.9', |
---|
| 96 | args = '--cflags --libs') |
---|
| 97 | if (Options.options.disable_lash == False): |
---|
| 98 | conf.check_cfg(package = 'lash-1.0', atleast_version = '0.5.0', |
---|
| 99 | args = '--cflags --libs', uselib_store = 'LASH') |
---|
| 100 | |
---|
| 101 | # swig |
---|
| 102 | if conf.find_program('swig', var='SWIG', mandatory = False): |
---|
| 103 | conf.check_tool('swig', tooldir='swig') |
---|
| 104 | conf.check_swig_version('1.3.27') |
---|
| 105 | |
---|
| 106 | # python |
---|
| 107 | if conf.find_program('python', mandatory = False): |
---|
| 108 | conf.check_tool('python') |
---|
| 109 | conf.check_python_version((2,4,2)) |
---|
| 110 | conf.check_python_headers() |
---|
| 111 | |
---|
| 112 | # java |
---|
| 113 | if (Options.options.enable_java == True): |
---|
| 114 | conf.fatal('Java build not yet implemented') |
---|
| 115 | conf.check_tool('java') |
---|
| 116 | |
---|
| 117 | # check support for C99 __VA_ARGS__ macros |
---|
| 118 | check_c99_varargs = ''' |
---|
| 119 | #include <stdio.h> |
---|
| 120 | #define AUBIO_ERR(...) fprintf(stderr, __VA_ARGS__) |
---|
| 121 | ''' |
---|
| 122 | if conf.check_cc(fragment = check_c99_varargs, |
---|
| 123 | type='cstaticlib', |
---|
| 124 | msg = 'Checking for C99 __VA_ARGS__ macro'): |
---|
| 125 | conf.define('HAVE_C99_VARARGS_MACROS', 1) |
---|
| 126 | |
---|
| 127 | # write configuration header |
---|
| 128 | conf.write_config_header('src/config.h') |
---|
| 129 | |
---|
| 130 | # check for puredata header |
---|
| 131 | conf.check(header_name='m_pd.h') |
---|
| 132 | |
---|
| 133 | # add some defines used in examples |
---|
| 134 | conf.define('AUBIO_PREFIX', conf.env['PREFIX']) |
---|
| 135 | conf.define('PACKAGE', APPNAME) |
---|
| 136 | |
---|
| 137 | # check if docbook-to-man is installed, optional |
---|
| 138 | conf.find_program('docbook-to-man', var='DOCBOOKTOMAN', mandatory=False) |
---|
| 139 | |
---|
| 140 | def build(bld): |
---|
| 141 | bld.env['VERSION'] = VERSION |
---|
| 142 | bld.env['LIB_VERSION'] = LIB_VERSION |
---|
| 143 | |
---|
| 144 | # add sub directories |
---|
| 145 | bld.add_subdirs('src ext examples cpp tests/src') |
---|
| 146 | if bld.env['SWIG']: |
---|
| 147 | if bld.env['PYTHON']: |
---|
| 148 | bld.add_subdirs('python/aubio python') |
---|
| 149 | if bld.env['JAVA']: |
---|
| 150 | pass |
---|
| 151 | |
---|
| 152 | # create the aubio.pc file for pkg-config |
---|
| 153 | aubiopc = bld.new_task_gen('subst') |
---|
| 154 | aubiopc.source = 'aubio.pc.in' |
---|
| 155 | aubiopc.target = 'aubio.pc' |
---|
| 156 | aubiopc.install_path = '${PREFIX}/lib/pkgconfig' |
---|
| 157 | |
---|
| 158 | # build manpages from sgml files |
---|
| 159 | if bld.env['DOCBOOKTOMAN']: |
---|
| 160 | import TaskGen |
---|
| 161 | TaskGen.declare_chain( |
---|
| 162 | name = 'docbooktoman', |
---|
| 163 | rule = '${DOCBOOKTOMAN} ${SRC} > ${TGT}', |
---|
| 164 | ext_in = '.sgml', |
---|
| 165 | ext_out = '.1', |
---|
| 166 | reentrant = 0, |
---|
| 167 | ) |
---|
| 168 | manpages = bld.new_task_gen(name = 'docbooktoman', |
---|
| 169 | source=bld.path.ant_glob('doc/*.sgml')) |
---|
| 170 | bld.install_files('${MANDIR}/man1', bld.path.ant_glob('doc/*.1')) |
---|
| 171 | |
---|
| 172 | if bld.env['HAVE_M_PD_H']: |
---|
| 173 | bld.add_subdirs('plugins/puredata') |
---|
| 174 | |
---|
| 175 | # install woodblock sound |
---|
| 176 | bld.install_files('${PREFIX}/share/sounds/aubio/', |
---|
| 177 | 'sounds/woodblock.aiff') |
---|
| 178 | |
---|
| 179 | def shutdown(bld): |
---|
| 180 | pass |
---|
| 181 | |
---|
| 182 | def check(bld): |
---|
| 183 | ut = UnitTest.unit_test() |
---|
| 184 | ut.change_to_testfile_dir = True |
---|
| 185 | ut.run() |
---|
| 186 | ut.print_results() |
---|