summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/librdkafka-2.1.0/mklove/modules/configure.libzstd
blob: e32378f789553dc701911db988b4cb3c5f69fdec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#
# libzstd support, with installer
#
# Usage:
#   mkl_require libzstd
#
# And then call the following function from the correct place/order in checks:
#   mkl_check libzstd
#

mkl_toggle_option "Feature" ENABLE_ZSTD "--enable-zstd" "Enable support for ZSTD compression" "try"

function manual_checks {
    case "$ENABLE_ZSTD" in
        n) return 0 ;;
        y) local action=fail ;;
        try) local action=disable ;;
        *) mkl_err "mklove internal error: invalid value for ENABLE_ZSTD: $ENABLE_ZSTD"; exit 1 ;;
    esac

    mkl_meta_set "libzstd" "brew" "zstd"
    mkl_meta_set "libzstd" "apk" "zstd-dev zstd-static"
    mkl_meta_set "libzstd" "static" "libzstd.a"
    mkl_lib_check "libzstd" "WITH_ZSTD" $action CC "-lzstd" \
                  "
#include <zstd.h>
#include <zstd_errors.h>

void foo (void) {
     ZSTD_getFrameContentSize(NULL, 0);
}
"
}


# Install zstd from source tarball
#
# Param 1: name (libzstd)
# Param 2: install-dir-prefix (e.g., DESTDIR)
# Param 2: version (optional)
function install_source {
    local name=$1
    local destdir=$2
    local ver=1.5.2
    local checksum="7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0"

    echo "### Installing $name $ver from source to $destdir"
    if [[ ! -f Makefile ]]; then
        mkl_download_archive \
            "https://github.com/facebook/zstd/releases/download/v${ver}/zstd-${ver}.tar.gz" \
            "256" \
            $checksum || return 1
    fi

    time make -j DESTDIR="${destdir}" prefix=/usr install
    return $?
}