1#!/usr/bin/env python
2from waflib.extras import autowaf as autowaf
3from waflib import TaskGen
4import os
5import sys
6
7# Version of this package (even if built as a child)
8MAJOR = '2'
9MINOR = '0'
10MICRO = '1'
11LIBFLUIDSYNTH_VERSION = "%s.%s.%s" % (MAJOR, MINOR, MICRO)
12
13# Variables for 'waf dist'
14APPNAME = 'libltc'
15VERSION = LIBFLUIDSYNTH_VERSION
16I18N_PACKAGE = 'libfluidsynth'
17
18# Mandatory variables
19top = '.'
20out = 'build'
21
22def options(opt):
23    autowaf.set_options(opt)
24
25def configure(conf):
26    if conf.is_defined('USE_EXTERNAL_LIBS'):
27        autowaf.check_pkg(conf, 'fluidsynth', uselib_store='LIBFLUIDSYNTH', atleast_version=LIBFLUIDSYNTH_VERSION, mandatory=True)
28    else:
29        conf.load('compiler_c')
30        autowaf.configure(conf)
31
32def build(bld):
33    if bld.is_defined('USE_EXTERNAL_LIBS'):
34        return
35    bld (export_includes = ['fluidsynth'],
36         name = 'libfluidsynth_includes'
37         )
38    obj = bld.stlib (source = [
39        'src/fluid_midi.c',
40        'src/fluid_adsr_env.c',
41        'src/fluid_chorus.c',
42        'src/fluid_iir_filter.c',
43        'src/fluid_lfo.c',
44        'src/fluid_rev.c',
45        'src/fluid_rvoice.c',
46        'src/fluid_rvoice_dsp.c',
47        'src/fluid_rvoice_event.c',
48        'src/fluid_rvoice_mixer.c',
49        'src/fluid_defsfont.c',
50        'src/fluid_chan.c',
51        'src/fluid_event.c',
52        'src/fluid_gen.c',
53        'src/fluid_mod.c',
54        'src/fluid_synth.c',
55        'src/fluid_tuning.c',
56        'src/fluid_voice.c',
57        'src/fluid_conv.c',
58        'src/fluid_hash.c',
59        'src/fluid_list.c',
60        'src/fluid_ringbuffer.c',
61        'src/fluid_samplecache.c',
62        'src/fluid_settings.c',
63        'src/fluid_sffile.c',
64        'src/fluid_sfont.c',
65        'src/fluid_synth_monopoly.c',
66        'src/fluid_sys.c'
67        ],
68        cflags = [ bld.env['compiler_flags_dict']['pic'], '-fvisibility=hidden', '-std=gnu99', '-Wno-unused-function' ],
69        includes = ['.', 'src/' ],
70               target = 'libfluidsynth',
71               use    = 'libfluidsynth_includes',
72               uselib = 'GLIB',
73               defines = [ 'HAVE_CONFIG_H', 'DEFAULT_SOUNDFONT=""' ]
74               )
75
76    # wine-gcc hacks:
77    # defining __MINGW32__ for wine-gcc is a workaround for fluidsynth's include
78    # strategy (which is made for mingw or windows) without it
79    # winsock2.h will complain about undeclared "u_short"
80    # we also need to explicitly define  _WIN32
81    if bld.is_defined('WINDOWS_VST_SUPPORT') and not bld.env['build_target'] == 'mingw':
82        obj.defines += [ '_WIN32', '__MINGW32__' ]
83
84def shutdown():
85    autowaf.shutdown()
86