1 # ########################################################################## 2 # LZ4 examples - Makefile 3 # Copyright (C) Yann Collet 2011-2014 4 # 5 # GPL v2 License 6 # 7 # This program is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License along 18 # with this program; if not, write to the Free Software Foundation, Inc., 19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # You can contact the author at : 22 # - LZ4 source repository : https://github.com/Cyan4973/lz4 23 # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c 24 # ########################################################################## 25 # This makefile compile and test 26 # example programs, using (mostly) LZ4 streaming library, 27 # kindly provided by Takayuki Matsuoka 28 # ########################################################################## 29 30 CPPFLAGS += -I../lib 31 CFLAGS ?= -O3 32 CFLAGS += -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes 33 FLAGS := $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS) 34 35 TESTFILE = Makefile 36 LZ4DIR := ../lib 37 LZ4 = ../programs/lz4 38 39 40 # Define *.exe as extension for Windows systems 41 ifneq (,$(filter Windows%,$(OS))) 42 EXT =.exe 43 VOID = nul 44 else 45 EXT = 46 VOID = /dev/null 47 endif 48 49 50 default: all 51 52 all: printVersion doubleBuffer dictionaryRandomAccess ringBuffer ringBufferHC \ 53 lineCompress frameCompress simpleBuffer 54 55 $(LZ4DIR)/liblz4.a: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.h $(LZ4DIR)/lz4hc.h $(LZ4DIR)/lz4frame.h $(LZ4DIR)/lz4frame_static.h 56 $(MAKE) -C $(LZ4DIR) liblz4.a 57 58 printVersion: printVersion.c $(LZ4DIR)/liblz4.a 59 $(CC) $(FLAGS) $^ -o $@$(EXT) 60 61 doubleBuffer: blockStreaming_doubleBuffer.c $(LZ4DIR)/liblz4.a 62 $(CC) $(FLAGS) $^ -o $@$(EXT) 63 64 dictionaryRandomAccess: dictionaryRandomAccess.c $(LZ4DIR)/liblz4.a 65 $(CC) $(FLAGS) $^ -o $@$(EXT) 66 67 ringBuffer : blockStreaming_ringBuffer.c $(LZ4DIR)/liblz4.a 68 $(CC) $(FLAGS) $^ -o $@$(EXT) 69 70 ringBufferHC: HCStreaming_ringBuffer.c $(LZ4DIR)/liblz4.a 71 $(CC) $(FLAGS) $^ -o $@$(EXT) 72 73 lineCompress: blockStreaming_lineByLine.c $(LZ4DIR)/liblz4.a 74 $(CC) $(FLAGS) $^ -o $@$(EXT) 75 76 frameCompress: frameCompress.c $(LZ4DIR)/liblz4.a 77 $(CC) $(FLAGS) $^ -o $@$(EXT) 78 79 compressFunctions: compress_functions.c $(LZ4DIR)/liblz4.a 80 $(CC) $(FLAGS) $^ -o $@$(EXT) -lrt 81 82 simpleBuffer: simple_buffer.c $(LZ4DIR)/liblz4.a 83 $(CC) $(FLAGS) $^ -o $@$(EXT) 84 85 $(LZ4) : 86 $(MAKE) -C ../programs lz4 87 88 test : all $(LZ4) 89 @echo "\n=== Print Version ===" 90 ./printVersion$(EXT) 91 @echo "\n=== Simple compression example ===" 92 ./simpleBuffer$(EXT) 93 @echo "\n=== Double-buffer ===" 94 ./doubleBuffer$(EXT) $(TESTFILE) 95 @echo "\n=== Ring Buffer ===" 96 ./ringBuffer$(EXT) $(TESTFILE) 97 @echo "\n=== Ring Buffer + LZ4 HC ===" 98 ./ringBufferHC$(EXT) $(TESTFILE) 99 @echo "\n=== Compress line by line ===" 100 ./lineCompress$(EXT) $(TESTFILE) 101 @echo "\n=== Dictionary Random Access ===" 102 ./dictionaryRandomAccess$(EXT) $(TESTFILE) $(TESTFILE) 1100 1400 103 @echo "\n=== Frame compression ===" 104 ./frameCompress$(EXT) $(TESTFILE) 105 $(LZ4) -vt $(TESTFILE).lz4 106 107 clean: 108 @rm -f core *.o *.dec *-0 *-9 *-8192 *.lz4s *.lz4 \ 109 printVersion$(EXT) doubleBuffer$(EXT) dictionaryRandomAccess$(EXT) \ 110 ringBuffer$(EXT) ringBufferHC$(EXT) lineCompress$(EXT) frameCompress$(EXT) \ 111 compressFunctions$(EXT) simpleBuffer$(EXT) 112 @echo Cleaning completed 113