2015-01-24 00:58:16 +00:00
|
|
|
# ##########################################################################
|
2016-08-30 20:33:20 +00:00
|
|
|
# Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
|
|
|
# All rights reserved.
|
2015-01-24 00:58:16 +00:00
|
|
|
#
|
2016-08-30 20:33:20 +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.
|
2015-01-24 00:58:16 +00:00
|
|
|
# ##########################################################################
|
|
|
|
# zstd : Command Line Utility, supporting gzip-like arguments
|
2016-08-18 11:18:11 +00:00
|
|
|
# zstd32 : Same as zstd, but forced to compile in 32-bits mode
|
|
|
|
# zstd_nolegacy : zstd without support of decompression of legacy versions
|
2016-08-25 08:07:20 +00:00
|
|
|
# zstd-small : minimal zstd without dictionary builder and benchmark
|
|
|
|
# zstd-compress : compressor-only version of zstd
|
|
|
|
# zstd-decompress : decompressor-only version of zstd
|
2015-01-24 00:58:16 +00:00
|
|
|
# ##########################################################################
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-07-22 01:36:50 +00:00
|
|
|
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version "), 1)
|
|
|
|
ALIGN_LOOP = -falign-loops=32
|
|
|
|
else
|
|
|
|
ALIGN_LOOP =
|
|
|
|
endif
|
|
|
|
|
2016-08-10 06:14:48 +00:00
|
|
|
CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder
|
2016-07-22 01:36:50 +00:00
|
|
|
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
|
2016-08-17 13:59:50 +00:00
|
|
|
ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/huf_decompress.c
|
2016-05-28 23:39:19 +00:00
|
|
|
ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
|
|
|
|
ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
|
2016-08-17 13:59:50 +00:00
|
|
|
ZSTDDECOMP_O = $(ZSTDDIR)/decompress/zstd_decompress.o
|
|
|
|
ZSTDDECOMP32_O = $(ZSTDDIR)/decompress/zstd_decompress32.o
|
2015-11-27 15:18:56 +00:00
|
|
|
|
2015-11-30 13:18:47 +00:00
|
|
|
ifeq ($(ZSTD_LEGACY_SUPPORT), 0)
|
2015-11-27 15:18:56 +00:00
|
|
|
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0
|
2016-05-28 23:39:19 +00:00
|
|
|
ZSTDLEGACY_FILES:=
|
2015-11-27 15:18:56 +00:00
|
|
|
else
|
2016-02-12 01:56:27 +00:00
|
|
|
ZSTD_LEGACY_SUPPORT:=1
|
2016-08-29 02:20:13 +00:00
|
|
|
CPPFLAGS += -I$(ZSTDDIR)/legacy
|
|
|
|
ZSTDLEGACY_FILES:= $(ZSTDDIR)/legacy/*.c
|
2015-11-27 15:18:56 +00:00
|
|
|
endif
|
|
|
|
|
2015-01-24 00:58:16 +00:00
|
|
|
|
|
|
|
# Define *.exe as extension for Windows systems
|
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
|
|
|
EXT =.exe
|
|
|
|
VOID = nul
|
2016-09-19 13:08:43 +00:00
|
|
|
RES64_FILE = ..\build\VS2010\zstd\generate_res\zstd64.res
|
|
|
|
RES32_FILE = ..\build\VS2010\zstd\generate_res\zstd32.res
|
2016-09-14 14:16:24 +00:00
|
|
|
ifneq (,$(filter x86_64%,$(shell $(CC) -dumpmachine)))
|
|
|
|
RES_FILE = $(RES64_FILE)
|
|
|
|
else
|
|
|
|
RES_FILE = $(RES32_FILE)
|
|
|
|
endif
|
2015-01-24 00:58:16 +00:00
|
|
|
else
|
|
|
|
EXT =
|
|
|
|
VOID = /dev/null
|
|
|
|
endif
|
|
|
|
|
2015-11-26 09:52:30 +00:00
|
|
|
|
2016-10-05 09:56:22 +00:00
|
|
|
.PHONY: default all clean clean_decomp_o install uninstall
|
2015-01-24 00:58:16 +00:00
|
|
|
|
|
|
|
default: zstd
|
|
|
|
|
2016-08-18 11:18:11 +00:00
|
|
|
all: zstd
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2016-07-22 01:36:50 +00:00
|
|
|
|
2016-08-17 13:59:50 +00:00
|
|
|
$(ZSTDDECOMP_O): $(ZSTDDIR)/decompress/zstd_decompress.c
|
2016-08-28 19:47:17 +00:00
|
|
|
$(CC) $(ALIGN_LOOP) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -c -o $@
|
2016-08-17 13:59:50 +00:00
|
|
|
|
|
|
|
$(ZSTDDECOMP32_O): $(ZSTDDIR)/decompress/zstd_decompress.c
|
2016-08-28 19:47:17 +00:00
|
|
|
$(CC) -m32 $(ALIGN_LOOP) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -c -o $@
|
2016-08-17 13:59:50 +00:00
|
|
|
|
|
|
|
zstd : $(ZSTDDECOMP_O) $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZDICT_FILES) \
|
2016-05-28 23:06:30 +00:00
|
|
|
zstdcli.c fileio.c bench.c datagen.c dibio.c
|
2016-09-13 11:53:43 +00:00
|
|
|
$(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ $(RES_FILE) -o $@$(EXT)
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2016-08-17 13:59:50 +00:00
|
|
|
zstd32 : $(ZSTDDECOMP32_O) $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZDICT_FILES) \
|
|
|
|
zstdcli.c fileio.c bench.c datagen.c dibio.c
|
2016-09-14 14:16:24 +00:00
|
|
|
$(CC) -m32 $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ $(RES32_FILE) -o $@$(EXT)
|
2016-08-17 13:59:50 +00:00
|
|
|
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2016-10-05 09:56:22 +00:00
|
|
|
zstd_nolegacy : clean_decomp_o
|
2015-11-30 13:18:47 +00:00
|
|
|
$(MAKE) zstd ZSTD_LEGACY_SUPPORT=0
|
2015-11-30 10:53:11 +00:00
|
|
|
|
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)
|
2016-08-30 20:33:20 +00:00
|
|
|
$(RM) zstd
|
2016-09-02 16:44:00 +00:00
|
|
|
$(RM) $(ZSTDDIR)/decompress/zstd_decompress.o
|
2015-12-01 00:28:32 +00:00
|
|
|
$(MAKE) zstd MOREFLAGS=-fprofile-use
|
|
|
|
|
2016-08-17 14:29:57 +00:00
|
|
|
zstd-frugal: $(ZSTDDECOMP_O) $(ZSTD_FILES) zstdcli.c fileio.c
|
2016-10-05 09:56:22 +00:00
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT $^ -o zstd$(EXT)
|
2015-12-03 11:11:30 +00:00
|
|
|
|
2016-10-05 09:56:22 +00:00
|
|
|
zstd-small: clean_decomp_o
|
|
|
|
ZSTD_LEGACY_SUPPORT=0 CFLAGS="-Os -s" $(MAKE) zstd-frugal
|
2016-04-22 15:14:25 +00:00
|
|
|
|
2016-10-05 09:56:22 +00:00
|
|
|
zstd-decompress-clean: $(ZSTDDECOMP_O) $(ZSTDCOMMON_FILES) $(ZSTDDECOMP_FILES) zstdcli.c fileio.c
|
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOCOMPRESS $^ -o zstd-decompress$(EXT)
|
2016-04-22 11:59:05 +00:00
|
|
|
|
2016-10-05 09:56:22 +00:00
|
|
|
zstd-decompress: clean_decomp_o
|
|
|
|
ZSTD_LEGACY_SUPPORT=0 $(MAKE) zstd-decompress-clean
|
|
|
|
|
|
|
|
zstd-compress: $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) zstdcli.c fileio.c
|
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NODECOMPRESS $^ -o $@$(EXT)
|
2015-12-03 11:11:30 +00:00
|
|
|
|
2016-05-28 13:30:01 +00:00
|
|
|
|
2015-01-24 00:58:16 +00:00
|
|
|
clean:
|
2016-07-22 01:36:50 +00:00
|
|
|
$(MAKE) -C ../lib clean
|
2016-09-02 16:44:00 +00:00
|
|
|
@$(RM) $(ZSTDDIR)/decompress/*.o $(ZSTDDIR)/decompress/zstd_decompress.gcda
|
2016-08-30 20:33:20 +00:00
|
|
|
@$(RM) core *.o tmp* result* *.gcda dictionary *.zst \
|
2016-09-02 16:44:00 +00:00
|
|
|
zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) \
|
|
|
|
*.gcda default.profraw
|
2015-01-24 00:58:16 +00:00
|
|
|
@echo Cleaning completed
|
|
|
|
|
2016-10-05 09:56:22 +00:00
|
|
|
clean_decomp_o:
|
|
|
|
@$(RM) $(ZSTDDECOMP_O)
|
|
|
|
@$(RM) $(ZSTDDECOMP32_O)
|
|
|
|
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2016-07-31 00:10:36 +00:00
|
|
|
#----------------------------------------------------------------------------------
|
|
|
|
#make install is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets
|
|
|
|
#----------------------------------------------------------------------------------
|
2016-09-04 12:37:57 +00:00
|
|
|
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly NetBSD))
|
2015-12-01 00:56:02 +00:00
|
|
|
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
|
2015-03-24 19:15:56 +00:00
|
|
|
@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
|
2015-08-27 02:16:04 +00:00
|
|
|
@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:
|
2016-08-30 20:33:20 +00:00
|
|
|
$(RM) $(DESTDIR)$(BINDIR)/zstdcat
|
|
|
|
$(RM) $(DESTDIR)$(BINDIR)/unzstd
|
2016-09-12 03:04:26 +00:00
|
|
|
$(RM) $(DESTDIR)$(BINDIR)/zstd$(EXT)
|
2016-08-30 20:33:20 +00:00
|
|
|
$(RM) $(DESTDIR)$(MANDIR)/zstdcat.1
|
|
|
|
$(RM) $(DESTDIR)$(MANDIR)/unzstd.1
|
2016-09-12 03:04:26 +00:00
|
|
|
$(RM) $(DESTDIR)$(MANDIR)/zstd.1
|
2015-01-24 00:58:16 +00:00
|
|
|
@echo zstd programs successfully uninstalled
|
|
|
|
endif
|