zstd/programs/Makefile

199 lines
6.3 KiB
Makefile
Raw Normal View History

2015-01-24 00:58:16 +00:00
# ##########################################################################
# Copyright (c) 2015-present, Yann Collet, Facebook, Inc.
2016-08-30 20:33:20 +00:00
# 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
# ##########################################################################
2016-05-28 23:39:19 +00:00
ZSTDDIR = ../lib
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version "), 1)
ALIGN_LOOP = -falign-loops=32
else
ALIGN_LOOP =
endif
2016-12-02 20:40:57 +00:00
CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder
CFLAGS ?= -O3
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
2016-11-03 05:28:37 +00:00
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef \
-Wpointer-arith
2016-12-02 20:40:57 +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-12-27 06:19:36 +00:00
ZSTDCOMP_FILES := $(ZSTDDIR)/compress/*.c
ZSTDDECOMP_FILES := $(ZSTDDIR)/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
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
CPPFLAGS += -I$(ZSTDDIR)/legacy
ZSTDLEGACY_FILES:= $(ZSTDDIR)/legacy/*.c
endif
ZSTDLIB_FILES := $(wildcard $(ZSTD_FILES)) $(wildcard $(ZSTDLEGACY_FILES)) $(wildcard $(ZDICT_FILES))
ZSTDLIB_OBJ := $(patsubst %.c,%.o,$(ZSTDLIB_FILES))
2015-01-24 00:58:16 +00:00
# Define *.exe as extension for Windows systems
ifneq (,$(filter Windows%,$(OS)))
EXT =.exe
2016-12-08 09:43:55 +00:00
RES64_FILE = windres/zstd64.res
RES32_FILE = windres/zstd32.res
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 =
endif
2015-11-26 09:52:30 +00:00
2016-10-28 11:16:06 +00:00
.PHONY: default all clean clean_decomp_o install uninstall generate_res
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
$(ZSTDDECOMP_O): CFLAGS += $(ALIGN_LOOP)
2016-08-17 13:59:50 +00:00
zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
zstd : $(ZSTDLIB_OBJ) zstdcli.o fileio.o bench.o datagen.o dibio.o
ifneq (,$(filter Windows%,$(OS)))
2016-12-08 09:43:55 +00:00
windres/generate_res.bat
endif
2016-12-02 20:40:57 +00:00
$(CC) $(FLAGS) $^ $(RES_FILE) -o $@$(EXT) $(LDFLAGS)
2015-01-24 00:58:16 +00:00
zstd32 : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
zstd32 : $(ZSTDLIB_FILES) zstdcli.c fileio.c bench.c datagen.c dibio.c
ifneq (,$(filter Windows%,$(OS)))
2016-12-08 09:43:55 +00:00
windres/generate_res.bat
endif
2016-12-02 20:40:57 +00:00
$(CC) -m32 $(FLAGS) $^ $(RES32_FILE) -o $@$(EXT)
2016-08-17 13:59:50 +00:00
2015-01-24 00:58:16 +00:00
zstd-nolegacy : clean_decomp_o
$(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)
2016-08-30 20:33:20 +00:00
$(RM) zstd
$(RM) $(ZSTDDECOMP_O)
2015-12-01 00:28:32 +00:00
$(MAKE) zstd MOREFLAGS=-fprofile-use
zstd-frugal: $(ZSTD_FILES) zstdcli.c fileio.c
2016-12-02 20:40:57 +00:00
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT $^ -o zstd$(EXT)
2015-12-03 11:11:30 +00:00
zstd-small:
CFLAGS="-Os -s" $(MAKE) zstd-frugal
zstd-decompress: $(ZSTDCOMMON_FILES) $(ZSTDDECOMP_FILES) zstdcli.c fileio.c
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOCOMPRESS $^ -o $@$(EXT)
zstd-compress: $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) zstdcli.c fileio.c
2016-12-02 20:40:57 +00:00
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NODECOMPRESS $^ -o $@$(EXT)
2015-12-03 11:11:30 +00:00
gzstd:
2016-12-06 19:23:15 +00:00
@echo "int main(){}" | $(CC) -o have_zlib -x c - -lz && echo found zlib || echo did not found zlib
@if [ -s have_zlib ]; then \
echo building gzstd with .gz decompression support \
&& $(RM) have_zlib$(EXT) fileio.o \
2016-12-06 19:23:15 +00:00
&& CPPFLAGS=-DZSTD_GZDECOMPRESS LDFLAGS="-lz" $(MAKE) zstd; \
else \
echo "WARNING : no zlib, building gzstd with only .zst files support : NO .gz SUPPORT !!!" \
&& $(MAKE) zstd; \
fi
2016-11-30 14:05:54 +00:00
2017-01-02 00:43:56 +00:00
zstdmt: CPPFLAGS += -DZSTD_PTHREAD
zstdmt: LDFLAGS += -lpthread
zstdmt: zstd
2017-01-02 00:43:56 +00:00
2016-10-28 11:16:06 +00:00
generate_res:
2016-12-08 09:43:55 +00:00
windres/generate_res.bat
2015-01-24 00:58:16 +00:00
clean:
$(MAKE) -C ../lib clean
@$(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 \
zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) \
*.gcda default.profraw
2015-01-24 00:58:16 +00:00
@echo Cleaning completed
clean_decomp_o:
@$(RM) $(ZSTDDECOMP_O)
2015-01-24 00:58:16 +00:00
2016-12-23 09:05:49 +00:00
#-----------------------------------------------------------------------------
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
#-----------------------------------------------------------------------------
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
ifneq (,$(filter $(shell uname),SunOS))
2016-12-22 19:14:37 +00:00
INSTALL ?= ginstall
else
2016-12-22 19:14:37 +00:00
INSTALL ?= install
endif
2016-12-23 09:05:49 +00:00
PREFIX ?= /usr/local
2016-12-22 19:14:37 +00:00
DESTDIR ?=
2016-12-23 09:05:49 +00:00
BINDIR ?= $(PREFIX)/bin
2016-12-28 11:32:41 +00:00
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
MANDIR ?= $(PREFIX)/man/man1
else
2016-12-23 09:05:49 +00:00
MANDIR ?= $(PREFIX)/share/man/man1
2017-01-02 00:43:56 +00:00
endif
INSTALL_PROGRAM ?= $(INSTALL) -m 755
2016-12-23 09:05:49 +00:00
INSTALL_SCRIPT ?= $(INSTALL) -m 755
INSTALL_MAN ?= $(INSTALL) -m 644
install: zstd
2015-01-24 00:58:16 +00:00
@echo Installing binaries
@$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
@$(INSTALL_PROGRAM) zstd $(DESTDIR)$(BINDIR)/zstd
2016-12-02 23:24:40 +00:00
@ln -sf zstd $(DESTDIR)$(BINDIR)/zstdcat
@ln -sf zstd $(DESTDIR)$(BINDIR)/unzstd
@$(INSTALL_SCRIPT) zstdless $(DESTDIR)$(BINDIR)/zstdless
@$(INSTALL_SCRIPT) zstdgrep $(DESTDIR)$(BINDIR)/zstdgrep
2015-01-24 00:58:16 +00:00
@echo Installing man pages
@$(INSTALL_MAN) 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:
2016-12-02 23:57:07 +00:00
@$(RM) $(DESTDIR)$(BINDIR)/zstdgrep
@$(RM) $(DESTDIR)$(BINDIR)/zstdless
2016-10-12 18:09:36 +00:00
@$(RM) $(DESTDIR)$(BINDIR)/zstdcat
@$(RM) $(DESTDIR)$(BINDIR)/unzstd
2016-12-02 23:24:40 +00:00
@$(RM) $(DESTDIR)$(BINDIR)/zstd
2016-10-12 18:09:36 +00:00
@$(RM) $(DESTDIR)$(MANDIR)/zstdcat.1
@$(RM) $(DESTDIR)$(MANDIR)/unzstd.1
@$(RM) $(DESTDIR)$(MANDIR)/zstd.1
2015-01-24 00:58:16 +00:00
@echo zstd programs successfully uninstalled
endif