Debian Codegraph @

mklove/modules/configure.libzstd

raw
1 #!/bin/bash
2 #
3 # libzstd support, with installer
4 #
5 # Usage:
6 # mkl_require libzstd
7 #
8 # And then call the following function from the correct place/order in checks:
9 # mkl_check libzstd
10 #
11
12 mkl_toggle_option "Feature" ENABLE_ZSTD "--enable-zstd" "Enable support for ZSTD compression" "try"
13
14 function manual_checks {
15 case "$ENABLE_ZSTD" in
16 n) return 0 ;;
17 y) local action=fail ;;
18 try) local action=disable ;;
19 *) mkl_err "mklove internal error: invalid value for ENABLE_ZSTD: $ENABLE_ZSTD"; exit 1 ;;
20 esac
21
22 mkl_meta_set "libzstd" "brew" "zstd"
23 mkl_meta_set "libzstd" "apk" "zstd-dev zstd-static"
24 mkl_meta_set "libzstd" "static" "libzstd.a"
25 mkl_lib_check "libzstd" "WITH_ZSTD" $action CC "-lzstd" \
26 "
27 #include <zstd.h>
28 #include <zstd_errors.h>
29
30 void foo (void) {
31 ZSTD_getFrameContentSize(NULL, 0);
32 }
33 "
34 }
35
36
37 # Install zstd from source tarball
38 #
39 # Param 1: name (libzstd)
40 # Param 2: install-dir-prefix (e.g., DESTDIR)
41 # Param 2: version (optional)
42 function install_source {
43 local name=$1
44 local destdir=$2
45 local ver=1.5.7
46 local checksum="eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3"
47
48 echo "### Installing $name $ver from source to $destdir"
49 if [[ ! -f Makefile ]]; then
50 mkl_download_archive \
51 "https://github.com/facebook/zstd/releases/download/v${ver}/zstd-${ver}.tar.gz" \
52 "256" \
53 $checksum || return 1
54 fi
55
56 time make -j DESTDIR="${destdir}" prefix=/usr install
57 return $?
58 }