zstd/programs/Makefile

266 lines
11 KiB
Makefile
Raw Normal View History

2015-01-24 00:58:16 +00: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-11-23 15:52:22 +00:00
VERSION?= 0.4.0
2015-01-24 00:58:16 +00:00
DESTDIR?=
2015-08-25 23:19:06 +00:00
PREFIX ?= /usr/local
CPPFLAGS= -I../lib -I../lib/legacy -I./legacy -DZSTD_VERSION=\"$(VERSION)\" -DZSTD_LEGACY_SUPPORT=1
2015-11-26 08:59:49 +00:00
CFLAGS ?= -O3 # -falign-loops=32 # not always beneficial
2015-10-18 21:18:32 +00:00
CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes
2015-07-07 08:14:27 +00:00
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
2015-01-24 00:58:16 +00:00
2015-08-25 23:19:06 +00:00
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1
ZSTDDIR = ../lib
2015-01-24 00:58:16 +00: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 09:52:30 +00:00
ZBUFFTEST = -T2mn
.PHONY: default all clean install uninstall test test32 test-all
2015-01-24 00:58:16 +00:00
default: zstd
all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32 zbufftest zbufftest32 paramgrill datagen
2015-01-24 00:58:16 +00:00
2015-11-25 13:42:45 +00:00
zstd: $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c $(ZSTDDIR)/zstd_buffered.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
xxhash.c bench.c fileio.c zstdcli.c legacy/fileio_legacy.c
2015-01-24 00:58:16 +00:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
2015-11-25 13:42:45 +00:00
zstd32: $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c $(ZSTDDIR)/zstd_buffered.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
xxhash.c bench.c fileio.c zstdcli.c legacy/fileio_legacy.c
2015-01-24 00:58:16 +00:00
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
fullbench : $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
datagen.c fullbench.c
2015-01-24 00:58:16 +00:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
fullbench32: $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
datagen.c fullbench.c
2015-01-24 00:58:16 +00:00
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
fuzzer : $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
datagen.c xxhash.c fuzzer.c
2015-01-24 00:58:16 +00:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
fuzzer32: $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
datagen.c xxhash.c fuzzer.c
2015-01-24 00:58:16 +00:00
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
2015-11-26 08:59:49 +00:00
zbufftest : $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/zstd_buffered.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
2015-11-26 08:59:49 +00:00
datagen.c xxhash.c zbufftest.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
zbufftest32: $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/zstd_buffered.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
datagen.c xxhash.c zbufftest.c
$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
paramgrill : $(ZSTDDIR)/zstd_compress.c $(ZSTDDIR)/zstd_decompress.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \
2015-11-26 15:02:04 +00:00
$(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c $(ZSTDDIR)/legacy/zstd_v03.c \
datagen.c xxhash.c paramgrill.c
2015-10-28 11:32:25 +00:00
$(CC) $(FLAGS) $^ -lm -o $@$(EXT)
2015-10-25 23:07:32 +00:00
datagen : datagen.c datagencli.c
2015-01-24 00:58:16 +00:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
clean:
2015-11-14 10:07:51 +00:00
@rm -f core *.o tmp* \
2015-01-24 00:58:16 +00:00
zstd$(EXT) zstd32$(EXT) \
fullbench$(EXT) fullbench32$(EXT) \
fuzzer$(EXT) fuzzer32$(EXT) zbufftest$(EXT) zbufftest32$(EXT) \
2015-10-25 23:11:16 +00:00
datagen$(EXT) paramgrill$(EXT)
2015-01-24 00:58:16 +00: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))
install: zstd
@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
@ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd
2015-01-24 00:58:16 +00:00
@echo Installing man pages
@install -m 644 zstd.1 $(DESTDIR)$(MANDIR)/zstd.1
@ln -sf zstd.1 $(DESTDIR)$(MANDIR)/zstdcat.1
@ln -sf zstd.1 $(DESTDIR)$(MANDIR)/unzstd.1
2015-01-24 00:58:16 +00:00
@echo zstd installation completed
uninstall:
rm -f $(DESTDIR)$(BINDIR)/zstdcat
rm -f $(DESTDIR)$(BINDIR)/unzstd
2015-01-24 00:58:16 +00:00
[ -x $(DESTDIR)$(BINDIR)/zstd$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/zstd$(EXT)
rm -f $(DESTDIR)$(MANDIR)/zstdcat.1
rm -f $(DESTDIR)$(MANDIR)/unzstd.1
2015-01-24 00:58:16 +00:00
[ -f $(DESTDIR)$(MANDIR)/zstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstd.1
@echo zstd programs successfully uninstalled
test: test-zstd test-fullbench test-fuzzer test-zbuff
2015-01-24 00:58:16 +00:00
test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zbuff32
2015-01-24 00:58:16 +00:00
2015-10-23 14:21:53 +00:00
test-all: test test32 valgrindTest
2015-01-24 00:58:16 +00:00
test-zstd: zstd datagen
2015-09-10 22:26:09 +00:00
@echo "\n**** frame concatenation **** "
@echo "hello " > hello.tmp
@echo "world!" > world.tmp
@cat hello.tmp world.tmp > helloworld.tmp
./zstd hello.tmp > hello.zstd
./zstd world.tmp > world.zstd
@cat hello.zstd world.zstd > helloworld.zstd
./zstd -d helloworld.zstd > result.tmp
cat result.tmp
sdiff helloworld.tmp result.tmp
@rm *.tmp *.zstd
@echo frame concatenation test completed
@echo "**** flush write error test **** "
2015-08-25 16:41:46 +00:00
echo foo | ./zstd > /dev/full; if [ $$? -eq 0 ] ; then echo "write error not detected!"; false; fi
echo foo | ./zstd | ./zstd -d > /dev/full; if [ $$? -eq 0 ] ; then echo "write error not detected!"; false; fi
2015-09-10 22:26:09 +00:00
@echo "**** zstd round-trip tests **** "
2015-11-22 13:40:51 +00:00
@./datagen | md5sum > tmp1
./datagen | ./zstd -v | ./zstd -d | md5sum > tmp2
@diff tmp1 tmp2
./datagen | ./zstd -6 -v | ./zstd -d | md5sum > tmp2
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
@./datagen -g257MB | md5sum > tmp1
./datagen -g257MB | ./zstd -v | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g257MB | ./zstd -v2 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g257MB | ./zstd -v3 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
@./datagen -g129MB -P60| md5sum > tmp1
./datagen -g129MB -P60 | ./zstd -v4 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g129MB -P60 | ./zstd -v5 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g129MB -P60 | ./zstd -v6 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
@./datagen -g65MB -P70 | md5sum > tmp1
./datagen -g65MB -P70 | ./zstd -v7 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g65MB -P70 | ./zstd -v8 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g65MB -P70 | ./zstd -v9 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
@./datagen -g33MB -P75 | md5sum > tmp1
./datagen -g33MB -P75 | ./zstd -v10 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g33MB -P75 | ./zstd -v11 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g33MB -P75 | ./zstd -v12 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
@./datagen -g17MB -P80 | md5sum > tmp1
./datagen -g17MB -P80 | ./zstd -v13 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g17MB -P80 | ./zstd -v14 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
2015-11-23 15:52:22 +00:00
./datagen -g17MB -P80 | ./zstd -v15 | ./zstd -d | md5sum > tmp2
@diff tmp1 tmp2
2015-11-25 14:16:19 +00:00
./datagen -g17MB -P80 | ./zstd -v16 | ./zstd -d | md5sum > tmp2
2015-11-23 15:52:22 +00:00
@diff tmp1 tmp2
2015-11-25 14:16:19 +00:00
./datagen -g17MB -P80 | ./zstd -v17 | ./zstd -d | md5sum > tmp2
2015-11-23 15:52:22 +00:00
@diff tmp1 tmp2
2015-11-25 14:16:19 +00:00
@./datagen -g49MB -P93 | md5sum > tmp1
./datagen -g49MB -P93 | ./zstd -v18 | ./zstd -d | md5sum > tmp2
2015-11-23 15:52:22 +00:00
@diff tmp1 tmp2
2015-11-25 14:16:19 +00:00
./datagen -g49MB -P93 | ./zstd -v19 | ./zstd -d | md5sum > tmp2
2015-11-23 15:52:22 +00:00
@diff tmp1 tmp2
2015-11-25 14:16:19 +00:00
@./datagen -g97MB -P99 | md5sum > tmp1
./datagen -g97MB -P99 | ./zstd -v20 | ./zstd -d | md5sum > tmp2
2015-11-22 13:40:51 +00:00
@diff tmp1 tmp2
./datagen -g6GB -P99 | md5sum > tmp1
./datagen -g6GB -P99 | ./zstd -vq | ./zstd -d | md5sum > tmp2
@diff tmp1 tmp2
2015-01-24 00:58:16 +00:00
test-zstd32: zstd32 datagen
./datagen | ./zstd32 -v | ./zstd32 -d > $(VOID)
./datagen -g256MB | ./zstd32 -v | ./zstd32 -d > $(VOID)
./datagen -g6GB -P99 | ./zstd32 -vq | ./zstd32 -d > $(VOID)
2015-01-24 00:58:16 +00:00
2015-01-24 12:31:55 +00:00
test-fullbench: fullbench datagen
2015-01-24 00:58:16 +00:00
./fullbench -i1
2015-02-11 07:34:50 +00:00
./fullbench -i1 -P0
2015-01-24 00:58:16 +00:00
2015-01-24 12:31:55 +00:00
test-fullbench32: fullbench32 datagen
2015-01-24 00:58:16 +00:00
./fullbench32 -i1
2015-02-11 07:34:50 +00:00
./fullbench32 -i1 -P0
2015-01-24 00:58:16 +00:00
test-fuzzer: fuzzer
./fuzzer
test-fuzzer32: fuzzer32
./fuzzer32
test-zbuff: zbufftest
2015-11-26 09:52:30 +00:00
./zbufftest $(ZBUFFTEST)
test-zbuff32: zbufftest32
2015-11-26 09:52:30 +00:00
./zbufftest32 $(ZBUFFTEST)
2015-11-26 11:43:28 +00:00
valgrindTest: zstd datagen fuzzer fullbench zbufftest
@echo "\n ---- valgrind tests : memory analyzer ----"
2015-08-25 23:19:06 +00:00
valgrind --leak-check=yes --error-exitcode=1 ./datagen -g50M > $(VOID)
2015-01-24 00:58:16 +00:00
./datagen -g16KB > tmp
2015-08-25 23:19:06 +00:00
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp $(VOID)
2015-10-30 06:11:07 +00:00
./datagen -g2930KB > tmp
2015-11-26 11:43:28 +00: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 08:36:49 +00:00
./datagen -g64MB > tmp
2015-08-25 23:19:06 +00:00
valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp $(VOID)
@rm tmp
2015-08-25 23:19:06 +00:00
valgrind --leak-check=yes --error-exitcode=1 ./fuzzer -i1000 -t1
valgrind --leak-check=yes --error-exitcode=1 ./fullbench -i1
2015-11-26 11:43:28 +00:00
valgrind --leak-check=yes --error-exitcode=1 ./zbufftest -T1mn
2015-01-24 00:58:16 +00:00
endif