extzstd 0.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/HISTORY.ja.md +39 -0
- data/README.md +38 -56
- data/contrib/zstd/CHANGELOG +613 -0
- data/contrib/zstd/CODE_OF_CONDUCT.md +5 -0
- data/contrib/zstd/CONTRIBUTING.md +406 -0
- data/contrib/zstd/COPYING +339 -0
- data/contrib/zstd/Makefile +420 -0
- data/contrib/zstd/README.md +179 -41
- data/contrib/zstd/TESTING.md +44 -0
- data/contrib/zstd/appveyor.yml +292 -0
- data/contrib/zstd/lib/BUCK +234 -0
- data/contrib/zstd/lib/Makefile +451 -0
- data/contrib/zstd/lib/README.md +207 -0
- data/contrib/zstd/{common → lib/common}/bitstream.h +187 -138
- data/contrib/zstd/lib/common/compiler.h +288 -0
- data/contrib/zstd/lib/common/cpu.h +213 -0
- data/contrib/zstd/lib/common/debug.c +24 -0
- data/contrib/zstd/lib/common/debug.h +107 -0
- data/contrib/zstd/lib/common/entropy_common.c +362 -0
- data/contrib/zstd/{common → lib/common}/error_private.c +25 -12
- data/contrib/zstd/{common → lib/common}/error_private.h +14 -10
- data/contrib/zstd/{common → lib/common}/fse.h +173 -92
- data/contrib/zstd/{common → lib/common}/fse_decompress.c +149 -85
- data/contrib/zstd/lib/common/huf.h +361 -0
- data/contrib/zstd/{common → lib/common}/mem.h +115 -59
- data/contrib/zstd/lib/common/pool.c +350 -0
- data/contrib/zstd/lib/common/pool.h +84 -0
- data/contrib/zstd/lib/common/threading.c +122 -0
- data/contrib/zstd/lib/common/threading.h +155 -0
- data/contrib/zstd/{common → lib/common}/xxhash.c +55 -96
- data/contrib/zstd/{common → lib/common}/xxhash.h +23 -47
- data/contrib/zstd/lib/common/zstd_common.c +83 -0
- data/contrib/zstd/lib/common/zstd_deps.h +111 -0
- data/contrib/zstd/lib/common/zstd_errors.h +95 -0
- data/contrib/zstd/lib/common/zstd_internal.h +478 -0
- data/contrib/zstd/{compress → lib/compress}/fse_compress.c +214 -319
- data/contrib/zstd/lib/compress/hist.c +181 -0
- data/contrib/zstd/lib/compress/hist.h +75 -0
- data/contrib/zstd/lib/compress/huf_compress.c +913 -0
- data/contrib/zstd/lib/compress/zstd_compress.c +5208 -0
- data/contrib/zstd/lib/compress/zstd_compress_internal.h +1203 -0
- data/contrib/zstd/lib/compress/zstd_compress_literals.c +158 -0
- data/contrib/zstd/lib/compress/zstd_compress_literals.h +29 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.c +433 -0
- data/contrib/zstd/lib/compress/zstd_compress_sequences.h +54 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.c +849 -0
- data/contrib/zstd/lib/compress/zstd_compress_superblock.h +32 -0
- data/contrib/zstd/lib/compress/zstd_cwksp.h +561 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.c +521 -0
- data/contrib/zstd/lib/compress/zstd_double_fast.h +38 -0
- data/contrib/zstd/lib/compress/zstd_fast.c +496 -0
- data/contrib/zstd/lib/compress/zstd_fast.h +37 -0
- data/contrib/zstd/lib/compress/zstd_lazy.c +1412 -0
- data/contrib/zstd/lib/compress/zstd_lazy.h +87 -0
- data/contrib/zstd/lib/compress/zstd_ldm.c +660 -0
- data/contrib/zstd/lib/compress/zstd_ldm.h +116 -0
- data/contrib/zstd/lib/compress/zstd_opt.c +1345 -0
- data/contrib/zstd/lib/compress/zstd_opt.h +56 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.c +1811 -0
- data/contrib/zstd/lib/compress/zstdmt_compress.h +110 -0
- data/contrib/zstd/lib/decompress/huf_decompress.c +1350 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.c +244 -0
- data/contrib/zstd/lib/decompress/zstd_ddict.h +44 -0
- data/contrib/zstd/lib/decompress/zstd_decompress.c +1930 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1540 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_block.h +62 -0
- data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +190 -0
- data/contrib/zstd/{common → lib/deprecated}/zbuff.h +68 -45
- data/contrib/zstd/lib/deprecated/zbuff_common.c +26 -0
- data/contrib/zstd/lib/deprecated/zbuff_compress.c +147 -0
- data/contrib/zstd/lib/deprecated/zbuff_decompress.c +75 -0
- data/contrib/zstd/lib/dictBuilder/cover.c +1245 -0
- data/contrib/zstd/lib/dictBuilder/cover.h +157 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.c +3 -3
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/divsufsort.h +0 -0
- data/contrib/zstd/lib/dictBuilder/fastcover.c +758 -0
- data/contrib/zstd/{dictBuilder → lib/dictBuilder}/zdict.c +318 -194
- data/contrib/zstd/lib/dictBuilder/zdict.h +305 -0
- data/contrib/zstd/{legacy → lib/legacy}/zstd_legacy.h +171 -15
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.c +191 -124
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v01.h +19 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.c +125 -125
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v02.h +19 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.c +125 -124
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v03.h +20 -6
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.c +151 -299
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v04.h +19 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.c +237 -243
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v05.h +19 -6
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.c +130 -143
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v06.h +18 -5
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.c +158 -157
- data/contrib/zstd/{legacy → lib/legacy}/zstd_v07.h +19 -5
- data/contrib/zstd/lib/libzstd.pc.in +15 -0
- data/contrib/zstd/lib/zstd.h +2391 -0
- data/ext/depend +2 -0
- data/ext/extconf.rb +15 -6
- data/ext/extzstd.c +76 -145
- data/ext/extzstd.h +80 -31
- data/ext/extzstd_stream.c +417 -142
- data/ext/libzstd_conf.h +8 -0
- data/ext/zstd_common.c +10 -7
- data/ext/zstd_compress.c +14 -5
- data/ext/zstd_decompress.c +5 -4
- data/ext/zstd_dictbuilder.c +9 -4
- data/ext/zstd_dictbuilder_fastcover.c +3 -0
- data/ext/zstd_legacy_v01.c +3 -1
- data/ext/zstd_legacy_v02.c +3 -1
- data/ext/zstd_legacy_v03.c +3 -1
- data/ext/zstd_legacy_v04.c +3 -1
- data/ext/zstd_legacy_v05.c +3 -1
- data/ext/zstd_legacy_v06.c +3 -1
- data/ext/zstd_legacy_v07.c +3 -1
- data/gemstub.rb +10 -24
- data/lib/extzstd.rb +64 -179
- data/lib/extzstd/version.rb +6 -1
- data/test/test_basic.rb +9 -6
- metadata +113 -57
- data/HISTORY.ja +0 -5
- data/contrib/zstd/common/entropy_common.c +0 -225
- data/contrib/zstd/common/huf.h +0 -228
- data/contrib/zstd/common/zstd_common.c +0 -83
- data/contrib/zstd/common/zstd_errors.h +0 -60
- data/contrib/zstd/common/zstd_internal.h +0 -267
- data/contrib/zstd/compress/huf_compress.c +0 -533
- data/contrib/zstd/compress/zbuff_compress.c +0 -319
- data/contrib/zstd/compress/zstd_compress.c +0 -3264
- data/contrib/zstd/compress/zstd_opt.h +0 -900
- data/contrib/zstd/decompress/huf_decompress.c +0 -883
- data/contrib/zstd/decompress/zbuff_decompress.c +0 -252
- data/contrib/zstd/decompress/zstd_decompress.c +0 -1842
- data/contrib/zstd/dictBuilder/zdict.h +0 -111
- data/contrib/zstd/zstd.h +0 -640
@@ -0,0 +1,451 @@
|
|
1
|
+
# ################################################################
|
2
|
+
# Copyright (c) 2015-2020, Yann Collet, Facebook, Inc.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This source code is licensed under both the BSD-style license (found in the
|
6
|
+
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
+
# in the COPYING file in the root directory of this source tree).
|
8
|
+
# You may select, at your option, one of the above-listed licenses.
|
9
|
+
# ################################################################
|
10
|
+
|
11
|
+
.PHONY: default
|
12
|
+
default: lib-release
|
13
|
+
|
14
|
+
# define silent mode as default (verbose mode with V=1 or VERBOSE=1)
|
15
|
+
$(V)$(VERBOSE).SILENT:
|
16
|
+
|
17
|
+
# When cross-compiling from linux to windows,
|
18
|
+
# one might need to specify TARGET_SYSTEM as "Windows."
|
19
|
+
# Building from Fedora fails without it.
|
20
|
+
# (but Ubuntu and Debian don't need to set anything)
|
21
|
+
TARGET_SYSTEM ?= $(OS)
|
22
|
+
|
23
|
+
# Version numbers
|
24
|
+
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
25
|
+
LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
26
|
+
LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
27
|
+
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
|
28
|
+
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
29
|
+
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
30
|
+
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
31
|
+
LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
32
|
+
VERSION?= $(LIBVER)
|
33
|
+
CCVER := $(shell $(CC) --version)
|
34
|
+
|
35
|
+
# ZSTD_LIB_MINIFY is a helper variable that
|
36
|
+
# configures a bunch of other variables to space-optimized defaults.
|
37
|
+
ZSTD_LIB_MINIFY ?= 0
|
38
|
+
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
39
|
+
HAVE_CC_OZ ?= $(shell echo "" | $(CC) -Oz -x c -c - -o /dev/null 2> /dev/null && echo 1 || echo 0)
|
40
|
+
ZSTD_LEGACY_SUPPORT ?= 0
|
41
|
+
ZSTD_LIB_DEPRECATED ?= 0
|
42
|
+
HUF_FORCE_DECOMPRESS_X1 ?= 1
|
43
|
+
ZSTD_FORCE_DECOMPRESS_SHORT ?= 1
|
44
|
+
ZSTD_NO_INLINE ?= 1
|
45
|
+
ZSTD_STRIP_ERROR_STRINGS ?= 1
|
46
|
+
ifneq ($(HAVE_CC_OZ), 0)
|
47
|
+
# Some compilers (clang) support an even more space-optimized setting.
|
48
|
+
CFLAGS += -Oz
|
49
|
+
else
|
50
|
+
CFLAGS += -Os
|
51
|
+
endif
|
52
|
+
CFLAGS += -fno-stack-protector -fomit-frame-pointer -fno-ident \
|
53
|
+
-DDYNAMIC_BMI2=0 -DNDEBUG
|
54
|
+
else
|
55
|
+
CFLAGS += -O3
|
56
|
+
endif
|
57
|
+
|
58
|
+
DEBUGLEVEL ?= 0
|
59
|
+
CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -DDEBUGLEVEL=$(DEBUGLEVEL)
|
60
|
+
ifeq ($(TARGET_SYSTEM),Windows_NT) # MinGW assumed
|
61
|
+
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
62
|
+
endif
|
63
|
+
DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
64
|
+
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
65
|
+
-Wstrict-prototypes -Wundef -Wpointer-arith \
|
66
|
+
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
67
|
+
-Wredundant-decls -Wmissing-prototypes -Wc++-compat
|
68
|
+
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
69
|
+
FLAGS = $(CPPFLAGS) $(CFLAGS)
|
70
|
+
|
71
|
+
HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
72
|
+
GREP_OPTIONS ?=
|
73
|
+
ifeq ($HAVE_COLORNEVER, 1)
|
74
|
+
GREP_OPTIONS += --color=never
|
75
|
+
endif
|
76
|
+
GREP = grep $(GREP_OPTIONS)
|
77
|
+
SED_ERE_OPT ?= -E
|
78
|
+
|
79
|
+
ZSTDCOMMON_FILES := $(sort $(wildcard common/*.c))
|
80
|
+
ZSTDCOMP_FILES := $(sort $(wildcard compress/*.c))
|
81
|
+
ZSTDDECOMP_FILES := $(sort $(wildcard decompress/*.c))
|
82
|
+
ZDICT_FILES := $(sort $(wildcard dictBuilder/*.c))
|
83
|
+
ZDEPR_FILES := $(sort $(wildcard deprecated/*.c))
|
84
|
+
ZSTD_FILES := $(ZSTDCOMMON_FILES)
|
85
|
+
|
86
|
+
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
87
|
+
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
88
|
+
endif
|
89
|
+
|
90
|
+
# Modules
|
91
|
+
ZSTD_LIB_COMPRESSION ?= 1
|
92
|
+
ZSTD_LIB_DECOMPRESSION ?= 1
|
93
|
+
ZSTD_LIB_DICTBUILDER ?= 1
|
94
|
+
ZSTD_LIB_DEPRECATED ?= 1
|
95
|
+
|
96
|
+
# Legacy support
|
97
|
+
ZSTD_LEGACY_SUPPORT ?= 5
|
98
|
+
ZSTD_LEGACY_MULTITHREADED_API ?= 0
|
99
|
+
|
100
|
+
# Build size optimizations
|
101
|
+
HUF_FORCE_DECOMPRESS_X1 ?= 0
|
102
|
+
HUF_FORCE_DECOMPRESS_X2 ?= 0
|
103
|
+
ZSTD_FORCE_DECOMPRESS_SHORT ?= 0
|
104
|
+
ZSTD_FORCE_DECOMPRESS_LONG ?= 0
|
105
|
+
ZSTD_NO_INLINE ?= 0
|
106
|
+
ZSTD_STRIP_ERROR_STRINGS ?= 0
|
107
|
+
|
108
|
+
ifeq ($(ZSTD_LIB_COMPRESSION), 0)
|
109
|
+
ZSTD_LIB_DICTBUILDER = 0
|
110
|
+
ZSTD_LIB_DEPRECATED = 0
|
111
|
+
endif
|
112
|
+
|
113
|
+
ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
114
|
+
ZSTD_LEGACY_SUPPORT = 0
|
115
|
+
ZSTD_LIB_DEPRECATED = 0
|
116
|
+
endif
|
117
|
+
|
118
|
+
ifneq ($(ZSTD_LIB_COMPRESSION), 0)
|
119
|
+
ZSTD_FILES += $(ZSTDCOMP_FILES)
|
120
|
+
endif
|
121
|
+
|
122
|
+
ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
123
|
+
ZSTD_FILES += $(ZSTDDECOMP_FILES)
|
124
|
+
endif
|
125
|
+
|
126
|
+
ifneq ($(ZSTD_LIB_DEPRECATED), 0)
|
127
|
+
ZSTD_FILES += $(ZDEPR_FILES)
|
128
|
+
endif
|
129
|
+
|
130
|
+
ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
|
131
|
+
ZSTD_FILES += $(ZDICT_FILES)
|
132
|
+
endif
|
133
|
+
|
134
|
+
ifneq ($(HUF_FORCE_DECOMPRESS_X1), 0)
|
135
|
+
CFLAGS += -DHUF_FORCE_DECOMPRESS_X1
|
136
|
+
endif
|
137
|
+
|
138
|
+
ifneq ($(HUF_FORCE_DECOMPRESS_X2), 0)
|
139
|
+
CFLAGS += -DHUF_FORCE_DECOMPRESS_X2
|
140
|
+
endif
|
141
|
+
|
142
|
+
ifneq ($(ZSTD_FORCE_DECOMPRESS_SHORT), 0)
|
143
|
+
CFLAGS += -DZSTD_FORCE_DECOMPRESS_SHORT
|
144
|
+
endif
|
145
|
+
|
146
|
+
ifneq ($(ZSTD_FORCE_DECOMPRESS_LONG), 0)
|
147
|
+
CFLAGS += -DZSTD_FORCE_DECOMPRESS_LONG
|
148
|
+
endif
|
149
|
+
|
150
|
+
ifneq ($(ZSTD_NO_INLINE), 0)
|
151
|
+
CFLAGS += -DZSTD_NO_INLINE
|
152
|
+
endif
|
153
|
+
|
154
|
+
ifneq ($(ZSTD_STRIP_ERROR_STRINGS), 0)
|
155
|
+
CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
|
156
|
+
endif
|
157
|
+
|
158
|
+
ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
|
159
|
+
CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
|
160
|
+
endif
|
161
|
+
|
162
|
+
ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
|
163
|
+
ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
|
164
|
+
ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
|
165
|
+
endif
|
166
|
+
endif
|
167
|
+
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
168
|
+
|
169
|
+
ZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES))
|
170
|
+
ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_SRC:.c=.o)
|
171
|
+
|
172
|
+
ZSTD_SUBDIR := common compress decompress dictBuilder legacy deprecated
|
173
|
+
vpath %.c $(ZSTD_SUBDIR)
|
174
|
+
|
175
|
+
UNAME := $(shell uname)
|
176
|
+
|
177
|
+
ifndef BUILD_DIR
|
178
|
+
ifeq ($(UNAME), Darwin)
|
179
|
+
HASH ?= md5
|
180
|
+
else ifeq ($(UNAME), FreeBSD)
|
181
|
+
HASH ?= gmd5sum
|
182
|
+
else ifeq ($(UNAME), OpenBSD)
|
183
|
+
HASH ?= md5
|
184
|
+
endif
|
185
|
+
HASH ?= md5sum
|
186
|
+
|
187
|
+
HASH_DIR = conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | cut -f 1 -d " " )
|
188
|
+
HAVE_HASH :=$(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
189
|
+
ifeq ($(HAVE_HASH),0)
|
190
|
+
$(info warning : could not find HASH ($(HASH)), needed to differentiate builds using different flags)
|
191
|
+
BUILD_DIR := obj/generic_noconf
|
192
|
+
endif
|
193
|
+
endif # BUILD_DIR
|
194
|
+
|
195
|
+
|
196
|
+
# macOS linker doesn't support -soname, and use different extension
|
197
|
+
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
198
|
+
ifeq ($(UNAME), Darwin)
|
199
|
+
SHARED_EXT = dylib
|
200
|
+
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
201
|
+
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
202
|
+
SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
|
203
|
+
else
|
204
|
+
SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
|
205
|
+
SHARED_EXT = so
|
206
|
+
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
|
207
|
+
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
|
208
|
+
endif
|
209
|
+
|
210
|
+
SET_CACHE_DIRECTORY = \
|
211
|
+
$(MAKE) --no-print-directory $@ \
|
212
|
+
BUILD_DIR=obj/$(HASH_DIR) \
|
213
|
+
CPPFLAGS="$(CPPFLAGS)" \
|
214
|
+
CFLAGS="$(CFLAGS)" \
|
215
|
+
LDFLAGS="$(LDFLAGS)"
|
216
|
+
|
217
|
+
|
218
|
+
.PHONY: lib-all all clean install uninstall
|
219
|
+
|
220
|
+
# alias
|
221
|
+
lib-all: all
|
222
|
+
|
223
|
+
all: lib
|
224
|
+
|
225
|
+
.PHONY: libzstd.a # must be run every time
|
226
|
+
|
227
|
+
ifndef BUILD_DIR
|
228
|
+
# determine BUILD_DIR from compilation flags
|
229
|
+
|
230
|
+
libzstd.a:
|
231
|
+
$(SET_CACHE_DIRECTORY)
|
232
|
+
|
233
|
+
else
|
234
|
+
# BUILD_DIR is defined
|
235
|
+
|
236
|
+
ZSTD_STATLIB_DIR := $(BUILD_DIR)/static
|
237
|
+
ZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a
|
238
|
+
ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
239
|
+
$(ZSTD_STATLIB): ARFLAGS = rcs
|
240
|
+
$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR)
|
241
|
+
$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ)
|
242
|
+
@echo compiling static library
|
243
|
+
$(AR) $(ARFLAGS) $@ $^
|
244
|
+
|
245
|
+
libzstd.a: $(ZSTD_STATLIB)
|
246
|
+
cp -f $< $@
|
247
|
+
|
248
|
+
endif
|
249
|
+
|
250
|
+
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
251
|
+
|
252
|
+
LIBZSTD = dll/libzstd.dll
|
253
|
+
$(LIBZSTD): $(ZSTD_FILES)
|
254
|
+
@echo compiling dynamic library $(LIBVER)
|
255
|
+
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@
|
256
|
+
|
257
|
+
else # not Windows
|
258
|
+
|
259
|
+
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
260
|
+
.PHONY: $(LIBZSTD) # must be run every time
|
261
|
+
$(LIBZSTD): CFLAGS += -fPIC
|
262
|
+
$(LIBZSTD): LDFLAGS += -shared -fvisibility=hidden
|
263
|
+
|
264
|
+
ifndef BUILD_DIR
|
265
|
+
# determine BUILD_DIR from compilation flags
|
266
|
+
|
267
|
+
$(LIBZSTD):
|
268
|
+
$(SET_CACHE_DIRECTORY)
|
269
|
+
|
270
|
+
else
|
271
|
+
# BUILD_DIR is defined
|
272
|
+
|
273
|
+
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic
|
274
|
+
ZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
275
|
+
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
276
|
+
|
277
|
+
$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR)
|
278
|
+
$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ)
|
279
|
+
@echo compiling dynamic library $(LIBVER)
|
280
|
+
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
281
|
+
@echo creating versioned links
|
282
|
+
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
283
|
+
ln -sf $@ libzstd.$(SHARED_EXT)
|
284
|
+
|
285
|
+
$(LIBZSTD): $(ZSTD_DYNLIB)
|
286
|
+
cp -f $< $@
|
287
|
+
|
288
|
+
endif # ifndef BUILD_DIR
|
289
|
+
endif # if windows
|
290
|
+
|
291
|
+
.PHONY: libzstd
|
292
|
+
libzstd : $(LIBZSTD)
|
293
|
+
|
294
|
+
.PHONY: lib
|
295
|
+
lib : libzstd.a libzstd
|
296
|
+
|
297
|
+
|
298
|
+
# note : do not define lib-mt or lib-release as .PHONY
|
299
|
+
# make does not consider implicit pattern rule for .PHONY target
|
300
|
+
|
301
|
+
%-mt : CPPFLAGS += -DZSTD_MULTITHREAD
|
302
|
+
%-mt : LDFLAGS += -pthread
|
303
|
+
%-mt : %
|
304
|
+
@echo multi-threading build completed
|
305
|
+
|
306
|
+
%-release : DEBUGFLAGS :=
|
307
|
+
%-release : %
|
308
|
+
@echo release build completed
|
309
|
+
|
310
|
+
|
311
|
+
# Generate .h dependencies automatically
|
312
|
+
|
313
|
+
DEPFLAGS = -MT $@ -MMD -MP -MF
|
314
|
+
|
315
|
+
$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR)
|
316
|
+
@echo CC $@
|
317
|
+
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
318
|
+
|
319
|
+
$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
|
320
|
+
@echo CC $@
|
321
|
+
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
322
|
+
|
323
|
+
MKDIR ?= mkdir
|
324
|
+
$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
325
|
+
$(MKDIR) -p $@
|
326
|
+
|
327
|
+
DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d)
|
328
|
+
$(DEPFILES):
|
329
|
+
|
330
|
+
include $(wildcard $(DEPFILES))
|
331
|
+
|
332
|
+
|
333
|
+
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
334
|
+
ZSTDMT_FILES = compress/zstdmt_compress.c
|
335
|
+
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
336
|
+
libzstd-nomt: LDFLAGS += -shared -fPIC -fvisibility=hidden
|
337
|
+
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
338
|
+
@echo compiling single-thread dynamic library $(LIBVER)
|
339
|
+
@echo files : $(ZSTD_NOMT_FILES)
|
340
|
+
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
341
|
+
|
342
|
+
clean:
|
343
|
+
$(RM) -r *.dSYM # macOS-specific
|
344
|
+
$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
345
|
+
$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
346
|
+
$(RM) -r obj/*
|
347
|
+
@echo Cleaning library completed
|
348
|
+
|
349
|
+
#-----------------------------------------------------------------------------
|
350
|
+
# make install is validated only for below listed environments
|
351
|
+
#-----------------------------------------------------------------------------
|
352
|
+
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
353
|
+
|
354
|
+
all: libzstd.pc
|
355
|
+
|
356
|
+
HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,)
|
357
|
+
|
358
|
+
DESTDIR ?=
|
359
|
+
# directory variables : GNU conventions prefer lowercase
|
360
|
+
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
|
361
|
+
# support both lower and uppercase (BSD), use uppercase in script
|
362
|
+
prefix ?= /usr/local
|
363
|
+
PREFIX ?= $(prefix)
|
364
|
+
exec_prefix ?= $(PREFIX)
|
365
|
+
EXEC_PREFIX ?= $(exec_prefix)
|
366
|
+
libdir ?= $(EXEC_PREFIX)/lib
|
367
|
+
LIBDIR ?= $(libdir)
|
368
|
+
includedir ?= $(PREFIX)/include
|
369
|
+
INCLUDEDIR ?= $(includedir)
|
370
|
+
|
371
|
+
PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
|
372
|
+
PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
|
373
|
+
|
374
|
+
# If we successfully stripped off a prefix, we'll add a reference to the
|
375
|
+
# relevant pc variable.
|
376
|
+
PCINCPREFIX := $(if $(findstring $(INCLUDEDIR),$(PCINCDIR)),,$${prefix})
|
377
|
+
PCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix})
|
378
|
+
|
379
|
+
# If no explicit EXEC_PREFIX was set by the caller, write it out as a reference
|
380
|
+
# to PREFIX, rather than as a resolved value.
|
381
|
+
PCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix})
|
382
|
+
|
383
|
+
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
384
|
+
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
385
|
+
else
|
386
|
+
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
387
|
+
endif
|
388
|
+
|
389
|
+
ifneq (,$(filter $(UNAME),SunOS))
|
390
|
+
INSTALL ?= ginstall
|
391
|
+
else
|
392
|
+
INSTALL ?= install
|
393
|
+
endif
|
394
|
+
|
395
|
+
INSTALL_PROGRAM ?= $(INSTALL)
|
396
|
+
INSTALL_DATA ?= $(INSTALL) -m 644
|
397
|
+
|
398
|
+
|
399
|
+
libzstd.pc:
|
400
|
+
libzstd.pc: libzstd.pc.in
|
401
|
+
@echo creating pkgconfig
|
402
|
+
@sed $(SED_ERE_OPT) \
|
403
|
+
-e 's|@PREFIX@|$(PREFIX)|' \
|
404
|
+
-e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
|
405
|
+
-e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
|
406
|
+
-e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
|
407
|
+
-e 's|@VERSION@|$(VERSION)|' \
|
408
|
+
$< >$@
|
409
|
+
|
410
|
+
install: install-pc install-static install-shared install-includes
|
411
|
+
@echo zstd static and shared library installed
|
412
|
+
|
413
|
+
install-pc: libzstd.pc
|
414
|
+
[ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
415
|
+
$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
416
|
+
|
417
|
+
install-static:
|
418
|
+
# only generate libzstd.a if it's not already present
|
419
|
+
[ -e libzstd.a ] || $(MAKE) libzstd.a-release
|
420
|
+
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
421
|
+
@echo Installing static library
|
422
|
+
$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
423
|
+
|
424
|
+
install-shared:
|
425
|
+
# only generate libzstd.so if it's not already present
|
426
|
+
[ -e $(LIBZSTD) ] || $(MAKE) libzstd-release
|
427
|
+
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
428
|
+
@echo Installing shared library
|
429
|
+
$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
|
430
|
+
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
431
|
+
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
432
|
+
|
433
|
+
install-includes:
|
434
|
+
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
435
|
+
@echo Installing includes
|
436
|
+
$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
437
|
+
$(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
438
|
+
$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
|
439
|
+
|
440
|
+
uninstall:
|
441
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
|
442
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
443
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
444
|
+
$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
|
445
|
+
$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
|
446
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
|
447
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
|
448
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
449
|
+
@echo zstd libraries successfully uninstalled
|
450
|
+
|
451
|
+
endif
|
@@ -0,0 +1,207 @@
|
|
1
|
+
Zstandard library files
|
2
|
+
================================
|
3
|
+
|
4
|
+
The __lib__ directory is split into several sub-directories,
|
5
|
+
in order to make it easier to select or exclude features.
|
6
|
+
|
7
|
+
|
8
|
+
#### Building
|
9
|
+
|
10
|
+
`Makefile` script is provided, supporting [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions),
|
11
|
+
including commands variables, staged install, directory variables and standard targets.
|
12
|
+
- `make` : generates both static and dynamic libraries
|
13
|
+
- `make install` : install libraries and headers in target system directories
|
14
|
+
|
15
|
+
`libzstd` default scope is pretty large, including compression, decompression, dictionary builder,
|
16
|
+
and support for decoding legacy formats >= v0.5.0.
|
17
|
+
The scope can be reduced on demand (see paragraph _modular build_).
|
18
|
+
|
19
|
+
|
20
|
+
#### Multithreading support
|
21
|
+
|
22
|
+
Multithreading is disabled by default when building with `make`.
|
23
|
+
Enabling multithreading requires 2 conditions :
|
24
|
+
- set build macro `ZSTD_MULTITHREAD` (`-DZSTD_MULTITHREAD` for `gcc`)
|
25
|
+
- for POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
|
26
|
+
|
27
|
+
Both conditions are automatically applied when invoking `make lib-mt` target.
|
28
|
+
|
29
|
+
When linking a POSIX program with a multithreaded version of `libzstd`,
|
30
|
+
note that it's necessary to invoke the `-pthread` flag during link stage.
|
31
|
+
|
32
|
+
Multithreading capabilities are exposed
|
33
|
+
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
|
34
|
+
|
35
|
+
|
36
|
+
#### API
|
37
|
+
|
38
|
+
Zstandard's stable API is exposed within [lib/zstd.h](zstd.h).
|
39
|
+
|
40
|
+
|
41
|
+
#### Advanced API
|
42
|
+
|
43
|
+
Optional advanced features are exposed via :
|
44
|
+
|
45
|
+
- `lib/common/zstd_errors.h` : translates `size_t` function results
|
46
|
+
into a `ZSTD_ErrorCode`, for accurate error handling.
|
47
|
+
|
48
|
+
- `ZSTD_STATIC_LINKING_ONLY` : if this macro is defined _before_ including `zstd.h`,
|
49
|
+
it unlocks access to the experimental API,
|
50
|
+
exposed in the second part of `zstd.h`.
|
51
|
+
All definitions in the experimental APIs are unstable,
|
52
|
+
they may still change in the future, or even be removed.
|
53
|
+
As a consequence, experimental definitions shall ___never be used with dynamic library___ !
|
54
|
+
Only static linking is allowed.
|
55
|
+
|
56
|
+
|
57
|
+
#### Modular build
|
58
|
+
|
59
|
+
It's possible to compile only a limited set of features within `libzstd`.
|
60
|
+
The file structure is designed to make this selection manually achievable for any build system :
|
61
|
+
|
62
|
+
- Directory `lib/common` is always required, for all variants.
|
63
|
+
|
64
|
+
- Compression source code lies in `lib/compress`
|
65
|
+
|
66
|
+
- Decompression source code lies in `lib/decompress`
|
67
|
+
|
68
|
+
- It's possible to include only `compress` or only `decompress`, they don't depend on each other.
|
69
|
+
|
70
|
+
- `lib/dictBuilder` : makes it possible to generate dictionaries from a set of samples.
|
71
|
+
The API is exposed in `lib/dictBuilder/zdict.h`.
|
72
|
+
This module depends on both `lib/common` and `lib/compress` .
|
73
|
+
|
74
|
+
- `lib/legacy` : makes it possible to decompress legacy zstd formats, starting from `v0.1.0`.
|
75
|
+
This module depends on `lib/common` and `lib/decompress`.
|
76
|
+
To enable this feature, define `ZSTD_LEGACY_SUPPORT` during compilation.
|
77
|
+
Specifying a number limits versions supported to that version onward.
|
78
|
+
For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats >= v0.2.0".
|
79
|
+
Conversely, `ZSTD_LEGACY_SUPPORT=0` means "do __not__ support legacy formats".
|
80
|
+
By default, this build macro is set as `ZSTD_LEGACY_SUPPORT=5`.
|
81
|
+
Decoding supported legacy format is a transparent capability triggered within decompression functions.
|
82
|
+
It's also allowed to invoke legacy API directly, exposed in `lib/legacy/zstd_legacy.h`.
|
83
|
+
Each version does also provide its own set of advanced API.
|
84
|
+
For example, advanced API for version `v0.4` is exposed in `lib/legacy/zstd_v04.h` .
|
85
|
+
|
86
|
+
- While invoking `make libzstd`, it's possible to define build macros
|
87
|
+
`ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
|
88
|
+
and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
|
89
|
+
corresponding features. This will also disable compilation of all
|
90
|
+
dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
|
91
|
+
dictBuilder).
|
92
|
+
|
93
|
+
- There are a number of options that can help minimize the binary size of
|
94
|
+
`libzstd`.
|
95
|
+
|
96
|
+
The first step is to select the components needed (using the above-described
|
97
|
+
`ZSTD_LIB_COMPRESSION` etc.).
|
98
|
+
|
99
|
+
The next step is to set `ZSTD_LIB_MINIFY` to `1` when invoking `make`. This
|
100
|
+
disables various optional components and changes the compilation flags to
|
101
|
+
prioritize space-saving.
|
102
|
+
|
103
|
+
Detailed options: Zstandard's code and build environment is set up by default
|
104
|
+
to optimize above all else for performance. In pursuit of this goal, Zstandard
|
105
|
+
makes significant trade-offs in code size. For example, Zstandard often has
|
106
|
+
more than one implementation of a particular component, with each
|
107
|
+
implementation optimized for different scenarios. For example, the Huffman
|
108
|
+
decoder has complementary implementations that decode the stream one symbol at
|
109
|
+
a time or two symbols at a time. Zstd normally includes both (and dispatches
|
110
|
+
between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1` or
|
111
|
+
`HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
|
112
|
+
compilation of the other. Similarly, `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`
|
113
|
+
and `ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG` force the compilation and use of
|
114
|
+
only one or the other of two decompression implementations. The smallest
|
115
|
+
binary is achieved by using `HUF_FORCE_DECOMPRESS_X1` and
|
116
|
+
`ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT` (implied by `ZSTD_LIB_MINIFY`).
|
117
|
+
|
118
|
+
For squeezing the last ounce of size out, you can also define
|
119
|
+
`ZSTD_NO_INLINE`, which disables inlining, and `ZSTD_STRIP_ERROR_STRINGS`,
|
120
|
+
which removes the error messages that are otherwise returned by
|
121
|
+
`ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
|
122
|
+
|
123
|
+
Finally, when integrating into your application, make sure you're doing link-
|
124
|
+
time optimation and unused symbol garbage collection (via some combination of,
|
125
|
+
e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
|
126
|
+
`-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
|
127
|
+
`-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
|
128
|
+
the compiler's intermediate representation, e.g., `AR=gcc-ar`). Consult your
|
129
|
+
compiler's documentation.
|
130
|
+
|
131
|
+
- While invoking `make libzstd`, the build macro `ZSTD_LEGACY_MULTITHREADED_API=1`
|
132
|
+
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
|
133
|
+
the shared library, which is now hidden by default.
|
134
|
+
|
135
|
+
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
|
136
|
+
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
|
137
|
+
These instructions contribute to better performance, notably on the decoder side.
|
138
|
+
By default, this feature is automatically enabled on detecting
|
139
|
+
the right instruction set (x64) and compiler (clang or gcc >= 5).
|
140
|
+
It's obviously disabled for different cpus,
|
141
|
+
or when BMI2 instruction set is _required_ by the compiler command line
|
142
|
+
(in this case, only the BMI2 code path is generated).
|
143
|
+
Setting this macro will either force to generate the BMI2 dispatcher (1)
|
144
|
+
or prevent it (0). It overrides automatic detection.
|
145
|
+
|
146
|
+
- The build macro `ZSTD_NO_UNUSED_FUNCTIONS` can be defined to hide the definitions of functions
|
147
|
+
that zstd does not use. Not all unused functions are hidden, but they can be if needed.
|
148
|
+
Currently, this macro will hide function definitions in FSE and HUF that use an excessive
|
149
|
+
amount of stack space.
|
150
|
+
|
151
|
+
- The build macro `ZSTD_NO_INTRINSICS` can be defined to disable all explicit intrinsics.
|
152
|
+
Compiler builtins are still used.
|
153
|
+
|
154
|
+
|
155
|
+
#### Windows : using MinGW+MSYS to create DLL
|
156
|
+
|
157
|
+
DLL can be created using MinGW+MSYS with the `make libzstd` command.
|
158
|
+
This command creates `dll\libzstd.dll` and the import library `dll\libzstd.lib`.
|
159
|
+
The import library is only required with Visual C++.
|
160
|
+
The header file `zstd.h` and the dynamic library `dll\libzstd.dll` are required to
|
161
|
+
compile a project using gcc/MinGW.
|
162
|
+
The dynamic library has to be added to linking options.
|
163
|
+
It means that if a project that uses ZSTD consists of a single `test-dll.c`
|
164
|
+
file it should be linked with `dll\libzstd.dll`. For example:
|
165
|
+
```
|
166
|
+
gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\libzstd.dll
|
167
|
+
```
|
168
|
+
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
169
|
+
|
170
|
+
|
171
|
+
#### Advanced Build options
|
172
|
+
|
173
|
+
The build system requires a hash function in order to
|
174
|
+
separate object files created with different compilation flags.
|
175
|
+
By default, it tries to use `md5sum` or equivalent.
|
176
|
+
The hash function can be manually switched by setting the `HASH` variable.
|
177
|
+
For example : `make HASH=xxhsum`
|
178
|
+
The hash function needs to generate at least 64-bit using hexadecimal format.
|
179
|
+
When no hash function is found,
|
180
|
+
the Makefile just generates all object files into the same default directory,
|
181
|
+
irrespective of compilation flags.
|
182
|
+
This functionality only matters if `libzstd` is compiled multiple times
|
183
|
+
with different build flags.
|
184
|
+
|
185
|
+
The build directory, where object files are stored
|
186
|
+
can also be manually controlled using variable `BUILD_DIR`,
|
187
|
+
for example `make BUILD_DIR=objectDir/v1`.
|
188
|
+
In which case, the hash function doesn't matter.
|
189
|
+
|
190
|
+
|
191
|
+
#### Deprecated API
|
192
|
+
|
193
|
+
Obsolete API on their way out are stored in directory `lib/deprecated`.
|
194
|
+
At this stage, it contains older streaming prototypes, in `lib/deprecated/zbuff.h`.
|
195
|
+
These prototypes will be removed in some future version.
|
196
|
+
Consider migrating code towards supported streaming API exposed in `zstd.h`.
|
197
|
+
|
198
|
+
|
199
|
+
#### Miscellaneous
|
200
|
+
|
201
|
+
The other files are not source code. There are :
|
202
|
+
|
203
|
+
- `BUCK` : support for `buck` build system (https://buckbuild.com/)
|
204
|
+
- `Makefile` : `make` script to build and install zstd library (static and dynamic)
|
205
|
+
- `README.md` : this file
|
206
|
+
- `dll/` : resources directory for Windows compilation
|
207
|
+
- `libzstd.pc.in` : script for `pkg-config` (used in `make install`)
|