From 5efbab5f3b59ebf94ac9c0b8adc8851b5f2b1cd6 Mon Sep 17 00:00:00 2001 From: Robert Manner Date: Sat, 18 Mar 2017 10:23:58 +0100 Subject: add lz4 library --- src/lz4-test.c | 36 ++++++++++++++++++++++++++++++++++++ src/lz4.mk | 27 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/lz4-test.c create mode 100644 src/lz4.mk diff --git a/src/lz4-test.c b/src/lz4-test.c new file mode 100644 index 0000000..c083f67 --- /dev/null +++ b/src/lz4-test.c @@ -0,0 +1,36 @@ +#include + +#include +#include + +int +main(int argc, char *argv[]) +{ + const char *data; + int data_len; + char compressed[100]; + int compressed_size; + char decompressed[100]; + + (void)argc; + (void)argv; + + data = "Some data to compress"; + data_len = strlen(data); + + /* compress */ + compressed_size = LZ4_compress_default(data, compressed, data_len, 100); + if (compressed_size <= 0) { + printf("Error compressing the data\n"); + return 1; + } + + LZ4_decompress_fast(compressed, decompressed, data_len); + if (strcmp(data, decompressed) != 0) { + printf("Error: the compression was not lossless. Original='%s' Result='%s'\n", data, decompressed); + return 3; + } + + printf("Successfully compressed and decompressed!\n"); + return 0; +} diff --git a/src/lz4.mk b/src/lz4.mk new file mode 100644 index 0000000..a76e301 --- /dev/null +++ b/src/lz4.mk @@ -0,0 +1,27 @@ +# This file is part of MXE. See LICENSE.md for licensing information. + +PKG := lz4 +$(PKG)_WEBSITE := https://github.com/$(PKG)/$(PKG) +$(PKG)_DESCR := lossless compression algorithm optimized for speed +$(PKG)_IGNORE := +$(PKG)_VERSION := 1.7.5 +$(PKG)_CHECKSUM := 0190cacd63022ccb86f44fa5041dc6c3804407ad61550ca21c382827319e7e7e +$(PKG)_GH_CONF := lz4/lz4,v +$(PKG)_DEPS := gcc + +define $(PKG)_BUILD + # build and install the library + cd '$(BUILD_DIR)' && $(TARGET)-cmake \ + -DCMAKE_INSTALL_BINDIR=$(BUILD_DIR)/null \ + -DCMAKE_INSTALL_MANDIR=$(BUILD_DIR)/null \ + '$(SOURCE_DIR)/contrib/cmake_unofficial' + $(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' + $(MAKE) -C '$(BUILD_DIR)' -j 1 install + $(if $(BUILD_SHARED), $(INSTALL) '$(BUILD_DIR)/liblz4.dll' '$(PREFIX)/$(TARGET)/bin/') + + # compile test + '$(TARGET)-gcc' \ + -W -Wall -Werror -ansi -pedantic \ + '$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe' \ + `'$(TARGET)-pkg-config' lib$(PKG) --cflags --libs` +endef -- cgit v0.12