extzstd 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -14
  3. data/contrib/zstd/CHANGELOG +114 -56
  4. data/contrib/zstd/CONTRIBUTING.md +14 -0
  5. data/contrib/zstd/Makefile +37 -31
  6. data/contrib/zstd/README.md +6 -0
  7. data/contrib/zstd/appveyor.yml +4 -1
  8. data/contrib/zstd/lib/Makefile +231 -134
  9. data/contrib/zstd/lib/README.md +28 -0
  10. data/contrib/zstd/lib/common/bitstream.h +24 -15
  11. data/contrib/zstd/lib/common/compiler.h +116 -3
  12. data/contrib/zstd/lib/common/cpu.h +0 -2
  13. data/contrib/zstd/lib/common/debug.h +11 -18
  14. data/contrib/zstd/lib/common/entropy_common.c +188 -42
  15. data/contrib/zstd/lib/common/error_private.c +1 -0
  16. data/contrib/zstd/lib/common/error_private.h +1 -1
  17. data/contrib/zstd/lib/common/fse.h +38 -11
  18. data/contrib/zstd/lib/common/fse_decompress.c +123 -16
  19. data/contrib/zstd/lib/common/huf.h +26 -5
  20. data/contrib/zstd/lib/common/mem.h +66 -93
  21. data/contrib/zstd/lib/common/pool.c +22 -16
  22. data/contrib/zstd/lib/common/pool.h +1 -1
  23. data/contrib/zstd/lib/common/threading.c +6 -5
  24. data/contrib/zstd/lib/common/xxhash.c +18 -56
  25. data/contrib/zstd/lib/common/xxhash.h +1 -1
  26. data/contrib/zstd/lib/common/zstd_common.c +9 -9
  27. data/contrib/zstd/lib/common/zstd_deps.h +111 -0
  28. data/contrib/zstd/lib/common/zstd_errors.h +1 -0
  29. data/contrib/zstd/lib/common/zstd_internal.h +89 -58
  30. data/contrib/zstd/lib/compress/fse_compress.c +30 -23
  31. data/contrib/zstd/lib/compress/hist.c +26 -28
  32. data/contrib/zstd/lib/compress/hist.h +1 -1
  33. data/contrib/zstd/lib/compress/huf_compress.c +210 -95
  34. data/contrib/zstd/lib/compress/zstd_compress.c +1339 -409
  35. data/contrib/zstd/lib/compress/zstd_compress_internal.h +119 -41
  36. data/contrib/zstd/lib/compress/zstd_compress_literals.c +4 -4
  37. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +17 -3
  38. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +23 -19
  39. data/contrib/zstd/lib/compress/zstd_cwksp.h +60 -24
  40. data/contrib/zstd/lib/compress/zstd_double_fast.c +22 -22
  41. data/contrib/zstd/lib/compress/zstd_fast.c +19 -19
  42. data/contrib/zstd/lib/compress/zstd_lazy.c +351 -77
  43. data/contrib/zstd/lib/compress/zstd_lazy.h +20 -0
  44. data/contrib/zstd/lib/compress/zstd_ldm.c +59 -18
  45. data/contrib/zstd/lib/compress/zstd_ldm.h +6 -0
  46. data/contrib/zstd/lib/compress/zstd_opt.c +190 -45
  47. data/contrib/zstd/lib/compress/zstdmt_compress.c +74 -406
  48. data/contrib/zstd/lib/compress/zstdmt_compress.h +26 -108
  49. data/contrib/zstd/lib/decompress/huf_decompress.c +302 -200
  50. data/contrib/zstd/lib/decompress/zstd_ddict.c +8 -8
  51. data/contrib/zstd/lib/decompress/zstd_ddict.h +1 -1
  52. data/contrib/zstd/lib/decompress/zstd_decompress.c +125 -80
  53. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +145 -37
  54. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +5 -2
  55. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +11 -10
  56. data/contrib/zstd/lib/dictBuilder/cover.c +29 -20
  57. data/contrib/zstd/lib/dictBuilder/cover.h +1 -1
  58. data/contrib/zstd/lib/dictBuilder/fastcover.c +20 -19
  59. data/contrib/zstd/lib/dictBuilder/zdict.c +15 -16
  60. data/contrib/zstd/lib/dictBuilder/zdict.h +1 -1
  61. data/contrib/zstd/lib/legacy/zstd_v01.c +5 -1
  62. data/contrib/zstd/lib/legacy/zstd_v02.c +5 -1
  63. data/contrib/zstd/lib/legacy/zstd_v03.c +5 -1
  64. data/contrib/zstd/lib/legacy/zstd_v04.c +6 -2
  65. data/contrib/zstd/lib/legacy/zstd_v05.c +5 -1
  66. data/contrib/zstd/lib/legacy/zstd_v06.c +5 -1
  67. data/contrib/zstd/lib/legacy/zstd_v07.c +5 -1
  68. data/contrib/zstd/lib/libzstd.pc.in +3 -3
  69. data/contrib/zstd/lib/zstd.h +348 -47
  70. data/ext/extzstd.c +6 -0
  71. data/ext/extzstd.h +6 -0
  72. data/gemstub.rb +3 -21
  73. data/lib/extzstd.rb +0 -2
  74. data/lib/extzstd/version.rb +6 -1
  75. data/test/test_basic.rb +0 -5
  76. metadata +5 -4
