2018-08-02 04:22:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-09-16 06:07:52 +02:00
|
|
|
if [ ! "$CC" ]; then
|
|
|
|
# The libdeflate authors recommend that we build using GCC as it produces "slightly faster binaries":
|
|
|
|
# https://github.com/ebiggers/libdeflate#for-unix
|
|
|
|
export CC=gcc
|
|
|
|
fi
|
|
|
|
|
2020-05-24 16:56:26 +02:00
|
|
|
if [ ! -d libdeflate ]; then
|
|
|
|
echo "Cloning libdeflate..."
|
2024-09-01 02:30:47 +02:00
|
|
|
git clone --branch v1.21 --single-branch https://github.com/ebiggers/libdeflate.git
|
2019-09-09 05:30:28 +02:00
|
|
|
fi
|
|
|
|
|
2020-05-24 16:56:26 +02:00
|
|
|
echo "Compiling libdeflate..."
|
|
|
|
cd libdeflate || exit
|
2024-09-01 02:30:47 +02:00
|
|
|
rm -rf build && cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -B build && cmake --build build --target libdeflate_static
|
2019-09-09 05:30:28 +02:00
|
|
|
cd ..
|
|
|
|
|
2020-10-27 06:44:14 +01:00
|
|
|
CFLAGS="-O2 -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/ -fPIC -shared -Wl,-z,noexecstack -Wall -Werror -fomit-frame-pointer"
|
2020-06-04 20:56:17 +02:00
|
|
|
ARCH=$(uname -m)
|
|
|
|
mkdir -p src/main/resources/linux_$ARCH
|
2020-09-16 06:07:52 +02:00
|
|
|
$CC $CFLAGS -Ilibdeflate src/main/c/jni_util.c src/main/c/jni_zlib_deflate.c src/main/c/jni_zlib_inflate.c \
|
2024-09-01 02:30:47 +02:00
|
|
|
libdeflate/build/libdeflate.a -o src/main/resources/linux_$ARCH/velocity-compress.so
|