]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/zstd/examples/Makefile
Update to Zstandard 1.4.0
[FreeBSD/FreeBSD.git] / sys / contrib / zstd / examples / Makefile
1 # ################################################################
2 # Copyright (c) 2016-present, 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 # ################################################################
9
10 # This Makefile presumes libzstd is installed, using `sudo make install`
11
12 CPPFLAGS += -I../lib
13 LIB = ../lib/libzstd.a
14
15 .PHONY: default all clean test
16
17 default: all
18
19 all: simple_compression simple_decompression \
20         multiple_simple_compression\
21         dictionary_compression dictionary_decompression \
22         streaming_compression streaming_decompression \
23         multiple_streaming_compression streaming_memory_usage
24
25 $(LIB) :
26         $(MAKE) -C ../lib libzstd.a
27
28 simple_compression : simple_compression.c common.h $(LIB)
29         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
30
31 simple_decompression : simple_decompression.c common.h $(LIB)
32         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
33
34 multiple_simple_compression : multiple_simple_compression.c common.h $(LIB)
35         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
36
37 dictionary_compression : dictionary_compression.c common.h $(LIB)
38         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
39
40 dictionary_decompression : dictionary_decompression.c common.h $(LIB)
41         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
42
43 streaming_compression : streaming_compression.c common.h $(LIB)
44         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
45
46 multiple_streaming_compression : multiple_streaming_compression.c common.h $(LIB)
47         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
48
49 streaming_decompression : streaming_decompression.c common.h $(LIB)
50         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
51
52 streaming_memory_usage : streaming_memory_usage.c $(LIB)
53         $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@
54
55 clean:
56         @rm -f core *.o tmp* result* *.zst \
57         simple_compression simple_decompression \
58         multiple_simple_compression \
59         dictionary_compression dictionary_decompression \
60         streaming_compression streaming_decompression \
61         multiple_streaming_compression streaming_memory_usage
62         @echo Cleaning completed
63
64 test: all
65         cp README.md tmp
66         cp Makefile tmp2
67         @echo -- Simple compression tests
68         ./simple_compression tmp
69         ./simple_decompression tmp.zst
70         ./multiple_simple_compression *.c
71         ./streaming_decompression tmp.zst > /dev/null
72         @echo -- Streaming memory usage
73         ./streaming_memory_usage
74         @echo -- Streaming compression tests
75         ./streaming_compression tmp
76         ./streaming_decompression tmp.zst > /dev/null
77         @echo -- Edge cases detection
78         ! ./streaming_decompression tmp    # invalid input, must fail
79         ! ./simple_decompression tmp       # invalid input, must fail
80         ! ./simple_decompression tmp.zst   # unknown input size, must fail
81         touch tmpNull                      # create 0-size file
82         ./simple_compression tmpNull
83         ./simple_decompression tmpNull.zst # 0-size frame : must work
84         @echo -- Multiple streaming tests
85         ./multiple_streaming_compression *.c
86         @echo -- Dictionary compression tests
87         ./dictionary_compression tmp2 tmp README.md
88         ./dictionary_decompression tmp2.zst tmp.zst README.md
89         $(RM) tmp* *.zst
90         @echo tests completed