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..."
|
|
|
|
git clone 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
|
2020-06-23 02:14:46 +02:00
|
|
|
CFLAGS="-fPIC -O2" make
|
2019-09-09 05:30:28 +02:00
|
|
|
cd ..
|
|
|
|
|
2020-09-16 06:07:52 +02:00
|
|
|
CFLAGS="-O2 -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/ -fPIC -shared -Wl,-z,noexecstack -Wall -Werror"
|
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 \
|
2020-06-04 20:56:17 +02:00
|
|
|
libdeflate/libdeflate.a -o src/main/resources/linux_$ARCH/velocity-compress.so
|
2020-09-16 06:07:52 +02:00
|
|
|
$CC $CFLAGS -shared src/main/c/jni_util.c src/main/c/jni_cipher.c \
|
2020-06-23 02:14:46 +02:00
|
|
|
-o src/main/resources/linux_$ARCH/velocity-cipher.so -lcrypto
|