2015-01-23 16:58:16 -08:00
|
|
|
# ##########################################################################
|
|
|
|
# ZSTD programs - Makefile
|
2016-02-07 14:58:32 -08:00
|
|
|
# Copyright (C) Yann Collet 2015-2016
|
2015-01-23 16:58:16 -08: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 14:58:32 -08:00
|
|
|
# - zstd homepage : http://www.zstd.net/
|
2015-01-23 16:58:16 -08:00
|
|
|
# ##########################################################################
|
|
|
|
# zstd : Command Line Utility, supporting gzip-like arguments
|
2016-08-18 04:18:11 -07:00
|
|
|
# zstd32 : Same as zstd, but forced to compile in 32-bits mode
|
|
|
|
# zstd_nolegacy : zstd without support of decompression of legacy versions
|
|
|
|
# zstd-small: minimal zstd without dictBuilder and bench
|
|
|
|
# zstd-compress: compressor-only version of zstd
|
|
|
|
# zstd-decompress: decompressor-only version of zstd
|
2015-01-23 16:58:16 -08:00
|
|
|
# ##########################################################################
|
|
|
|
|
|
|
|
DESTDIR?=
|
2015-08-25 16:19:06 -07:00
|
|
|
PREFIX ?= /usr/local
|
2016-05-28 16:39:19 -07:00
|
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
MANDIR = $(PREFIX)/share/man/man1
|
|
|
|
|
|
|
|
ZSTDDIR = ../lib
|
|
|
|
|
2016-07-21 18:36:50 -07:00
|
|
|
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version "), 1)
|
|
|
|
ALIGN_LOOP = -falign-loops=32
|
|
|
|
else
|
|
|
|
ALIGN_LOOP =
|
|
|
|
endif
|
|
|
|
|
2016-08-09 23:14:48 -07:00
|
|
|
CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder
|
2016-07-21 18:36:50 -07:00
|
|
|
CFLAGS ?= -O3
|
2016-07-21 19:45:06 -07:00
|
|
|
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
|
|
|
|
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
|
2016-07-24 08:46:05 -07:00
|
|
|
CFLAGS += $(MOREFLAGS)
|
|
|
|
FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
|
2016-05-28 16:39:19 -07:00
|
|
|
ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
|
2016-05-28 16:06:30 -07:00
|
|
|
ZSTDCOMP_FILES := $(ZSTDDIR)/compress/zstd_compress.c $(ZSTDDIR)/compress/fse_compress.c $(ZSTDDIR)/compress/huf_compress.c
|
2016-08-17 06:59:50 -07:00
|
|
|
ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/huf_decompress.c
|
2016-05-28 16:39:19 -07:00
|
|
|
ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
|
|
|
|
ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
|
2016-08-17 06:59:50 -07:00
|
|
|
ZSTDDECOMP_O = $(ZSTDDIR)/decompress/zstd_decompress.o
|
|
|
|
ZSTDDECOMP32_O = $(ZSTDDIR)/decompress/zstd_decompress32.o
|
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
|
2016-05-28 16:39:19 -07:00
|
|
|
ZSTDLEGACY_FILES:=
|
2015-11-27 07:18:56 -08:00
|
|
|
else
|
2016-02-11 17:56:27 -08:00
|
|
|
ZSTD_LEGACY_SUPPORT:=1
|
2016-05-28 16:39:19 -07:00
|
|
|
CPPFLAGS += -I$(ZSTDDIR)/legacy -I./legacy
|
|
|
|
ZSTDLEGACY_FILES:= $(ZSTDDIR)/legacy/*.c legacy/fileio_legacy.c
|
2015-11-27 07:18:56 -08:00
|
|
|
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
|
|
|
|
2016-08-18 04:18:11 -07:00
|
|
|
.PHONY: default all clean install uninstall
|
2015-01-23 16:58:16 -08:00
|
|
|
|
|
|
|
default: zstd
|
|
|
|
|
2016-08-18 04:18:11 -07:00
|
|
|
all: zstd
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2016-07-21 18:36:50 -07:00
|
|
|
|
2016-08-17 06:59:50 -07:00
|
|
|
$(ZSTDDECOMP_O): $(ZSTDDIR)/decompress/zstd_decompress.c
|
|
|
|
$(CC) $(ALIGN_LOOP) $(FLAGS) $^ -c -o $@
|
|
|
|
|
|
|
|
$(ZSTDDECOMP32_O): $(ZSTDDIR)/decompress/zstd_decompress.c
|
|
|
|
$(CC) -m32 $(ALIGN_LOOP) $(FLAGS) $^ -c -o $@
|
|
|
|
|
|
|
|
zstd : $(ZSTDDECOMP_O) $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZDICT_FILES) \
|
2016-05-28 16:06:30 -07:00
|
|
|
zstdcli.c fileio.c bench.c datagen.c dibio.c
|
2016-03-30 00:55:37 -07:00
|
|
|
$(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT)
|
2015-01-23 16:58:16 -08:00
|
|
|
|
2016-08-17 06:59:50 -07:00
|
|
|
zstd32 : $(ZSTDDECOMP32_O) $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZDICT_FILES) \
|
|
|
|
zstdcli.c fileio.c bench.c datagen.c dibio.c
|
|
|
|
$(CC) -m32 $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT)
|
|
|
|
|
2015-01-23 16:58:16 -08:00
|
|
|
|
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
|
2016-02-17 08:04:12 -08:00
|
|
|
./zstd -b19i1 $(PROFILE_WITH)
|
|
|
|
./zstd -b16i1 $(PROFILE_WITH)
|
|
|
|
./zstd -b9i2 $(PROFILE_WITH)
|
2015-11-30 16:28:32 -08:00
|
|
|
./zstd -b $(PROFILE_WITH)
|
2016-02-17 08:04:12 -08:00
|
|
|
./zstd -b7i2 $(PROFILE_WITH)
|
|
|
|
./zstd -b5 $(PROFILE_WITH)
|
2015-11-30 16:28:32 -08:00
|
|
|
rm zstd
|
|
|
|
$(MAKE) zstd MOREFLAGS=-fprofile-use
|
|
|
|
|
2016-08-17 07:29:57 -07:00
|
|
|
zstd-frugal: $(ZSTDDECOMP_O) $(ZSTD_FILES) zstdcli.c fileio.c
|
2016-02-11 17:56:27 -08:00
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_LEGACY_SUPPORT=0 $^ -o zstd$(EXT)
|
2015-12-03 03:11:30 -08:00
|
|
|
|
2016-05-28 16:39:19 -07:00
|
|
|
zstd-compress: $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) \
|
2016-08-13 14:45:45 -07:00
|
|
|
zstdcli.c fileio.c
|
2016-04-22 08:14:25 -07:00
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NODECOMPRESS -DZSTD_LEGACY_SUPPORT=0 $^ -o $@$(EXT)
|
|
|
|
|
2016-05-28 16:39:19 -07:00
|
|
|
zstd-decompress: $(ZSTDCOMMON_FILES) $(ZSTDDECOMP_FILES) \
|
2016-08-13 14:45:45 -07:00
|
|
|
zstdcli.c fileio.c
|
2016-04-22 04:59:05 -07:00
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOCOMPRESS -DZSTD_LEGACY_SUPPORT=0 $^ -o $@$(EXT)
|
|
|
|
|
2016-05-28 06:30:01 -07:00
|
|
|
zstd-small: clean
|
|
|
|
CFLAGS="-Os -s" $(MAKE) zstd-frugal
|
2015-12-03 03:11:30 -08:00
|
|
|
|
2016-05-28 06:30:01 -07:00
|
|
|
|
2015-01-23 16:58:16 -08:00
|
|
|
clean:
|
2016-07-21 18:36:50 -07:00
|
|
|
$(MAKE) -C ../lib clean
|
2016-08-19 01:45:59 -07:00
|
|
|
@rm -f ../lib/decompress/*.o
|
2016-02-11 17:31:57 -08:00
|
|
|
@rm -f core *.o tmp* result* *.gcda dictionary *.zst \
|
2016-08-18 04:18:11 -07:00
|
|
|
zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT)
|
2015-01-23 16:58:16 -08:00
|
|
|
@echo Cleaning completed
|
|
|
|
|
|
|
|
|
2016-07-30 17:10:36 -07: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))
|
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
|
|
|
|
endif
|