zstd/programs/Makefile

281 lines
9.0 KiB
Makefile
Raw Normal View History

2015-01-24 00:58:16 +00:00
# ##########################################################################
# ZSTD programs - Makefile
2016-02-07 22:58:32 +00:00
# Copyright (C) Yann Collet 2015-2016
2015-01-24 00:58:16 +00:00
#
# 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 :
2016-02-07 22:58:32 +00:00
# - zstd homepage : http://www.zstd.net/
2015-01-24 00:58:16 +00:00
# ##########################################################################
# 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
2016-02-07 22:58:32 +00:00
# zbufftest : Test tool, to check ZBUFF integrity on target platform
# zbufftest32: Same as zbufftest, but forced to compile in 32-bits mode
2015-01-24 00:58:16 +00:00
# fullbench : Precisely measure speed for each zstd inner function
# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
# ##########################################################################
DESTDIR?=
2015-08-25 23:19:06 +00:00
PREFIX ?= /usr/local
2016-05-28 23:39:19 +00:00
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1
ZSTDDIR = ../lib
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version "), 1)
ALIGN_LOOP = -falign-loops=32
else
ALIGN_LOOP =
endif
CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder
CFLAGS ?= -O3
2016-07-22 02:45:06 +00:00
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
2016-07-24 15:46:05 +00:00
CFLAGS += $(MOREFLAGS)
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
2015-01-24 00:58:16 +00:00
2016-05-28 23:39:19 +00:00
ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
2016-05-28 23:06:30 +00:00
ZSTDCOMP_FILES := $(ZSTDDIR)/compress/zstd_compress.c $(ZSTDDIR)/compress/fse_compress.c $(ZSTDDIR)/compress/huf_compress.c
ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/zstd_decompress.o $(ZSTDDIR)/decompress/huf_decompress.c
2016-05-28 23:39:19 +00:00
ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
ZBUFF_FILES := $(ZSTDDIR)/compress/zbuff_compress.c $(ZSTDDIR)/decompress/zbuff_decompress.c
2016-05-28 23:39:19 +00:00
ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
ifeq ($(ZSTD_LEGACY_SUPPORT), 0)
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0
2016-05-28 23:39:19 +00:00
ZSTDLEGACY_FILES:=
else
2016-02-12 01:56:27 +00:00
ZSTD_LEGACY_SUPPORT:=1
2016-05-28 23:39:19 +00:00
CPPFLAGS += -I$(ZSTDDIR)/legacy -I./legacy
ZSTDLEGACY_FILES:= $(ZSTDDIR)/legacy/*.c legacy/fileio_legacy.c
endif
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
2015-12-04 16:45:35 +00:00
FUZZERTEST= -T5mn
ZSTDRTTEST= --test-large-data
2015-11-26 09:52:30 +00:00
2016-07-22 02:45:06 +00:00
.PHONY: default all all32 clean install uninstall test test32 test-all
2015-01-24 00:58:16 +00:00
default: zstd
2016-07-22 02:45:06 +00:00
all: zstd fullbench fuzzer zbufftest paramgrill datagen
2016-07-22 03:02:27 +00:00
all32: CFLAGS += -m32
all32: EXT := 32$(EXT)
all32: cleano32 all
2015-01-24 00:58:16 +00:00
$(ZSTDDIR)/decompress/zstd_decompress.o: CFLAGS += $(ALIGN_LOOP)
2016-05-28 23:39:19 +00:00
zstd : $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZBUFF_FILES) $(ZDICT_FILES) \
2016-05-28 23:06:30 +00:00
zstdcli.c fileio.c bench.c datagen.c dibio.c
2016-03-30 07:55:37 +00:00
$(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT)
2015-01-24 00:58:16 +00:00
2016-07-22 02:45:06 +00:00
zstd32: CFLAGS += -m32
2016-07-22 03:02:27 +00:00
zstd32: EXT := 32$(EXT)
zstd32: zstd
2015-01-24 00:58:16 +00:00
zstd_nolegacy :
$(MAKE) zstd ZSTD_LEGACY_SUPPORT=0
2015-12-01 00:28:32 +00:00
zstd-pgo : MOREFLAGS = -fprofile-generate
zstd-pgo : clean zstd
2016-02-17 16:04:12 +00:00
./zstd -b19i1 $(PROFILE_WITH)
./zstd -b16i1 $(PROFILE_WITH)
./zstd -b9i2 $(PROFILE_WITH)
2015-12-01 00:28:32 +00:00
./zstd -b $(PROFILE_WITH)
2016-02-17 16:04:12 +00:00
./zstd -b7i2 $(PROFILE_WITH)
./zstd -b5 $(PROFILE_WITH)
2015-12-01 00:28:32 +00:00
rm zstd
$(MAKE) zstd MOREFLAGS=-fprofile-use
zstd-frugal: $(ZSTD_FILES) $(ZBUFF_FILES) zstdcli.c fileio.c
2016-02-12 01:56:27 +00:00
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_LEGACY_SUPPORT=0 $^ -o zstd$(EXT)
2015-12-03 11:11:30 +00:00
2016-05-28 23:39:19 +00:00
zstd-compress: $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) \
$(ZSTDDIR)/compress/zbuff_compress.c zstdcli.c fileio.c
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NODECOMPRESS -DZSTD_LEGACY_SUPPORT=0 $^ -o $@$(EXT)
2016-05-28 23:39:19 +00:00
zstd-decompress: $(ZSTDCOMMON_FILES) $(ZSTDDECOMP_FILES) \
$(ZSTDDIR)/decompress/zbuff_decompress.c zstdcli.c fileio.c
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOCOMPRESS -DZSTD_LEGACY_SUPPORT=0 $^ -o $@$(EXT)
zstd-small: clean
CFLAGS="-Os -s" $(MAKE) zstd-frugal
2015-12-03 11:11:30 +00:00
fullbench : $(ZSTD_FILES) $(ZBUFF_FILES) datagen.c fullbench.c
2015-01-24 00:58:16 +00:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-07-22 03:02:27 +00:00
fullbench32 : CFLAGS += -m32
fullbench32 : EXT := 32$(EXT)
fullbench32 : fullbench
2015-01-24 00:58:16 +00:00
fuzzer : CPPFLAGS += -I$(ZSTDDIR)/dictBuilder
fuzzer : $(ZSTD_FILES) $(ZDICT_FILES) datagen.c fuzzer.c
2015-01-24 00:58:16 +00:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-07-22 03:02:27 +00:00
fuzzer32 : CFLAGS += -m32
fuzzer32 : EXT := 32$(EXT)
fuzzer32 : fuzzer
2015-01-24 00:58:16 +00:00
2016-05-28 23:39:19 +00:00
zbufftest : $(ZSTD_FILES) $(ZBUFF_FILES) datagen.c zbufftest.c
2015-11-26 08:59:49 +00:00
$(CC) $(FLAGS) $^ -o $@$(EXT)
2016-07-22 03:02:27 +00:00
zbufftest32 : CFLAGS += -m32
zbufftest32 : EXT := 32$(EXT)
zbufftest32 : zbufftest
2016-08-12 14:48:02 +00:00
zstreamtest : $(ZSTD_FILES) $(ZBUFF_FILES) datagen.c zstreamtest.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
zstreamtest32 : CFLAGS += -m32
zstreamtest32 : EXT := 32$(EXT)
zstreamtest32 : zstreamtest
2016-05-28 23:06:30 +00:00
paramgrill : $(ZSTD_FILES) datagen.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)
2016-05-28 23:39:19 +00:00
roundTripCrash : $(ZSTD_FILES) roundTripCrash.c
$(CC) $(FLAGS) $^ -o $@$(EXT)
2015-01-24 00:58:16 +00:00
clean:
$(MAKE) -C ../lib clean
@rm -f core *.o tmp* result* *.gcda dictionary *.zst \
2016-04-22 16:54:05 +00:00
zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) \
2015-01-24 00:58:16 +00:00
fullbench$(EXT) fullbench32$(EXT) \
fuzzer$(EXT) fuzzer32$(EXT) zbufftest$(EXT) zbufftest32$(EXT) \
2016-05-28 14:06:29 +00:00
datagen$(EXT) paramgrill$(EXT) roundTripCrash$(EXT)
2015-01-24 00:58:16 +00:00
@echo Cleaning completed
2016-07-22 02:45:06 +00:00
cleano32:
@rm -f ../lib/decompress/*.o
2015-01-24 00:58:16 +00:00
#----------------------------------------------------------------------------------
#make install is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets
#----------------------------------------------------------------------------------
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly))
2016-05-18 14:38:36 +00:00
HOST_OS = POSIX
install: zstd
2015-01-24 00:58:16 +00: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
@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
2016-05-18 14:38:36 +00:00
valgrindTest: VALGRIND = valgrind --leak-check=full --error-exitcode=1
valgrindTest: zstd datagen fuzzer fullbench zbufftest
@echo "\n ---- valgrind tests : memory analyzer ----"
$(VALGRIND) ./datagen -g50M > $(VOID)
$(VALGRIND) ./zstd ; if [ $$? -eq 0 ] ; then echo "zstd without argument should have failed"; false; fi
./datagen -g80 | $(VALGRIND) ./zstd - -c > $(VOID)
./datagen -g16KB | $(VALGRIND) ./zstd -vf - -o $(VOID)
./datagen -g2930KB | $(VALGRIND) ./zstd -5 -vf - -o tmp
$(VALGRIND) ./zstd -vdf tmp -o $(VOID)
./datagen -g64MB | $(VALGRIND) ./zstd -vf - -o $(VOID)
@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)
2016-08-12 14:48:02 +00:00
test: test-zstd test-fullbench test-fuzzer test-zbuff test-zstream
2015-01-24 00:58:16 +00:00
2016-08-12 14:48:02 +00:00
test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zbuff32 test-zstream32
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
2015-11-28 15:03:22 +00:00
test-zstd: ZSTD = ./zstd
test-zstd: zstd zstd-playTests
test-zstd32: ZSTD = ./zstd32
test-zstd32: zstd32 zstd-playTests
2015-01-24 00:58:16 +00:00
test-zstd_nolegacy: ZSTD = ./zstd
test-zstd_nolegacy: zstd_nolegacy zstd-playTests
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
2015-12-04 16:45:35 +00:00
./fuzzer $(FUZZERTEST)
2015-01-24 00:58:16 +00:00
test-fuzzer32: fuzzer32
2015-12-04 16:45:35 +00:00
./fuzzer32 $(FUZZERTEST)
2015-01-24 00:58:16 +00:00
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)
2016-08-12 14:48:02 +00:00
test-zstream: zstreamtest
./zstreamtest $(ZBUFFTEST)
test-zstream32: zstreamtest32
./zstreamtest32 $(ZBUFFTEST)
2015-01-24 00:58:16 +00:00
endif