zstd-ruby 1.4.1.0 → 1.5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/ruby.yml +35 -0
- data/README.md +2 -2
- data/ext/zstdruby/libzstd/BUCK +5 -7
- data/ext/zstdruby/libzstd/Makefile +304 -113
- data/ext/zstdruby/libzstd/README.md +83 -20
- data/ext/zstdruby/libzstd/common/bitstream.h +59 -51
- data/ext/zstdruby/libzstd/common/compiler.h +150 -8
- data/ext/zstdruby/libzstd/common/cpu.h +1 -3
- data/ext/zstdruby/libzstd/common/debug.c +11 -31
- data/ext/zstdruby/libzstd/common/debug.h +22 -49
- data/ext/zstdruby/libzstd/common/entropy_common.c +201 -75
- data/ext/zstdruby/libzstd/common/error_private.c +3 -1
- data/ext/zstdruby/libzstd/common/error_private.h +8 -4
- data/ext/zstdruby/libzstd/common/fse.h +50 -42
- data/ext/zstdruby/libzstd/common/fse_decompress.c +149 -55
- data/ext/zstdruby/libzstd/common/huf.h +43 -39
- data/ext/zstdruby/libzstd/common/mem.h +69 -25
- data/ext/zstdruby/libzstd/common/pool.c +30 -20
- data/ext/zstdruby/libzstd/common/pool.h +3 -3
- data/ext/zstdruby/libzstd/common/threading.c +51 -4
- data/ext/zstdruby/libzstd/common/threading.h +36 -4
- data/ext/zstdruby/libzstd/common/xxhash.c +40 -92
- data/ext/zstdruby/libzstd/common/xxhash.h +12 -32
- data/ext/zstdruby/libzstd/common/zstd_common.c +10 -10
- data/ext/zstdruby/libzstd/common/zstd_deps.h +111 -0
- data/ext/zstdruby/libzstd/common/zstd_internal.h +230 -111
- data/ext/zstdruby/libzstd/common/zstd_trace.h +154 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +47 -63
- data/ext/zstdruby/libzstd/compress/hist.c +41 -63
- data/ext/zstdruby/libzstd/compress/hist.h +13 -33
- data/ext/zstdruby/libzstd/compress/huf_compress.c +332 -193
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +3614 -1696
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +546 -86
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +158 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +29 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +441 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +54 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +572 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +662 -0
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +43 -41
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +2 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +85 -80
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +2 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +1184 -111
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +59 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +333 -208
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +15 -3
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +103 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +228 -129
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +151 -440
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +32 -114
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +395 -276
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +20 -16
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +3 -3
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +630 -231
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +606 -380
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +8 -5
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +39 -9
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +9 -8
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +2 -2
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +55 -46
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +20 -9
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +43 -31
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +53 -30
- data/ext/zstdruby/libzstd/dll/example/Makefile +2 -1
- data/ext/zstdruby/libzstd/dll/example/README.md +16 -22
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +4 -4
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +24 -14
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +17 -8
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +17 -8
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +25 -11
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +43 -32
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +2 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +27 -19
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +32 -20
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +1 -1
- data/ext/zstdruby/libzstd/libzstd.pc.in +2 -1
- data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +201 -31
- data/ext/zstdruby/libzstd/zstd.h +740 -153
- data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +3 -1
- data/lib/zstd-ruby/version.rb +1 -1
- data/zstd-ruby.gemspec +1 -1
- metadata +21 -10
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32e9b82b8d17f82c2e75104bbac8b5a63a510d1e46af93d31b103534cf947e40
|
4
|
+
data.tar.gz: 264b1409dd10bc7ba8436576a1de143116b2d4616a24d58e66bb7e1ccd024b98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 736aaee9390871b6dfb7a03254c2c3cf86ccb2e2f46936cc147e4b3772438591f11a589e6f38fbd52c24214007a9d2293ddb9fe987dba84912608af802f179f9
|
7
|
+
data.tar.gz: a9c3846d7ae00794301da5dce514b2f6ef90cea9a3cc293659a4d7f1bc54de82973ad90c86a388967eddb6466449cccacc5094f170b21870ffeb0208329c393d
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on: [push, pull_request]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
ruby-version: ['2.5', '2.6', '2.7', '3.0']
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
- name: Set up Ruby
|
23
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
24
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
25
|
+
# uses: ruby/setup-ruby@v1
|
26
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby-version }}
|
29
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
30
|
+
- name: Install dependencies
|
31
|
+
run: bundle install
|
32
|
+
- name: Compile
|
33
|
+
run: bundle exec rake compile
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rspec
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/zstd-ruby.svg)](https://badge.fury.io/rb/zstd-ruby)
|
2
|
-
|
2
|
+
![Build Status](https://github.com/SpringMT/zstd-ruby/actions/workflows/ruby.yml/badge.svg?branch=master)
|
3
3
|
|
4
4
|
# zstd-ruby
|
5
5
|
|
@@ -10,7 +10,7 @@ See https://github.com/facebook/zstd
|
|
10
10
|
Fork from https://github.com/jarredholman/ruby-zstd.
|
11
11
|
|
12
12
|
## Zstd version
|
13
|
-
v1.
|
13
|
+
v1.5.0 (https://github.com/facebook/zstd/tree/v1.5.0)
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
data/ext/zstdruby/libzstd/BUCK
CHANGED
@@ -65,9 +65,7 @@ cxx_library(
|
|
65
65
|
name='zdict',
|
66
66
|
header_namespace='',
|
67
67
|
visibility=['PUBLIC'],
|
68
|
-
exported_headers=
|
69
|
-
('dictBuilder', 'zdict.h'),
|
70
|
-
]),
|
68
|
+
exported_headers=['zdict.h'],
|
71
69
|
headers=subdir_glob([
|
72
70
|
('dictBuilder', 'divsufsort.h'),
|
73
71
|
('dictBuilder', 'cover.h'),
|
@@ -131,10 +129,10 @@ cxx_library(
|
|
131
129
|
name='errors',
|
132
130
|
header_namespace='',
|
133
131
|
visibility=['PUBLIC'],
|
134
|
-
exported_headers=
|
135
|
-
|
136
|
-
|
137
|
-
]
|
132
|
+
exported_headers=[
|
133
|
+
'zstd_errors.h',
|
134
|
+
'common/error_private.h',
|
135
|
+
]
|
138
136
|
srcs=['common/error_private.c'],
|
139
137
|
)
|
140
138
|
|
@@ -1,12 +1,28 @@
|
|
1
1
|
# ################################################################
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) Yann Collet, Facebook, Inc.
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# This source code is licensed under both the BSD-style license (found in the
|
6
6
|
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
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.
|
8
9
|
# ################################################################
|
9
10
|
|
11
|
+
# Note: by default, the static library is built single-threaded and dynamic library is built
|
12
|
+
# multi-threaded. It is possible to force multi or single threaded builds by appending
|
13
|
+
# -mt or -nomt to the build target (like lib-mt for multi-threaded, lib-nomt for single-threaded).
|
14
|
+
.PHONY: default
|
15
|
+
default: lib-release
|
16
|
+
|
17
|
+
# define silent mode as default (verbose mode with V=1 or VERBOSE=1)
|
18
|
+
$(V)$(VERBOSE).SILENT:
|
19
|
+
|
20
|
+
# When cross-compiling from linux to windows,
|
21
|
+
# one might need to specify TARGET_SYSTEM as "Windows."
|
22
|
+
# Building from Fedora fails without it.
|
23
|
+
# (but Ubuntu and Debian don't need to set anything)
|
24
|
+
TARGET_SYSTEM ?= $(OS)
|
25
|
+
|
10
26
|
# Version numbers
|
11
27
|
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
12
28
|
LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
@@ -19,25 +35,53 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
|
19
35
|
VERSION?= $(LIBVER)
|
20
36
|
CCVER := $(shell $(CC) --version)
|
21
37
|
|
22
|
-
|
23
|
-
|
24
|
-
|
38
|
+
# ZSTD_LIB_MINIFY is a helper variable that
|
39
|
+
# configures a bunch of other variables to space-optimized defaults.
|
40
|
+
ZSTD_LIB_MINIFY ?= 0
|
41
|
+
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
42
|
+
HAVE_CC_OZ ?= $(shell echo "" | $(CC) -Oz -x c -c - -o /dev/null 2> /dev/null && echo 1 || echo 0)
|
43
|
+
ZSTD_LEGACY_SUPPORT ?= 0
|
44
|
+
ZSTD_LIB_DEPRECATED ?= 0
|
45
|
+
HUF_FORCE_DECOMPRESS_X1 ?= 1
|
46
|
+
ZSTD_FORCE_DECOMPRESS_SHORT ?= 1
|
47
|
+
ZSTD_NO_INLINE ?= 1
|
48
|
+
ZSTD_STRIP_ERROR_STRINGS ?= 1
|
49
|
+
ifneq ($(HAVE_CC_OZ), 0)
|
50
|
+
# Some compilers (clang) support an even more space-optimized setting.
|
51
|
+
CFLAGS += -Oz
|
52
|
+
else
|
53
|
+
CFLAGS += -Os
|
54
|
+
endif
|
55
|
+
CFLAGS += -fno-stack-protector -fomit-frame-pointer -fno-ident \
|
56
|
+
-DDYNAMIC_BMI2=0 -DNDEBUG
|
57
|
+
else
|
58
|
+
CFLAGS += -O3
|
59
|
+
endif
|
60
|
+
|
61
|
+
DEBUGLEVEL ?= 0
|
62
|
+
CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ -DDEBUGLEVEL=$(DEBUGLEVEL)
|
63
|
+
ifeq ($(TARGET_SYSTEM),Windows_NT) # MinGW assumed
|
64
|
+
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
25
65
|
endif
|
26
|
-
CFLAGS ?= -O3
|
27
66
|
DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
28
67
|
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
29
68
|
-Wstrict-prototypes -Wundef -Wpointer-arith \
|
30
69
|
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
31
70
|
-Wredundant-decls -Wmissing-prototypes -Wc++-compat
|
32
|
-
CFLAGS
|
33
|
-
FLAGS
|
71
|
+
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
72
|
+
FLAGS = $(CPPFLAGS) $(CFLAGS)
|
73
|
+
|
74
|
+
CPPFLAGS_DYNLIB = -DZSTD_MULTITHREAD # dynamic library build defaults to multi-threaded
|
75
|
+
LDFLAGS_DYNLIB = -pthread
|
76
|
+
CPPFLAGS_STATLIB = # static library build defaults to single-threaded
|
34
77
|
|
35
78
|
HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
36
79
|
GREP_OPTIONS ?=
|
37
80
|
ifeq ($HAVE_COLORNEVER, 1)
|
38
|
-
GREP_OPTIONS += --color=never
|
81
|
+
GREP_OPTIONS += --color=never
|
39
82
|
endif
|
40
83
|
GREP = grep $(GREP_OPTIONS)
|
84
|
+
SED_ERE_OPT ?= -E
|
41
85
|
|
42
86
|
ZSTDCOMMON_FILES := $(sort $(wildcard common/*.c))
|
43
87
|
ZSTDCOMP_FILES := $(sort $(wildcard compress/*.c))
|
@@ -47,170 +91,294 @@ ZDEPR_FILES := $(sort $(wildcard deprecated/*.c))
|
|
47
91
|
ZSTD_FILES := $(ZSTDCOMMON_FILES)
|
48
92
|
|
49
93
|
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
50
|
-
decompress/zstd_decompress_block.o :
|
94
|
+
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
51
95
|
endif
|
52
96
|
|
53
|
-
|
97
|
+
# Modules
|
54
98
|
ZSTD_LIB_COMPRESSION ?= 1
|
55
99
|
ZSTD_LIB_DECOMPRESSION ?= 1
|
56
100
|
ZSTD_LIB_DICTBUILDER ?= 1
|
57
|
-
ZSTD_LIB_DEPRECATED ?=
|
101
|
+
ZSTD_LIB_DEPRECATED ?= 0
|
102
|
+
|
103
|
+
# Legacy support
|
104
|
+
ZSTD_LEGACY_SUPPORT ?= 5
|
105
|
+
ZSTD_LEGACY_MULTITHREADED_API ?= 0
|
106
|
+
|
107
|
+
# Build size optimizations
|
58
108
|
HUF_FORCE_DECOMPRESS_X1 ?= 0
|
59
109
|
HUF_FORCE_DECOMPRESS_X2 ?= 0
|
60
110
|
ZSTD_FORCE_DECOMPRESS_SHORT ?= 0
|
61
111
|
ZSTD_FORCE_DECOMPRESS_LONG ?= 0
|
62
112
|
ZSTD_NO_INLINE ?= 0
|
63
113
|
ZSTD_STRIP_ERROR_STRINGS ?= 0
|
64
|
-
ZSTD_LEGACY_MULTITHREADED_API ?= 0
|
65
114
|
|
66
115
|
ifeq ($(ZSTD_LIB_COMPRESSION), 0)
|
67
|
-
|
68
|
-
|
116
|
+
ZSTD_LIB_DICTBUILDER = 0
|
117
|
+
ZSTD_LIB_DEPRECATED = 0
|
69
118
|
endif
|
70
119
|
|
71
120
|
ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
72
|
-
|
73
|
-
|
121
|
+
ZSTD_LEGACY_SUPPORT = 0
|
122
|
+
ZSTD_LIB_DEPRECATED = 0
|
74
123
|
endif
|
75
124
|
|
76
125
|
ifneq ($(ZSTD_LIB_COMPRESSION), 0)
|
77
|
-
|
126
|
+
ZSTD_FILES += $(ZSTDCOMP_FILES)
|
78
127
|
endif
|
79
128
|
|
80
129
|
ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
81
|
-
|
130
|
+
ZSTD_FILES += $(ZSTDDECOMP_FILES)
|
82
131
|
endif
|
83
132
|
|
84
133
|
ifneq ($(ZSTD_LIB_DEPRECATED), 0)
|
85
|
-
|
134
|
+
ZSTD_FILES += $(ZDEPR_FILES)
|
86
135
|
endif
|
87
136
|
|
88
137
|
ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
|
89
|
-
|
138
|
+
ZSTD_FILES += $(ZDICT_FILES)
|
90
139
|
endif
|
91
140
|
|
92
141
|
ifneq ($(HUF_FORCE_DECOMPRESS_X1), 0)
|
93
|
-
|
142
|
+
CFLAGS += -DHUF_FORCE_DECOMPRESS_X1
|
94
143
|
endif
|
95
144
|
|
96
145
|
ifneq ($(HUF_FORCE_DECOMPRESS_X2), 0)
|
97
|
-
|
146
|
+
CFLAGS += -DHUF_FORCE_DECOMPRESS_X2
|
98
147
|
endif
|
99
148
|
|
100
149
|
ifneq ($(ZSTD_FORCE_DECOMPRESS_SHORT), 0)
|
101
|
-
|
150
|
+
CFLAGS += -DZSTD_FORCE_DECOMPRESS_SHORT
|
102
151
|
endif
|
103
152
|
|
104
153
|
ifneq ($(ZSTD_FORCE_DECOMPRESS_LONG), 0)
|
105
|
-
|
154
|
+
CFLAGS += -DZSTD_FORCE_DECOMPRESS_LONG
|
106
155
|
endif
|
107
156
|
|
108
157
|
ifneq ($(ZSTD_NO_INLINE), 0)
|
109
|
-
|
158
|
+
CFLAGS += -DZSTD_NO_INLINE
|
110
159
|
endif
|
111
160
|
|
112
161
|
ifneq ($(ZSTD_STRIP_ERROR_STRINGS), 0)
|
113
|
-
|
162
|
+
CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
|
114
163
|
endif
|
115
164
|
|
116
165
|
ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
|
117
|
-
|
166
|
+
CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
|
118
167
|
endif
|
119
168
|
|
120
169
|
ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
|
121
170
|
ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
|
122
|
-
|
171
|
+
ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
|
123
172
|
endif
|
124
|
-
CPPFLAGS += -I./legacy
|
125
173
|
endif
|
126
174
|
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
127
175
|
|
128
|
-
|
176
|
+
ZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES))
|
177
|
+
ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_SRC:.c=.o)
|
178
|
+
|
179
|
+
ZSTD_SUBDIR := common compress decompress dictBuilder legacy deprecated
|
180
|
+
vpath %.c $(ZSTD_SUBDIR)
|
181
|
+
|
182
|
+
UNAME := $(shell uname)
|
183
|
+
|
184
|
+
ifndef BUILD_DIR
|
185
|
+
ifeq ($(UNAME), Darwin)
|
186
|
+
ifeq ($(shell md5 < /dev/null > /dev/null; echo $$?), 0)
|
187
|
+
HASH ?= md5
|
188
|
+
endif
|
189
|
+
else ifeq ($(UNAME), FreeBSD)
|
190
|
+
HASH ?= gmd5sum
|
191
|
+
else ifeq ($(UNAME), NetBSD)
|
192
|
+
HASH ?= md5 -n
|
193
|
+
else ifeq ($(UNAME), OpenBSD)
|
194
|
+
HASH ?= md5
|
195
|
+
endif
|
196
|
+
HASH ?= md5sum
|
197
|
+
|
198
|
+
HASH_DIR = conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | cut -f 1 -d " " )
|
199
|
+
HAVE_HASH :=$(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
200
|
+
ifeq ($(HAVE_HASH),0)
|
201
|
+
$(info warning : could not find HASH ($(HASH)), needed to differentiate builds using different flags)
|
202
|
+
BUILD_DIR := obj/generic_noconf
|
203
|
+
endif
|
204
|
+
endif # BUILD_DIR
|
205
|
+
|
129
206
|
|
130
207
|
# macOS linker doesn't support -soname, and use different extension
|
131
208
|
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
132
|
-
ifeq ($(
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
209
|
+
ifeq ($(UNAME), Darwin)
|
210
|
+
SHARED_EXT = dylib
|
211
|
+
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
212
|
+
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
213
|
+
SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
|
137
214
|
else
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
215
|
+
SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
|
216
|
+
SHARED_EXT = so
|
217
|
+
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
|
218
|
+
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
|
142
219
|
endif
|
143
220
|
|
221
|
+
SET_CACHE_DIRECTORY = \
|
222
|
+
+$(MAKE) --no-print-directory $@ \
|
223
|
+
BUILD_DIR=obj/$(HASH_DIR) \
|
224
|
+
CPPFLAGS="$(CPPFLAGS)" \
|
225
|
+
CFLAGS="$(CFLAGS)" \
|
226
|
+
LDFLAGS="$(LDFLAGS)"
|
144
227
|
|
145
|
-
.PHONY: default all clean install uninstall
|
146
|
-
|
147
|
-
default: lib-release
|
148
228
|
|
229
|
+
.PHONY: all
|
149
230
|
all: lib
|
150
231
|
|
151
|
-
libzstd.a: ARFLAGS = rcs
|
152
|
-
libzstd.a: $(ZSTD_OBJ)
|
153
|
-
@echo compiling static library
|
154
|
-
@$(AR) $(ARFLAGS) $@ $^
|
155
232
|
|
156
|
-
libzstd.a
|
157
|
-
libzstd.a
|
233
|
+
.PHONY: libzstd.a # must be run every time
|
234
|
+
libzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB)
|
158
235
|
|
159
|
-
|
236
|
+
ifndef BUILD_DIR
|
237
|
+
# determine BUILD_DIR from compilation flags
|
160
238
|
|
161
|
-
|
162
|
-
$(
|
163
|
-
@echo compiling dynamic library $(LIBVER)
|
164
|
-
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll\libzstd.lib -shared $^ -o $@
|
239
|
+
libzstd.a:
|
240
|
+
$(SET_CACHE_DIRECTORY)
|
165
241
|
|
166
242
|
else
|
243
|
+
# BUILD_DIR is defined
|
244
|
+
|
245
|
+
ZSTD_STATLIB_DIR := $(BUILD_DIR)/static
|
246
|
+
ZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a
|
247
|
+
ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
248
|
+
$(ZSTD_STATLIB): ARFLAGS = rcs
|
249
|
+
$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR)
|
250
|
+
$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ)
|
251
|
+
# Check for multithread flag at target execution time
|
252
|
+
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
253
|
+
@echo compiling multi-threaded static library $(LIBVER),\
|
254
|
+
@echo compiling single-threaded static library $(LIBVER))
|
255
|
+
$(AR) $(ARFLAGS) $@ $^
|
256
|
+
|
257
|
+
libzstd.a: $(ZSTD_STATLIB)
|
258
|
+
cp -f $< $@
|
167
259
|
|
168
|
-
|
169
|
-
|
260
|
+
endif
|
261
|
+
|
262
|
+
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
263
|
+
|
264
|
+
LIBZSTD = dll/libzstd.dll
|
170
265
|
$(LIBZSTD): $(ZSTD_FILES)
|
171
266
|
@echo compiling dynamic library $(LIBVER)
|
172
|
-
|
267
|
+
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@
|
268
|
+
|
269
|
+
else # not Windows
|
270
|
+
|
271
|
+
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
272
|
+
.PHONY: $(LIBZSTD) # must be run every time
|
273
|
+
$(LIBZSTD): CPPFLAGS += $(CPPFLAGS_DYNLIB)
|
274
|
+
$(LIBZSTD): CFLAGS += -fPIC -fvisibility=hidden
|
275
|
+
$(LIBZSTD): LDFLAGS += -shared $(LDFLAGS_DYNLIB)
|
276
|
+
|
277
|
+
ifndef BUILD_DIR
|
278
|
+
# determine BUILD_DIR from compilation flags
|
279
|
+
|
280
|
+
$(LIBZSTD):
|
281
|
+
$(SET_CACHE_DIRECTORY)
|
282
|
+
|
283
|
+
else
|
284
|
+
# BUILD_DIR is defined
|
285
|
+
|
286
|
+
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic
|
287
|
+
ZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
288
|
+
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
289
|
+
|
290
|
+
$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR)
|
291
|
+
$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ)
|
292
|
+
# Check for multithread flag at target execution time
|
293
|
+
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
294
|
+
@echo compiling multi-threaded dynamic library $(LIBVER),\
|
295
|
+
@echo compiling single-threaded dynamic library $(LIBVER))
|
296
|
+
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
173
297
|
@echo creating versioned links
|
174
|
-
|
175
|
-
|
298
|
+
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
299
|
+
ln -sf $@ libzstd.$(SHARED_EXT)
|
176
300
|
|
177
|
-
|
301
|
+
$(LIBZSTD): $(ZSTD_DYNLIB)
|
302
|
+
cp -f $< $@
|
178
303
|
|
304
|
+
endif # ifndef BUILD_DIR
|
305
|
+
endif # if windows
|
179
306
|
|
307
|
+
.PHONY: libzstd
|
180
308
|
libzstd : $(LIBZSTD)
|
181
309
|
|
182
|
-
|
183
|
-
|
310
|
+
.PHONY: lib
|
311
|
+
lib : libzstd.a libzstd
|
312
|
+
|
313
|
+
|
314
|
+
# note : do not define lib-mt or lib-release as .PHONY
|
315
|
+
# make does not consider implicit pattern rule for .PHONY target
|
316
|
+
|
317
|
+
%-mt : CPPFLAGS_DYNLIB := -DZSTD_MULTITHREAD
|
318
|
+
%-mt : CPPFLAGS_STATLIB := -DZSTD_MULTITHREAD
|
319
|
+
%-mt : LDFLAGS_DYNLIB := -pthread
|
320
|
+
%-mt : %
|
321
|
+
@echo multi-threaded build completed
|
322
|
+
|
323
|
+
%-nomt : CPPFLAGS_DYNLIB :=
|
324
|
+
%-nomt : LDFLAGS_DYNLIB :=
|
325
|
+
%-nomt : CPPFLAGS_STATLIB :=
|
326
|
+
%-nomt : %
|
327
|
+
@echo single-threaded build completed
|
328
|
+
|
329
|
+
%-release : DEBUGFLAGS :=
|
330
|
+
%-release : %
|
331
|
+
@echo release build completed
|
184
332
|
|
185
|
-
lib: libzstd.a libzstd
|
186
333
|
|
187
|
-
|
188
|
-
|
334
|
+
# Generate .h dependencies automatically
|
335
|
+
|
336
|
+
DEPFLAGS = -MT $@ -MMD -MP -MF
|
337
|
+
|
338
|
+
$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR)
|
339
|
+
@echo CC $@
|
340
|
+
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
341
|
+
|
342
|
+
$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
|
343
|
+
@echo CC $@
|
344
|
+
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
345
|
+
|
346
|
+
MKDIR ?= mkdir
|
347
|
+
$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
348
|
+
$(MKDIR) -p $@
|
349
|
+
|
350
|
+
DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d)
|
351
|
+
$(DEPFILES):
|
352
|
+
|
353
|
+
include $(wildcard $(DEPFILES))
|
189
354
|
|
190
|
-
lib-release lib-release-mt: DEBUGFLAGS :=
|
191
|
-
lib-release: lib
|
192
|
-
lib-release-mt: lib-mt
|
193
355
|
|
194
356
|
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
195
357
|
ZSTDMT_FILES = compress/zstdmt_compress.c
|
196
358
|
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
197
|
-
libzstd-nomt:
|
359
|
+
libzstd-nomt: CFLAGS += -fPIC -fvisibility=hidden
|
360
|
+
libzstd-nomt: LDFLAGS += -shared
|
198
361
|
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
199
362
|
@echo compiling single-thread dynamic library $(LIBVER)
|
200
363
|
@echo files : $(ZSTD_NOMT_FILES)
|
201
|
-
|
364
|
+
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
202
365
|
|
366
|
+
.PHONY: clean
|
203
367
|
clean:
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
368
|
+
$(RM) -r *.dSYM # macOS-specific
|
369
|
+
$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
370
|
+
$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
371
|
+
$(RM) -r obj/*
|
208
372
|
@echo Cleaning library completed
|
209
373
|
|
210
374
|
#-----------------------------------------------------------------------------
|
211
|
-
# make install is validated only for
|
375
|
+
# make install is validated only for below listed environments
|
212
376
|
#-----------------------------------------------------------------------------
|
213
|
-
ifneq (,$(filter $(
|
377
|
+
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
378
|
+
|
379
|
+
all: libzstd.pc
|
380
|
+
|
381
|
+
HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,)
|
214
382
|
|
215
383
|
DESTDIR ?=
|
216
384
|
# directory variables : GNU conventions prefer lowercase
|
@@ -219,21 +387,34 @@ DESTDIR ?=
|
|
219
387
|
prefix ?= /usr/local
|
220
388
|
PREFIX ?= $(prefix)
|
221
389
|
exec_prefix ?= $(PREFIX)
|
222
|
-
|
390
|
+
EXEC_PREFIX ?= $(exec_prefix)
|
391
|
+
libdir ?= $(EXEC_PREFIX)/lib
|
223
392
|
LIBDIR ?= $(libdir)
|
224
393
|
includedir ?= $(PREFIX)/include
|
225
394
|
INCLUDEDIR ?= $(includedir)
|
226
395
|
|
227
|
-
|
228
|
-
|
396
|
+
PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
|
397
|
+
PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
|
398
|
+
|
399
|
+
# If we successfully stripped off a prefix, we'll add a reference to the
|
400
|
+
# relevant pc variable.
|
401
|
+
PCINCPREFIX := $(if $(findstring $(INCLUDEDIR),$(PCINCDIR)),,$${prefix})
|
402
|
+
PCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix})
|
403
|
+
|
404
|
+
# If no explicit EXEC_PREFIX was set by the caller, write it out as a reference
|
405
|
+
# to PREFIX, rather than as a resolved value.
|
406
|
+
PCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix})
|
407
|
+
|
408
|
+
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
409
|
+
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
229
410
|
else
|
230
|
-
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
411
|
+
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
231
412
|
endif
|
232
413
|
|
233
|
-
ifneq (,$(filter $(
|
234
|
-
INSTALL ?= ginstall
|
414
|
+
ifneq (,$(filter $(UNAME),SunOS))
|
415
|
+
INSTALL ?= ginstall
|
235
416
|
else
|
236
|
-
INSTALL ?= install
|
417
|
+
INSTALL ?= install
|
237
418
|
endif
|
238
419
|
|
239
420
|
INSTALL_PROGRAM ?= $(INSTALL)
|
@@ -243,49 +424,59 @@ INSTALL_DATA ?= $(INSTALL) -m 644
|
|
243
424
|
libzstd.pc:
|
244
425
|
libzstd.pc: libzstd.pc.in
|
245
426
|
@echo creating pkgconfig
|
246
|
-
@sed
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
427
|
+
@sed $(SED_ERE_OPT) \
|
428
|
+
-e 's|@PREFIX@|$(PREFIX)|' \
|
429
|
+
-e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
|
430
|
+
-e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
|
431
|
+
-e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
|
432
|
+
-e 's|@VERSION@|$(VERSION)|' \
|
433
|
+
$< >$@
|
434
|
+
|
435
|
+
.PHONY: install
|
252
436
|
install: install-pc install-static install-shared install-includes
|
253
437
|
@echo zstd static and shared library installed
|
254
438
|
|
439
|
+
.PHONY: install-pc
|
255
440
|
install-pc: libzstd.pc
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
install-static
|
441
|
+
[ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
442
|
+
$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
443
|
+
|
444
|
+
.PHONY: install-static
|
445
|
+
install-static:
|
446
|
+
# only generate libzstd.a if it's not already present
|
447
|
+
[ -e libzstd.a ] || $(MAKE) libzstd.a-release
|
448
|
+
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
260
449
|
@echo Installing static library
|
261
|
-
|
262
|
-
@$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
450
|
+
$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
263
451
|
|
264
|
-
install-shared
|
452
|
+
.PHONY: install-shared
|
453
|
+
install-shared:
|
454
|
+
# only generate libzstd.so if it's not already present
|
455
|
+
[ -e $(LIBZSTD) ] || $(MAKE) libzstd-release
|
456
|
+
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
265
457
|
@echo Installing shared library
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
@ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
458
|
+
$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
|
459
|
+
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
460
|
+
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
270
461
|
|
462
|
+
.PHONY: install-includes
|
271
463
|
install-includes:
|
464
|
+
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
272
465
|
@echo Installing includes
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
@$(INSTALL_DATA) deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
|
277
|
-
@$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
|
466
|
+
$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
467
|
+
$(INSTALL_DATA) zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
468
|
+
$(INSTALL_DATA) zdict.h $(DESTDIR)$(INCLUDEDIR)
|
278
469
|
|
470
|
+
.PHONY: uninstall
|
279
471
|
uninstall:
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
@$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
472
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
|
473
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
474
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
475
|
+
$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
|
476
|
+
$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
|
477
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
|
478
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
|
479
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
289
480
|
@echo zstd libraries successfully uninstalled
|
290
481
|
|
291
482
|
endif
|