2019-09-10 09:36:02 -07:00
|
|
|
# ################################################################
|
2022-12-20 12:49:47 -05:00
|
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
2019-09-10 09:36:02 -07:00
|
|
|
# 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).
|
2020-03-26 15:19:05 -07:00
|
|
|
# You may select, at your option, one of the above-listed licenses.
|
2019-09-10 09:36:02 -07:00
|
|
|
# ################################################################
|
|
|
|
|
|
2019-10-17 14:03:20 -07:00
|
|
|
ZSTD ?= zstd # note: requires zstd installation on local system
|
|
|
|
|
|
2024-06-05 18:21:34 +02:00
|
|
|
UNAME?= $(shell sh -c 'MSYSTEM="MSYS" uname')
|
2019-10-17 14:03:20 -07:00
|
|
|
ifeq ($(UNAME), SunOS)
|
|
|
|
|
DIFF ?= gdiff
|
|
|
|
|
else
|
2019-09-10 09:36:02 -07:00
|
|
|
DIFF ?= diff
|
2019-10-17 14:03:20 -07:00
|
|
|
endif
|
|
|
|
|
|
2017-08-11 14:35:13 -07:00
|
|
|
HARNESS_FILES=*.c
|
|
|
|
|
|
|
|
|
|
MULTITHREAD_LDFLAGS = -pthread
|
|
|
|
|
DEBUGFLAGS= -g -DZSTD_DEBUG=1
|
|
|
|
|
CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
|
|
|
|
|
-I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR)
|
2019-09-10 09:36:02 -07:00
|
|
|
CFLAGS ?= -O2
|
2017-08-11 14:35:13 -07:00
|
|
|
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
2019-09-06 16:51:16 -07:00
|
|
|
-Wstrict-aliasing=1 -Wswitch-enum \
|
|
|
|
|
-Wredundant-decls -Wstrict-prototypes -Wundef \
|
2017-08-11 14:35:13 -07:00
|
|
|
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
2019-09-06 16:51:16 -07:00
|
|
|
-std=c99
|
2017-08-11 14:35:13 -07:00
|
|
|
CFLAGS += $(DEBUGFLAGS)
|
|
|
|
|
CFLAGS += $(MOREFLAGS)
|
|
|
|
|
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MULTITHREAD_LDFLAGS)
|
|
|
|
|
|
|
|
|
|
harness: $(HARNESS_FILES)
|
|
|
|
|
$(CC) $(FLAGS) $^ -o $@
|
|
|
|
|
|
|
|
|
|
clean:
|
2020-01-27 11:39:29 -08:00
|
|
|
@$(RM) harness *.o
|
2019-10-17 14:03:20 -07:00
|
|
|
@$(RM) -rf harness.dSYM # MacOS specific
|
2017-08-11 14:42:15 -07:00
|
|
|
|
|
|
|
|
test: harness
|
2019-09-10 09:36:02 -07:00
|
|
|
#
|
|
|
|
|
# Testing single-file decompression with educational decoder
|
|
|
|
|
#
|
2019-10-17 13:01:18 -07:00
|
|
|
@$(ZSTD) -f README.md -o tmp.zst
|
2017-08-11 14:42:15 -07:00
|
|
|
@./harness tmp.zst tmp
|
2019-09-10 09:36:02 -07:00
|
|
|
@$(DIFF) -s tmp README.md
|
2019-10-17 13:01:18 -07:00
|
|
|
@$(RM) tmp*
|
2019-09-10 09:36:02 -07:00
|
|
|
#
|
|
|
|
|
# Testing dictionary decompression with education decoder
|
|
|
|
|
#
|
|
|
|
|
# note : files are presented multiple for training, to reach minimum threshold
|
|
|
|
|
@$(ZSTD) --train harness.c zstd_decompress.c zstd_decompress.h README.md \
|
2019-09-06 14:30:13 -07:00
|
|
|
harness.c zstd_decompress.c zstd_decompress.h README.md \
|
2019-10-17 14:03:20 -07:00
|
|
|
harness.c zstd_decompress.c zstd_decompress.h README.md \
|
|
|
|
|
-o dictionary
|
2019-10-17 13:01:18 -07:00
|
|
|
@$(ZSTD) -f README.md -D dictionary -o tmp.zst
|
2017-08-11 17:53:37 -07:00
|
|
|
@./harness tmp.zst tmp dictionary
|
2019-09-10 09:36:02 -07:00
|
|
|
@$(DIFF) -s tmp README.md
|
2019-10-17 13:01:18 -07:00
|
|
|
@$(RM) tmp* dictionary
|