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