summaryrefslogtreecommitdiffstats
path: root/src/zstd/examples/Makefile
blob: 52470f59933eb00533e18ce95ff9a1fe94ce182e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# ################################################################
# Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under both the BSD-style license (found in the
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
# in the COPYING file in the root directory of this source tree).
# ################################################################

# This Makefile presumes libzstd is installed, using `sudo make install`

LIB = ../lib/libzstd.a

.PHONY: default all clean test

default: all

all: simple_compression simple_decompression \
	dictionary_compression dictionary_decompression \
	streaming_compression streaming_decompression \
	multiple_streaming_compression streaming_memory_usage

$(LIB) :
	make -C ../lib libzstd.a

simple_compression : simple_compression.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

simple_decompression : simple_decompression.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

dictionary_compression : dictionary_compression.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

dictionary_decompression : dictionary_decompression.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

streaming_compression : streaming_compression.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

multiple_streaming_compression : multiple_streaming_compression.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

streaming_decompression : streaming_decompression.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

streaming_memory_usage : streaming_memory_usage.c $(LIB)
	$(CC) $(CPPFLAGS) $(CFLAGS) $^ $(LDFLAGS) -o $@

clean:
	@rm -f core *.o tmp* result* *.zst \
        simple_compression simple_decompression \
        dictionary_compression dictionary_decompression \
        streaming_compression streaming_decompression \
        multiple_streaming_compression streaming_memory_usage
	@echo Cleaning completed

test: all
	cp README.md tmp
	cp Makefile tmp2
	@echo -- Simple compression tests
	./simple_compression tmp
	./simple_decompression tmp.zst
	./streaming_decompression tmp.zst > /dev/null
	@echo -- Streaming memory usage
	./streaming_memory_usage
	@echo -- Streaming compression tests
	./streaming_compression tmp
	./streaming_decompression tmp.zst > /dev/null
	@echo -- Edge cases detection
	! ./streaming_decompression tmp    # invalid input, must fail
	! ./simple_decompression tmp       # invalid input, must fail
	! ./simple_decompression tmp.zst   # unknown input size, must fail
	touch tmpNull                      # create 0-size file
	./simple_compression tmpNull
	./simple_decompression tmpNull.zst # 0-size frame : must work
	@echo -- Multiple streaming tests
	./multiple_streaming_compression *.c
	@echo -- Dictionary compression tests
	./dictionary_compression tmp2 tmp README.md
	./dictionary_decompression tmp2.zst tmp.zst README.md
	$(RM) tmp* *.zst
	@echo tests completed