2017-08-31 19:20:50 +00:00
|
|
|
# ################################################################
|
2017-01-02 02:22:18 +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
|
|
|
#
|
2017-08-31 19:20:50 +00:00
|
|
|
# This source code is licensed under both the BSD-style license (found in the
|
|
|
|
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
|
|
# in the COPYING file in the root directory of this source tree).
|
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
|
|
|
|
|
2017-03-16 22:33:21 +00:00
|
|
|
# Version numbers
|
|
|
|
LIBVER_SRC := $(ZSTDDIR)/zstd.h
|
|
|
|
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
|
|
|
LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
|
|
|
LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
|
|
|
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
|
|
|
|
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
|
|
|
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
|
|
|
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
|
|
|
LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
|
|
|
|
2018-09-25 23:56:53 +00:00
|
|
|
ZSTD_VERSION = $(LIBVER)
|
2017-03-16 22:33:21 +00:00
|
|
|
|
2018-12-03 23:46:55 +00:00
|
|
|
HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
|
|
|
GREP_OPTIONS ?=
|
|
|
|
ifeq ($HAVE_COLORNEVER, 1)
|
|
|
|
GREP_OPTIONS += --color=never
|
|
|
|
endif
|
|
|
|
GREP = grep $(GREP_OPTIONS)
|
2018-09-25 23:56:53 +00:00
|
|
|
|
|
|
|
ifeq ($(shell $(CC) -v 2>&1 | $(GREP) -c "gcc version "), 1)
|
2016-07-22 01:36:50 +00:00
|
|
|
ALIGN_LOOP = -falign-loops=32
|
|
|
|
else
|
|
|
|
ALIGN_LOOP =
|
|
|
|
endif
|
|
|
|
|
2017-03-02 05:02:06 +00:00
|
|
|
CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
|
|
|
|
-I$(ZSTDDIR)/dictBuilder \
|
2017-10-19 00:01:53 +00:00
|
|
|
-DXXH_NAMESPACE=ZSTD_
|
2018-07-30 14:56:18 +00:00
|
|
|
ifeq ($(OS),Windows_NT) # MinGW assumed
|
|
|
|
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
|
|
|
endif
|
2016-12-02 20:40:57 +00:00
|
|
|
CFLAGS ?= -O3
|
2017-09-25 21:26:26 +00:00
|
|
|
DEBUGFLAGS+=-Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
2017-05-16 18:34:38 +00:00
|
|
|
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
2019-02-01 09:31:46 +00:00
|
|
|
-Wstrict-prototypes -Wundef -Wpointer-arith \
|
2017-05-16 18:34:38 +00:00
|
|
|
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
2018-10-26 23:38:23 +00:00
|
|
|
-Wredundant-decls -Wmissing-prototypes -Wc++-compat
|
2017-02-03 04:54:14 +00:00
|
|
|
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
2016-12-02 20:40:57 +00:00
|
|
|
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
|
2017-01-02 02:22:18 +00:00
|
|
|
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
|
2015-11-27 15:18:56 +00:00
|
|
|
|
2018-09-20 21:24:23 +00:00
|
|
|
ZSTD_LEGACY_SUPPORT ?= 5
|
2017-05-16 00:15:46 +00:00
|
|
|
ZSTDLEGACY_FILES :=
|
2017-03-13 21:32:30 +00:00
|
|
|
ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
|
|
|
|
ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
|
2018-09-25 23:56:53 +00:00
|
|
|
ZSTDLEGACY_FILES += $(shell ls $(ZSTDDIR)/legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
|
2017-03-13 21:32:30 +00:00
|
|
|
endif
|
|
|
|
CPPFLAGS += -I$(ZSTDDIR)/legacy
|
2015-11-27 15:18:56 +00:00
|
|
|
else
|
|
|
|
endif
|
|
|
|
|
2017-11-27 21:47:35 +00:00
|
|
|
# Sort files in alphabetical order for reproducible builds
|
2017-08-26 15:08:00 +00:00
|
|
|
ZSTDLIB_FILES := $(sort $(wildcard $(ZSTD_FILES)) $(wildcard $(ZSTDLEGACY_FILES)) $(wildcard $(ZDICT_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
|
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 =
|
|
|
|
endif
|
|
|
|
|
2017-04-14 18:33:04 +00:00
|
|
|
VOID = /dev/null
|
|
|
|
|
|
|
|
# thread detection
|
|
|
|
NO_THREAD_MSG := ==> no threads, building without multithreading support
|
2018-11-16 09:49:15 +00:00
|
|
|
HAVE_PTHREAD := $(shell printf '\#include <pthread.h>\nint main(void) { return 0; }' > have_pthread.c && $(CC) $(FLAGS) -o have_pthread$(EXT) have_pthread.c -pthread 2> $(VOID) && rm have_pthread$(EXT) && echo 1 || echo 0; rm have_pthread.c)
|
2017-04-14 18:33:04 +00:00
|
|
|
HAVE_THREAD := $(shell [ "$(HAVE_PTHREAD)" -eq "1" -o -n "$(filter Windows%,$(OS))" ] && echo 1 || echo 0)
|
|
|
|
ifeq ($(HAVE_THREAD), 1)
|
|
|
|
THREAD_MSG := ==> building with threading support
|
|
|
|
THREAD_CPP := -DZSTD_MULTITHREAD
|
|
|
|
THREAD_LD := -pthread
|
|
|
|
else
|
2017-04-18 20:52:00 +00:00
|
|
|
THREAD_MSG := $(NO_THREAD_MSG)
|
2017-04-14 18:33:04 +00:00
|
|
|
endif
|
|
|
|
|
2017-02-03 00:49:34 +00:00
|
|
|
# zlib detection
|
2017-03-14 01:11:07 +00:00
|
|
|
NO_ZLIB_MSG := ==> no zlib, building zstd without .gz support
|
2018-11-16 09:49:15 +00:00
|
|
|
HAVE_ZLIB := $(shell printf '\#include <zlib.h>\nint main(void) { return 0; }' > have_zlib.c && $(CC) $(FLAGS) -o have_zlib$(EXT) have_zlib.c -lz 2> $(VOID) && rm have_zlib$(EXT) && echo 1 || echo 0; rm have_zlib.c)
|
2017-02-08 13:32:49 +00:00
|
|
|
ifeq ($(HAVE_ZLIB), 1)
|
2017-03-14 01:11:07 +00:00
|
|
|
ZLIB_MSG := ==> building zstd with .gz compression support
|
2017-02-08 14:17:55 +00:00
|
|
|
ZLIBCPP = -DZSTD_GZCOMPRESS -DZSTD_GZDECOMPRESS
|
2017-02-03 00:49:34 +00:00
|
|
|
ZLIBLD = -lz
|
2017-03-14 01:11:07 +00:00
|
|
|
else
|
|
|
|
ZLIB_MSG := $(NO_ZLIB_MSG)
|
|
|
|
endif
|
2017-05-03 21:32:33 +00:00
|
|
|
|
2017-03-14 01:11:07 +00:00
|
|
|
# lzma detection
|
|
|
|
NO_LZMA_MSG := ==> no liblzma, building zstd without .xz/.lzma support
|
2018-11-16 09:49:15 +00:00
|
|
|
HAVE_LZMA := $(shell printf '\#include <lzma.h>\nint main(void) { return 0; }' > have_lzma.c && $(CC) $(FLAGS) -o have_lzma$(EXT) have_lzma.c -llzma 2> $(VOID) && rm have_lzma$(EXT) && echo 1 || echo 0; rm have_lzma.c)
|
2017-03-14 01:11:07 +00:00
|
|
|
ifeq ($(HAVE_LZMA), 1)
|
|
|
|
LZMA_MSG := ==> building zstd with .xz/.lzma compression support
|
|
|
|
LZMACPP = -DZSTD_LZMACOMPRESS -DZSTD_LZMADECOMPRESS
|
|
|
|
LZMALD = -llzma
|
|
|
|
else
|
|
|
|
LZMA_MSG := $(NO_LZMA_MSG)
|
2017-02-03 00:49:34 +00:00
|
|
|
endif
|
2017-05-03 21:32:33 +00:00
|
|
|
|
2017-04-24 23:48:25 +00:00
|
|
|
# lz4 detection
|
|
|
|
NO_LZ4_MSG := ==> no liblz4, building zstd without .lz4 support
|
2018-11-16 09:49:15 +00:00
|
|
|
HAVE_LZ4 := $(shell printf '\#include <lz4frame.h>\n\#include <lz4.h>\nint main(void) { return 0; }' > have_lz4.c && $(CC) $(FLAGS) -o have_lz4$(EXT) have_lz4.c -llz4 2> $(VOID) && rm have_lz4$(EXT) && echo 1 || echo 0; rm have_lz4.c)
|
2017-04-24 23:48:25 +00:00
|
|
|
ifeq ($(HAVE_LZ4), 1)
|
|
|
|
LZ4_MSG := ==> building zstd with .lz4 compression support
|
|
|
|
LZ4CPP = -DZSTD_LZ4COMPRESS -DZSTD_LZ4DECOMPRESS
|
|
|
|
LZ4LD = -llz4
|
|
|
|
else
|
|
|
|
LZ4_MSG := $(NO_LZ4_MSG)
|
|
|
|
endif
|
2015-11-26 09:52:30 +00:00
|
|
|
|
2018-10-10 00:12:21 +00:00
|
|
|
# explicit backtrace enable/disable for Linux & Darwin
|
|
|
|
ifeq ($(BACKTRACE), 0)
|
|
|
|
DEBUGFLAGS += -DBACKTRACE_ENABLE=0
|
|
|
|
endif
|
2018-09-12 21:00:08 +00:00
|
|
|
ifeq (,$(filter Windows%, $(OS)))
|
2018-10-09 00:03:06 +00:00
|
|
|
ifeq ($(BACKTRACE), 1)
|
|
|
|
DEBUGFLAGS += -DBACKTRACE_ENABLE=1
|
|
|
|
DEBUGFLAGS_LD += -rdynamic
|
2018-09-12 21:00:08 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: default
|
2017-02-03 04:54:14 +00:00
|
|
|
default: zstd-release
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: all
|
2016-08-18 11:18:11 +00:00
|
|
|
all: zstd
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: allVariants
|
2017-08-19 08:01:53 +00:00
|
|
|
allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy
|
2017-08-19 01:30:41 +00:00
|
|
|
|
2016-10-18 23:01:03 +00:00
|
|
|
$(ZSTDDECOMP_O): CFLAGS += $(ALIGN_LOOP)
|
2016-08-17 13:59:50 +00:00
|
|
|
|
2017-09-21 18:29:35 +00:00
|
|
|
zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP)
|
2018-09-11 21:49:47 +00:00
|
|
|
zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD)
|
2017-09-21 18:29:35 +00:00
|
|
|
zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
2018-11-13 19:01:59 +00:00
|
|
|
zstd : $(ZSTDLIB_FILES) zstdcli.o util.o fileio.o benchfn.o benchzstd.o datagen.o dibio.o
|
2017-04-14 18:33:04 +00:00
|
|
|
@echo "$(THREAD_MSG)"
|
2017-03-14 01:11:07 +00:00
|
|
|
@echo "$(ZLIB_MSG)"
|
|
|
|
@echo "$(LZMA_MSG)"
|
2017-04-24 23:48:25 +00:00
|
|
|
@echo "$(LZ4_MSG)"
|
2016-10-28 16:15:34 +00:00
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
2016-12-08 09:43:55 +00:00
|
|
|
windres/generate_res.bat
|
2016-10-28 16:15:34 +00:00
|
|
|
endif
|
2017-08-19 08:01:53 +00:00
|
|
|
$(CC) $(FLAGS) $^ $(RES_FILE) -o $@$(EXT) $(LDFLAGS)
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: zstd-release
|
2018-10-09 00:03:06 +00:00
|
|
|
zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0
|
2018-09-11 21:49:47 +00:00
|
|
|
zstd-release: DEBUGFLAGS_LD :=
|
2017-02-03 04:54:14 +00:00
|
|
|
zstd-release: zstd
|
2016-10-18 23:01:03 +00:00
|
|
|
|
2018-01-17 20:10:15 +00:00
|
|
|
zstd32 : CPPFLAGS += $(THREAD_CPP)
|
2018-10-09 00:03:06 +00:00
|
|
|
zstd32 : LDFLAGS += $(THREAD_LD)
|
2016-11-03 00:02:45 +00:00
|
|
|
zstd32 : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
2018-11-13 19:01:59 +00:00
|
|
|
zstd32 : $(ZSTDLIB_FILES) zstdcli.c util.c fileio.c benchfn.c benchzstd.c datagen.c dibio.c
|
2016-10-28 16:15:34 +00:00
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
2016-12-08 09:43:55 +00:00
|
|
|
windres/generate_res.bat
|
2016-10-28 16:15:34 +00:00
|
|
|
endif
|
2016-12-02 20:40:57 +00:00
|
|
|
$(CC) -m32 $(FLAGS) $^ $(RES32_FILE) -o $@$(EXT)
|
2016-08-17 13:59:50 +00:00
|
|
|
|
2018-11-13 19:01:59 +00:00
|
|
|
zstd-nolegacy : $(ZSTD_FILES) $(ZDICT_FILES) zstdcli.o util.o fileio.c benchfn.o benchzstd.o datagen.o dibio.o
|
2017-08-19 08:01:53 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS)
|
2015-11-30 10:53:11 +00:00
|
|
|
|
2017-04-14 18:33:04 +00:00
|
|
|
zstd-nomt : THREAD_CPP :=
|
2018-10-09 00:03:06 +00:00
|
|
|
zstd-nomt : THREAD_LD :=
|
2017-05-02 23:55:57 +00:00
|
|
|
zstd-nomt : THREAD_MSG := - multi-threading disabled
|
2017-04-14 18:33:04 +00:00
|
|
|
zstd-nomt : zstd
|
|
|
|
|
2017-05-03 00:18:24 +00:00
|
|
|
zstd-nogz : ZLIBCPP :=
|
2018-10-09 00:03:06 +00:00
|
|
|
zstd-nogz : ZLIBLD :=
|
2017-05-03 00:18:24 +00:00
|
|
|
zstd-nogz : ZLIB_MSG := - gzip support is disabled
|
|
|
|
zstd-nogz : zstd
|
|
|
|
|
2017-06-26 18:25:00 +00:00
|
|
|
zstd-noxz : LZMACPP :=
|
2018-10-09 00:03:06 +00:00
|
|
|
zstd-noxz : LZMALD :=
|
2017-06-26 18:25:00 +00:00
|
|
|
zstd-noxz : LZMA_MSG := - xz/lzma support is disabled
|
|
|
|
zstd-noxz : zstd
|
|
|
|
|
2017-05-03 00:18:24 +00:00
|
|
|
|
2018-10-29 14:11:28 +00:00
|
|
|
zstd-pgo :
|
|
|
|
$(MAKE) clean
|
|
|
|
$(MAKE) zstd MOREFLAGS=-fprofile-generate
|
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)
|
2018-10-29 16:20:03 +00:00
|
|
|
$(RM) zstd *.o $(ZSTDDECOMP_O) $(ZSTDDIR)/compress/*.o
|
2015-12-01 00:28:32 +00:00
|
|
|
$(MAKE) zstd MOREFLAGS=-fprofile-use
|
|
|
|
|
2017-05-02 23:55:57 +00:00
|
|
|
# minimal target, with only zstd compression and decompression. no bench. no legacy.
|
2017-08-19 07:48:29 +00:00
|
|
|
zstd-small: CFLAGS = -Os -s
|
2018-10-11 19:52:19 +00:00
|
|
|
zstd-frugal zstd-small: $(ZSTD_FILES) zstdcli.c util.c fileio.c
|
2017-08-19 07:48:29 +00:00
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT $^ -o $@$(EXT)
|
2015-12-03 11:11:30 +00:00
|
|
|
|
2018-10-11 19:52:19 +00:00
|
|
|
zstd-decompress: $(ZSTDCOMMON_FILES) $(ZSTDDECOMP_FILES) zstdcli.c util.c fileio.c
|
2017-01-02 02:22:18 +00:00
|
|
|
$(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOCOMPRESS $^ -o $@$(EXT)
|
2016-10-05 09:56:22 +00:00
|
|
|
|
2018-10-11 19:52:19 +00:00
|
|
|
zstd-compress: $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) zstdcli.c util.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
|
|
|
|
2017-01-11 17:21:25 +00:00
|
|
|
zstdmt: zstd
|
2017-09-06 23:53:59 +00:00
|
|
|
ln -sf zstd zstdmt
|
2017-01-02 00:43:56 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: generate_res
|
2016-10-28 11:16:06 +00:00
|
|
|
generate_res:
|
2016-12-08 09:43:55 +00:00
|
|
|
windres/generate_res.bat
|
2016-05-28 13:30:01 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: clean
|
2015-01-24 00:58:16 +00:00
|
|
|
clean:
|
2017-02-22 09:31:30 +00:00
|
|
|
$(MAKE) -C $(ZSTDDIR) 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) \
|
2017-08-19 20:33:50 +00:00
|
|
|
zstd-small$(EXT) zstd-frugal$(EXT) zstd-nolegacy$(EXT) zstd4$(EXT) \
|
2017-02-08 13:32:49 +00:00
|
|
|
*.gcda default.profraw have_zlib$(EXT)
|
2015-01-24 00:58:16 +00:00
|
|
|
@echo Cleaning completed
|
|
|
|
|
2017-05-03 21:32:33 +00:00
|
|
|
MD2ROFF = ronn
|
|
|
|
MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="zstd $(ZSTD_VERSION)"
|
|
|
|
|
2017-12-15 00:11:20 +00:00
|
|
|
zstd.1: zstd.1.md ../lib/zstd.h
|
|
|
|
cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
|
2017-03-16 22:33:21 +00:00
|
|
|
|
2018-10-15 09:20:10 +00:00
|
|
|
zstdgrep.1: zstdgrep.1.md ../lib/zstd.h
|
|
|
|
cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
|
|
|
|
|
|
|
|
zstdless.1: zstdless.1.md ../lib/zstd.h
|
|
|
|
cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
|
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: man
|
2018-10-15 09:20:10 +00:00
|
|
|
man: zstd.1 zstdgrep.1 zstdless.1
|
2017-03-16 22:33:21 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: clean-man
|
2017-03-16 22:33:21 +00:00
|
|
|
clean-man:
|
|
|
|
rm zstd.1
|
2018-10-15 09:20:10 +00:00
|
|
|
rm zstdgrep.1
|
|
|
|
rm zstdless.1
|
2017-03-16 22:33:21 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: preview-man
|
2017-03-16 22:33:21 +00:00
|
|
|
preview-man: clean-man man
|
|
|
|
man ./zstd.1
|
2018-10-15 09:20:10 +00:00
|
|
|
man ./zstdgrep.1
|
|
|
|
man ./zstdless.1
|
2015-01-24 00:58:16 +00:00
|
|
|
|
2016-12-23 09:05:49 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
2018-06-09 19:31:17 +00:00
|
|
|
# make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets
|
2016-12-23 09:05:49 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
2017-08-06 20:27:54 +00:00
|
|
|
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
2016-12-22 18:26:01 +00:00
|
|
|
|
2018-12-03 23:46:55 +00:00
|
|
|
HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
|
|
|
EGREP_OPTIONS ?=
|
|
|
|
ifeq ($HAVE_COLORNEVER, 1)
|
|
|
|
EGREP_OPTIONS += --color=never
|
|
|
|
endif
|
|
|
|
EGREP = egrep $(EGREP_OPTIONS)
|
2018-09-25 23:56:53 +00:00
|
|
|
|
|
|
|
# Print a two column output of targets and their description. To add a target description, put a
|
|
|
|
# comment in the Makefile with the format "## <TARGET>: <DESCRIPTION>". For example:
|
|
|
|
#
|
|
|
|
## list: Print all targets and their descriptions (if provided)
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: list
|
|
|
|
list:
|
2018-09-25 23:56:53 +00:00
|
|
|
@TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
|
|
|
|
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
|
|
|
|
| $(EGREP) -v -e '^[^[:alnum:]]' | sort); \
|
|
|
|
{ \
|
|
|
|
printf "Target Name\tDescription\n"; \
|
|
|
|
printf "%0.s-" {1..16}; printf "\t"; printf "%0.s-" {1..40}; printf "\n"; \
|
|
|
|
for target in $$TARGETS; do \
|
|
|
|
line=$$($(EGREP) "^##[[:space:]]+$$target:" $(lastword $(MAKEFILE_LIST))); \
|
|
|
|
description=$$(echo $$line | awk '{i=index($$0,":"); print substr($$0,i+1)}' | xargs); \
|
|
|
|
printf "$$target\t$$description\n"; \
|
|
|
|
done \
|
|
|
|
} | column -t -s $$'\t'
|
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
|
2017-09-06 23:53:59 +00:00
|
|
|
DESTDIR ?=
|
|
|
|
# directory variables : GNU conventions prefer lowercase
|
|
|
|
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
|
|
|
|
# support both lower and uppercase (BSD), use uppercase in script
|
|
|
|
prefix ?= /usr/local
|
|
|
|
PREFIX ?= $(prefix)
|
|
|
|
exec_prefix ?= $(PREFIX)
|
|
|
|
bindir ?= $(exec_prefix)/bin
|
|
|
|
BINDIR ?= $(bindir)
|
|
|
|
datarootdir ?= $(PREFIX)/share
|
|
|
|
mandir ?= $(datarootdir)/man
|
|
|
|
man1dir ?= $(mandir)/man1
|
2016-12-28 11:32:41 +00:00
|
|
|
|
|
|
|
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
2017-11-27 21:47:35 +00:00
|
|
|
MANDIR ?= $(PREFIX)/man
|
|
|
|
MAN1DIR ?= $(MANDIR)/man1
|
2016-12-28 11:32:41 +00:00
|
|
|
else
|
2017-11-27 21:47:35 +00:00
|
|
|
MAN1DIR ?= $(man1dir)
|
2017-09-06 23:53:59 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$(filter $(shell uname),SunOS))
|
|
|
|
INSTALL ?= ginstall
|
|
|
|
else
|
|
|
|
INSTALL ?= install
|
2017-01-02 00:43:56 +00:00
|
|
|
endif
|
2016-12-22 18:26:01 +00:00
|
|
|
|
2017-09-06 23:53:59 +00:00
|
|
|
INSTALL_PROGRAM ?= $(INSTALL)
|
|
|
|
INSTALL_SCRIPT ?= $(INSTALL_PROGRAM)
|
|
|
|
INSTALL_DATA ?= $(INSTALL) -m 644
|
|
|
|
INSTALL_MAN ?= $(INSTALL_DATA)
|
2016-12-22 18:26:01 +00:00
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: install
|
2015-12-01 00:56:02 +00:00
|
|
|
install: zstd
|
2015-01-24 00:58:16 +00:00
|
|
|
@echo Installing binaries
|
2017-11-27 21:47:35 +00:00
|
|
|
@$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MAN1DIR)/
|
2016-12-22 18:26:01 +00:00
|
|
|
@$(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
|
2017-04-14 18:33:04 +00:00
|
|
|
@ln -sf zstd $(DESTDIR)$(BINDIR)/zstdmt
|
2016-12-22 18:26:01 +00:00
|
|
|
@$(INSTALL_SCRIPT) zstdless $(DESTDIR)$(BINDIR)/zstdless
|
|
|
|
@$(INSTALL_SCRIPT) zstdgrep $(DESTDIR)$(BINDIR)/zstdgrep
|
2015-01-24 00:58:16 +00:00
|
|
|
@echo Installing man pages
|
2017-11-27 21:47:35 +00:00
|
|
|
@$(INSTALL_MAN) zstd.1 $(DESTDIR)$(MAN1DIR)/zstd.1
|
|
|
|
@ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/zstdcat.1
|
|
|
|
@ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/unzstd.1
|
2018-10-15 09:20:10 +00:00
|
|
|
@$(INSTALL_MAN) zstdgrep.1 $(DESTDIR)$(MAN1DIR)/zstdgrep.1
|
|
|
|
@$(INSTALL_MAN) zstdless.1 $(DESTDIR)$(MAN1DIR)/zstdless.1
|
2015-01-24 00:58:16 +00:00
|
|
|
@echo zstd installation completed
|
|
|
|
|
2017-08-19 01:30:41 +00:00
|
|
|
.PHONY: uninstall
|
2015-01-24 00:58:16 +00:00
|
|
|
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
|
2018-10-22 19:51:56 +00:00
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/zstdmt
|
2016-12-02 23:24:40 +00:00
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/zstd
|
2018-10-15 09:20:10 +00:00
|
|
|
@$(RM) $(DESTDIR)$(MAN1DIR)/zstdless.1
|
|
|
|
@$(RM) $(DESTDIR)$(MAN1DIR)/zstdgrep.1
|
2017-11-27 21:47:35 +00:00
|
|
|
@$(RM) $(DESTDIR)$(MAN1DIR)/zstdcat.1
|
|
|
|
@$(RM) $(DESTDIR)$(MAN1DIR)/unzstd.1
|
|
|
|
@$(RM) $(DESTDIR)$(MAN1DIR)/zstd.1
|
2015-01-24 00:58:16 +00:00
|
|
|
@echo zstd programs successfully uninstalled
|
2017-08-19 07:48:29 +00:00
|
|
|
|
2015-01-24 00:58:16 +00:00
|
|
|
endif
|