1# ##########################################################################
2# LZ4 examples - Makefile
3# Copyright (C) Yann Collet 2011-2020
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/lz4/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
30CPPFLAGS += -I../lib
31CFLAGS   ?= -O3
32CFLAGS   += -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes
33FLAGS    := $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
34
35TESTFILE  = Makefile
36LZ4DIR   := ../lib
37LZ4       = ../programs/lz4
38
39include ../Makefile.inc
40
41default: all
42
43all: printVersion doubleBuffer dictionaryRandomAccess ringBuffer ringBufferHC \
44     lineCompress frameCompress simpleBuffer
45
46$(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
47	$(MAKE) -C $(LZ4DIR) liblz4.a
48
49printVersion: printVersion.c $(LZ4DIR)/liblz4.a
50	$(CC) $(FLAGS) $^ -o $@$(EXT)
51
52doubleBuffer: blockStreaming_doubleBuffer.c $(LZ4DIR)/liblz4.a
53	$(CC) $(FLAGS) $^ -o $@$(EXT)
54
55dictionaryRandomAccess: dictionaryRandomAccess.c $(LZ4DIR)/liblz4.a
56	$(CC) $(FLAGS) $^ -o $@$(EXT)
57
58ringBuffer  : blockStreaming_ringBuffer.c $(LZ4DIR)/liblz4.a
59	$(CC) $(FLAGS) $^ -o $@$(EXT)
60
61ringBufferHC: HCStreaming_ringBuffer.c $(LZ4DIR)/liblz4.a
62	$(CC) $(FLAGS) $^ -o $@$(EXT)
63
64lineCompress: blockStreaming_lineByLine.c $(LZ4DIR)/liblz4.a
65	$(CC) $(FLAGS) $^ -o $@$(EXT)
66
67frameCompress: frameCompress.c $(LZ4DIR)/liblz4.a
68	$(CC) $(FLAGS) $^ -o $@$(EXT)
69
70compressFunctions: compress_functions.c $(LZ4DIR)/liblz4.a
71	$(CC) $(FLAGS) $^ -o $@$(EXT) -lrt
72
73simpleBuffer: simple_buffer.c $(LZ4DIR)/liblz4.a
74	$(CC) $(FLAGS) $^ -o $@$(EXT)
75
76$(LZ4) :
77	$(MAKE) -C ../programs lz4
78
79test : all $(LZ4)
80	@echo "\n=== Print Version ==="
81	./printVersion$(EXT)
82	@echo "\n=== Simple compression example ==="
83	./simpleBuffer$(EXT)
84	@echo "\n=== Double-buffer ==="
85	./doubleBuffer$(EXT) $(TESTFILE)
86	@echo "\n=== Ring Buffer ==="
87	./ringBuffer$(EXT)   $(TESTFILE)
88	@echo "\n=== Ring Buffer + LZ4 HC ==="
89	./ringBufferHC$(EXT) $(TESTFILE)
90	@echo "\n=== Compress line by line ==="
91	./lineCompress$(EXT) $(TESTFILE)
92	@echo "\n=== Dictionary Random Access ==="
93	./dictionaryRandomAccess$(EXT) $(TESTFILE) $(TESTFILE) 1100 1400
94	@echo "\n=== Frame compression ==="
95	./frameCompress$(EXT) $(TESTFILE)
96	$(LZ4) -vt $(TESTFILE).lz4
97
98clean:
99	@rm -f core *.o *.dec *-0 *-9 *-8192 *.lz4s *.lz4 \
100	 printVersion$(EXT) doubleBuffer$(EXT) dictionaryRandomAccess$(EXT) \
101	 ringBuffer$(EXT) ringBufferHC$(EXT) lineCompress$(EXT) frameCompress$(EXT) \
102	 compressFunctions$(EXT) simpleBuffer$(EXT)
103	@echo Cleaning completed
104