@@ -126,6 +126,20 @@ just `contrib/largeNbDicts` and nothing else, you can run:
126
126
  scan-build make -C contrib/largeNbDicts largeNbDicts
127
127
  ```
128
128
 
129
+ ### Pitfalls of static analysis
130
+ `scan-build` is part of our regular CI suite. Other static analyzers are not.
131
+
132
+ It can be useful to look at additional static analyzers once in a while (and we do), but it's not a good idea to multiply the nb of analyzers run continuously at each commit and PR. The reasons are :
133
+
134
+ - Static analyzers are full of false positive. The signal to noise ratio is actually pretty low.
135
+ - A good CI policy is "zero-warning tolerance". That means that all issues must be solved, including false positives. This quickly becomes a tedious workload.
136
+ - Multiple static analyzers will feature multiple kind of false positives, sometimes applying to the same code but in different ways leading to :
137
+ + torteous code, trying to please multiple constraints, hurting readability and therefore maintenance. Sometimes, such complexity introduce other more subtle bugs, that are just out of scope of the analyzers.
138
+ + sometimes, these constraints are mutually exclusive : if one try to solve one, the other static analyzer will complain, they can't be both happy at the same time.
139
+ - As if that was not enough, the list of false positives change with each version. It's hard enough to follow one static analyzer, but multiple ones with their own update agenda, this quickly becomes a massive velocity reducer.
140
+
141
+ This is different from running a static analyzer once in a while, looking at the output, and __cherry picking__ a few warnings that seem helpful, either because they detected a genuine risk of bug, or because it helps expressing the code in a way which is more readable or more difficult to misuse. These kind of reports can be useful, and are accepted.
142
+
129
143
  ## Performance
130
144
  Performance is extremely important for zstd and we only merge pull requests whose performance
131
145
  landscape and corresponding trade-offs have been adequately analyzed, reproduced, and presented.
@@ -8,6 +8,9 @@
8
8
  # You may select, at your option, one of the above-listed licenses.
9
9
  # ################################################################
10
10
 
11
+ # verbose mode (print commands) on V=1 or VERBOSE=1
12
+ Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
13
+
11
14
  PRGDIR = programs
12
15
  ZSTDDIR = lib
13
16
  BUILDIR = build
@@ -28,9 +31,9 @@ VOID = /dev/null
28
31
  TARGET_SYSTEM ?= $(OS)
29
32
 
30
33
  ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
31
- EXT =.exe
34
+ EXT =.exe
32
35
  else
33
- EXT =
36
+ EXT =
34
37
  endif
35
38
 
36
39
  ## default: Build lib-release and zstd-release
@@ -46,8 +49,8 @@ allmost: allzstd zlibwrapper
46
49
  # skip zwrapper, can't build that on alternate architectures without the proper zlib installed
47
50
  .PHONY: allzstd
48
51
  allzstd: lib-all
49
- $(MAKE) -C $(PRGDIR) all
50
- $(MAKE) -C $(TESTDIR) all
52
+ $(Q)$(MAKE) -C $(PRGDIR) all
53
+ $(Q)$(MAKE) -C $(TESTDIR) all
51
54
 
52
55
  .PHONY: all32
53
56
  all32:
@@ -55,18 +58,19 @@ all32:
55
58
  $(MAKE) -C $(TESTDIR) all32
56
59
 
57
60
  .PHONY: lib lib-release libzstd.a
61
+ lib-all : lib
58
62
  lib lib-release lib-all :
59
- @$(MAKE) -C $(ZSTDDIR) $@
63
+ $(Q)$(MAKE) -C $(ZSTDDIR) $@
60
64
 
61
65
  .PHONY: zstd zstd-release
62
66
  zstd zstd-release:
63
- @$(MAKE) -C $(PRGDIR) $@
64
- cp $(PRGDIR)/zstd$(EXT) .
67
+ $(Q)$(MAKE) -C $(PRGDIR) $@
68
+ $(Q)ln -sf $(PRGDIR)/zstd$(EXT) zstd$(EXT)
65
69
 
66
70
  .PHONY: zstdmt
67
71
  zstdmt:
68
- @$(MAKE) -C $(PRGDIR) $@
69
- cp $(PRGDIR)/zstd$(EXT) ./zstdmt$(EXT)
72
+ $(Q)$(MAKE) -C $(PRGDIR) $@
73
+ $(Q)cp $(PRGDIR)/zstd$(EXT) ./zstdmt$(EXT)
70
74
 
71
75
  .PHONY: zlibwrapper
72
76
  zlibwrapper: lib
@@ -75,16 +79,16 @@ zlibwrapper: lib
75
79
  ## test: run long-duration tests
76
80
  .PHONY: test
77
81
  DEBUGLEVEL ?= 1
78
- test: MOREFLAGS += -g -DDEBUGLEVEL=$(DEBUGLEVEL) -Werror
82
+ test: MOREFLAGS += -g -Werror
79
83
  test:
80
- MOREFLAGS="$(MOREFLAGS)" $(MAKE) -j -C $(PRGDIR) allVariants
84
+ DEBUGLEVEL=$(DEBUGLEVEL) MOREFLAGS="$(MOREFLAGS)" $(MAKE) -j -C $(PRGDIR) allVariants
81
85
  $(MAKE) -C $(TESTDIR) $@
82
- ZSTD=../../programs/zstd $(MAKE) -C doc/educational_decoder test
86
+ ZSTD=../../programs/zstd $(MAKE) -C doc/educational_decoder $@
83
87
 
84
88
  ## shortest: same as `make check`
85
89
  .PHONY: shortest
86
90
  shortest:
87
- $(MAKE) -C $(TESTDIR) $@
91
+ $(Q)$(MAKE) -C $(TESTDIR) $@
88
92
 
89
93
  ## check: run basic tests for `zstd` cli
90
94
  .PHONY: check
@@ -97,10 +101,10 @@ automated_benchmarking:
97
101
  .PHONY: benchmarking
98
102
  benchmarking: automated_benchmarking
99
103
 
100
- ## examples: build all examples in `/examples` directory
104
+ ## examples: build all examples in `examples/` directory
101
105
  .PHONY: examples
102
106
  examples: lib
103
- CPPFLAGS=-I../lib LDFLAGS=-L../lib $(MAKE) -C examples/ all
107
+ $(MAKE) -C examples all
104
108
 
105
109
  ## manual: generate API documentation in html format
106
110
  .PHONY: manual
@@ -117,6 +121,7 @@ man:
117
121
  contrib: lib
118
122
  $(MAKE) -C contrib/pzstd all
119
123
  $(MAKE) -C contrib/seekable_format/examples all
124
+ $(MAKE) -C contrib/seekable_format/tests test
120
125
  $(MAKE) -C contrib/largeNbDicts all
121
126
  cd contrib/single_file_libs/ ; ./build_decoder_test.sh
122
127
  cd contrib/single_file_libs/ ; ./build_library_test.sh
@@ -127,17 +132,18 @@ cleanTabs:
127
132
 
128
133
  .PHONY: clean
129
134
  clean:
130
- @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
131
- @$(MAKE) -C $(PRGDIR) $@ > $(VOID)
132
- @$(MAKE) -C $(TESTDIR) $@ > $(VOID)
133
- @$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID)
134
- @$(MAKE) -C examples/ $@ > $(VOID)
135
- @$(MAKE) -C contrib/gen_html $@ > $(VOID)
136
- @$(MAKE) -C contrib/pzstd $@ > $(VOID)
137
- @$(MAKE) -C contrib/seekable_format/examples $@ > $(VOID)
138
- @$(MAKE) -C contrib/largeNbDicts $@ > $(VOID)
139
- @$(RM) zstd$(EXT) zstdmt$(EXT) tmp*
140
- @$(RM) -r lz4
135
+ $(Q)$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
136
+ $(Q)$(MAKE) -C $(PRGDIR) $@ > $(VOID)
137
+ $(Q)$(MAKE) -C $(TESTDIR) $@ > $(VOID)
138
+ $(Q)$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID)
139
+ $(Q)$(MAKE) -C examples/ $@ > $(VOID)
140
+ $(Q)$(MAKE) -C contrib/gen_html $@ > $(VOID)
141
+ $(Q)$(MAKE) -C contrib/pzstd $@ > $(VOID)
142
+ $(Q)$(MAKE) -C contrib/seekable_format/examples $@ > $(VOID)
143
+ $(Q)$(MAKE) -C contrib/seekable_format/tests $@ > $(VOID)
144
+ $(Q)$(MAKE) -C contrib/largeNbDicts $@ > $(VOID)
145
+ $(Q)$(RM) zstd$(EXT) zstdmt$(EXT) tmp*
146
+ $(Q)$(RM) -r lz4
141
147
  @echo Cleaning completed
142
148
 
143
149
  #------------------------------------------------------------------------------
@@ -161,7 +167,7 @@ EGREP = egrep $(EGREP_OPTIONS)
161
167
  ## list: Print all targets and their descriptions (if provided)
162
168
  .PHONY: list
163
169
  list:
164
- @TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
170
+ $(Q)TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
165
171
  | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
166
172
  | $(EGREP) -v -e '^[^[:alnum:]]' | sort); \
167
173
  { \
@@ -176,13 +182,13 @@ list:
176
182
 
177
183
  .PHONY: install armtest usan asan uasan
178
184
  install:
179
- @$(MAKE) -C $(ZSTDDIR) $@
180
- @$(MAKE) -C $(PRGDIR) $@
185
+ $(Q)$(MAKE) -C $(ZSTDDIR) $@
186
+ $(Q)$(MAKE) -C $(PRGDIR) $@
181
187
 
182
188
  .PHONY: uninstall
183
189
  uninstall:
184
- @$(MAKE) -C $(ZSTDDIR) $@
185
- @$(MAKE) -C $(PRGDIR) $@
190
+ $(Q)$(MAKE) -C $(ZSTDDIR) $@
191
+ $(Q)$(MAKE) -C $(PRGDIR) $@
186
192
 
187
193
  .PHONY: travis-install
188
194
  travis-install:
@@ -176,6 +176,12 @@ Going into `build` directory, you will find additional possibilities:
176
176
  You can build the zstd binary via buck by executing: `buck build programs:zstd` from the root of the repo.
177
177
  The output binary will be in `buck-out/gen/programs/`.
178
178
 
179
+ ## Testing
180
+
181
+ You can run quick local smoke tests by executing the `playTest.sh` script from the `src/tests` directory.
182
+ Two env variables `$ZSTD_BIN` and `$DATAGEN_BIN` are needed for the test script to locate the zstd and datagen binary.
183
+ For information on CI testing, please refer to TESTING.md
184
+
179
185
  ## Status
180
186
 
181
187
  Zstandard is currently deployed within Facebook. It is used continuously to compress large amounts of data in multiple formats and use cases.
@@ -162,6 +162,8 @@
162
162
  - if [%TEST%]==[cmake] (
163
163
  mkdir build\cmake\build &&
164
164
  cd build\cmake\build &&
165
+ SET FUZZERTEST=-T2mn &&
166
+ SET ZSTREAM_TESTTIME=-T2mn &&
165
167
  cmake -G "Visual Studio 14 2015 Win64" .. &&
166
168
  cd ..\..\.. &&
167
169
  make clean
@@ -194,7 +196,7 @@
194
196
  - COMPILER: "gcc"
195
197
  HOST: "mingw"
196
198
  PLATFORM: "x64"
197
- SCRIPT: "CPPFLAGS=-DDEBUGLEVEL=2 CFLAGS=-Werror make -j allzstd DEBUGLEVEL=2"
199
+ SCRIPT: "CFLAGS=-Werror make -j allzstd DEBUGLEVEL=2"
198
200
  - COMPILER: "gcc"
199
201
  HOST: "mingw"
200
202
  PLATFORM: "x86"
@@ -285,5 +287,6 @@
285
287
  - ECHO Testing %COMPILER% %PLATFORM% %CONFIGURATION%
286
288
  - if [%HOST%]==[mingw] (
287
289
  set "CC=%COMPILER%" &&
290
+ make clean &&
288
291
  make check
289
292
  )
@@ -8,15 +8,16 @@
8
8
  # You may select, at your option, one of the above-listed licenses.
9
9
  # ################################################################
10
10
 
11
- Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
11
+ .PHONY: default
12
+ default: lib-release
12
13
 
13
- # When cross-compiling from linux to windows, you might
14
- # need to specify this as "Windows." Fedora build fails
15
- # without it.
16
- #
17
- # Note: mingw-w64 build from linux to windows does not
18
- # fail on other tested distros (ubuntu, debian) even
19
- # without manually specifying the TARGET_SYSTEM.
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)
20
21
  TARGET_SYSTEM ?= $(OS)
21
22
 
22
23
  # Version numbers
@@ -31,24 +32,49 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT))
31
32
  VERSION?= $(LIBVER)
32
33
  CCVER := $(shell $(CC) --version)
33
34
 
34
- CPPFLAGS+= -DXXH_NAMESPACE=ZSTD_
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)
35
60
  ifeq ($(TARGET_SYSTEM),Windows_NT) # MinGW assumed
36
- CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
61
+ CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
37
62
  endif
38
63
  DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
39
64
  -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
40
65
  -Wstrict-prototypes -Wundef -Wpointer-arith \
41
66
  -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
42
67
  -Wredundant-decls -Wmissing-prototypes -Wc++-compat
43
- CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
44
- FLAGS = $(CPPFLAGS) $(CFLAGS)
68
+ CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
69
+ FLAGS = $(CPPFLAGS) $(CFLAGS)
45
70
 
46
71
  HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
47
72
  GREP_OPTIONS ?=
48
73
  ifeq ($HAVE_COLORNEVER, 1)
49
- GREP_OPTIONS += --color=never
74
+ GREP_OPTIONS += --color=never
50
75
  endif
51
76
  GREP = grep $(GREP_OPTIONS)
77
+ SED_ERE_OPT ?= -E
52
78
 
53
79
  ZSTDCOMMON_FILES := $(sort $(wildcard common/*.c))
54
80
  ZSTDCOMP_FILES := $(sort $(wildcard compress/*.c))
@@ -58,30 +84,7 @@ ZDEPR_FILES := $(sort $(wildcard deprecated/*.c))
58
84
  ZSTD_FILES := $(ZSTDCOMMON_FILES)
59
85
 
60
86
  ifeq ($(findstring GCC,$(CCVER)),GCC)
61
- decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
62
- endif
63
-
64
- # This is a helper variable that configures a bunch of other variables to new,
65
- # space-optimized defaults.
66
- ZSTD_LIB_MINIFY ?= 0
67
- ifneq ($(ZSTD_LIB_MINIFY), 0)
68
- HAVE_CC_OZ ?= $(shell echo "" | $(CC) -Oz -x c -c - -o /dev/null 2> /dev/null && echo 1 || echo 0)
69
- ZSTD_LEGACY_SUPPORT ?= 0
70
- ZSTD_LIB_DEPRECATED ?= 0
71
- HUF_FORCE_DECOMPRESS_X1 ?= 1
72
- ZSTD_FORCE_DECOMPRESS_SHORT ?= 1
73
- ZSTD_NO_INLINE ?= 1
74
- ZSTD_STRIP_ERROR_STRINGS ?= 1
75
- ifneq ($(HAVE_CC_OZ), 0)
76
- # Some compilers (clang) support an even more space-optimized setting.
77
- CFLAGS += -Oz
78
- else
79
- CFLAGS += -Os
80
- endif
81
- CFLAGS += -fno-stack-protector -fomit-frame-pointer -fno-ident \
82
- -DDYNAMIC_BMI2=0 -DNDEBUG
83
- else
84
- CFLAGS += -O3
87
+ decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
85
88
  endif
86
89
 
87
90
  # Modules
@@ -103,116 +106,187 @@ ZSTD_NO_INLINE ?= 0
103
106
  ZSTD_STRIP_ERROR_STRINGS ?= 0
104
107
 
105
108
  ifeq ($(ZSTD_LIB_COMPRESSION), 0)
106
- ZSTD_LIB_DICTBUILDER = 0
107
- ZSTD_LIB_DEPRECATED = 0
109
+ ZSTD_LIB_DICTBUILDER = 0
110
+ ZSTD_LIB_DEPRECATED = 0
108
111
  endif
109
112
 
110
113
  ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
111
- ZSTD_LEGACY_SUPPORT = 0
112
- ZSTD_LIB_DEPRECATED = 0
114
+ ZSTD_LEGACY_SUPPORT = 0
115
+ ZSTD_LIB_DEPRECATED = 0
113
116
  endif
114
117
 
115
118
  ifneq ($(ZSTD_LIB_COMPRESSION), 0)
116
- ZSTD_FILES += $(ZSTDCOMP_FILES)
119
+ ZSTD_FILES += $(ZSTDCOMP_FILES)
117
120
  endif
118
121
 
119
122
  ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
120
- ZSTD_FILES += $(ZSTDDECOMP_FILES)
123
+ ZSTD_FILES += $(ZSTDDECOMP_FILES)
121
124
  endif
122
125
 
123
126
  ifneq ($(ZSTD_LIB_DEPRECATED), 0)
124
- ZSTD_FILES += $(ZDEPR_FILES)
127
+ ZSTD_FILES += $(ZDEPR_FILES)
125
128
  endif
126
129
 
127
130
  ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
128
- ZSTD_FILES += $(ZDICT_FILES)
131
+ ZSTD_FILES += $(ZDICT_FILES)
129
132
  endif
130
133
 
131
134
  ifneq ($(HUF_FORCE_DECOMPRESS_X1), 0)
132
- CFLAGS += -DHUF_FORCE_DECOMPRESS_X1
135
+ CFLAGS += -DHUF_FORCE_DECOMPRESS_X1
133
136
  endif
134
137
 
135
138
  ifneq ($(HUF_FORCE_DECOMPRESS_X2), 0)
136
- CFLAGS += -DHUF_FORCE_DECOMPRESS_X2
139
+ CFLAGS += -DHUF_FORCE_DECOMPRESS_X2
137
140
  endif
138
141
 
139
142
  ifneq ($(ZSTD_FORCE_DECOMPRESS_SHORT), 0)
140
- CFLAGS += -DZSTD_FORCE_DECOMPRESS_SHORT
143
+ CFLAGS += -DZSTD_FORCE_DECOMPRESS_SHORT
141
144
  endif
142
145
 
143
146
  ifneq ($(ZSTD_FORCE_DECOMPRESS_LONG), 0)
144
- CFLAGS += -DZSTD_FORCE_DECOMPRESS_LONG
147
+ CFLAGS += -DZSTD_FORCE_DECOMPRESS_LONG
145
148
  endif
146
149
 
147
150
  ifneq ($(ZSTD_NO_INLINE), 0)
148
- CFLAGS += -DZSTD_NO_INLINE
151
+ CFLAGS += -DZSTD_NO_INLINE
149
152
  endif
150
153
 
151
154
  ifneq ($(ZSTD_STRIP_ERROR_STRINGS), 0)
152
- CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
155
+ CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
153
156
  endif
154
157
 
155
158
  ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
156
- CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
159
+ CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
157
160
  endif
158
161
 
159
162
  ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
160
163
  ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
161
- ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
164
+ ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
162
165
  endif
163
166
  endif
164
167
  CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
165
168
 
166
- ZSTD_OBJ := $(patsubst %.c,%.o,$(ZSTD_FILES))
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
+
167
195
 
168
196
  # macOS linker doesn't support -soname, and use different extension
169
197
  # see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
170
- ifeq ($(shell uname), Darwin)
171
- SHARED_EXT = dylib
172
- SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
173
- SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
174
- SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
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)
175
203
  else
176
- SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
177
- SHARED_EXT = so
178
- SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
179
- SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
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)
180
208
  endif
181
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)"
182
216
 
183
- .PHONY: default lib-all all clean install uninstall
184
217
 
185
- default: lib-release
218
+ .PHONY: lib-all all clean install uninstall
186
219
 
187
220
  # alias
188
221
  lib-all: all
189
222
 
190
223
  all: lib
191
224
 
192
- libzstd.a: ARFLAGS = rcs
193
- libzstd.a: $(ZSTD_OBJ)
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)
194
242
  @echo compiling static library
195
- $(Q)$(AR) $(ARFLAGS) $@ $^
243
+ $(AR) $(ARFLAGS) $@ $^
244
+
245
+ libzstd.a: $(ZSTD_STATLIB)
246
+ cp -f $< $@
247
+
248
+ endif
196
249
 
197
250
  ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
198
251
 
199
- LIBZSTD = dll\libzstd.dll
252
+ LIBZSTD = dll/libzstd.dll
200
253
  $(LIBZSTD): $(ZSTD_FILES)
201
254
  @echo compiling dynamic library $(LIBVER)
202
- $(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll\libzstd.dll.a -shared $^ -o $@
255
+ $(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@
203
256
 
204
- else
257
+ else # not Windows
205
258
 
206
259
  LIBZSTD = libzstd.$(SHARED_EXT_VER)
207
- $(LIBZSTD): LDFLAGS += -shared -fPIC -fvisibility=hidden
208
- $(LIBZSTD): $(ZSTD_FILES)
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)
209
279
  @echo compiling dynamic library $(LIBVER)
210
- $(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
280
+ $(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
211
281
  @echo creating versioned links
212
- $(Q)ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
213
- $(Q)ln -sf $@ libzstd.$(SHARED_EXT)
282
+ ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
283
+ ln -sf $@ libzstd.$(SHARED_EXT)
214
284
 
215
- endif
285
+ $(LIBZSTD): $(ZSTD_DYNLIB)
286
+ cp -f $< $@
287
+
288
+ endif # ifndef BUILD_DIR
289
+ endif # if windows
216
290
 
217
291
  .PHONY: libzstd
218
292
  libzstd : $(LIBZSTD)
@@ -220,18 +294,42 @@ libzstd : $(LIBZSTD)
220
294
  .PHONY: lib
221
295
  lib : libzstd.a libzstd
222
296
 
223
- .PHONY: lib-mt
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
+
224
301
  %-mt : CPPFLAGS += -DZSTD_MULTITHREAD
225
302
  %-mt : LDFLAGS += -pthread
226
303
  %-mt : %
227
304
  @echo multi-threading build completed
228
305
 
229
- .PHONY: lib-release
230
306
  %-release : DEBUGFLAGS :=
231
307
  %-release : %
232
308
  @echo release build completed
233
309
 
234
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
+
235
333
  # Special case : building library in single-thread mode _and_ without zstdmt_compress.c
236
334
  ZSTDMT_FILES = compress/zstdmt_compress.c
237
335
  ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
@@ -239,22 +337,24 @@ libzstd-nomt: LDFLAGS += -shared -fPIC -fvisibility=hidden
239
337
  libzstd-nomt: $(ZSTD_NOMT_FILES)
240
338
  @echo compiling single-thread dynamic library $(LIBVER)
241
339
  @echo files : $(ZSTD_NOMT_FILES)
242
- $(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
340
+ $(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
243
341
 
244
342
  clean:
245
- $(Q)$(RM) -r *.dSYM # macOS-specific
246
- $(Q)$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
247
- $(Q)$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
248
- $(Q)$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
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/*
249
347
  @echo Cleaning library completed
250
348
 
251
349
  #-----------------------------------------------------------------------------
252
350
  # make install is validated only for below listed environments
253
351
  #-----------------------------------------------------------------------------
254
- ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
352
+ ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
255
353
 
256
354
  all: libzstd.pc
257
355
 
356
+ HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,)
357
+
258
358
  DESTDIR ?=
259
359
  # directory variables : GNU conventions prefer lowercase
260
360
  # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
@@ -268,35 +368,28 @@ LIBDIR ?= $(libdir)
268
368
  includedir ?= $(PREFIX)/include
269
369
  INCLUDEDIR ?= $(includedir)
270
370
 
271
- PCLIBDIR ?= $(shell echo "$(LIBDIR)" | sed -n -E -e "s@^$(EXEC_PREFIX)(/|$$)@@p")
272
- PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | sed -n -E -e "s@^$(PREFIX)(/|$$)@@p")
371
+ PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
372
+ PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
273
373
 
274
- ifeq (,$(PCLIBDIR))
275
- # Additional prefix check is required, since the empty string is technically a
276
- # valid PCLIBDIR
277
- ifeq (,$(shell echo "$(LIBDIR)" | sed -n -E -e "\\@^$(EXEC_PREFIX)(/|$$)@ p"))
278
- $(error configured libdir ($(LIBDIR)) is outside of prefix ($(PREFIX)), can't generate pkg-config file)
279
- endif
280
- endif
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})
281
378
 
282
- ifeq (,$(PCINCDIR))
283
- # Additional prefix check is required, since the empty string is technically a
284
- # valid PCINCDIR
285
- ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n -E -e "\\@^$(PREFIX)(/|$$)@ p"))
286
- $(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(EXEC_PREFIX)), can't generate pkg-config file)
287
- endif
288
- endif
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})
289
382
 
290
- ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
291
- PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
383
+ ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
384
+ PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
292
385
  else
293
- PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
386
+ PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
294
387
  endif
295
388
 
296
- ifneq (,$(filter $(shell uname),SunOS))
297
- INSTALL ?= ginstall
389
+ ifneq (,$(filter $(UNAME),SunOS))
390
+ INSTALL ?= ginstall
298
391
  else
299
- INSTALL ?= install
392
+ INSTALL ?= install
300
393
  endif
301
394
 
302
395
  INSTALL_PROGRAM ?= $(INSTALL)
@@ -306,9 +399,11 @@ INSTALL_DATA ?= $(INSTALL) -m 644
306
399
  libzstd.pc:
307
400
  libzstd.pc: libzstd.pc.in
308
401
  @echo creating pkgconfig
309
- $(Q)@sed -E -e 's|@PREFIX@|$(PREFIX)|' \
310
- -e 's|@LIBDIR@|$(PCLIBDIR)|' \
311
- -e 's|@INCLUDEDIR@|$(PCINCDIR)|' \
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)|' \
312
407
  -e 's|@VERSION@|$(VERSION)|' \
313
408
  $< >$@
314
409
 
@@ -316,39 +411,41 @@ install: install-pc install-static install-shared install-includes
316
411
  @echo zstd static and shared library installed
317
412
 
318
413
  install-pc: libzstd.pc
319
- $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
320
- $(Q)$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
414
+ [ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
415
+ $(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
321
416
 
322
- install-static: libzstd.a
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)/
323
421
  @echo Installing static library
324
- $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
325
- $(Q)$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
422
+ $(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
326
423
 
327
- install-shared: libzstd
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)/
328
428
  @echo Installing shared library
329
- $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
330
- $(Q)$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
331
- $(Q)ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
332
- $(Q)ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
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)
333
432
 
334
433
  install-includes:
434
+ [ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
335
435
  @echo Installing includes
336
- $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
337
- $(Q)$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
338
- $(Q)$(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
339
- $(Q)$(INSTALL_DATA) deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
340
- $(Q)$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
436
+ $(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
437
+ $(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
438
+ $(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
341
439
 
342
440
  uninstall:
343
- $(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
344
- $(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
345
- $(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
346
- $(Q)$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
347
- $(Q)$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
348
- $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
349
- $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
350
- $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zbuff.h # Deprecated streaming functions
351
- $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
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
352
449
  @echo zstd libraries successfully uninstalled
353
450
 
354
451
  endif