xref: /freebsd/sys/contrib/zstd/examples/Makefile (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
1# ################################################################
2# Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
3# All rights reserved.
4#
5# This source code is licensed under both the BSD-style license (found in the
6# LICENSE file in the root directory of this source tree) and the GPLv2 (found
7# in the COPYING file in the root directory of this source tree).
8# You may select, at your option, one of the above-listed licenses.
9# ################################################################
10
11LIBDIR =../lib
12CPPFLAGS += -I$(LIBDIR)
13LIB = $(LIBDIR)/libzstd.a
14
15
16.PHONY: default
17default: all
18
19.PHONY: all
20all: simple_compression simple_decompression \
21	multiple_simple_compression\
22	dictionary_compression dictionary_decompression \
23	streaming_compression streaming_decompression \
24	multiple_streaming_compression streaming_memory_usage
25
26$(LIB) :
27	$(MAKE) -C $(LIBDIR) libzstd.a
28
29simple_compression.o: common.h
30simple_compression : $(LIB)
31
32simple_decompression.o: common.h
33simple_decompression : $(LIB)
34
35multiple_simple_compression.o: common.h
36multiple_simple_compression : $(LIB)
37
38dictionary_compression.o: common.h
39dictionary_compression : $(LIB)
40
41dictionary_decompression.o: common.h
42dictionary_decompression : $(LIB)
43
44streaming_compression.o: common.h
45streaming_compression : $(LIB)
46
47multiple_streaming_compression.o: common.h
48multiple_streaming_compression : $(LIB)
49
50streaming_decompression.o: common.h
51streaming_decompression : $(LIB)
52
53streaming_memory_usage.o: common.h
54streaming_memory_usage : $(LIB)
55
56
57.PHONY:clean
58clean:
59	@$(RM) core *.o tmp* result* *.zst \
60        simple_compression simple_decompression \
61        multiple_simple_compression \
62        dictionary_compression dictionary_decompression \
63        streaming_compression streaming_decompression \
64        multiple_streaming_compression streaming_memory_usage
65	@echo Cleaning completed
66
67.PHONY:test
68test: all
69	cp README.md tmp
70	cp Makefile tmp2
71	@echo -- Simple compression tests
72	./simple_compression tmp
73	./simple_decompression tmp.zst
74	./multiple_simple_compression *.c
75	./streaming_decompression tmp.zst > /dev/null
76	@echo -- Streaming memory usage
77	./streaming_memory_usage
78	@echo -- Streaming compression tests
79	./streaming_compression tmp
80	./streaming_decompression tmp.zst > /dev/null
81	@echo -- Edge cases detection
82	! ./streaming_decompression tmp    # invalid input, must fail
83	! ./simple_decompression tmp       # invalid input, must fail
84	touch tmpNull                      # create 0-size file
85	./simple_compression tmpNull
86	./simple_decompression tmpNull.zst # 0-size frame : must work
87	@echo -- Multiple streaming tests
88	./multiple_streaming_compression *.c
89	@echo -- Dictionary compression tests
90	./dictionary_compression tmp2 tmp README.md
91	./dictionary_decompression tmp2.zst tmp.zst README.md
92	$(RM) tmp* *.zst
93	@echo tests completed
94