2016-05-23 12:23:55 +00:00
|
|
|
# ##########################################################################
|
2016-10-11 22:27:44 +00:00
|
|
|
# Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
|
|
|
# All rights reserved.
|
2016-05-23 12:23:55 +00:00
|
|
|
#
|
2016-10-11 22:27:44 +00:00
|
|
|
# This source code is licensed under the BSD-style license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
# of patent rights can be found in the PATENTS file in the same directory.
|
2016-05-23 12:23:55 +00:00
|
|
|
# ##########################################################################
|
2016-08-18 11:18:11 +00:00
|
|
|
# datagen : Synthetic and parametrable data generator, for tests
|
2016-08-25 06:47:18 +00:00
|
|
|
# fullbench : Precisely measure speed for each zstd inner functions
|
|
|
|
# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
|
2016-08-18 11:18:11 +00:00
|
|
|
# fuzzer : Test tool, to check zstd integrity on target platform
|
|
|
|
# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
|
2016-08-25 06:47:18 +00:00
|
|
|
# paramgrill : parameter tester for zstd
|
|
|
|
# test-zstd-speed.py : script for testing zstd speed difference between commits
|
|
|
|
# versionsTest : compatibility test between zstd versions stored on Github (v0.1+)
|
2016-08-18 11:18:11 +00:00
|
|
|
# zbufftest : Test tool, to check ZBUFF integrity on target platform
|
|
|
|
# zbufftest32: Same as zbufftest, but forced to compile in 32-bits mode
|
2016-08-25 06:47:18 +00:00
|
|
|
# zstreamtest : Fuzzer test tool for zstd streaming API
|
|
|
|
# zbufftest32: Same as zstreamtest, but forced to compile in 32-bits mode
|
2016-05-23 12:23:55 +00:00
|
|
|
# ##########################################################################
|
|
|
|
|
2016-08-18 11:18:11 +00:00
|
|
|
DESTDIR?=
|
|
|
|
PREFIX ?= /usr/local
|
|
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
MANDIR = $(PREFIX)/share/man/man1
|
|
|
|
ZSTDDIR = ../lib
|
2016-08-18 11:53:26 +00:00
|
|
|
PRGDIR = ../programs
|
2016-08-18 12:04:57 +00:00
|
|
|
PYTHON ?= python3
|
|
|
|
TESTARTEFACT := versionsTest namespaceTest
|
|
|
|
|
2016-06-12 20:31:47 +00:00
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder -I$(PRGDIR)
|
2016-08-18 11:18:11 +00:00
|
|
|
CFLAGS ?= -O3
|
|
|
|
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
|
|
|
|
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
|
|
|
|
CFLAGS += $(MOREFLAGS)
|
|
|
|
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
|
2016-08-10 06:14:48 +00:00
|
|
|
|
2016-05-23 12:23:55 +00:00
|
|
|
|
2016-08-18 11:18:11 +00:00
|
|
|
ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
|
|
|
|
ZSTDCOMP_FILES := $(ZSTDDIR)/compress/zstd_compress.c $(ZSTDDIR)/compress/fse_compress.c $(ZSTDDIR)/compress/huf_compress.c
|
|
|
|
ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/zstd_decompress.c $(ZSTDDIR)/decompress/huf_decompress.c
|
|
|
|
ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
|
|
|
|
ZBUFF_FILES := $(ZSTDDIR)/compress/zbuff_compress.c $(ZSTDDIR)/decompress/zbuff_decompress.c
|
|
|
|
ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Define *.exe as extension for Windows systems
|
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
|
|
|
EXT =.exe
|
|
|
|
VOID = nul
|
|
|
|
else
|
|
|
|
EXT =
|
|
|
|
VOID = /dev/null
|
|
|
|
endif
|
|
|
|
|
|
|
|
ZBUFFTEST = -T2mn
|
|
|
|
FUZZERTEST= -T5mn
|
|
|
|
ZSTDRTTEST= --test-large-data
|
|
|
|
|
2016-08-18 12:04:57 +00:00
|
|
|
.PHONY: default all all32 clean test test32 test-all namespaceTest versionsTest
|
2016-08-18 11:53:26 +00:00
|
|
|
|
|
|
|
default: fullbench
|
2016-08-18 11:18:11 +00:00
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
all: fullbench fuzzer zbufftest zstreamtest paramgrill datagen
|
2016-08-18 11:18:11 +00:00
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
all32: fullbench32 fuzzer32 zbufftest32 zstreamtest32
|
2016-08-18 11:18:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
zstd:
|
|
|
|
$(MAKE) -C $(PRGDIR) $@
|
2016-08-18 11:18:11 +00:00
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
zstd32:
|
|
|
|
$(MAKE) -C $(PRGDIR) $@
|
2016-08-18 11:18:11 +00:00
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
zstd_nolegacy:
|
|
|
|
$(MAKE) -C $(PRGDIR) $@
|
2016-08-18 11:18:11 +00:00
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
fullbench : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c fullbench.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
fullbench32 : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c fullbench.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
|
|
|
fuzzer : CPPFLAGS += -I$(ZSTDDIR)/dictBuilder
|
2016-08-18 11:53:26 +00:00
|
|
|
fuzzer : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c fuzzer.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
|
|
|
fuzzer32 : CPPFLAGS += -I$(ZSTDDIR)/dictBuilder
|
2016-08-18 11:53:26 +00:00
|
|
|
fuzzer32 : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c fuzzer.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
zbufftest : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c zbufftest.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
zbufftest32 : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c zbufftest.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
zstreamtest : $(ZSTD_FILES) $(PRGDIR)/datagen.c zstreamtest.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
zstreamtest32 : $(ZSTD_FILES) $(PRGDIR)/datagen.c zstreamtest.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
paramgrill : $(ZSTD_FILES) $(PRGDIR)/datagen.c paramgrill.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) $(FLAGS) $^ -lm -o $@$(EXT)
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
datagen : $(PRGDIR)/datagen.c datagencli.c
|
2016-08-18 11:18:11 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
|
|
|
roundTripCrash : $(ZSTD_FILES) roundTripCrash.c
|
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
2016-05-23 12:23:55 +00:00
|
|
|
|
2016-08-18 12:04:57 +00:00
|
|
|
namespaceTest:
|
|
|
|
if $(CC) namespaceTest.c ../lib/common/xxhash.c -o $@ ; then echo compilation should fail; exit 1 ; fi
|
|
|
|
$(RM) $@
|
|
|
|
|
|
|
|
versionsTest:
|
|
|
|
$(PYTHON) test-zstd-versions.py
|
|
|
|
|
2016-05-23 12:23:55 +00:00
|
|
|
clean:
|
2016-08-18 11:18:11 +00:00
|
|
|
$(MAKE) -C ../lib clean
|
2016-08-18 12:04:57 +00:00
|
|
|
@$(RM) -fR $(TESTARTEFACT)
|
|
|
|
@$(RM) -f core *.o tmp* result* *.gcda dictionary *.zst \
|
2016-08-18 11:53:26 +00:00
|
|
|
$(PRGDIR)/zstd$(EXT) $(PRGDIR)/zstd32$(EXT) \
|
2016-08-18 11:18:11 +00:00
|
|
|
fullbench$(EXT) fullbench32$(EXT) \
|
|
|
|
fuzzer$(EXT) fuzzer32$(EXT) zbufftest$(EXT) zbufftest32$(EXT) \
|
2016-08-28 17:14:27 +00:00
|
|
|
zstreamtest$(EXT) zstreamtest32$(EXT) \
|
2016-08-18 11:18:11 +00:00
|
|
|
datagen$(EXT) paramgrill$(EXT) roundTripCrash$(EXT)
|
2016-05-23 12:23:55 +00:00
|
|
|
@echo Cleaning completed
|
2016-08-18 11:18:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------------------
|
2016-08-18 11:35:36 +00:00
|
|
|
#make valgrindTest is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets
|
2016-08-18 11:18:11 +00:00
|
|
|
#----------------------------------------------------------------------------------
|
|
|
|
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly))
|
|
|
|
HOST_OS = POSIX
|
|
|
|
|
2016-09-15 15:23:15 +00:00
|
|
|
valgrindTest: VALGRIND = valgrind --leak-check=full --error-exitcode=1
|
2016-08-18 11:18:11 +00:00
|
|
|
valgrindTest: zstd datagen fuzzer fullbench zbufftest
|
|
|
|
@echo "\n ---- valgrind tests : memory analyzer ----"
|
|
|
|
$(VALGRIND) ./datagen -g50M > $(VOID)
|
2016-08-18 11:53:26 +00:00
|
|
|
$(VALGRIND) $(PRGDIR)/zstd ; if [ $$? -eq 0 ] ; then echo "zstd without argument should have failed"; false; fi
|
|
|
|
./datagen -g80 | $(VALGRIND) $(PRGDIR)/zstd - -c > $(VOID)
|
2016-09-01 22:46:09 +00:00
|
|
|
./datagen -g16KB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
|
2016-08-18 11:53:26 +00:00
|
|
|
./datagen -g2930KB | $(VALGRIND) $(PRGDIR)/zstd -5 -vf - -o tmp
|
2016-09-01 22:46:09 +00:00
|
|
|
$(VALGRIND) $(PRGDIR)/zstd -vdf tmp -c > $(VOID)
|
|
|
|
./datagen -g64MB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
|
2016-08-18 11:18:11 +00:00
|
|
|
@rm tmp
|
|
|
|
$(VALGRIND) ./fuzzer -T1mn -t1
|
|
|
|
$(VALGRIND) ./fullbench -i1
|
|
|
|
$(VALGRIND) ./zbufftest -T1mn
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
ifneq (,$(filter MSYS%,$(shell uname)))
|
|
|
|
HOST_OS = MSYS
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
ifneq (,$(filter $(HOST_OS),MSYS POSIX))
|
|
|
|
zstd-playTests: datagen
|
|
|
|
ZSTD=$(ZSTD) ./playTests.sh $(ZSTDRTTEST)
|
|
|
|
|
|
|
|
test: test-zstd test-fullbench test-fuzzer test-zbuff test-zstream
|
|
|
|
|
|
|
|
test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zbuff32 test-zstream32
|
|
|
|
|
|
|
|
test-all: test test32 valgrindTest
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
test-zstd: ZSTD = $(PRGDIR)/zstd
|
2016-08-18 11:18:11 +00:00
|
|
|
test-zstd: zstd zstd-playTests
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
test-zstd32: ZSTD = $(PRGDIR)/zstd32
|
2016-08-18 11:18:11 +00:00
|
|
|
test-zstd32: zstd32 zstd-playTests
|
|
|
|
|
2016-08-18 11:53:26 +00:00
|
|
|
test-zstd_nolegacy: ZSTD = $(PRGDIR)/zstd
|
2016-08-18 11:18:11 +00:00
|
|
|
test-zstd_nolegacy: zstd_nolegacy zstd-playTests
|
|
|
|
|
|
|
|
test-fullbench: fullbench datagen
|
|
|
|
./fullbench -i1
|
|
|
|
./fullbench -i1 -P0
|
|
|
|
|
|
|
|
test-fullbench32: fullbench32 datagen
|
|
|
|
./fullbench32 -i1
|
|
|
|
./fullbench32 -i1 -P0
|
|
|
|
|
|
|
|
test-fuzzer: fuzzer
|
|
|
|
./fuzzer $(FUZZERTEST)
|
|
|
|
|
|
|
|
test-fuzzer32: fuzzer32
|
|
|
|
./fuzzer32 $(FUZZERTEST)
|
|
|
|
|
|
|
|
test-zbuff: zbufftest
|
|
|
|
./zbufftest $(ZBUFFTEST)
|
|
|
|
|
|
|
|
test-zbuff32: zbufftest32
|
|
|
|
./zbufftest32 $(ZBUFFTEST)
|
|
|
|
|
|
|
|
test-zstream: zstreamtest
|
|
|
|
./zstreamtest $(ZBUFFTEST)
|
|
|
|
|
|
|
|
test-zstream32: zstreamtest32
|
|
|
|
./zstreamtest32 $(ZBUFFTEST)
|
|
|
|
|
|
|
|
endif
|