1 # ################################################################
2 # Copyright (c) Meta Platforms, Inc. and affiliates.
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 # ################################################################
11 ZSTD ?= zstd # note: requires zstd installation on local system
13 UNAME?= $(shell uname)
14 ifeq ($(UNAME), SunOS)
22 MULTITHREAD_LDFLAGS = -pthread
23 DEBUGFLAGS= -g -DZSTD_DEBUG=1
24 CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
25 -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR)
27 CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
28 -Wstrict-aliasing=1 -Wswitch-enum \
29 -Wredundant-decls -Wstrict-prototypes -Wundef \
30 -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
32 CFLAGS += $(DEBUGFLAGS)
33 CFLAGS += $(MOREFLAGS)
34 FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MULTITHREAD_LDFLAGS)
36 harness: $(HARNESS_FILES)
37 $(CC) $(FLAGS) $^ -o $@
41 @$(RM) -rf harness.dSYM # MacOS specific
45 # Testing single-file decompression with educational decoder
47 @$(ZSTD) -f README.md -o tmp.zst
48 @./harness tmp.zst tmp
49 @$(DIFF) -s tmp README.md
52 # Testing dictionary decompression with education decoder
54 # note : files are presented multiple for training, to reach minimum threshold
55 @$(ZSTD) --train harness.c zstd_decompress.c zstd_decompress.h README.md \
56 harness.c zstd_decompress.c zstd_decompress.h README.md \
57 harness.c zstd_decompress.c zstd_decompress.h README.md \
59 @$(ZSTD) -f README.md -D dictionary -o tmp.zst
60 @./harness tmp.zst tmp dictionary
61 @$(DIFF) -s tmp README.md
62 @$(RM) tmp* dictionary