xref: /aosp_15_r20/external/lz4/examples/Makefile (revision 27162e4e17433d5aa7cb38e7b6a433a09405fc7f)
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
30LIBDIR    := ../lib
31
32CPPFLAGS  += -I$(LIBDIR)
33USERCFLAGS:= $(CFLAGS)
34WFLAGS     = -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -Wc++-compat
35CFLAGS     = $(WFLAGS) -O2 $(USERCFLAGS)
36
37TESTFILE   = Makefile
38SLIBLZ4   := $(LIBDIR)/liblz4.a
39LZ4DIR     = ../programs
40LZ4        = $(LZ4DIR)/lz4
41
42default: all
43
44$(SLIBLZ4): $(LIBDIR)/lz4.c $(LIBDIR)/lz4hc.c $(LIBDIR)/lz4frame.c $(LIBDIR)/lz4.h $(LIBDIR)/lz4hc.h $(LIBDIR)/lz4frame.h $(LIBDIR)/lz4frame_static.h
45	$(MAKE) -j -C $(LIBDIR) liblz4.a
46
47ALL = print_version \
48	  simple_buffer \
49	  frameCompress \
50	  fileCompress \
51      blockStreaming_doubleBuffer \
52	  blockStreaming_ringBuffer \
53	  streamingHC_ringBuffer \
54      blockStreaming_lineByLine \
55	  dictionaryRandomAccess \
56	  bench_functions
57
58.PHONY: all
59all: $(ALL)
60
61$(ALL): $(SLIBLZ4)
62
63.PHONY:$(LZ4)
64$(LZ4) :
65	$(MAKE) -j -C $(LZ4DIR) lz4
66
67.PHONY: test
68test : all $(LZ4)
69	@echo "\n=== Print Version ==="
70	./print_version$(EXT)
71	@echo "\n=== Simple compression example ==="
72	./simple_buffer$(EXT)
73	@echo "\n=== Double-buffer ==="
74	./blockStreaming_doubleBuffer$(EXT) $(TESTFILE)
75	@echo "\n=== Ring Buffer ==="
76	./blockStreaming_ringBuffer$(EXT)   $(TESTFILE)
77	@echo "\n=== Ring Buffer + LZ4 HC ==="
78	./streamingHC_ringBuffer$(EXT) $(TESTFILE)
79	@echo "\n=== Compress line by line ==="
80	./blockStreaming_lineByLine$(EXT) $(TESTFILE)
81	@echo "\n=== Dictionary Random Access ==="
82	./dictionaryRandomAccess$(EXT) $(TESTFILE) $(TESTFILE) 1100 1400
83	@echo "\n=== Frame compression ==="
84	./frameCompress$(EXT) $(TESTFILE)
85	$(LZ4) -vt $(TESTFILE).lz4
86	@echo "\n=== file compression ==="
87	./fileCompress$(EXT) $(TESTFILE)
88	$(LZ4) -vt $(TESTFILE).lz4
89	@echo "\n=== Q&D benchmark ==="
90	./bench_functions$(EXT) 10000
91
92.PHONY: clean
93clean:
94	@$(RM) core *.o *.dec *-0 *-9 *-8192 *.lz4s *.lz4 $(ALL)
95	@echo Cleaning completed
96