Merge pull request #2370 from facebook/libzstd_autoconf
Automatic configuration detection
This commit is contained in:
@@ -65,7 +65,7 @@ lib lib-release lib-all :
|
|||||||
.PHONY: zstd zstd-release
|
.PHONY: zstd zstd-release
|
||||||
zstd zstd-release:
|
zstd zstd-release:
|
||||||
$(Q)$(MAKE) -C $(PRGDIR) $@
|
$(Q)$(MAKE) -C $(PRGDIR) $@
|
||||||
$(Q)cp $(PRGDIR)/zstd$(EXT) .
|
$(Q)ln -sf $(PRGDIR)/zstd$(EXT) zstd$(EXT)
|
||||||
|
|
||||||
.PHONY: zstdmt
|
.PHONY: zstdmt
|
||||||
zstdmt:
|
zstdmt:
|
||||||
@@ -79,9 +79,9 @@ zlibwrapper: lib
|
|||||||
## test: run long-duration tests
|
## test: run long-duration tests
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
DEBUGLEVEL ?= 1
|
DEBUGLEVEL ?= 1
|
||||||
test: MOREFLAGS += -g -DDEBUGLEVEL=$(DEBUGLEVEL) -Werror
|
test: MOREFLAGS += -g -Werror
|
||||||
test:
|
test:
|
||||||
MOREFLAGS="$(MOREFLAGS)" $(MAKE) -j -C $(PRGDIR) allVariants
|
DEBUGLEVEL=$(DEBUGLEVEL) MOREFLAGS="$(MOREFLAGS)" $(MAKE) -j -C $(PRGDIR) allVariants
|
||||||
$(MAKE) -C $(TESTDIR) $@
|
$(MAKE) -C $(TESTDIR) $@
|
||||||
ZSTD=../../programs/zstd $(MAKE) -C doc/educational_decoder $@
|
ZSTD=../../programs/zstd $(MAKE) -C doc/educational_decoder $@
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -194,7 +194,7 @@
|
|||||||
- COMPILER: "gcc"
|
- COMPILER: "gcc"
|
||||||
HOST: "mingw"
|
HOST: "mingw"
|
||||||
PLATFORM: "x64"
|
PLATFORM: "x64"
|
||||||
SCRIPT: "CPPFLAGS=-DDEBUGLEVEL=2 CFLAGS=-Werror make -j allzstd DEBUGLEVEL=2"
|
SCRIPT: "CFLAGS=-Werror make -j allzstd DEBUGLEVEL=2"
|
||||||
- COMPILER: "gcc"
|
- COMPILER: "gcc"
|
||||||
HOST: "mingw"
|
HOST: "mingw"
|
||||||
PLATFORM: "x86"
|
PLATFORM: "x86"
|
||||||
|
|||||||
+46
-13
@@ -54,7 +54,8 @@ else
|
|||||||
CFLAGS += -O3
|
CFLAGS += -O3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPPFLAGS+= -DXXH_NAMESPACE=ZSTD_
|
DEBUGLEVEL ?= 0
|
||||||
|
CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -DDEBUGLEVEL=$(DEBUGLEVEL)
|
||||||
ifeq ($(TARGET_SYSTEM),Windows_NT) # MinGW assumed
|
ifeq ($(TARGET_SYSTEM),Windows_NT) # MinGW assumed
|
||||||
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
||||||
endif
|
endif
|
||||||
@@ -170,7 +171,29 @@ ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_SRC:.c=.o)
|
|||||||
ZSTD_SUBDIR := common compress decompress dictBuilder legacy deprecated
|
ZSTD_SUBDIR := common compress decompress dictBuilder legacy deprecated
|
||||||
vpath %.c $(ZSTD_SUBDIR)
|
vpath %.c $(ZSTD_SUBDIR)
|
||||||
|
|
||||||
BUILD_DIR ?= obj
|
UNAME := $(shell uname)
|
||||||
|
ifeq ($(UNAME), Darwin)
|
||||||
|
HASH ?= md5
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME), FreeBSD)
|
||||||
|
HASH ?= gmd5sum
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME), OpenBSD)
|
||||||
|
HASH ?= md5
|
||||||
|
endif
|
||||||
|
HASH ?= md5sum
|
||||||
|
|
||||||
|
HAVE_HASH := $(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
||||||
|
ifeq ($(HAVE_HASH), 1)
|
||||||
|
HASH_VALUE := $(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | head -c 16)
|
||||||
|
HASH_DIR := conf_$(HASH_VALUE)
|
||||||
|
else
|
||||||
|
$(info warning : could not find hash function to differentiate builds with different flags)
|
||||||
|
HASH_DIR := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_DIR ?= obj/$(HASH_DIR)
|
||||||
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynlib
|
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynlib
|
||||||
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/, $(ZSTD_LOCAL_OBJ))
|
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/, $(ZSTD_LOCAL_OBJ))
|
||||||
ZSTD_STATLIB_DIR := $(BUILD_DIR)/statlib
|
ZSTD_STATLIB_DIR := $(BUILD_DIR)/statlib
|
||||||
@@ -178,7 +201,7 @@ ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/, $(ZSTD_LOCAL_OBJ))
|
|||||||
|
|
||||||
# macOS linker doesn't support -soname, and use different extension
|
# macOS linker doesn't support -soname, and use different extension
|
||||||
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
||||||
ifeq ($(shell uname), Darwin)
|
ifeq ($(UNAME), Darwin)
|
||||||
SHARED_EXT = dylib
|
SHARED_EXT = dylib
|
||||||
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
||||||
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
||||||
@@ -200,14 +223,20 @@ lib-all: all
|
|||||||
|
|
||||||
all: lib
|
all: lib
|
||||||
|
|
||||||
libzstd.a: ARFLAGS = rcs
|
$(ZSTD_STATLIB_DIR)/libzstd.a: ARFLAGS = rcs
|
||||||
libzstd.a: $(ZSTD_STATLIB_OBJ)
|
$(ZSTD_STATLIB_DIR)/libzstd.a: | $(ZSTD_STATLIB_DIR)
|
||||||
|
$(ZSTD_STATLIB_DIR)/libzstd.a: $(ZSTD_STATLIB_OBJ)
|
||||||
@echo compiling static library
|
@echo compiling static library
|
||||||
$(Q)$(AR) $(ARFLAGS) $@ $^
|
$(Q)$(AR) $(ARFLAGS) $@ $^
|
||||||
|
|
||||||
|
.PHONY: libzstd.a # must be run every time
|
||||||
|
libzstd.a: $(ZSTD_STATLIB_DIR)/libzstd.a
|
||||||
|
$(Q)ln -sf $< $@
|
||||||
|
|
||||||
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
||||||
|
|
||||||
LIBZSTD = dll\libzstd.dll
|
LIBZSTD = dll\libzstd.dll
|
||||||
|
$(LIBZSTD):
|
||||||
$(LIBZSTD): $(ZSTD_FILES)
|
$(LIBZSTD): $(ZSTD_FILES)
|
||||||
@echo compiling dynamic library $(LIBVER)
|
@echo compiling dynamic library $(LIBVER)
|
||||||
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll\libzstd.dll.a -shared $^ -o $@
|
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll\libzstd.dll.a -shared $^ -o $@
|
||||||
@@ -215,15 +244,20 @@ $(LIBZSTD): $(ZSTD_FILES)
|
|||||||
else
|
else
|
||||||
|
|
||||||
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
||||||
$(LIBZSTD): CFLAGS += -fPIC
|
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): CFLAGS += -fPIC
|
||||||
$(LIBZSTD): LDFLAGS += -shared -fvisibility=hidden
|
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): LDFLAGS += -shared -fvisibility=hidden
|
||||||
$(LIBZSTD): $(ZSTD_DYNLIB_OBJ)
|
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): | $(ZSTD_DYNLIB_DIR)
|
||||||
|
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): $(ZSTD_DYNLIB_OBJ)
|
||||||
@echo compiling dynamic library $(LIBVER)
|
@echo compiling dynamic library $(LIBVER)
|
||||||
$(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
$(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||||
@echo creating versioned links
|
@echo creating versioned links
|
||||||
$(Q)ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
$(Q)ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
||||||
$(Q)ln -sf $@ libzstd.$(SHARED_EXT)
|
$(Q)ln -sf $@ libzstd.$(SHARED_EXT)
|
||||||
|
|
||||||
|
.PHONY: $(LIBZSTD) # must be run every time
|
||||||
|
$(LIBZSTD): $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
||||||
|
$(Q)ln -sf $< $@
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: libzstd
|
.PHONY: libzstd
|
||||||
@@ -281,14 +315,13 @@ clean:
|
|||||||
$(Q)$(RM) -r *.dSYM # macOS-specific
|
$(Q)$(RM) -r *.dSYM # macOS-specific
|
||||||
$(Q)$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
$(Q)$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
||||||
$(Q)$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
$(Q)$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
||||||
$(Q)$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
|
$(Q)$(RM) -r obj/*
|
||||||
$(Q)$(RM) -r $(ZSTD_STATLIB_DIR)/* $(ZSTD_DYNLIB_DIR)/*
|
|
||||||
@echo Cleaning library completed
|
@echo Cleaning library completed
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# make install is validated only for below listed environments
|
# make install is validated only for below listed environments
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
||||||
|
|
||||||
all: libzstd.pc
|
all: libzstd.pc
|
||||||
|
|
||||||
@@ -324,13 +357,13 @@ $(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(PREFI
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
|
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
||||||
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
||||||
else
|
else
|
||||||
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter $(shell uname),SunOS))
|
ifneq (,$(filter $(UNAME),SunOS))
|
||||||
INSTALL ?= ginstall
|
INSTALL ?= ginstall
|
||||||
else
|
else
|
||||||
INSTALL ?= install
|
INSTALL ?= install
|
||||||
|
|||||||
@@ -168,6 +168,26 @@ file it should be linked with `dll\libzstd.dll`. For example:
|
|||||||
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
||||||
|
|
||||||
|
|
||||||
|
#### Advanced Build options
|
||||||
|
|
||||||
|
The build system requires a hash function in order to
|
||||||
|
separate object files created with different compilation flags.
|
||||||
|
By default, it tries to use `md5sum` or equivalent.
|
||||||
|
The hash function can be manually switched by setting the `HASH` variable.
|
||||||
|
For example : `make HASH=xxhsum`
|
||||||
|
The hash function needs to generate at least 64-bit using hexadecimal format.
|
||||||
|
When no hash function is found,
|
||||||
|
the Makefile just generates all object files into the same default directory,
|
||||||
|
irrespective of compilation flags.
|
||||||
|
This functionality only matters if `libzstd` is compiled multiple times
|
||||||
|
with different build flags.
|
||||||
|
|
||||||
|
The build directory, where object files are stored
|
||||||
|
can also be manually controlled using variable `BUILD_DIR`,
|
||||||
|
for example `make BUILD_DIR=objectDir/v1`.
|
||||||
|
In which case, the hash function doesn't matter.
|
||||||
|
|
||||||
|
|
||||||
#### Deprecated API
|
#### Deprecated API
|
||||||
|
|
||||||
Obsolete API on their way out are stored in directory `lib/deprecated`.
|
Obsolete API on their way out are stored in directory `lib/deprecated`.
|
||||||
|
|||||||
+52
-26
@@ -46,7 +46,8 @@ else
|
|||||||
ALIGN_LOOP =
|
ALIGN_LOOP =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPPFLAGS += -DXXH_NAMESPACE=ZSTD_
|
DEBUGLEVEL ?= 0
|
||||||
|
CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -DDEBUGLEVEL=$(DEBUGLEVEL)
|
||||||
ifeq ($(OS),Windows_NT) # MinGW assumed
|
ifeq ($(OS),Windows_NT) # MinGW assumed
|
||||||
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
||||||
endif
|
endif
|
||||||
@@ -65,11 +66,7 @@ ZSTDLIB_DECOMPRESS := $(ZSTDDIR)/decompress
|
|||||||
ZDICT_DIR := $(ZSTDDIR)/dictBuilder
|
ZDICT_DIR := $(ZSTDDIR)/dictBuilder
|
||||||
ZSTDLEGACY_DIR := $(ZSTDDIR)/legacy
|
ZSTDLEGACY_DIR := $(ZSTDDIR)/legacy
|
||||||
|
|
||||||
vpath %.c $(ZSTDLIB_COMMON)
|
vpath %.c $(ZSTDLIB_COMMON) $(ZSTDLIB_COMPRESS) $(ZSTDLIB_DECOMPRESS) $(ZDICT_DIR) $(ZSTDLEGACY_DIR)
|
||||||
vpath %.c $(ZSTDLIB_COMPRESS)
|
|
||||||
vpath %.c $(ZSTDLIB_DECOMPRESS)
|
|
||||||
vpath %.c $(ZDICT_DIR)
|
|
||||||
vpath %.c $(ZSTDLEGACY_DIR)
|
|
||||||
|
|
||||||
ZSTDLIB_COMMON_C := $(wildcard $(ZSTDLIB_COMMON)/*.c)
|
ZSTDLIB_COMMON_C := $(wildcard $(ZSTDLIB_COMMON)/*.c)
|
||||||
ZSTDLIB_COMPRESS_C := $(wildcard $(ZSTDLIB_COMPRESS)/*.c)
|
ZSTDLIB_COMPRESS_C := $(wildcard $(ZSTDLIB_COMPRESS)/*.c)
|
||||||
@@ -94,6 +91,31 @@ ZSTD_CLI_SRC := $(wildcard *.c)
|
|||||||
ZSTD_CLI_OBJ := $(ZSTD_CLI_SRC:.c=.o)
|
ZSTD_CLI_OBJ := $(ZSTD_CLI_SRC:.c=.o)
|
||||||
|
|
||||||
ZSTD_ALL_SRC := $(ZSTDLIB_LOCAL_SRC) $(ZSTD_CLI_SRC)
|
ZSTD_ALL_SRC := $(ZSTDLIB_LOCAL_SRC) $(ZSTD_CLI_SRC)
|
||||||
|
ZSTD_ALL_OBJ := $(ZSTD_ALL_SRC:.c=.o)
|
||||||
|
|
||||||
|
UNAME := $(shell uname)
|
||||||
|
ifeq ($(UNAME), Darwin)
|
||||||
|
HASH ?= md5
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME), FreeBSD)
|
||||||
|
HASH ?= gmd5sum
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME), OpenBSD)
|
||||||
|
HASH ?= md5
|
||||||
|
endif
|
||||||
|
HASH ?= md5sum
|
||||||
|
|
||||||
|
HAVE_HASH := $(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
||||||
|
ifeq ($(HAVE_HASH), 1)
|
||||||
|
HASH_VALUE := $(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) | $(HASH) | head -c 16)
|
||||||
|
HASH_DIR := conf_$(HASH_VALUE)
|
||||||
|
else
|
||||||
|
$(info warning : could not find hash function to differentiate builds with different flags)
|
||||||
|
HASH_DIR := 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
BUILD_DIR ?= obj/$(HASH_DIR)
|
||||||
|
ZSTD_OBJ := $(addprefix $(BUILD_DIR)/, $(ZSTD_ALL_OBJ))
|
||||||
|
|
||||||
# Define *.exe as extension for Windows systems
|
# Define *.exe as extension for Windows systems
|
||||||
ifneq (,$(filter Windows%,$(OS)))
|
ifneq (,$(filter Windows%,$(OS)))
|
||||||
@@ -180,18 +202,23 @@ all: zstd
|
|||||||
.PHONY: allVariants
|
.PHONY: allVariants
|
||||||
allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy zstd-dictBuilder
|
allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy zstd-dictBuilder
|
||||||
|
|
||||||
|
$(BUILD_DIR)/zstd : $(ZSTD_OBJ)
|
||||||
|
@echo "$(THREAD_MSG)"
|
||||||
|
@echo "$(ZLIB_MSG)"
|
||||||
|
@echo "$(LZMA_MSG)"
|
||||||
|
@echo "$(LZ4_MSG)"
|
||||||
|
$(Q)$(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS)
|
||||||
|
|
||||||
|
.PHONY: zstd
|
||||||
zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP)
|
zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP)
|
||||||
zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD)
|
zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD)
|
||||||
zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
||||||
ifneq (,$(filter Windows%,$(OS)))
|
ifneq (,$(filter Windows%,$(OS)))
|
||||||
zstd : $(RES_FILE)
|
zstd : $(RES_FILE)
|
||||||
endif
|
endif
|
||||||
zstd : $(ZSTDLIB_LOCAL_OBJ) $(ZSTD_CLI_OBJ)
|
zstd : $(BUILD_DIR)/zstd
|
||||||
@echo "$(THREAD_MSG)"
|
$(Q)ln -sf $< $@
|
||||||
@echo "$(ZLIB_MSG)"
|
@echo zstd build completed
|
||||||
@echo "$(LZMA_MSG)"
|
|
||||||
@echo "$(LZ4_MSG)"
|
|
||||||
$(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS)
|
|
||||||
|
|
||||||
.PHONY: zstd-release
|
.PHONY: zstd-release
|
||||||
zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0
|
zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0
|
||||||
@@ -292,6 +319,7 @@ clean:
|
|||||||
zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) \
|
zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) \
|
||||||
zstd-small$(EXT) zstd-frugal$(EXT) zstd-nolegacy$(EXT) zstd4$(EXT) \
|
zstd-small$(EXT) zstd-frugal$(EXT) zstd-nolegacy$(EXT) zstd4$(EXT) \
|
||||||
zstd-dictBuilder$(EXT) *.gcda default*.profraw default.profdata have_zlib$(EXT)
|
zstd-dictBuilder$(EXT) *.gcda default*.profraw default.profdata have_zlib$(EXT)
|
||||||
|
$(Q)$(RM) -r obj/*
|
||||||
@echo Cleaning completed
|
@echo Cleaning completed
|
||||||
|
|
||||||
MD2ROFF = ronn
|
MD2ROFF = ronn
|
||||||
@@ -324,29 +352,27 @@ preview-man: clean-man man
|
|||||||
|
|
||||||
# Generate .h dependencies automatically
|
# Generate .h dependencies automatically
|
||||||
|
|
||||||
MKDIR = mkdir
|
DEPFLAGS = -MT $@ -MMD -MP -MF
|
||||||
|
|
||||||
DEPDIR := .deps
|
$(BUILD_DIR)/%.o : %.c $(BUILD_DIR)/%.d | $(BUILD_DIR)
|
||||||
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d
|
@echo $@
|
||||||
|
$(Q)$(COMPILE.c) $(DEPFLAGS) $(BUILD_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) -c
|
MKDIR ?= mkdir
|
||||||
|
$(BUILD_DIR): ; $(Q)$(MKDIR) -p $@
|
||||||
|
|
||||||
%.o : %.c
|
DEPFILES := $(ZSTD_OBJ:.o=.d)
|
||||||
%.o : %.c $(DEPDIR)/%.d | $(DEPDIR)
|
|
||||||
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
|
||||||
|
|
||||||
$(DEPDIR): ; $(Q)$(MKDIR) -p $@
|
|
||||||
|
|
||||||
DEPFILES := $(ZSTD_ALL_SRC:%.c=$(DEPDIR)/%.d)
|
|
||||||
$(DEPFILES):
|
$(DEPFILES):
|
||||||
|
|
||||||
include $(wildcard $(DEPFILES))
|
include $(wildcard $(DEPFILES))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
# make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets
|
# make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
UNAME := $(shell uname)
|
||||||
|
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
||||||
|
|
||||||
HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
||||||
EGREP_OPTIONS ?=
|
EGREP_OPTIONS ?=
|
||||||
@@ -389,14 +415,14 @@ datarootdir ?= $(PREFIX)/share
|
|||||||
mandir ?= $(datarootdir)/man
|
mandir ?= $(datarootdir)/man
|
||||||
man1dir ?= $(mandir)/man1
|
man1dir ?= $(mandir)/man1
|
||||||
|
|
||||||
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
ifneq (,$(filter $(UNAME),OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
||||||
MANDIR ?= $(PREFIX)/man
|
MANDIR ?= $(PREFIX)/man
|
||||||
MAN1DIR ?= $(MANDIR)/man1
|
MAN1DIR ?= $(MANDIR)/man1
|
||||||
else
|
else
|
||||||
MAN1DIR ?= $(man1dir)
|
MAN1DIR ?= $(man1dir)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter $(shell uname),SunOS))
|
ifneq (,$(filter $(UNAME),SunOS))
|
||||||
INSTALL ?= ginstall
|
INSTALL ?= ginstall
|
||||||
else
|
else
|
||||||
INSTALL ?= install
|
INSTALL ?= install
|
||||||
|
|||||||
+39
-24
@@ -3,7 +3,7 @@ Command Line Interface for Zstandard library
|
|||||||
|
|
||||||
Command Line Interface (CLI) can be created using the `make` command without any additional parameters.
|
Command Line Interface (CLI) can be created using the `make` command without any additional parameters.
|
||||||
There are however other Makefile targets that create different variations of CLI:
|
There are however other Makefile targets that create different variations of CLI:
|
||||||
- `zstd` : default CLI supporting gzip-like arguments; includes dictionary builder, benchmark, and support for decompression of legacy zstd formats
|
- `zstd` : default CLI supporting gzip-like arguments; includes dictionary builder, benchmark, and supports decompression of legacy zstd formats
|
||||||
- `zstd_nolegacy` : Same as `zstd` but without support for legacy zstd formats
|
- `zstd_nolegacy` : Same as `zstd` but without support for legacy zstd formats
|
||||||
- `zstd-small` : CLI optimized for minimal size; no dictionary builder, no benchmark, and no support for legacy zstd formats
|
- `zstd-small` : CLI optimized for minimal size; no dictionary builder, no benchmark, and no support for legacy zstd formats
|
||||||
- `zstd-compress` : version of CLI which can only compress into zstd format
|
- `zstd-compress` : version of CLI which can only compress into zstd format
|
||||||
@@ -147,76 +147,91 @@ FILE : a filename
|
|||||||
Arguments :
|
Arguments :
|
||||||
-# : # compression level (1-19, default: 3)
|
-# : # compression level (1-19, default: 3)
|
||||||
-d : decompression
|
-d : decompression
|
||||||
-D file: use `file` as Dictionary
|
-D DICT: use DICT as Dictionary for compression or decompression
|
||||||
-o file: result stored into `file` (only if 1 input file)
|
-o file: result stored into `file` (only 1 output file)
|
||||||
-f : overwrite output without prompting and (de)compress links
|
-f : overwrite output without prompting, also (de)compress links
|
||||||
--rm : remove source file(s) after successful de/compression
|
--rm : remove source file(s) after successful de/compression
|
||||||
-k : preserve source file(s) (default)
|
-k : preserve source file(s) (default)
|
||||||
-h/-H : display help/long help and exit
|
-h/-H : display help/long help and exit
|
||||||
|
|
||||||
Advanced arguments :
|
Advanced arguments :
|
||||||
-V : display Version number and exit
|
-V : display Version number and exit
|
||||||
|
-c : force write to standard output, even if it is the console
|
||||||
-v : verbose mode; specify multiple times to increase verbosity
|
-v : verbose mode; specify multiple times to increase verbosity
|
||||||
-q : suppress warnings; specify twice to suppress errors too
|
-q : suppress warnings; specify twice to suppress errors too
|
||||||
-c : force write to standard output, even if it is the console
|
--no-progress : do not display the progress counter
|
||||||
-l : print information about zstd compressed files
|
-r : operate recursively on directories
|
||||||
--exclude-compressed: only compress files that are not previously compressed
|
--filelist FILE : read list of files to operate upon from FILE
|
||||||
|
--output-dir-flat DIR : processed files are stored into DIR
|
||||||
|
--output-dir-mirror DIR : processed files are stored into DIR respecting original directory structure
|
||||||
|
--[no-]check : during compression, add XXH64 integrity checksum to frame (default: enabled). If specified with -d, decompressor will ignore/validate checksums in compressed frame (default: validate).
|
||||||
|
-- : All arguments after "--" are treated as files
|
||||||
|
|
||||||
|
Advanced compression arguments :
|
||||||
--ultra : enable levels beyond 19, up to 22 (requires more memory)
|
--ultra : enable levels beyond 19, up to 22 (requires more memory)
|
||||||
--long[=#]: enable long distance matching with given window log (default: 27)
|
--long[=#]: enable long distance matching with given window log (default: 27)
|
||||||
--fast[=#]: switch to very fast compression levels (default: 1)
|
--fast[=#]: switch to very fast compression levels (default: 1)
|
||||||
--adapt : dynamically adapt compression level to I/O conditions
|
--adapt : dynamically adapt compression level to I/O conditions
|
||||||
--stream-size=# : optimize compression parameters for streaming input of given number of bytes
|
|
||||||
--size-hint=# optimize compression parameters for streaming input of approximately this size
|
|
||||||
--target-compressed-block-size=# : make compressed block near targeted size
|
|
||||||
-T# : spawns # compression threads (default: 1, 0==# cores)
|
-T# : spawns # compression threads (default: 1, 0==# cores)
|
||||||
-B# : select size of each job (default: 0==automatic)
|
-B# : select size of each job (default: 0==automatic)
|
||||||
|
--single-thread : use a single thread for both I/O and compression (result slightly different than -T1)
|
||||||
--rsyncable : compress using a rsync-friendly method (-B sets block size)
|
--rsyncable : compress using a rsync-friendly method (-B sets block size)
|
||||||
--no-dictID : don't write dictID into header (dictionary compression)
|
--exclude-compressed: only compress files that are not already compressed
|
||||||
--[no-]check : integrity check (default: enabled)
|
--stream-size=# : specify size of streaming input from `stdin`
|
||||||
|
--size-hint=# optimize compression parameters for streaming input of approximately this size
|
||||||
|
--target-compressed-block-size=# : generate compressed block of approximately targeted size
|
||||||
|
--no-dictID : don't write dictID into header (dictionary compression only)
|
||||||
--[no-]compress-literals : force (un)compressed literals
|
--[no-]compress-literals : force (un)compressed literals
|
||||||
-r : operate recursively on directories
|
|
||||||
--output-dir-flat[=directory]: all resulting files stored into `directory`.
|
|
||||||
--format=zstd : compress files to the .zst format (default)
|
--format=zstd : compress files to the .zst format (default)
|
||||||
--format=gzip : compress files to the .gz format
|
--format=gzip : compress files to the .gz format
|
||||||
|
--format=xz : compress files to the .xz format
|
||||||
|
--format=lzma : compress files to the .lzma format
|
||||||
|
--format=lz4 : compress files to the .lz4 format
|
||||||
|
|
||||||
|
Advanced decompression arguments :
|
||||||
|
-l : print information about zstd compressed files
|
||||||
--test : test compressed file integrity
|
--test : test compressed file integrity
|
||||||
--[no-]sparse : sparse mode (default: disabled)
|
|
||||||
-M# : Set a memory usage limit for decompression
|
-M# : Set a memory usage limit for decompression
|
||||||
--no-progress : do not display the progress bar
|
--[no-]sparse : sparse mode (default: disabled)
|
||||||
-- : All arguments after "--" are treated as files
|
|
||||||
|
|
||||||
Dictionary builder :
|
Dictionary builder :
|
||||||
--train ## : create a dictionary from a training set of files
|
--train ## : create a dictionary from a training set of files
|
||||||
--train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]] : use the cover algorithm with optional args
|
--train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]] : use the cover algorithm with optional args
|
||||||
--train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]] : use the fast cover algorithm with optional args
|
--train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]] : use the fast cover algorithm with optional args
|
||||||
--train-legacy[=s=#] : use the legacy algorithm with selectivity (default: 9)
|
--train-legacy[=s=#] : use the legacy algorithm with selectivity (default: 9)
|
||||||
-o file : `file` is dictionary name (default: dictionary)
|
-o DICT : DICT is dictionary name (default: dictionary)
|
||||||
--maxdict=# : limit dictionary to specified size (default: 112640)
|
--maxdict=# : limit dictionary to specified size (default: 112640)
|
||||||
--dictID=# : force dictionary ID to specified value (default: random)
|
--dictID=# : force dictionary ID to specified value (default: random)
|
||||||
|
|
||||||
Benchmark arguments :
|
Benchmark arguments :
|
||||||
-b# : benchmark file(s), using # compression level (default: 3)
|
-b# : benchmark file(s), using # compression level (default: 3)
|
||||||
-e# : test all compression levels from -bX to # (default: 1)
|
-e# : test all compression levels successively from -b# to -e# (default: 1)
|
||||||
-i# : minimum evaluation time in seconds (default: 3s)
|
-i# : minimum evaluation time in seconds (default: 3s)
|
||||||
-B# : cut file into independent blocks of size # (default: no block)
|
-B# : cut file into independent blocks of size # (default: no block)
|
||||||
|
-S : output one benchmark result per input file (default: consolidated result)
|
||||||
--priority=rt : set process priority to real-time
|
--priority=rt : set process priority to real-time
|
||||||
```
|
```
|
||||||
|
|
||||||
### Passing parameters through Environment Variables
|
### Passing parameters through Environment Variables
|
||||||
|
There is no "generic" way to pass "any kind of parameter" to `zstd` in a pass-through manner.
|
||||||
|
Using environment variables for this purpose has security implications.
|
||||||
|
Therefore, this avenue is intentionally restricted and only supports `ZSTD_CLEVEL` and `ZSTD_NBTHREADS`.
|
||||||
|
|
||||||
`ZSTD_CLEVEL` can be used to modify the default compression level of `zstd`
|
`ZSTD_CLEVEL` can be used to modify the default compression level of `zstd`
|
||||||
(usually set to `3`) to another value between 1 and 19 (the "normal" range).
|
(usually set to `3`) to another value between 1 and 19 (the "normal" range).
|
||||||
`ZSTD_NBTHREADS` can be used to specify number of threads that `zstd` will use during compression, which by default is `1`.
|
|
||||||
|
`ZSTD_NBTHREADS` can be used to specify a number of threads
|
||||||
|
that `zstd` will use for compression, which by default is `1`.
|
||||||
This functionality only exists when `zstd` is compiled with multithread support.
|
This functionality only exists when `zstd` is compiled with multithread support.
|
||||||
|
`0` means "use as many threads as detected cpu cores on local system".
|
||||||
The max # of threads is capped at: `ZSTDMT_NBWORKERS_MAX==200`.
|
The max # of threads is capped at: `ZSTDMT_NBWORKERS_MAX==200`.
|
||||||
|
|
||||||
This functionality can be useful when `zstd` CLI is invoked in a way that doesn't allow passing arguments.
|
This functionality can be useful when `zstd` CLI is invoked in a way that doesn't allow passing arguments.
|
||||||
One such scenario is `tar --zstd`.
|
One such scenario is `tar --zstd`.
|
||||||
As `ZSTD_CLEVEL` and `ZSTD_NBTHREADS` only replace the default compression level
|
As `ZSTD_CLEVEL` and `ZSTD_NBTHREADS` only replace the default compression level
|
||||||
and number of threads, respectively, they can both be overridden by corresponding command line arguments:
|
and number of threads respectively, they can both be overridden by corresponding command line arguments:
|
||||||
`-#` for compression level and `-T#` for number of threads.
|
`-#` for compression level and `-T#` for number of threads.
|
||||||
|
|
||||||
There is no "generic" way to pass "any kind of parameter" to `zstd` in a pass-through manner.
|
|
||||||
Using environment variables for this purpose has security implications.
|
|
||||||
Therefore, this avenue is intentionally restricted and only supports `ZSTD_CLEVEL` and `ZSTD_NBTHREADS`.
|
|
||||||
|
|
||||||
### Long distance matching mode
|
### Long distance matching mode
|
||||||
The long distance matching mode, enabled with `--long`, is designed to improve
|
The long distance matching mode, enabled with `--long`, is designed to improve
|
||||||
|
|||||||
+9
-8
@@ -94,23 +94,23 @@ allnothread: fullbench fuzzer paramgrill datagen decodecorpus
|
|||||||
# note : broken : requires symbols unavailable from dynamic library
|
# note : broken : requires symbols unavailable from dynamic library
|
||||||
dll: fuzzer-dll zstreamtest-dll
|
dll: fuzzer-dll zstreamtest-dll
|
||||||
|
|
||||||
PHONY: zstd zstd32 zstd-nolegacy # must be phony, only external makefile knows how to build them, or if they need an update
|
PHONY: zstd zstd32 zstd-nolegacy # phony: only external makefile knows how to build or update them
|
||||||
zstd zstd32 zstd-nolegacy:
|
zstd zstd32 zstd-nolegacy:
|
||||||
$(MAKE) -C $(PRGDIR) $@ MOREFLAGS+="$(DEBUGFLAGS)"
|
$(MAKE) -C $(PRGDIR) $@ MOREFLAGS+="$(DEBUGFLAGS)" DEBUGLEVEL=$(DEBUGLEVEL)
|
||||||
|
|
||||||
gzstd:
|
gzstd:
|
||||||
$(MAKE) -C $(PRGDIR) $@ HAVE_ZLIB=1 MOREFLAGS+="$(DEBUGFLAGS)"
|
$(MAKE) -C $(PRGDIR) $@ HAVE_ZLIB=1 MOREFLAGS+="$(DEBUGFLAGS)" DEBUGLEVEL=$(DEBUGLEVEL)
|
||||||
|
|
||||||
.PHONY: libzstd
|
.PHONY: libzstd
|
||||||
libzstd :
|
libzstd :
|
||||||
$(MAKE) -C $(ZSTDDIR) libzstd
|
$(MAKE) -C $(ZSTDDIR) libzstd DEBUGLEVEL=$(DEBUGLEVEL)
|
||||||
|
|
||||||
%-dll : libzstd
|
%-dll : libzstd
|
||||||
%-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd
|
%-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd
|
||||||
|
|
||||||
.PHONY: zstd-staticLib
|
.PHONY: zstd-staticLib
|
||||||
zstd-staticLib :
|
zstd-staticLib :
|
||||||
$(MAKE) -C $(ZSTDDIR) libzstd.a
|
$(MAKE) -C $(ZSTDDIR) libzstd.a DEBUGLEVEL=$(DEBUGLEVEL)
|
||||||
|
|
||||||
zstdm_%.o : $(ZSTDDIR)/common/%.c
|
zstdm_%.o : $(ZSTDDIR)/common/%.c
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
|
||||||
@@ -255,7 +255,8 @@ clean:
|
|||||||
#----------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------
|
||||||
# valgrind tests are validated only for some posix platforms
|
# valgrind tests are validated only for some posix platforms
|
||||||
#----------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------
|
||||||
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
UNAME := $(shell uname)
|
||||||
|
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
||||||
HOST_OS = POSIX
|
HOST_OS = POSIX
|
||||||
|
|
||||||
valgrindTest: VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1
|
valgrindTest: VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1
|
||||||
@@ -275,7 +276,7 @@ valgrindTest: zstd datagen fuzzer fullbench
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifneq (,$(filter MINGW% MSYS%,$(shell uname)))
|
ifneq (,$(filter MINGW% MSYS%,$(UNAME)))
|
||||||
HOST_OS = MSYS
|
HOST_OS = MSYS
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -286,7 +287,7 @@ endif
|
|||||||
ifneq (,$(filter $(HOST_OS),MSYS POSIX))
|
ifneq (,$(filter $(HOST_OS),MSYS POSIX))
|
||||||
|
|
||||||
DIFF:=diff
|
DIFF:=diff
|
||||||
ifneq (,$(filter $(shell uname),SunOS))
|
ifneq (,$(filter $(UNAME),SunOS))
|
||||||
DIFF:=gdiff
|
DIFF:=gdiff
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ mustBeAbsent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# default compilation : all features enabled
|
# default compilation : all features enabled
|
||||||
make clean > /dev/null
|
|
||||||
$ECHO "testing default library compilation"
|
$ECHO "testing default library compilation"
|
||||||
CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID
|
CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID
|
||||||
nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog
|
nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog
|
||||||
|
|||||||
Reference in New Issue
Block a user