2015-01-23 16:58:16 -08:00
|
|
|
# ##########################################################################
|
|
|
|
# ZSTD programs - Makefile
|
|
|
|
# Copyright (C) Yann Collet 2015
|
|
|
|
#
|
|
|
|
# GPL v2 License
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# You can contact the author at :
|
|
|
|
# - ZSTD source repository : http://code.google.com/p/zstd/
|
|
|
|
# - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
|
|
|
# ##########################################################################
|
|
|
|
# zstd : Command Line Utility, supporting gzip-like arguments
|
|
|
|
# datagen : Synthetic and parametrable data generator, for tests
|
|
|
|
# fuzzer : Test tool, to check zstd integrity on target platform
|
|
|
|
# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
|
|
|
|
# fullbench : Precisely measure speed for each zstd inner function
|
|
|
|
# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
|
|
|
|
# ##########################################################################
|
|
|
|
|
2015-12-30 10:52:08 -08:00
|
|
|
# Version numbers
|
|
|
|
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ../lib/zstd.h`
|
|
|
|
LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ../lib/zstd.h`
|
|
|
|
LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ../lib/zstd.h`
|
|
|
|
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
|
|
|
|
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
|
|
|
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
|
|
|
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
|
|
|
LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
2015-12-31 09:32:15 -08:00
|
|
|
VERSION?= $(LIBVER)
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
DESTDIR?=
|
2015-08-25 16:19:06 -07:00
|
|
|
PREFIX ?= /usr/local
|
2015-11-27 07:18:56 -08:00
|
|
|
CPPFLAGS= -I../lib -DZSTD_VERSION=\"$(VERSION)\"
|
2015-11-26 00:59:49 -08:00
|
|
|
CFLAGS ?= -O3 # -falign-loops=32 # not always beneficial
|
2016-01-21 06:38:47 -08:00
|
|
|
CFLAGS += -std=c99 -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wstrict-prototypes -Wundef
|
2015-07-07 01:14:27 -07:00
|
|
|
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-08-25 16:19:06 -07:00
|
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
MANDIR = $(PREFIX)/share/man/man1
|
|
|
|
ZSTDDIR = ../lib
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-11-28 07:03:22 -08:00
|
|
|
ZSTD_FILES := $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c
|
2016-02-02 16:09:46 -08:00
|
|
|
ZSTD_LEGACY:= $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c $(ZSTDDIR)/legacy/zstd_v04.c
|
2015-11-27 07:18:56 -08:00
|
|
|
|
2015-11-30 05:18:47 -08:00
|
|
|
ifeq ($(ZSTD_LEGACY_SUPPORT), 0)
|
2015-11-27 07:18:56 -08:00
|
|
|
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0
|
|
|
|
else
|
|
|
|
ZSTD_FILES+= $(ZSTD_LEGACY)
|
|
|
|
CPPFLAGS += -I../lib/legacy -I./legacy -DZSTD_LEGACY_SUPPORT=1
|
|
|
|
ZSTD_FILEIO_LEGACY = legacy/fileio_legacy.c
|
|
|
|
endif
|
|
|
|
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
# Define *.exe as extension for Windows systems
|
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
|
|
|
EXT =.exe
|
|
|
|
VOID = nul
|
|
|
|
else
|
|
|
|
EXT =
|
|
|
|
VOID = /dev/null
|
|
|
|
endif
|
|
|
|
|
2015-11-26 01:52:30 -08:00
|
|
|
ZBUFFTEST = -T2mn
|
2015-12-04 08:45:35 -08:00
|
|
|
FUZZERTEST= -T5mn
|
2015-11-26 01:52:30 -08:00
|
|
|
|
2015-11-26 01:32:17 -08:00
|
|
|
.PHONY: default all clean install uninstall test test32 test-all
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
default: zstd
|
|
|
|
|
2015-11-26 01:32:17 -08:00
|
|
|
all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32 zbufftest zbufftest32 paramgrill datagen
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
zstd : $(ZSTD_FILES) $(ZSTDDIR)/zstd_buffered.c \
|
2015-11-30 16:28:32 -08:00
|
|
|
zstdcli.c fileio.c $(ZSTD_FILEIO_LEGACY) bench.c xxhash.c datagen.c
|
2015-01-23 16:58:16 -08:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
zstd32: $(ZSTD_FILES) $(ZSTDDIR)/zstd_buffered.c \
|
2015-11-30 16:28:32 -08:00
|
|
|
zstdcli.c fileio.c $(ZSTD_FILEIO_LEGACY) bench.c xxhash.c datagen.c
|
2015-01-23 16:58:16 -08:00
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-30 02:53:11 -08:00
|
|
|
zstd_nolegacy :
|
2015-11-30 05:18:47 -08:00
|
|
|
$(MAKE) zstd ZSTD_LEGACY_SUPPORT=0
|
2015-11-30 02:53:11 -08:00
|
|
|
|
2015-11-30 16:28:32 -08:00
|
|
|
zstd-pgo : MOREFLAGS = -fprofile-generate
|
|
|
|
zstd-pgo : clean zstd
|
|
|
|
./zstd -b $(PROFILE_WITH)
|
|
|
|
rm zstd
|
|
|
|
$(MAKE) zstd MOREFLAGS=-fprofile-use
|
|
|
|
|
2015-12-03 03:11:30 -08:00
|
|
|
zstd-noBench: $(ZSTD_FILES) $(ZSTDDIR)/zstd_buffered.c \
|
|
|
|
zstdcli.c fileio.c $(ZSTD_FILEIO_LEGACY)
|
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH $^ -o zstd$(EXT)
|
|
|
|
|
2015-12-13 04:35:21 -08:00
|
|
|
zstd-frugal: clean
|
|
|
|
$(MAKE) zstd-noBench ZSTD_LEGACY_SUPPORT=0
|
2015-12-03 03:11:30 -08:00
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
fullbench : $(ZSTD_FILES) \
|
|
|
|
datagen.c fullbench.c
|
2015-01-23 16:58:16 -08:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
fullbench32: $(ZSTD_FILES) \
|
2015-10-30 03:21:50 -07:00
|
|
|
datagen.c fullbench.c
|
2015-01-23 16:58:16 -08:00
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
fuzzer : $(ZSTD_FILES) \
|
2015-10-30 03:21:50 -07:00
|
|
|
datagen.c xxhash.c fuzzer.c
|
2015-01-23 16:58:16 -08:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
fuzzer32: $(ZSTD_FILES) \
|
2015-10-30 03:21:50 -07:00
|
|
|
datagen.c xxhash.c fuzzer.c
|
2015-01-23 16:58:16 -08:00
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
zbufftest : $(ZSTD_FILES) $(ZSTDDIR)/zstd_buffered.c \
|
2015-11-26 00:59:49 -08:00
|
|
|
datagen.c xxhash.c zbufftest.c
|
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
zbufftest32: $(ZSTD_FILES) $(ZSTDDIR)/zstd_buffered.c \
|
2015-11-26 01:32:17 -08:00
|
|
|
datagen.c xxhash.c zbufftest.c
|
|
|
|
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
2015-11-27 07:18:56 -08:00
|
|
|
paramgrill : $(ZSTD_FILES) \
|
2015-11-26 07:02:04 -08:00
|
|
|
datagen.c xxhash.c paramgrill.c
|
2015-10-28 04:32:25 -07:00
|
|
|
$(CC) $(FLAGS) $^ -lm -o $@$(EXT)
|
2015-10-25 16:07:32 -07:00
|
|
|
|
2015-02-08 23:00:26 -08:00
|
|
|
datagen : datagen.c datagencli.c
|
2015-01-23 16:58:16 -08:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
|
|
|
clean:
|
2015-11-30 16:28:32 -08:00
|
|
|
@rm -f core *.o tmp* result* *.gcda \
|
2015-01-23 16:58:16 -08:00
|
|
|
zstd$(EXT) zstd32$(EXT) \
|
|
|
|
fullbench$(EXT) fullbench32$(EXT) \
|
2015-11-26 01:32:17 -08:00
|
|
|
fuzzer$(EXT) fuzzer32$(EXT) zbufftest$(EXT) zbufftest32$(EXT) \
|
2015-10-25 16:11:16 -07:00
|
|
|
datagen$(EXT) paramgrill$(EXT)
|
2015-01-23 16:58:16 -08:00
|
|
|
@echo Cleaning completed
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
|
|
|
|
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
|
|
|
|
|
2015-11-30 16:56:02 -08:00
|
|
|
install: zstd
|
2015-01-23 16:58:16 -08:00
|
|
|
@echo Installing binaries
|
|
|
|
@install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
|
|
|
|
@install -m 755 zstd$(EXT) $(DESTDIR)$(BINDIR)/zstd$(EXT)
|
|
|
|
@ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdcat
|
2015-03-24 12:15:56 -07:00
|
|
|
@ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd
|
2015-01-23 16:58:16 -08:00
|
|
|
@echo Installing man pages
|
|
|
|
@install -m 644 zstd.1 $(DESTDIR)$(MANDIR)/zstd.1
|
2015-08-26 19:16:04 -07:00
|
|
|
@ln -sf zstd.1 $(DESTDIR)$(MANDIR)/zstdcat.1
|
|
|
|
@ln -sf zstd.1 $(DESTDIR)$(MANDIR)/unzstd.1
|
2015-01-23 16:58:16 -08:00
|
|
|
@echo zstd installation completed
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -f $(DESTDIR)$(BINDIR)/zstdcat
|
2015-03-24 12:15:56 -07:00
|
|
|
rm -f $(DESTDIR)$(BINDIR)/unzstd
|
2015-01-23 16:58:16 -08:00
|
|
|
[ -x $(DESTDIR)$(BINDIR)/zstd$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/zstd$(EXT)
|
2015-08-26 19:16:04 -07:00
|
|
|
rm -f $(DESTDIR)$(MANDIR)/zstdcat.1
|
|
|
|
rm -f $(DESTDIR)$(MANDIR)/unzstd.1
|
2015-01-23 16:58:16 -08:00
|
|
|
[ -f $(DESTDIR)$(MANDIR)/zstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstd.1
|
|
|
|
@echo zstd programs successfully uninstalled
|
|
|
|
|
2015-11-26 01:32:17 -08:00
|
|
|
test: test-zstd test-fullbench test-fuzzer test-zbuff
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-11-26 01:32:17 -08:00
|
|
|
test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zbuff32
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-10-23 07:21:53 -07:00
|
|
|
test-all: test test32 valgrindTest
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-11-28 07:03:22 -08:00
|
|
|
zstd-playTests: datagen
|
2015-12-08 07:47:43 -08:00
|
|
|
ZSTD=$(ZSTD) ./playTests.sh --test-large-data
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-11-28 07:03:22 -08:00
|
|
|
test-zstd: ZSTD = ./zstd
|
|
|
|
test-zstd: zstd zstd-playTests
|
|
|
|
|
|
|
|
test-zstd32: ZSTD = ./zstd32
|
|
|
|
test-zstd32: zstd32 zstd-playTests
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-11-30 02:53:11 -08:00
|
|
|
test-zstd_nolegacy: ZSTD = ./zstd
|
|
|
|
test-zstd_nolegacy: zstd_nolegacy zstd-playTests
|
|
|
|
|
2015-01-24 04:31:55 -08:00
|
|
|
test-fullbench: fullbench datagen
|
2015-01-23 16:58:16 -08:00
|
|
|
./fullbench -i1
|
2015-02-10 23:34:50 -08:00
|
|
|
./fullbench -i1 -P0
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-01-24 04:31:55 -08:00
|
|
|
test-fullbench32: fullbench32 datagen
|
2015-01-23 16:58:16 -08:00
|
|
|
./fullbench32 -i1
|
2015-02-10 23:34:50 -08:00
|
|
|
./fullbench32 -i1 -P0
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
test-fuzzer: fuzzer
|
2015-12-04 08:45:35 -08:00
|
|
|
./fuzzer $(FUZZERTEST)
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
test-fuzzer32: fuzzer32
|
2015-12-04 08:45:35 -08:00
|
|
|
./fuzzer32 $(FUZZERTEST)
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2015-11-26 01:32:17 -08:00
|
|
|
test-zbuff: zbufftest
|
2015-11-26 01:52:30 -08:00
|
|
|
./zbufftest $(ZBUFFTEST)
|
2015-11-26 01:32:17 -08:00
|
|
|
|
|
|
|
test-zbuff32: zbufftest32
|
2015-11-26 01:52:30 -08:00
|
|
|
./zbufftest32 $(ZBUFFTEST)
|
2015-11-26 01:32:17 -08:00
|
|
|
|
2015-11-26 03:43:28 -08:00
|
|
|
valgrindTest: zstd datagen fuzzer fullbench zbufftest
|
2015-06-20 20:37:53 -07:00
|
|
|
@echo "\n ---- valgrind tests : memory analyzer ----"
|
2015-08-25 16:19:06 -07:00
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./datagen -g50M > $(VOID)
|
2015-01-23 16:58:16 -08:00
|
|
|
./datagen -g16KB > tmp
|
2015-08-25 16:19:06 -07:00
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp $(VOID)
|
2015-10-29 23:11:07 -07:00
|
|
|
./datagen -g2930KB > tmp
|
2015-11-26 03:43:28 -08:00
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./zstd -5 -vf tmp tmp2
|
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vdf tmp2 $(VOID)
|
2015-07-07 01:36:49 -07:00
|
|
|
./datagen -g64MB > tmp
|
2015-08-25 16:19:06 -07:00
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp $(VOID)
|
2015-01-28 22:00:43 -08:00
|
|
|
@rm tmp
|
2015-12-05 00:23:53 -08:00
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./fuzzer -T1mn -t1
|
2015-06-20 20:37:53 -07:00
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./fullbench -i1
|
2015-11-26 03:43:28 -08:00
|
|
|
valgrind --leak-check=yes --error-exitcode=1 ./zbufftest -T1mn
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
endif
|