zstd-ruby 1.4.4.0 → 1.5.1.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/extconf.rb +1 -0
- data/ext/zstdruby/libzstd/BUCK +5 -7
- data/ext/zstdruby/libzstd/Makefile +241 -173
- data/ext/zstdruby/libzstd/README.md +76 -18
- data/ext/zstdruby/libzstd/common/bitstream.h +75 -57
- data/ext/zstdruby/libzstd/common/compiler.h +196 -20
- 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 +208 -76
- data/ext/zstdruby/libzstd/common/error_private.c +3 -1
- data/ext/zstdruby/libzstd/common/error_private.h +87 -4
- data/ext/zstdruby/libzstd/common/fse.h +51 -42
- data/ext/zstdruby/libzstd/common/fse_decompress.c +149 -57
- data/ext/zstdruby/libzstd/common/huf.h +60 -54
- data/ext/zstdruby/libzstd/common/mem.h +87 -98
- data/ext/zstdruby/libzstd/common/pool.c +23 -17
- data/ext/zstdruby/libzstd/common/pool.h +3 -3
- data/ext/zstdruby/libzstd/common/portability_macros.h +131 -0
- data/ext/zstdruby/libzstd/common/threading.c +10 -8
- data/ext/zstdruby/libzstd/common/threading.h +4 -3
- data/ext/zstdruby/libzstd/common/xxhash.c +15 -873
- data/ext/zstdruby/libzstd/common/xxhash.h +5572 -191
- 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 +252 -108
- data/ext/zstdruby/libzstd/common/zstd_trace.h +163 -0
- data/ext/zstdruby/libzstd/compress/clevels.h +134 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +105 -85
- 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 +831 -259
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +3213 -1007
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +493 -71
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +21 -16
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +4 -2
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +51 -24
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +10 -3
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +573 -0
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +32 -0
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +208 -81
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +315 -137
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +2 -2
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +319 -128
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +2 -2
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +1156 -171
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +59 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +331 -206
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +15 -3
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +403 -226
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +188 -453
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +32 -114
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +1065 -410
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +571 -0
- 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 +691 -230
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +1072 -323
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +16 -7
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +71 -10
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +3 -3
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +2 -2
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +24 -4
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +57 -40
- 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 +54 -35
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +151 -57
- 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 +25 -19
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +18 -14
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +18 -14
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +22 -16
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +29 -25
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +2 -2
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +29 -25
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +34 -26
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +1 -1
- data/ext/zstdruby/libzstd/libzstd.mk +185 -0
- data/ext/zstdruby/libzstd/libzstd.pc.in +4 -3
- data/ext/zstdruby/libzstd/modulemap/module.modulemap +4 -0
- data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +201 -31
- data/ext/zstdruby/libzstd/zstd.h +760 -234
- data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +3 -1
- data/ext/zstdruby/zstdruby.c +2 -2
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +20 -9
- 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: 9c5390f204466dadf3276d3d7841d5dcc0c2be4f9cdafd11be705b6304b8cb27
|
4
|
+
data.tar.gz: 3538385c093224f15c6199ae51cdedb944a1b6e0ff4e9c3287ea907911fb07b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fc0f3ca375ee6b9fd6564eb0807c8d9e5c0f39e19ba9a9692d07c28e55e2fc70a625d3dc682ae402eb7bce76caf114f0c5b103a047f46c88b033bc2bdccc52f
|
7
|
+
data.tar.gz: 2bdb03fade1bca81eedcac96a63b5cbaea4774373f06f483ce77978a3795241e523905b6845c5fac0c70465df3575691e70441cca7a68b7f32b81202c82e69c0
|
@@ -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.6', '2.7', '3.0', '3.1']
|
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@168d6a54b412713c0ed60998a78093a270ca8d84
|
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.1 (https://github.com/facebook/zstd/tree/v1.5.1)
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
data/ext/zstdruby/extconf.rb
CHANGED
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,216 +1,259 @@
|
|
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
|
|
10
|
-
#
|
11
|
-
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
12
|
-
LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
13
|
-
LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
14
|
-
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
|
15
|
-
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
16
|
-
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
17
|
-
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
18
|
-
LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
19
|
-
VERSION?= $(LIBVER)
|
20
|
-
CCVER := $(shell $(CC) --version)
|
21
|
-
|
22
|
-
CPPFLAGS+= -I. -I./common -DXXH_NAMESPACE=ZSTD_
|
23
|
-
ifeq ($(OS),Windows_NT) # MinGW assumed
|
24
|
-
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
25
|
-
endif
|
26
|
-
CFLAGS ?= -O3
|
27
|
-
DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
28
|
-
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
29
|
-
-Wstrict-prototypes -Wundef -Wpointer-arith \
|
30
|
-
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
31
|
-
-Wredundant-decls -Wmissing-prototypes -Wc++-compat
|
32
|
-
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
33
|
-
FLAGS = $(CPPFLAGS) $(CFLAGS)
|
34
|
-
|
35
|
-
HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
36
|
-
GREP_OPTIONS ?=
|
37
|
-
ifeq ($HAVE_COLORNEVER, 1)
|
38
|
-
GREP_OPTIONS += --color=never
|
39
|
-
endif
|
40
|
-
GREP = grep $(GREP_OPTIONS)
|
41
|
-
|
42
|
-
ZSTDCOMMON_FILES := $(sort $(wildcard common/*.c))
|
43
|
-
ZSTDCOMP_FILES := $(sort $(wildcard compress/*.c))
|
44
|
-
ZSTDDECOMP_FILES := $(sort $(wildcard decompress/*.c))
|
45
|
-
ZDICT_FILES := $(sort $(wildcard dictBuilder/*.c))
|
46
|
-
ZDEPR_FILES := $(sort $(wildcard deprecated/*.c))
|
47
|
-
ZSTD_FILES := $(ZSTDCOMMON_FILES)
|
48
|
-
|
49
|
-
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
50
|
-
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
51
|
-
endif
|
52
|
-
|
53
|
-
ZSTD_LEGACY_SUPPORT ?= 5
|
11
|
+
# Modules
|
54
12
|
ZSTD_LIB_COMPRESSION ?= 1
|
55
13
|
ZSTD_LIB_DECOMPRESSION ?= 1
|
56
14
|
ZSTD_LIB_DICTBUILDER ?= 1
|
57
|
-
ZSTD_LIB_DEPRECATED ?=
|
58
|
-
HUF_FORCE_DECOMPRESS_X1 ?= 0
|
59
|
-
HUF_FORCE_DECOMPRESS_X2 ?= 0
|
60
|
-
ZSTD_FORCE_DECOMPRESS_SHORT ?= 0
|
61
|
-
ZSTD_FORCE_DECOMPRESS_LONG ?= 0
|
62
|
-
ZSTD_NO_INLINE ?= 0
|
63
|
-
ZSTD_STRIP_ERROR_STRINGS ?= 0
|
64
|
-
ZSTD_LEGACY_MULTITHREADED_API ?= 0
|
15
|
+
ZSTD_LIB_DEPRECATED ?= 0
|
65
16
|
|
17
|
+
# Input variables for libzstd.mk
|
66
18
|
ifeq ($(ZSTD_LIB_COMPRESSION), 0)
|
67
|
-
|
68
|
-
|
19
|
+
ZSTD_LIB_DICTBUILDER = 0
|
20
|
+
ZSTD_LIB_DEPRECATED = 0
|
69
21
|
endif
|
70
22
|
|
71
23
|
ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
72
|
-
|
73
|
-
|
24
|
+
ZSTD_LEGACY_SUPPORT = 0
|
25
|
+
ZSTD_LIB_DEPRECATED = 0
|
74
26
|
endif
|
75
27
|
|
28
|
+
include libzstd.mk
|
29
|
+
|
30
|
+
ZSTD_FILES := $(ZSTD_COMMON_FILES) $(ZSTD_LEGACY_FILES)
|
31
|
+
|
76
32
|
ifneq ($(ZSTD_LIB_COMPRESSION), 0)
|
77
|
-
|
33
|
+
ZSTD_FILES += $(ZSTD_COMPRESS_FILES)
|
78
34
|
endif
|
79
35
|
|
80
36
|
ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
81
|
-
|
37
|
+
ZSTD_FILES += $(ZSTD_DECOMPRESS_FILES)
|
82
38
|
endif
|
83
39
|
|
84
40
|
ifneq ($(ZSTD_LIB_DEPRECATED), 0)
|
85
|
-
|
41
|
+
ZSTD_FILES += $(ZSTD_DEPRECATED_FILES)
|
86
42
|
endif
|
87
43
|
|
88
44
|
ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
|
89
|
-
|
90
|
-
endif
|
91
|
-
|
92
|
-
ifneq ($(HUF_FORCE_DECOMPRESS_X1), 0)
|
93
|
-
CFLAGS += -DHUF_FORCE_DECOMPRESS_X1
|
45
|
+
ZSTD_FILES += $(ZSTD_DICTBUILDER_FILES)
|
94
46
|
endif
|
95
47
|
|
96
|
-
|
97
|
-
|
98
|
-
|
48
|
+
ZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES))
|
49
|
+
ZSTD_LOCAL_OBJ0 := $(ZSTD_LOCAL_SRC:.c=.o)
|
50
|
+
ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_OBJ0:.S=.o)
|
99
51
|
|
100
|
-
|
101
|
-
CFLAGS += -DZSTD_FORCE_DECOMPRESS_SHORT
|
102
|
-
endif
|
103
|
-
|
104
|
-
ifneq ($(ZSTD_FORCE_DECOMPRESS_LONG), 0)
|
105
|
-
CFLAGS += -DZSTD_FORCE_DECOMPRESS_LONG
|
106
|
-
endif
|
52
|
+
VERSION := $(ZSTD_VERSION)
|
107
53
|
|
108
|
-
|
109
|
-
|
110
|
-
|
54
|
+
# Note: by default, the static library is built single-threaded and dynamic library is built
|
55
|
+
# multi-threaded. It is possible to force multi or single threaded builds by appending
|
56
|
+
# -mt or -nomt to the build target (like lib-mt for multi-threaded, lib-nomt for single-threaded).
|
57
|
+
.PHONY: default
|
58
|
+
default: lib-release
|
111
59
|
|
112
|
-
|
113
|
-
|
114
|
-
|
60
|
+
CPPFLAGS_DYNLIB += -DZSTD_MULTITHREAD # dynamic library build defaults to multi-threaded
|
61
|
+
LDFLAGS_DYNLIB += -pthread
|
62
|
+
CPPFLAGS_STATLIB += # static library build defaults to single-threaded
|
115
63
|
|
116
|
-
ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
|
117
|
-
CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
|
118
|
-
endif
|
119
64
|
|
120
|
-
|
121
|
-
|
122
|
-
ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
|
123
|
-
endif
|
124
|
-
CPPFLAGS += -I./legacy
|
65
|
+
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
66
|
+
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
125
67
|
endif
|
126
|
-
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
127
68
|
|
128
|
-
ZSTD_OBJ := $(patsubst %.c,%.o,$(ZSTD_FILES))
|
129
69
|
|
130
70
|
# macOS linker doesn't support -soname, and use different extension
|
131
71
|
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
132
|
-
ifeq ($(
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
72
|
+
ifeq ($(UNAME), Darwin)
|
73
|
+
SHARED_EXT = dylib
|
74
|
+
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
75
|
+
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
76
|
+
SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
|
137
77
|
else
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
78
|
+
ifeq ($(UNAME), AIX)
|
79
|
+
SONAME_FLAGS =
|
80
|
+
else
|
81
|
+
SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
|
82
|
+
endif
|
83
|
+
SHARED_EXT = so
|
84
|
+
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
|
85
|
+
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
|
142
86
|
endif
|
143
87
|
|
144
88
|
|
145
|
-
.PHONY:
|
89
|
+
.PHONY: all
|
90
|
+
all: lib
|
91
|
+
|
146
92
|
|
147
|
-
|
93
|
+
.PHONY: libzstd.a # must be run every time
|
94
|
+
libzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB)
|
148
95
|
|
149
|
-
|
96
|
+
SET_CACHE_DIRECTORY = \
|
97
|
+
+$(MAKE) --no-print-directory $@ \
|
98
|
+
BUILD_DIR=obj/$(HASH_DIR) \
|
99
|
+
CPPFLAGS="$(CPPFLAGS)" \
|
100
|
+
CFLAGS="$(CFLAGS)" \
|
101
|
+
LDFLAGS="$(LDFLAGS)"
|
102
|
+
|
103
|
+
ifndef BUILD_DIR
|
104
|
+
# determine BUILD_DIR from compilation flags
|
150
105
|
|
151
|
-
libzstd.a:
|
152
|
-
|
153
|
-
@echo compiling static library
|
154
|
-
@$(AR) $(ARFLAGS) $@ $^
|
106
|
+
libzstd.a:
|
107
|
+
$(SET_CACHE_DIRECTORY)
|
155
108
|
|
156
|
-
|
157
|
-
|
109
|
+
else
|
110
|
+
# BUILD_DIR is defined
|
111
|
+
|
112
|
+
ZSTD_STATLIB_DIR := $(BUILD_DIR)/static
|
113
|
+
ZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a
|
114
|
+
ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
115
|
+
$(ZSTD_STATLIB): ARFLAGS = rcs
|
116
|
+
$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR)
|
117
|
+
$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ)
|
118
|
+
# Check for multithread flag at target execution time
|
119
|
+
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
120
|
+
@echo compiling multi-threaded static library $(LIBVER),\
|
121
|
+
@echo compiling single-threaded static library $(LIBVER))
|
122
|
+
$(AR) $(ARFLAGS) $@ $^
|
123
|
+
|
124
|
+
libzstd.a: $(ZSTD_STATLIB)
|
125
|
+
cp -f $< $@
|
126
|
+
|
127
|
+
endif
|
158
128
|
|
159
|
-
ifneq (,$(filter Windows%,$(
|
129
|
+
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
160
130
|
|
161
|
-
LIBZSTD = dll
|
131
|
+
LIBZSTD = dll/libzstd.dll
|
162
132
|
$(LIBZSTD): $(ZSTD_FILES)
|
163
133
|
@echo compiling dynamic library $(LIBVER)
|
164
|
-
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll
|
134
|
+
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@
|
165
135
|
|
166
|
-
else
|
136
|
+
else # not Windows
|
167
137
|
|
168
138
|
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
169
|
-
$(LIBZSTD)
|
170
|
-
$(LIBZSTD): $(
|
171
|
-
|
172
|
-
|
139
|
+
.PHONY: $(LIBZSTD) # must be run every time
|
140
|
+
$(LIBZSTD): CPPFLAGS += $(CPPFLAGS_DYNLIB)
|
141
|
+
$(LIBZSTD): CFLAGS += -fPIC -fvisibility=hidden
|
142
|
+
$(LIBZSTD): LDFLAGS += -shared $(LDFLAGS_DYNLIB)
|
143
|
+
|
144
|
+
ifndef BUILD_DIR
|
145
|
+
# determine BUILD_DIR from compilation flags
|
146
|
+
|
147
|
+
$(LIBZSTD):
|
148
|
+
$(SET_CACHE_DIRECTORY)
|
149
|
+
|
150
|
+
else
|
151
|
+
# BUILD_DIR is defined
|
152
|
+
|
153
|
+
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic
|
154
|
+
ZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
155
|
+
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
156
|
+
|
157
|
+
$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR)
|
158
|
+
$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ)
|
159
|
+
# Check for multithread flag at target execution time
|
160
|
+
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
161
|
+
@echo compiling multi-threaded dynamic library $(LIBVER),\
|
162
|
+
@echo compiling single-threaded dynamic library $(LIBVER))
|
163
|
+
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
173
164
|
@echo creating versioned links
|
174
|
-
|
175
|
-
|
165
|
+
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
166
|
+
ln -sf $@ libzstd.$(SHARED_EXT)
|
176
167
|
|
177
|
-
|
168
|
+
$(LIBZSTD): $(ZSTD_DYNLIB)
|
169
|
+
cp -f $< $@
|
178
170
|
|
171
|
+
endif # ifndef BUILD_DIR
|
172
|
+
endif # if windows
|
179
173
|
|
174
|
+
.PHONY: libzstd
|
180
175
|
libzstd : $(LIBZSTD)
|
181
176
|
|
182
|
-
|
183
|
-
|
177
|
+
.PHONY: lib
|
178
|
+
lib : libzstd.a libzstd
|
179
|
+
|
180
|
+
|
181
|
+
# note : do not define lib-mt or lib-release as .PHONY
|
182
|
+
# make does not consider implicit pattern rule for .PHONY target
|
183
|
+
|
184
|
+
%-mt : CPPFLAGS_DYNLIB := -DZSTD_MULTITHREAD
|
185
|
+
%-mt : CPPFLAGS_STATLIB := -DZSTD_MULTITHREAD
|
186
|
+
%-mt : LDFLAGS_DYNLIB := -pthread
|
187
|
+
%-mt : %
|
188
|
+
@echo multi-threaded build completed
|
189
|
+
|
190
|
+
%-nomt : CPPFLAGS_DYNLIB :=
|
191
|
+
%-nomt : LDFLAGS_DYNLIB :=
|
192
|
+
%-nomt : CPPFLAGS_STATLIB :=
|
193
|
+
%-nomt : %
|
194
|
+
@echo single-threaded build completed
|
195
|
+
|
196
|
+
%-release : DEBUGFLAGS :=
|
197
|
+
%-release : %
|
198
|
+
@echo release build completed
|
199
|
+
|
184
200
|
|
185
|
-
|
201
|
+
# Generate .h dependencies automatically
|
186
202
|
|
187
|
-
|
188
|
-
|
203
|
+
DEPFLAGS = -MT $@ -MMD -MP -MF
|
204
|
+
|
205
|
+
$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR)
|
206
|
+
@echo CC $@
|
207
|
+
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
208
|
+
|
209
|
+
$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
|
210
|
+
@echo CC $@
|
211
|
+
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
212
|
+
|
213
|
+
$(ZSTD_DYNLIB_DIR)/%.o : %.S | $(ZSTD_DYNLIB_DIR)
|
214
|
+
@echo AS $@
|
215
|
+
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
216
|
+
|
217
|
+
$(ZSTD_STATLIB_DIR)/%.o : %.S | $(ZSTD_STATLIB_DIR)
|
218
|
+
@echo AS $@
|
219
|
+
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
220
|
+
|
221
|
+
MKDIR ?= mkdir
|
222
|
+
$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
223
|
+
$(MKDIR) -p $@
|
224
|
+
|
225
|
+
DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d)
|
226
|
+
$(DEPFILES):
|
227
|
+
|
228
|
+
include $(wildcard $(DEPFILES))
|
189
229
|
|
190
|
-
lib-release lib-release-mt: DEBUGFLAGS :=
|
191
|
-
lib-release: lib
|
192
|
-
lib-release-mt: lib-mt
|
193
230
|
|
194
231
|
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
195
232
|
ZSTDMT_FILES = compress/zstdmt_compress.c
|
196
233
|
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
197
|
-
libzstd-nomt:
|
234
|
+
libzstd-nomt: CFLAGS += -fPIC -fvisibility=hidden
|
235
|
+
libzstd-nomt: LDFLAGS += -shared
|
198
236
|
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
199
237
|
@echo compiling single-thread dynamic library $(LIBVER)
|
200
238
|
@echo files : $(ZSTD_NOMT_FILES)
|
201
|
-
|
239
|
+
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
202
240
|
|
241
|
+
.PHONY: clean
|
203
242
|
clean:
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
243
|
+
$(RM) -r *.dSYM # macOS-specific
|
244
|
+
$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
245
|
+
$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
246
|
+
$(RM) -r obj/*
|
208
247
|
@echo Cleaning library completed
|
209
248
|
|
210
249
|
#-----------------------------------------------------------------------------
|
211
|
-
# make install is validated only for
|
250
|
+
# make install is validated only for below listed environments
|
212
251
|
#-----------------------------------------------------------------------------
|
213
|
-
ifneq (,$(filter $(
|
252
|
+
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX))
|
253
|
+
|
254
|
+
lib: libzstd.pc
|
255
|
+
|
256
|
+
HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,)
|
214
257
|
|
215
258
|
DESTDIR ?=
|
216
259
|
# directory variables : GNU conventions prefer lowercase
|
@@ -219,71 +262,96 @@ DESTDIR ?=
|
|
219
262
|
prefix ?= /usr/local
|
220
263
|
PREFIX ?= $(prefix)
|
221
264
|
exec_prefix ?= $(PREFIX)
|
222
|
-
|
265
|
+
EXEC_PREFIX ?= $(exec_prefix)
|
266
|
+
libdir ?= $(EXEC_PREFIX)/lib
|
223
267
|
LIBDIR ?= $(libdir)
|
224
268
|
includedir ?= $(PREFIX)/include
|
225
269
|
INCLUDEDIR ?= $(includedir)
|
226
270
|
|
227
|
-
|
228
|
-
|
271
|
+
PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
|
272
|
+
PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
|
273
|
+
|
274
|
+
# If we successfully stripped off a prefix, we'll add a reference to the
|
275
|
+
# relevant pc variable.
|
276
|
+
PCINCPREFIX := $(if $(findstring $(INCLUDEDIR),$(PCINCDIR)),,$${prefix})
|
277
|
+
PCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix})
|
278
|
+
|
279
|
+
# If no explicit EXEC_PREFIX was set by the caller, write it out as a reference
|
280
|
+
# to PREFIX, rather than as a resolved value.
|
281
|
+
PCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix})
|
282
|
+
|
283
|
+
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
284
|
+
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
229
285
|
else
|
230
|
-
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
286
|
+
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
231
287
|
endif
|
232
288
|
|
233
|
-
ifneq (,$(filter $(
|
234
|
-
INSTALL ?= ginstall
|
289
|
+
ifneq (,$(filter $(UNAME),SunOS))
|
290
|
+
INSTALL ?= ginstall
|
235
291
|
else
|
236
|
-
INSTALL ?= install
|
292
|
+
INSTALL ?= install
|
237
293
|
endif
|
238
294
|
|
239
295
|
INSTALL_PROGRAM ?= $(INSTALL)
|
240
296
|
INSTALL_DATA ?= $(INSTALL) -m 644
|
241
297
|
|
242
298
|
|
243
|
-
libzstd.pc:
|
244
299
|
libzstd.pc: libzstd.pc.in
|
245
300
|
@echo creating pkgconfig
|
246
|
-
@sed
|
247
|
-
|
248
|
-
|
249
|
-
|
301
|
+
@sed $(SED_ERE_OPT) \
|
302
|
+
-e 's|@PREFIX@|$(PREFIX)|' \
|
303
|
+
-e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
|
304
|
+
-e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
|
305
|
+
-e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
|
306
|
+
-e 's|@VERSION@|$(VERSION)|' \
|
307
|
+
-e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \
|
308
|
+
$< >$@
|
309
|
+
|
310
|
+
.PHONY: install
|
250
311
|
install: install-pc install-static install-shared install-includes
|
251
312
|
@echo zstd static and shared library installed
|
252
313
|
|
314
|
+
.PHONY: install-pc
|
253
315
|
install-pc: libzstd.pc
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
install-static
|
316
|
+
[ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
317
|
+
$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
318
|
+
|
319
|
+
.PHONY: install-static
|
320
|
+
install-static:
|
321
|
+
# only generate libzstd.a if it's not already present
|
322
|
+
[ -e libzstd.a ] || $(MAKE) libzstd.a-release
|
323
|
+
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
258
324
|
@echo Installing static library
|
259
|
-
|
260
|
-
@$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
325
|
+
$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
261
326
|
|
262
|
-
install-shared
|
327
|
+
.PHONY: install-shared
|
328
|
+
install-shared:
|
329
|
+
# only generate libzstd.so if it's not already present
|
330
|
+
[ -e $(LIBZSTD) ] || $(MAKE) libzstd-release
|
331
|
+
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
263
332
|
@echo Installing shared library
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
@ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
333
|
+
$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
|
334
|
+
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
335
|
+
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
268
336
|
|
337
|
+
.PHONY: install-includes
|
269
338
|
install-includes:
|
339
|
+
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
270
340
|
@echo Installing includes
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
@$(INSTALL_DATA) deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
|
275
|
-
@$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
|
341
|
+
$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
342
|
+
$(INSTALL_DATA) zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
343
|
+
$(INSTALL_DATA) zdict.h $(DESTDIR)$(INCLUDEDIR)
|
276
344
|
|
345
|
+
.PHONY: uninstall
|
277
346
|
uninstall:
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
@$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
347
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
|
348
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
349
|
+
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
350
|
+
$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
|
351
|
+
$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
|
352
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
|
353
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
|
354
|
+
$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
287
355
|
@echo zstd libraries successfully uninstalled
|
288
356
|
|
289
357
|
endif
|