1# ################################################################ 2# Copyright (c) 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# You may select, at your option, one of the above-listed licenses. 9# ################################################################ 10 11ZSTD ?= zstd # note: requires zstd installation on local system 12 13UNAME?= $(shell uname) 14ifeq ($(UNAME), SunOS) 15DIFF ?= gdiff 16else 17DIFF ?= diff 18endif 19 20HARNESS_FILES=*.c 21 22MULTITHREAD_LDFLAGS = -pthread 23DEBUGFLAGS= -g -DZSTD_DEBUG=1 24CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \ 25 -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR) 26CFLAGS ?= -O2 27CFLAGS += -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 \ 31 -std=c99 32CFLAGS += $(DEBUGFLAGS) 33CFLAGS += $(MOREFLAGS) 34FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MULTITHREAD_LDFLAGS) 35 36harness: $(HARNESS_FILES) 37 $(CC) $(FLAGS) $^ -o $@ 38 39clean: 40 @$(RM) harness *.o 41 @$(RM) -rf harness.dSYM # MacOS specific 42 43test: harness 44 # 45 # Testing single-file decompression with educational decoder 46 # 47 @$(ZSTD) -f README.md -o tmp.zst 48 @./harness tmp.zst tmp 49 @$(DIFF) -s tmp README.md 50 @$(RM) tmp* 51 # 52 # Testing dictionary decompression with education decoder 53 # 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 \ 58 -o dictionary 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 63