xref: /aosp_15_r20/external/zstd/doc/educational_decoder/Makefile (revision 01826a4963a0d8a59bc3812d29bdf0fb76416722)
1*01826a49SYabin Cui# ################################################################
2*01826a49SYabin Cui# Copyright (c) Meta Platforms, Inc. and affiliates.
3*01826a49SYabin Cui# All rights reserved.
4*01826a49SYabin Cui#
5*01826a49SYabin Cui# This source code is licensed under both the BSD-style license (found in the
6*01826a49SYabin Cui# LICENSE file in the root directory of this source tree) and the GPLv2 (found
7*01826a49SYabin Cui# in the COPYING file in the root directory of this source tree).
8*01826a49SYabin Cui# You may select, at your option, one of the above-listed licenses.
9*01826a49SYabin Cui# ################################################################
10*01826a49SYabin Cui
11*01826a49SYabin CuiZSTD ?= zstd   # note: requires zstd installation on local system
12*01826a49SYabin Cui
13*01826a49SYabin CuiUNAME?= $(shell uname)
14*01826a49SYabin Cuiifeq ($(UNAME), SunOS)
15*01826a49SYabin CuiDIFF ?= gdiff
16*01826a49SYabin Cuielse
17*01826a49SYabin CuiDIFF ?= diff
18*01826a49SYabin Cuiendif
19*01826a49SYabin Cui
20*01826a49SYabin CuiHARNESS_FILES=*.c
21*01826a49SYabin Cui
22*01826a49SYabin CuiMULTITHREAD_LDFLAGS = -pthread
23*01826a49SYabin CuiDEBUGFLAGS= -g -DZSTD_DEBUG=1
24*01826a49SYabin CuiCPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
25*01826a49SYabin Cui            -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR)
26*01826a49SYabin CuiCFLAGS   ?= -O2
27*01826a49SYabin CuiCFLAGS   += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow                 \
28*01826a49SYabin Cui            -Wstrict-aliasing=1 -Wswitch-enum                               \
29*01826a49SYabin Cui            -Wredundant-decls -Wstrict-prototypes -Wundef                   \
30*01826a49SYabin Cui            -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings      \
31*01826a49SYabin Cui            -std=c99
32*01826a49SYabin CuiCFLAGS   += $(DEBUGFLAGS)
33*01826a49SYabin CuiCFLAGS   += $(MOREFLAGS)
34*01826a49SYabin CuiFLAGS     = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MULTITHREAD_LDFLAGS)
35*01826a49SYabin Cui
36*01826a49SYabin Cuiharness: $(HARNESS_FILES)
37*01826a49SYabin Cui	$(CC) $(FLAGS) $^ -o $@
38*01826a49SYabin Cui
39*01826a49SYabin Cuiclean:
40*01826a49SYabin Cui	@$(RM) harness *.o
41*01826a49SYabin Cui	@$(RM) -rf harness.dSYM  # MacOS specific
42*01826a49SYabin Cui
43*01826a49SYabin Cuitest: harness
44*01826a49SYabin Cui	#
45*01826a49SYabin Cui	# Testing single-file decompression with educational decoder
46*01826a49SYabin Cui	#
47*01826a49SYabin Cui	@$(ZSTD) -f README.md -o tmp.zst
48*01826a49SYabin Cui	@./harness tmp.zst tmp
49*01826a49SYabin Cui	@$(DIFF) -s tmp README.md
50*01826a49SYabin Cui	@$(RM) tmp*
51*01826a49SYabin Cui	#
52*01826a49SYabin Cui	# Testing dictionary decompression with education decoder
53*01826a49SYabin Cui	#
54*01826a49SYabin Cui	# note : files are presented multiple for training, to reach minimum threshold
55*01826a49SYabin Cui	@$(ZSTD) --train harness.c zstd_decompress.c zstd_decompress.h README.md \
56*01826a49SYabin Cui                  harness.c zstd_decompress.c zstd_decompress.h README.md \
57*01826a49SYabin Cui                  harness.c zstd_decompress.c zstd_decompress.h README.md \
58*01826a49SYabin Cui                  -o dictionary
59*01826a49SYabin Cui	@$(ZSTD) -f README.md -D dictionary -o tmp.zst
60*01826a49SYabin Cui	@./harness tmp.zst tmp dictionary
61*01826a49SYabin Cui	@$(DIFF) -s tmp README.md
62*01826a49SYabin Cui	@$(RM) tmp* dictionary
63