cc_library {
    name: "libsonivox",
    srcs: [
        "lib_src/eas_chorus.c",
        "lib_src/eas_chorusdata.c",
        "lib_src/eas_data.c",
        "lib_src/eas_dlssynth.c",
        "lib_src/eas_flog.c",
        "lib_src/eas_ima_tables.c",
        "lib_src/eas_imaadpcm.c",
        "lib_src/eas_imelody.c",
        "lib_src/eas_imelodydata.c",
        "lib_src/eas_math.c",
        "lib_src/eas_mdls.c",
        "lib_src/eas_midi.c",
        "lib_src/eas_mididata.c",
        "lib_src/eas_mixbuf.c",
        "lib_src/eas_mixer.c",
        "lib_src/eas_ota.c",
        "lib_src/eas_otadata.c",
        "lib_src/eas_pan.c",
        "lib_src/eas_pcm.c",
        "lib_src/eas_pcmdata.c",
        "lib_src/eas_public.c",
        "lib_src/eas_reverb.c",
        "lib_src/eas_reverbdata.c",
        "lib_src/eas_rtttl.c",
        "lib_src/eas_rtttldata.c",
        "lib_src/eas_smf.c",
        "lib_src/eas_smfdata.c",
        "lib_src/eas_voicemgt.c",
        "lib_src/eas_wtengine.c",
        "lib_src/eas_wtsynth.c",
        "lib_src/eas_xmf.c",
        "lib_src/eas_xmfdata.c",
        "lib_src/wt_22khz.c",
        "lib_src/jet.c",
        "host_src/eas_config.c",
        "host_src/eas_hostmm.c",
        "host_src/eas_report.c",

        // not using these modules
        //"host_src/eas_main.c",
        //"host_src/eas_wave.c",
        //"lib_src/eas_wavefile.c",
        //"lib_src/eas_wavefiledata.c",
    ],

    cflags: [
        "-O2",
        "-DUNIFIED_DEBUG_MESSAGES",
        "-DEAS_WT_SYNTH",
        "-D_IMELODY_PARSER",
        "-D_RTTTL_PARSER",
        "-D_OTA_PARSER",
        "-D_XMF_PARSER",
        "-DNUM_OUTPUT_CHANNELS=2",
        "-D_SAMPLE_RATE_22050",
        "-DMAX_SYNTH_VOICES=64",
        "-D_16_BIT_SAMPLES",
        "-D_FILTER_ENABLED",
        "-DDLS_SYNTHESIZER",
        "-D_REVERB_ENABLED",

        "-Wno-unused-parameter",
        "-Werror",

        // not using these options
        // "-D_WAVE_PARSER",
        // "-D_IMA_DECODER", // (needed for IMA-ADPCM wave files)
        // "-D_CHORUS_ENABLED",
    ],

    local_include_dirs: [
        "host_src",
        "lib_src",
    ],
    export_include_dirs: ["include"],

    shared_libs: [
        "liblog",
    ],

    arch: {
        arm: {
            instruction_set: "arm",

            srcs: [
                "lib_src/ARM-E_filter_gnu.s",
                //"lib_src/ARM-E_interpolate_loop_gnu.s",
                //"lib_src/ARM-E_interpolate_noloop_gnu.s",
                "lib_src/ARM-E_mastergain_gnu.s",
                //"lib_src/ARM-E_voice_gain_gnu.s",
            ],

            asflags: [
                // In order to use #include instead of .include
                "-xassembler-with-cpp",

                "-Wa,--defsym,SAMPLE_RATE_22050=1",
                "-Wa,--defsym,STEREO_OUTPUT=1",
                "-Wa,--defsym,FILTER_ENABLED=1",
                "-Wa,--defsym,SAMPLES_16_BIT=1",
            ],

            cflags: [
                "-DNATIVE_EAS_KERNEL",
            ],

            // .s files not ported for Clang assembler yet.
            clang_asflags: ["-no-integrated-as"],
        },
        arm64: {
            // .s files not ported for Clang assembler yet.
            clang_asflags: ["-no-integrated-as"],
        },
    },
}