#!/bin/bash -eu

#  Copyright (c) 2025-2026, Bertrand Lebonnois
#  All rights reserved.
#
#  This source code is licensed under the BSD-style license found in the
#  LICENSE file in the root directory of this source tree.

FUZZERS="decompress roundtrip seekable pstream dict"

LIB_SOURCES="src/lib/zxc_common.c src/lib/zxc_compress.c src/lib/zxc_decompress.c src/lib/zxc_dict.c src/lib/zxc_driver.c src/lib/zxc_dispatch.c src/lib/zxc_huffman.c src/lib/zxc_seekable.c src/lib/zxc_pstream.c"

for fuzzer in $FUZZERS; do
    $CC $CFLAGS -I include \
        -I src/lib/vendors \
        -DZXC_FUNCTION_SUFFIX=_default -DZXC_ONLY_DEFAULT \
        $LIB_SOURCES \
        tests/fuzz_${fuzzer}.c \
        -o $OUT/zxc_fuzzer_${fuzzer} \
        $LIB_FUZZING_ENGINE \
        -lm -pthread
done