• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 fileCompress 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
70fileCompress: fileCompress.c $(LZ4DIR)/liblz4.a
71	$(CC) $(FLAGS) $^ -o $@$(EXT)
72
73compressFunctions: compress_functions.c $(LZ4DIR)/liblz4.a
74	$(CC) $(FLAGS) $^ -o $@$(EXT) -lrt
75
76simpleBuffer: simple_buffer.c $(LZ4DIR)/liblz4.a
77	$(CC) $(FLAGS) $^ -o $@$(EXT)
78
79$(LZ4) :
80	$(MAKE) -C ../programs lz4
81
82test : all $(LZ4)
83	@echo "\n=== Print Version ==="
84	./printVersion$(EXT)
85	@echo "\n=== Simple compression example ==="
86	./simpleBuffer$(EXT)
87	@echo "\n=== Double-buffer ==="
88	./doubleBuffer$(EXT) $(TESTFILE)
89	@echo "\n=== Ring Buffer ==="
90	./ringBuffer$(EXT)   $(TESTFILE)
91	@echo "\n=== Ring Buffer + LZ4 HC ==="
92	./ringBufferHC$(EXT) $(TESTFILE)
93	@echo "\n=== Compress line by line ==="
94	./lineCompress$(EXT) $(TESTFILE)
95	@echo "\n=== Dictionary Random Access ==="
96	./dictionaryRandomAccess$(EXT) $(TESTFILE) $(TESTFILE) 1100 1400
97	@echo "\n=== Frame compression ==="
98	./frameCompress$(EXT) $(TESTFILE)
99	$(LZ4) -vt $(TESTFILE).lz4
100	@echo "\n=== file compression ==="
101	./fileCompress$(EXT) $(TESTFILE)
102	$(LZ4) -vt $(TESTFILE).lz4
103
104.PHONY: cxxtest
105cxxtest: CFLAGS := -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror
106cxxtest: clean
107	CC=$(CXX) $(MAKE) -C . all CFLAGS="$(CFLAGS)"
108
109clean:
110	@rm -f core *.o *.dec *-0 *-9 *-8192 *.lz4s *.lz4 \
111	 printVersion$(EXT) doubleBuffer$(EXT) dictionaryRandomAccess$(EXT) \
112	 ringBuffer$(EXT) ringBufferHC$(EXT) lineCompress$(EXT) frameCompress$(EXT) \
113	 fileCompress$(EXT) compressFunctions$(EXT) simpleBuffer$(EXT)
114	@echo Cleaning completed
115