--- /dev/null
+LZ4 Library
+Copyright (c) 2013, Yann Collet
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
# ################################################################
-# LZ4 Makefile
-# Copyright (C) Yann Collet 2011-2013
-# GPL v2 License
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
+# LZ4 library - Makefile
+# Copyright (C) Yann Collet 2011-2014
+# All rights reserved.
+#
+# BSD license
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice, this
+# list of conditions and the following disclaimer in the documentation and/or
+# other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
# You can contact the author at :
# - LZ4 source repository : http://code.google.com/p/lz4/
# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
# ################################################################
-# lz4 : Command Line Utility, supporting gzip-like arguments
-# lz4c : CLU, supporting also legacy lz4demo arguments
-# lz4c32: Same as lz4c, but forced to compile in 32-bits mode
-# fuzzer : Test tool, to check lz4 integrity on target platform
-# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
-# fullbench : Precisely measure speed for each LZ4 function variant
-# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
-# ################################################################
-RELEASE=r110
+RELEASE=r111
DESTDIR=
-PREFIX=${DESTDIR}/usr
-BINDIR=$(PREFIX)/bin
-MANDIR=$(PREFIX)/share/man/man1
-DISTRIBNAME=lz4-$(RELEASE).tar.gz
+PREFIX=/usr
CC=gcc
-CFLAGS=-I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"$(RELEASE)\"
+CFLAGS+= -I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"$(RELEASE)\"
+
+LIBDIR=$(PREFIX)/lib
+INCLUDEDIR=$(PREFIX)/include
+PRGDIR=programs
+DISTRIBNAME=lz4-$(RELEASE).tar.gz
+
# Define *.exe as extension for Windows systems
-# ifeq ($(OS),Windows_NT)
ifneq (,$(filter Windows%,$(OS)))
EXT =.exe
else
EXT =
endif
-TEXT = bench.c bench.h fullbench.c fuzzer.c lz4.1 lz4.c lz4cli.c \
- lz4_format_description.txt lz4.h lz4hc.c lz4hc.h \
- Makefile xxhash.c xxhash.h \
- NEWS COPYING \
- cmake/CMakeLists.txt cmake/pack/release_COPYING.txt \
- cmake/pack/CMakeLists.txt
+TEXT = lz4.c lz4.h lz4hc.c lz4hc.h \
+ lz4_format_description.txt Makefile NEWS LICENSE \
+ cmake_unofficial/CMakeLists.txt \
+ $(PRGDIR)/fullbench.c $(PRGDIR)/fuzzer.c $(PRGDIR)/lz4cli.c \
+ $(PRGDIR)/bench.c $(PRGDIR)/bench.h \
+ $(PRGDIR)/xxhash.c $(PRGDIR)/xxhash.h \
+ $(PRGDIR)/lz4.1 $(PRGDIR)/Makefile $(PRGDIR)/COPYING
NONTEXT = LZ4_Streaming_Format.odt
SOURCES = $(TEXT) $(NONTEXT)
-default: lz4 lz4c
-
-all: lz4 lz4c lz4c32 fuzzer fuzzer32 fullbench fullbench32
-
-lz4: lz4.c lz4hc.c bench.c xxhash.c lz4cli.c
- $(CC) -O3 $(CFLAGS) -DDISABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT)
-
-lz4c : lz4.c lz4hc.c bench.c xxhash.c lz4cli.c
- $(CC) -O3 $(CFLAGS) $^ -o $@$(EXT)
+default: liblz4
-lz4c32: lz4.c lz4hc.c bench.c xxhash.c lz4cli.c
- $(CC) -m32 -O3 $(CFLAGS) $^ -o $@$(EXT)
+all: liblz4 lz4programs
-fuzzer : lz4.c lz4hc.c fuzzer.c
- @echo fuzzer is a test tool to check lz4 integrity on target platform
- $(CC) -O3 $(CFLAGS) $^ -o $@$(EXT)
+liblz4: liblz4.a liblz4.so
-fuzzer32: lz4.c lz4hc.c fuzzer.c
- $(CC) -m32 -O3 $(CFLAGS) $^ -o $@$(EXT)
+lz4programs: lz4.c lz4hc.c
+ @cd $(PRGDIR); make all
-fullbench : lz4.c lz4hc.c xxhash.c fullbench.c
- $(CC) -O3 $(CFLAGS) $^ -o $@$(EXT)
+liblz4.a: lz4.c lz4hc.c
+ $(CC) -O3 -c $(CFLAGS) $^
+ ar rcs liblz4.a lz4.o lz4hc.o
-fullbench32: lz4.c lz4hc.c xxhash.c fullbench.c
- $(CC) -m32 -O3 $(CFLAGS) $^ -o $@$(EXT)
+liblz4.so: lz4.c lz4hc.c lz4.h
+ $(CC) -shared -fPIC -Wl,--soname=liblz4.so.1 $(CFLAGS) -o $@
clean:
- @rm -f core *.o lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) \
- fuzzer$(EXT) fuzzer32$(EXT) fullbench$(EXT) fullbench32$(EXT) \
- $(DISTRIBNAME)
+ @rm -f core *.o *.a *.so $(DISTRIBNAME)
+ @cd $(PRGDIR); make clean
@echo Cleaning completed
-ifeq ($(shell uname),Linux)
+#ifeq ($(shell uname),Linux)
+ifneq (,$(filter $(shell uname),Linux Darwin))
-install: lz4 lz4c
- @install -d -m 755 $(BINDIR)/ $(MANDIR)/
- @install -m 755 lz4 $(BINDIR)/lz4
- @install -m 755 lz4c $(BINDIR)/lz4c
- @install -m 644 lz4.1 $(MANDIR)/lz4.1
+install: liblz4
+ @install -d -m 755 $(DESTDIR)$(LIBDIR)/ $(DESTDIR)$(INCLUDEDIR)/
+ @install -m 755 liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a
+ @install -m 755 liblz4.so $(DESTDIR)$(LIBDIR)/liblz4.so
+ @install -m 755 lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h
+ @install -m 755 lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h
+ @echo lz4 static and shared library installed
+ @cd $(PRGDIR); make install
uninstall:
- [ -x $(BINDIR)/lz4 ] && rm -f $(BINDIR)/lz4
- [ -x $(BINDIR)/lz4c ] && rm -f $(BINDIR)/lz4c
- [ -f $(MANDIR)/lz4.1 ] && rm -f $(MANDIR)/lz4.1
+ [ -x $(DESTDIR)$(LIBDIR)/liblz4.a ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.a
+ [ -x $(DESTDIR)$(LIBDIR)/liblz4.so ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.so
+ [ -f $(DESTDIR)$(INCLUDEDIR)/lz4.h ] && rm -f lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h
+ [ -f $(DESTDIR)$(INCLUDEDIR)/lz4hc.h ] && rm -f lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h
+ @echo lz4 libraries successfully uninstalled
+ @cd $(PRGDIR); make uninstall
dist: clean
- @install -dD -m 700 lz4-$(RELEASE)/cmake/pack/
+ @install -dD -m 700 lz4-$(RELEASE)/programs/
+ @install -dD -m 700 lz4-$(RELEASE)/cmake_unofficial/
@for f in $(TEXT); do \
tr -d '\r' < $$f > .tmp; \
install -m 600 .tmp lz4-$(RELEASE)/$$f; \
+r111 :
+Makefile : added capability to install libraries
+Modified Directory tree, to better separate libraries from programs.
+
r110 :
lz4 & lz4hc : added capability to allocate state & stream state with custom allocator (issue 99)
fuzzer & fullbench : updated to test new functions
+++ /dev/null
-cmake_minimum_required (VERSION 2.8)\r
-PROJECT(LZ4)\r
-\r
-############################## CPACK\r
-set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../)\r
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 Packer")\r
-set(CPACK_PACKAGE_VERSION_MAJOR 0)\r
-set(CPACK_PACKAGE_VERSION_MINOR 0)\r
-set(CPACK_PACKAGE_VERSION_PATCH r107)\r
-#set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_BINARY_DIR}/COPYING_LGPL)\r
-##############################\r
-FIND_PACKAGE(Subversion)\r
-IF(SUBVERSION_FOUND)\r
- Subversion_WC_INFO(${SRC_DIR} revision)\r
- set(revision_MY_WC_STATUS "LZ4 has revision ${revision_WC_REVISION} at ${revision_WC_LAST_CHANGED_DATE}")\r
- message(STATUS ${revision_MY_WC_STATUS})\r
- if(NOT ${revision_WC_REVISION})\r
- else(NOT ${revision_WC_REVISION})\r
- set(CPACK_PACKAGE_VERSION_PATCH "r${revision_WC_REVISION}")\r
- endif(NOT ${revision_WC_REVISION})\r
-ELSE(SUBVERSION_FOUND)\r
- message(WARNING "NO Subversion FOUND!!!")\r
-ENDIF(SUBVERSION_FOUND)\r
-set(VERSION_STRING " \"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ")\r
-##############################\r
-INCLUDE (CheckTypeSize)\r
-check_type_size("void *" SIZEOF_VOID_P)\r
-IF( ${SIZEOF_VOID_P} STREQUAL "8" )\r
- set (CMAKE_SYSTEM_PROCESSOR "64bit")\r
- MESSAGE( STATUS "64 bit architecture detected size of void * is " ${SIZEOF_VOID_P})\r
-ENDIF()\r
-############################### warnings\r
-\r
-ADD_DEFINITIONS("-Wall")\r
-ADD_DEFINITIONS("-W")\r
-ADD_DEFINITIONS("-Wundef")\r
-ADD_DEFINITIONS("-Wcast-align")\r
-ADD_DEFINITIONS("-Wno-implicit-function-declaration")\r
-ADD_DEFINITIONS("-O3 -march=native -std=c99")\r
-INCLUDE_DIRECTORIES (${SRC_DIR})\r
-\r
-\r
-\r
-set(LZ4_SRCS_LIB ${SRC_DIR}lz4.c ${SRC_DIR}lz4hc.c ${SRC_DIR}lz4.h ${SRC_DIR}lz4_format_description.txt)\r
-set(LZ4_SRCS ${LZ4_SRCS_LIB} ${SRC_DIR}xxhash.c ${SRC_DIR}bench.c ${SRC_DIR}lz4cli.c )\r
-set(FUZZER_SRCS ${SRC_DIR}lz4.c ${SRC_DIR}lz4hc.c ${SRC_DIR}lz4.h ${SRC_DIR}fuzzer.c)\r
-\r
-# EXECUTABLES FOR 32 Bit and 64 versions\r
-if(CMAKE_SYSTEM_PROCESSOR STREQUAL "64bit")\r
- add_executable(lz4c32 ${LZ4_SRCS})\r
- install(TARGETS lz4c32 RUNTIME DESTINATION "bin/")\r
-SET_TARGET_PROPERTIES(lz4c32 PROPERTIES\r
- COMPILE_FLAGS PROPERTIES COMPILE_FLAGS "-m32 -Os" LINK_FLAGS "-m32")\r
-endif()\r
-\r
-add_executable(lz4c ${LZ4_SRCS})\r
-install(TARGETS lz4c RUNTIME DESTINATION "bin/")\r
-\r
-add_executable(fuzzer ${FUZZER_SRCS})\r
-install(TARGETS fuzzer RUNTIME DESTINATION "bin/")\r
-\r
-#target_link_libraries(lz4 ${LZ4_SRCS_LIB})\r
-####################### CPACK PACKAGING ###################\r
-install(FILES ${SRC_DIR}lz4_format_description.txt DESTINATION "./")\r
-\r
-set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})\r
-set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/release_COPYING.txt")\r
-set(CPACK_PACKAGE_VENDOR "Yann Collet")\r
-set(CPACK_WWW_SITE "http://fastcompression.blogspot.com/p/lz4.html")\r
-set(CPACK_NSIS_URL_INFO_ABOUT "${CPACK_WWW_SITE}")\r
-set(CPACK_NSIS_HELP_LINK "${CPACK_WWW_SITE}")\r
-\r
-set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_NAME})\r
-set(CPACK_NSIS_COMPRESSOR "/SOLID lzma \r\n SetCompressorDictSize 32")\r
-\r
-set(CPACK_NSIS_MENU_LINKS\r
- "${CPACK_WWW_SITE}" "${CPACK_PACKAGE_NAME} homepage"\r
- "/lz4_format_description.txt " "lz4 format description"\r
- "/" "LZ4 directory "\r
-)\r
-\r
-include (CPack)\r
+++ /dev/null
-\r
- lz4demo and fuzzer is an open-source demo compression algorithm LZ4 programs\r
- Copyright (C) Yann Collet 2012\r
-\r
- This program is free software; you can redistribute it and/or modify\r
- it under the terms of the GNU General Public License as published by\r
- the Free Software Foundation; either version 2 of the License, or\r
- (at your option) any later version.\r
-\r
- This program is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License along\r
- with this program; if not, write to the Free Software Foundation, Inc.,\r
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
-\r
- You can contact the author at :\r
- - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html\r
- - LZ4 source repository : http://code.google.com/p/lz4/\r
-PROJECT(LZ4 C)\r
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library")\r
-set(CPACK_PACKAGE_VERSION_MAJOR 0)\r
-set(CPACK_PACKAGE_VERSION_MINOR 0)\r
-set(CPACK_PACKAGE_VERSION_PATCH r110)\r
-#set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_BINARY_DIR}/COPYING_LGPL)\r
-set(VERSION_STRING " \"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ")\r
-include(CPack)\r
-\r
-cmake_minimum_required (VERSION 2.6)\r
-INCLUDE (CheckTypeSize)\r
-check_type_size("void *" SIZEOF_VOID_P)\r
-IF( ${SIZEOF_VOID_P} STREQUAL "8" )\r
- set (CMAKE_SYSTEM_PROCESSOR "64bit")\r
- MESSAGE( STATUS "64 bit architecture detected size of void * is " ${SIZEOF_VOID_P})\r
-ENDIF()\r
-\r
-option(BUILD_TOOLS "Build the command line tools" ON)\r
-option(BUILD_LIBS "Build the libraries in addition to the tools" OFF)\r
-\r
-if(UNIX AND BUILD_LIBS)\r
- if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")\r
- add_definitions(-fPIC)\r
- endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")\r
-endif()\r
-\r
-set(SRC_DIR ../)\r
-set(LZ4_SRCS_LIB ${SRC_DIR}lz4.c ${SRC_DIR}lz4hc.c ${SRC_DIR}lz4.h )\r
-set(LZ4_SRCS ${SRC_DIR}xxhash.c ${SRC_DIR}bench.c ${SRC_DIR}lz4cli.c)\r
-\r
-if(BUILD_TOOLS AND NOT BUILD_LIBS)\r
- set(LZ4_SRCS ${LZ4_SRCS} ${LZ4_SRCS_LIB})\r
-endif()\r
-\r
-if(BUILD_TOOLS)\r
- add_executable(lz4 ${LZ4_SRCS})\r
- set_target_properties(lz4 PROPERTIES COMPILE_DEFINITIONS DISABLE_LZ4C_LEGACY_OPTIONS)\r
- install(TARGETS lz4 RUNTIME DESTINATION "bin/")\r
- add_executable(lz4c ${LZ4_SRCS})\r
- install(TARGETS lz4c RUNTIME DESTINATION "bin/")\r
-endif()\r
-\r
-if(BUILD_LIBS) \r
- add_library(liblz4 ${LZ4_SRCS_LIB})\r
- \r
- set_target_properties(liblz4 PROPERTIES\r
- OUTPUT_NAME lz4\r
- SOVERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}"\r
- )\r
- \r
- install(TARGETS liblz4\r
- LIBRARY DESTINATION lib\r
- ARCHIVE DESTINATION lib\r
- )\r
-\r
- install(FILES\r
- ${SRC_DIR}/lz4.h\r
- ${SRC_DIR}/lz4hc.h\r
- DESTINATION include\r
- )\r
- \r
- if(BUILD_TOOLS)\r
- target_link_libraries(lz4 liblz4)\r
- target_link_libraries(lz4c liblz4)\r
- endif()\r
-endif()\r
-\r
-\r
-#warnings\r
-\r
-ADD_DEFINITIONS("-Wall")\r
-ADD_DEFINITIONS("-W")\r
-ADD_DEFINITIONS("-Wundef")\r
-ADD_DEFINITIONS("-Wcast-align")\r
-ADD_DEFINITIONS("-std=c99")\r
-ADD_DEFINITIONS("-DLZ4_VERSION=\"${CPACK_PACKAGE_VERSION_PATCH}\"")\r
-INCLUDE_DIRECTORIES (${SRC_DIR})\r
-\r
-\r
-\r
+PROJECT(LZ4 C)
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library")
+set(CPACK_PACKAGE_VERSION_MAJOR 0)
+set(CPACK_PACKAGE_VERSION_MINOR 0)
+set(CPACK_PACKAGE_VERSION_PATCH r111)
+#set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_BINARY_DIR}/COPYING_LGPL)
+set(VERSION_STRING " \"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ")
+include(CPack)
+
+cmake_minimum_required (VERSION 2.6)
+INCLUDE (CheckTypeSize)
+check_type_size("void *" SIZEOF_VOID_P)
+IF( ${SIZEOF_VOID_P} STREQUAL "8" )
+ set (CMAKE_SYSTEM_PROCESSOR "64bit")
+ MESSAGE( STATUS "64 bit architecture detected size of void * is " ${SIZEOF_VOID_P})
+ENDIF()
+
+option(BUILD_TOOLS "Build the command line tools" ON)
+option(BUILD_LIBS "Build the libraries in addition to the tools" OFF)
+
+if(UNIX AND BUILD_LIBS)
+ if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ add_definitions(-fPIC)
+ endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+endif()
+
+set(LZ4_DIR ../)
+set(PRG_DIR ../programs/)
+set(LZ4_SRCS_LIB ${LZ4_DIR}lz4.c ${LZ4_DIR}lz4hc.c ${LZ4_DIR}lz4.h ${LZ4_DIR}lz4hc.h)
+set(LZ4_SRCS ${PRG_DIR}xxhash.c ${PRG_DIR}bench.c ${PRG_DIR}lz4cli.c)
+
+if(BUILD_TOOLS AND NOT BUILD_LIBS)
+ set(LZ4_SRCS ${LZ4_SRCS} ${LZ4_SRCS_LIB})
+endif()
+
+if(BUILD_TOOLS)
+ add_executable(lz4 ${LZ4_SRCS})
+ set_target_properties(lz4 PROPERTIES COMPILE_DEFINITIONS DISABLE_LZ4C_LEGACY_OPTIONS)
+ install(TARGETS lz4 RUNTIME DESTINATION "bin/")
+ add_executable(lz4c ${LZ4_SRCS})
+ install(TARGETS lz4c RUNTIME DESTINATION "bin/")
+endif()
+
+if(BUILD_LIBS)
+ add_library(liblz4 ${LZ4_SRCS_LIB})
+
+ set_target_properties(liblz4 PROPERTIES
+ OUTPUT_NAME lz4
+ SOVERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}"
+ )
+
+ install(TARGETS liblz4
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ )
+
+ install(FILES
+ ${LZ4_DIR}/lz4.h
+ ${LZ4_DIR}/lz4hc.h
+ DESTINATION include
+ )
+
+ if(BUILD_TOOLS)
+ target_link_libraries(lz4 liblz4)
+ target_link_libraries(lz4c liblz4)
+ endif()
+endif()
+
+
+#warnings
+
+ADD_DEFINITIONS("-Wall")
+ADD_DEFINITIONS("-W")
+ADD_DEFINITIONS("-Wundef")
+ADD_DEFINITIONS("-Wcast-align")
+ADD_DEFINITIONS("-std=c99")
+ADD_DEFINITIONS("-DLZ4_VERSION=\"${CPACK_PACKAGE_VERSION_PATCH}\"")
+INCLUDE_DIRECTORIES (${LZ4_DIR})
+
+
+
-LZ4 Format Description\r
-Last revised: 2012-02-27\r
-Author : Y. Collet\r
-\r
-\r
-\r
-This small specification intents to provide enough information\r
-to anyone willing to produce LZ4-compatible compressed data blocks\r
-using any programming language.\r
-\r
-LZ4 is an LZ77-type compressor with a fixed, byte-oriented encoding.\r
-The most important design principle behind LZ4 is simplicity.\r
-It helps to create an easy to read and maintain source code.\r
-It also helps later on for optimisations, compactness, and speed.\r
-There is no entropy encoder backend nor framing layer.\r
-The latter is assumed to be handled by other parts of the system.\r
-\r
-This document only describes the format,\r
-not how the LZ4 compressor nor decompressor actually work.\r
-The correctness of the decompressor should not depend\r
-on implementation details of the compressor, and vice versa.\r
-\r
-\r
-\r
--- Compressed block format --\r
-\r
-An LZ4 compressed block is composed of sequences.\r
-Schematically, a sequence is a suite of literals, followed by a match copy.\r
-\r
-Each sequence starts with a token.\r
-The token is a one byte value, separated into two 4-bits fields.\r
-Therefore each field ranges from 0 to 15.\r
-\r
-\r
-The first field uses the 4 high-bits of the token.\r
-It provides the length of literals to follow.\r
-(Note : a literal is a not-compressed byte).\r
-If the field value is 0, then there is no literal.\r
-If it is 15, then we need to add some more bytes to indicate the full length.\r
-Each additionnal byte then represent a value from 0 to 255,\r
-which is added to the previous value to produce a total length.\r
-When the byte value is 255, another byte is output.\r
-There can be any number of bytes following the token. There is no "size limit".\r
-(Sidenote this is why a not-compressible input block is expanded by 0.4%).\r
-\r
-Example 1 : A length of 48 will be represented as :\r
-- 15 : value for the 4-bits High field\r
-- 33 : (=48-15) remaining length to reach 48\r
-\r
-Example 2 : A length of 280 will be represented as :\r
-- 15 : value for the 4-bits High field\r
-- 255 : following byte is maxed, since 280-15 >= 255\r
-- 10 : (=280 - 15 - 255) ) remaining length to reach 280\r
-\r
-Example 3 : A length of 15 will be represented as :\r
-- 15 : value for the 4-bits High field\r
-- 0 : (=15-15) yes, the zero must be output\r
-\r
-Following the token and optional length bytes, are the literals themselves.\r
-They are exactly as numerous as previously decoded (length of literals).\r
-It's possible that there are zero literal.\r
-\r
-\r
-Following the literals is the match copy operation.\r
-\r
-It starts by the offset.\r
-This is a 2 bytes value, in little endian format.\r
-\r
-The offset represents the position of the match to be copied from.\r
-1 means "current position - 1 byte".\r
-The maximum offset value is 65535, 65536 cannot be coded.\r
-Note that 0 is an invalid value, not used. \r
-\r
-Then we need to extract the match length.\r
-For this, we use the second token field, the low 4-bits.\r
-Value, obviously, ranges from 0 to 15.\r
-However here, 0 means that the copy operation will be minimal.\r
-The minimum length of a match, called minmatch, is 4. \r
-As a consequence, a 0 value means 4 bytes, and a value of 15 means 19+ bytes.\r
-Similar to literal length, on reaching the highest possible value (15), \r
-we output additional bytes, one at a time, with values ranging from 0 to 255.\r
-They are added to total to provide the final match length.\r
-A 255 value means there is another byte to read and add.\r
-There is no limit to the number of optional bytes that can be output this way.\r
-(This points towards a maximum achievable compression ratio of ~250).\r
-\r
-With the offset and the matchlength,\r
-the decoder can now proceed to copy the data from the already decoded buffer.\r
-On decoding the matchlength, we reach the end of the compressed sequence,\r
-and therefore start another one.\r
-\r
-\r
--- Parsing restrictions --\r
-\r
-There are specific parsing rules to respect in order to remain compatible\r
-with assumptions made by the decoder :\r
-1) The last 5 bytes are always literals\r
-2) The last match must start at least 12 bytes before end of block\r
-Consequently, a block with less than 13 bytes cannot be compressed.\r
-These rules are in place to ensure that the decoder\r
-will never read beyond the input buffer, nor write beyond the output buffer.\r
-\r
-Note that the last sequence is also incomplete,\r
-and stops right after literals.\r
-\r
-\r
--- Additional notes --\r
-\r
-There is no assumption nor limits to the way the compressor\r
-searches and selects matches within the source data block.\r
-It could be a fast scan, a multi-probe, a full search using BST,\r
-standard hash chains or MMC, well whatever.\r
-\r
-Advanced parsing strategies can also be implemented, such as lazy match,\r
-or full optimal parsing.\r
-\r
-All these trade-off offer distinctive speed/memory/compression advantages.\r
-Whatever the method used by the compressor, its result will be decodable\r
-by any LZ4 decoder if it follows the format specification described above.\r
-\r
+LZ4 Format Description
+Last revised: 2012-02-27
+Author : Y. Collet
+
+
+
+This small specification intents to provide enough information
+to anyone willing to produce LZ4-compatible compressed data blocks
+using any programming language.
+
+LZ4 is an LZ77-type compressor with a fixed, byte-oriented encoding.
+The most important design principle behind LZ4 is simplicity.
+It helps to create an easy to read and maintain source code.
+It also helps later on for optimisations, compactness, and speed.
+There is no entropy encoder backend nor framing layer.
+The latter is assumed to be handled by other parts of the system.
+
+This document only describes the format,
+not how the LZ4 compressor nor decompressor actually work.
+The correctness of the decompressor should not depend
+on implementation details of the compressor, and vice versa.
+
+
+
+-- Compressed block format --
+
+An LZ4 compressed block is composed of sequences.
+Schematically, a sequence is a suite of literals, followed by a match copy.
+
+Each sequence starts with a token.
+The token is a one byte value, separated into two 4-bits fields.
+Therefore each field ranges from 0 to 15.
+
+
+The first field uses the 4 high-bits of the token.
+It provides the length of literals to follow.
+(Note : a literal is a not-compressed byte).
+If the field value is 0, then there is no literal.
+If it is 15, then we need to add some more bytes to indicate the full length.
+Each additionnal byte then represent a value from 0 to 255,
+which is added to the previous value to produce a total length.
+When the byte value is 255, another byte is output.
+There can be any number of bytes following the token. There is no "size limit".
+(Sidenote this is why a not-compressible input block is expanded by 0.4%).
+
+Example 1 : A length of 48 will be represented as :
+- 15 : value for the 4-bits High field
+- 33 : (=48-15) remaining length to reach 48
+
+Example 2 : A length of 280 will be represented as :
+- 15 : value for the 4-bits High field
+- 255 : following byte is maxed, since 280-15 >= 255
+- 10 : (=280 - 15 - 255) ) remaining length to reach 280
+
+Example 3 : A length of 15 will be represented as :
+- 15 : value for the 4-bits High field
+- 0 : (=15-15) yes, the zero must be output
+
+Following the token and optional length bytes, are the literals themselves.
+They are exactly as numerous as previously decoded (length of literals).
+It's possible that there are zero literal.
+
+
+Following the literals is the match copy operation.
+
+It starts by the offset.
+This is a 2 bytes value, in little endian format.
+
+The offset represents the position of the match to be copied from.
+1 means "current position - 1 byte".
+The maximum offset value is 65535, 65536 cannot be coded.
+Note that 0 is an invalid value, not used.
+
+Then we need to extract the match length.
+For this, we use the second token field, the low 4-bits.
+Value, obviously, ranges from 0 to 15.
+However here, 0 means that the copy operation will be minimal.
+The minimum length of a match, called minmatch, is 4.
+As a consequence, a 0 value means 4 bytes, and a value of 15 means 19+ bytes.
+Similar to literal length, on reaching the highest possible value (15),
+we output additional bytes, one at a time, with values ranging from 0 to 255.
+They are added to total to provide the final match length.
+A 255 value means there is another byte to read and add.
+There is no limit to the number of optional bytes that can be output this way.
+(This points towards a maximum achievable compression ratio of ~250).
+
+With the offset and the matchlength,
+the decoder can now proceed to copy the data from the already decoded buffer.
+On decoding the matchlength, we reach the end of the compressed sequence,
+and therefore start another one.
+
+
+-- Parsing restrictions --
+
+There are specific parsing rules to respect in order to remain compatible
+with assumptions made by the decoder :
+1) The last 5 bytes are always literals
+2) The last match must start at least 12 bytes before end of block
+Consequently, a block with less than 13 bytes cannot be compressed.
+These rules are in place to ensure that the decoder
+will never read beyond the input buffer, nor write beyond the output buffer.
+
+Note that the last sequence is also incomplete,
+and stops right after literals.
+
+
+-- Additional notes --
+
+There is no assumption nor limits to the way the compressor
+searches and selects matches within the source data block.
+It could be a fast scan, a multi-probe, a full search using BST,
+standard hash chains or MMC, well whatever.
+
+Advanced parsing strategies can also be implemented, such as lazy match,
+or full optimal parsing.
+
+All these trade-off offer distinctive speed/memory/compression advantages.
+Whatever the method used by the compressor, its result will be decodable
+by any LZ4 decoder if it follows the format specification described above.
+
--- /dev/null
+# ################################################################
+# LZ4 programs - Makefile
+# Copyright (C) Yann Collet 2011-2014
+# GPL v2 License
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# You can contact the author at :
+# - LZ4 source repository : http://code.google.com/p/lz4/
+# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
+# ################################################################
+# lz4 : Command Line Utility, supporting gzip-like arguments
+# lz4c : CLU, supporting also legacy lz4demo arguments
+# lz4c32: Same as lz4c, but forced to compile in 32-bits mode
+# fuzzer : Test tool, to check lz4 integrity on target platform
+# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
+# fullbench : Precisely measure speed for each LZ4 function variant
+# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
+# ################################################################
+
+RELEASE=r111
+DESTDIR=
+PREFIX=/usr
+CC=gcc
+CFLAGS+= -I. -std=c99 -Wall -W -Wundef -DLZ4_VERSION=\"$(RELEASE)\"
+
+BINDIR=$(PREFIX)/bin
+MANDIR=$(PREFIX)/share/man/man1
+LZ4DIR=..
+
+
+# Define *.exe as extension for Windows systems
+ifneq (,$(filter Windows%,$(OS)))
+EXT =.exe
+else
+EXT =
+endif
+
+
+default: lz4 lz4c
+
+all: lz4 lz4c lz4c32 fuzzer fuzzer32 fullbench fullbench32
+
+lz4: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c bench.c xxhash.c lz4cli.c
+ $(CC) -O3 $(CFLAGS) -DDISABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT)
+
+lz4c : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c bench.c xxhash.c lz4cli.c
+ $(CC) -O3 $(CFLAGS) $^ -o $@$(EXT)
+
+lz4c32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c bench.c xxhash.c lz4cli.c
+ $(CC) -m32 -O3 $(CFLAGS) $^ -o $@$(EXT)
+
+fuzzer : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c fuzzer.c
+ @echo fuzzer is a test tool to check lz4 integrity on target platform
+ $(CC) -O3 $(CFLAGS) $^ -o $@$(EXT)
+
+fuzzer32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c fuzzer.c
+ $(CC) -m32 -O3 $(CFLAGS) $^ -o $@$(EXT)
+
+fullbench : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c xxhash.c fullbench.c
+ $(CC) -O3 $(CFLAGS) $^ -o $@$(EXT)
+
+fullbench32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c xxhash.c fullbench.c
+ $(CC) -m32 -O3 $(CFLAGS) $^ -o $@$(EXT)
+
+clean:
+ @rm -f core *.o \
+ lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) \
+ fuzzer$(EXT) fuzzer32$(EXT) fullbench$(EXT) fullbench32$(EXT)
+ @echo Cleaning completed
+
+
+ifneq (,$(filter $(shell uname),Linux Darwin))
+
+install: lz4 lz4c
+ @install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
+ @install -m 755 lz4 $(DESTDIR)$(BINDIR)/lz4
+ @install -m 755 lz4c $(DESTDIR)$(BINDIR)/lz4c
+ @install -m 644 lz4.1 $(DESTDIR)$(MANDIR)/lz4.1
+ @echo lz4 installation completed
+
+uninstall:
+ [ -x $(DESTDIR)$(BINDIR)/lz4 ] && rm -f $(DESTDIR)$(BINDIR)/lz4
+ [ -x $(DESTDIR)$(BINDIR)/lz4c ] && rm -f $(DESTDIR)$(BINDIR)/lz4c
+ [ -f $(DESTDIR)$(MANDIR)/lz4.1 ] && rm -f $(DESTDIR)$(MANDIR)/lz4.1
+ @echo lz4 successfully uninstalled
+
+endif