Update to Zstandard 1.4.4
[freebsd.git] / sys / contrib / zstd / doc / educational_decoder / 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 ZSTD ?= zstd   # note: requires zstd installation on local system
11
12 UNAME?= $(shell uname)
13 ifeq ($(UNAME), SunOS)
14 DIFF ?= gdiff
15 else
16 DIFF ?= diff
17 endif
18
19 HARNESS_FILES=*.c
20
21 MULTITHREAD_LDFLAGS = -pthread
22 DEBUGFLAGS= -g -DZSTD_DEBUG=1
23 CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
24             -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR)
25 CFLAGS   ?= -O2
26 CFLAGS   += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow                 \
27             -Wstrict-aliasing=1 -Wswitch-enum                               \
28             -Wredundant-decls -Wstrict-prototypes -Wundef                   \
29             -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings      \
30             -std=c99
31 CFLAGS   += $(DEBUGFLAGS)
32 CFLAGS   += $(MOREFLAGS)
33 FLAGS     = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MULTITHREAD_LDFLAGS)
34
35 harness: $(HARNESS_FILES)
36         $(CC) $(FLAGS) $^ -o $@
37
38 clean:
39         @$(RM) harness
40         @$(RM) -rf harness.dSYM  # MacOS specific
41
42 test: harness
43         #
44         # Testing single-file decompression with educational decoder
45         #
46         @$(ZSTD) -f README.md -o tmp.zst
47         @./harness tmp.zst tmp
48         @$(DIFF) -s tmp README.md
49         @$(RM) tmp*
50         #
51         # Testing dictionary decompression with education decoder
52         #
53         # note : files are presented multiple for training, to reach minimum threshold
54         @$(ZSTD) --train harness.c zstd_decompress.c zstd_decompress.h README.md \
55                   harness.c zstd_decompress.c zstd_decompress.h README.md \
56                   harness.c zstd_decompress.c zstd_decompress.h README.md \
57                   -o dictionary
58         @$(ZSTD) -f README.md -D dictionary -o tmp.zst
59         @./harness tmp.zst tmp dictionary
60         @$(DIFF) -s tmp README.md
61         @$(RM) tmp* dictionary
62         @$(MAKE) clean