]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | # ################################################################ |
2 | # Copyright (c) 2015-present, Yann Collet, Facebook, Inc. | |
7c673cae FG |
3 | # All rights reserved. |
4 | # | |
11fdf7f2 TL |
5 | # This source code is licensed under both the BSD-style license (found in the |
6 | # LICENSE file in the root directory of this source tree) and the GPLv2 (found | |
7 | # in the COPYING file in the root directory of this source tree). | |
7c673cae FG |
8 | # ########################################################################## |
9 | # zstd : Command Line Utility, supporting gzip-like arguments | |
10 | # zstd32 : Same as zstd, but forced to compile in 32-bits mode | |
11 | # zstd_nolegacy : zstd without support of decompression of legacy versions | |
12 | # zstd-small : minimal zstd without dictionary builder and benchmark | |
13 | # zstd-compress : compressor-only version of zstd | |
14 | # zstd-decompress : decompressor-only version of zstd | |
15 | # ########################################################################## | |
16 | ||
7c673cae FG |
17 | ZSTDDIR = ../lib |
18 | ||
11fdf7f2 TL |
19 | # Version numbers |
20 | LIBVER_SRC := $(ZSTDDIR)/zstd.h | |
21 | LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)` | |
22 | LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)` | |
23 | LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)` | |
24 | LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT) | |
25 | LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT)) | |
26 | LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT)) | |
27 | LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT)) | |
28 | LIBVER := $(shell echo $(LIBVER_SCRIPT)) | |
29 | ||
9f95a23c | 30 | ZSTD_VERSION = $(LIBVER) |
11fdf7f2 | 31 | |
9f95a23c TL |
32 | HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0) |
33 | GREP_OPTIONS ?= | |
34 | ifeq ($HAVE_COLORNEVER, 1) | |
35 | GREP_OPTIONS += --color=never | |
36 | endif | |
37 | GREP = grep $(GREP_OPTIONS) | |
38 | ||
39 | ifeq ($(shell $(CC) -v 2>&1 | $(GREP) -c "gcc version "), 1) | |
7c673cae FG |
40 | ALIGN_LOOP = -falign-loops=32 |
41 | else | |
42 | ALIGN_LOOP = | |
43 | endif | |
44 | ||
11fdf7f2 TL |
45 | CPPFLAGS+= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \ |
46 | -I$(ZSTDDIR)/dictBuilder \ | |
9f95a23c TL |
47 | -DXXH_NAMESPACE=ZSTD_ |
48 | ifeq ($(OS),Windows_NT) # MinGW assumed | |
49 | CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting | |
50 | endif | |
7c673cae | 51 | CFLAGS ?= -O3 |
11fdf7f2 TL |
52 | DEBUGFLAGS+=-Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ |
53 | -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \ | |
9f95a23c | 54 | -Wstrict-prototypes -Wundef -Wpointer-arith \ |
11fdf7f2 | 55 | -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ |
9f95a23c | 56 | -Wredundant-decls -Wmissing-prototypes -Wc++-compat |
11fdf7f2 | 57 | CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) |
7c673cae FG |
58 | FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) |
59 | ||
60 | ||
61 | ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c | |
11fdf7f2 TL |
62 | ZSTDCOMP_FILES := $(ZSTDDIR)/compress/*.c |
63 | ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/*.c | |
7c673cae FG |
64 | ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) |
65 | ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c | |
66 | ZSTDDECOMP_O = $(ZSTDDIR)/decompress/zstd_decompress.o | |
67 | ||
9f95a23c | 68 | ZSTD_LEGACY_SUPPORT ?= 5 |
11fdf7f2 TL |
69 | ZSTDLEGACY_FILES := |
70 | ifneq ($(ZSTD_LEGACY_SUPPORT), 0) | |
71 | ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0) | |
9f95a23c | 72 | ZSTDLEGACY_FILES += $(shell ls $(ZSTDDIR)/legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]') |
11fdf7f2 TL |
73 | endif |
74 | CPPFLAGS += -I$(ZSTDDIR)/legacy | |
7c673cae | 75 | else |
7c673cae FG |
76 | endif |
77 | ||
9f95a23c | 78 | # Sort files in alphabetical order for reproducible builds |
11fdf7f2 | 79 | ZSTDLIB_FILES := $(sort $(wildcard $(ZSTD_FILES)) $(wildcard $(ZSTDLEGACY_FILES)) $(wildcard $(ZDICT_FILES))) |
7c673cae FG |
80 | |
81 | # Define *.exe as extension for Windows systems | |
82 | ifneq (,$(filter Windows%,$(OS))) | |
83 | EXT =.exe | |
84 | RES64_FILE = windres/zstd64.res | |
85 | RES32_FILE = windres/zstd32.res | |
86 | ifneq (,$(filter x86_64%,$(shell $(CC) -dumpmachine))) | |
87 | RES_FILE = $(RES64_FILE) | |
88 | else | |
89 | RES_FILE = $(RES32_FILE) | |
90 | endif | |
91 | else | |
92 | EXT = | |
93 | endif | |
94 | ||
11fdf7f2 TL |
95 | VOID = /dev/null |
96 | ||
97 | # thread detection | |
98 | NO_THREAD_MSG := ==> no threads, building without multithreading support | |
9f95a23c | 99 | HAVE_PTHREAD := $(shell printf '\#include <pthread.h>\nint main(void) { return 0; }' > have_pthread.c && $(CC) $(FLAGS) -o have_pthread$(EXT) have_pthread.c -pthread 2> $(VOID) && rm have_pthread$(EXT) && echo 1 || echo 0; rm have_pthread.c) |
11fdf7f2 TL |
100 | HAVE_THREAD := $(shell [ "$(HAVE_PTHREAD)" -eq "1" -o -n "$(filter Windows%,$(OS))" ] && echo 1 || echo 0) |
101 | ifeq ($(HAVE_THREAD), 1) | |
102 | THREAD_MSG := ==> building with threading support | |
103 | THREAD_CPP := -DZSTD_MULTITHREAD | |
104 | THREAD_LD := -pthread | |
105 | else | |
106 | THREAD_MSG := $(NO_THREAD_MSG) | |
107 | endif | |
108 | ||
109 | # zlib detection | |
110 | NO_ZLIB_MSG := ==> no zlib, building zstd without .gz support | |
9f95a23c | 111 | HAVE_ZLIB := $(shell printf '\#include <zlib.h>\nint main(void) { return 0; }' > have_zlib.c && $(CC) $(FLAGS) -o have_zlib$(EXT) have_zlib.c -lz 2> $(VOID) && rm have_zlib$(EXT) && echo 1 || echo 0; rm have_zlib.c) |
11fdf7f2 TL |
112 | ifeq ($(HAVE_ZLIB), 1) |
113 | ZLIB_MSG := ==> building zstd with .gz compression support | |
114 | ZLIBCPP = -DZSTD_GZCOMPRESS -DZSTD_GZDECOMPRESS | |
115 | ZLIBLD = -lz | |
116 | else | |
117 | ZLIB_MSG := $(NO_ZLIB_MSG) | |
118 | endif | |
119 | ||
120 | # lzma detection | |
121 | NO_LZMA_MSG := ==> no liblzma, building zstd without .xz/.lzma support | |
9f95a23c | 122 | HAVE_LZMA := $(shell printf '\#include <lzma.h>\nint main(void) { return 0; }' > have_lzma.c && $(CC) $(FLAGS) -o have_lzma$(EXT) have_lzma.c -llzma 2> $(VOID) && rm have_lzma$(EXT) && echo 1 || echo 0; rm have_lzma.c) |
11fdf7f2 TL |
123 | ifeq ($(HAVE_LZMA), 1) |
124 | LZMA_MSG := ==> building zstd with .xz/.lzma compression support | |
125 | LZMACPP = -DZSTD_LZMACOMPRESS -DZSTD_LZMADECOMPRESS | |
126 | LZMALD = -llzma | |
127 | else | |
128 | LZMA_MSG := $(NO_LZMA_MSG) | |
129 | endif | |
7c673cae | 130 | |
11fdf7f2 TL |
131 | # lz4 detection |
132 | NO_LZ4_MSG := ==> no liblz4, building zstd without .lz4 support | |
9f95a23c | 133 | HAVE_LZ4 := $(shell printf '\#include <lz4frame.h>\n\#include <lz4.h>\nint main(void) { return 0; }' > have_lz4.c && $(CC) $(FLAGS) -o have_lz4$(EXT) have_lz4.c -llz4 2> $(VOID) && rm have_lz4$(EXT) && echo 1 || echo 0; rm have_lz4.c) |
11fdf7f2 TL |
134 | ifeq ($(HAVE_LZ4), 1) |
135 | LZ4_MSG := ==> building zstd with .lz4 compression support | |
136 | LZ4CPP = -DZSTD_LZ4COMPRESS -DZSTD_LZ4DECOMPRESS | |
137 | LZ4LD = -llz4 | |
138 | else | |
139 | LZ4_MSG := $(NO_LZ4_MSG) | |
140 | endif | |
7c673cae | 141 | |
9f95a23c TL |
142 | # explicit backtrace enable/disable for Linux & Darwin |
143 | ifeq ($(BACKTRACE), 0) | |
144 | DEBUGFLAGS += -DBACKTRACE_ENABLE=0 | |
145 | endif | |
146 | ifeq (,$(filter Windows%, $(OS))) | |
147 | ifeq ($(BACKTRACE), 1) | |
148 | DEBUGFLAGS += -DBACKTRACE_ENABLE=1 | |
149 | DEBUGFLAGS_LD += -rdynamic | |
150 | endif | |
151 | endif | |
152 | ||
153 | ||
11fdf7f2 TL |
154 | .PHONY: default |
155 | default: zstd-release | |
7c673cae | 156 | |
11fdf7f2 | 157 | .PHONY: all |
7c673cae FG |
158 | all: zstd |
159 | ||
11fdf7f2 TL |
160 | .PHONY: allVariants |
161 | allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy | |
162 | ||
7c673cae FG |
163 | $(ZSTDDECOMP_O): CFLAGS += $(ALIGN_LOOP) |
164 | ||
11fdf7f2 | 165 | zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP) |
9f95a23c | 166 | zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD) |
11fdf7f2 | 167 | zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) |
9f95a23c | 168 | zstd : $(ZSTDLIB_FILES) zstdcli.o util.o timefn.o fileio.o benchfn.o benchzstd.o datagen.o dibio.o |
11fdf7f2 TL |
169 | @echo "$(THREAD_MSG)" |
170 | @echo "$(ZLIB_MSG)" | |
171 | @echo "$(LZMA_MSG)" | |
172 | @echo "$(LZ4_MSG)" | |
7c673cae FG |
173 | ifneq (,$(filter Windows%,$(OS))) |
174 | windres/generate_res.bat | |
175 | endif | |
176 | $(CC) $(FLAGS) $^ $(RES_FILE) -o $@$(EXT) $(LDFLAGS) | |
177 | ||
11fdf7f2 | 178 | .PHONY: zstd-release |
9f95a23c TL |
179 | zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0 |
180 | zstd-release: DEBUGFLAGS_LD := | |
11fdf7f2 | 181 | zstd-release: zstd |
7c673cae | 182 | |
9f95a23c TL |
183 | zstd32 : CPPFLAGS += $(THREAD_CPP) |
184 | zstd32 : LDFLAGS += $(THREAD_LD) | |
7c673cae | 185 | zstd32 : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) |
9f95a23c | 186 | zstd32 : $(ZSTDLIB_FILES) zstdcli.c util.c timefn.c fileio.c benchfn.c benchzstd.c datagen.c dibio.c |
7c673cae FG |
187 | ifneq (,$(filter Windows%,$(OS))) |
188 | windres/generate_res.bat | |
189 | endif | |
190 | $(CC) -m32 $(FLAGS) $^ $(RES32_FILE) -o $@$(EXT) | |
191 | ||
9f95a23c | 192 | zstd-nolegacy : $(ZSTD_FILES) $(ZDICT_FILES) zstdcli.o util.o fileio.c benchfn.o benchzstd.o timefn.o datagen.o dibio.o |
11fdf7f2 TL |
193 | $(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS) |
194 | ||
195 | zstd-nomt : THREAD_CPP := | |
9f95a23c | 196 | zstd-nomt : THREAD_LD := |
11fdf7f2 TL |
197 | zstd-nomt : THREAD_MSG := - multi-threading disabled |
198 | zstd-nomt : zstd | |
199 | ||
200 | zstd-nogz : ZLIBCPP := | |
9f95a23c | 201 | zstd-nogz : ZLIBLD := |
11fdf7f2 TL |
202 | zstd-nogz : ZLIB_MSG := - gzip support is disabled |
203 | zstd-nogz : zstd | |
204 | ||
205 | zstd-noxz : LZMACPP := | |
9f95a23c | 206 | zstd-noxz : LZMALD := |
11fdf7f2 TL |
207 | zstd-noxz : LZMA_MSG := - xz/lzma support is disabled |
208 | zstd-noxz : zstd | |
7c673cae | 209 | |
7c673cae | 210 | |
9f95a23c TL |
211 | zstd-pgo : |
212 | $(MAKE) clean | |
213 | $(MAKE) zstd MOREFLAGS=-fprofile-generate | |
7c673cae FG |
214 | ./zstd -b19i1 $(PROFILE_WITH) |
215 | ./zstd -b16i1 $(PROFILE_WITH) | |
216 | ./zstd -b9i2 $(PROFILE_WITH) | |
217 | ./zstd -b $(PROFILE_WITH) | |
218 | ./zstd -b7i2 $(PROFILE_WITH) | |
219 | ./zstd -b5 $(PROFILE_WITH) | |
9f95a23c | 220 | $(RM) zstd *.o $(ZSTDDECOMP_O) $(ZSTDDIR)/compress/*.o |
7c673cae FG |
221 | $(MAKE) zstd MOREFLAGS=-fprofile-use |
222 | ||
11fdf7f2 TL |
223 | # minimal target, with only zstd compression and decompression. no bench. no legacy. |
224 | zstd-small: CFLAGS = -Os -s | |
9f95a23c | 225 | zstd-frugal zstd-small: $(ZSTD_FILES) zstdcli.c util.c timefn.c fileio.c |
11fdf7f2 | 226 | $(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT $^ -o $@$(EXT) |
7c673cae | 227 | |
9f95a23c | 228 | zstd-decompress: $(ZSTDCOMMON_FILES) $(ZSTDDECOMP_FILES) zstdcli.c util.c timefn.c fileio.c |
11fdf7f2 | 229 | $(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOCOMPRESS $^ -o $@$(EXT) |
7c673cae | 230 | |
9f95a23c | 231 | zstd-compress: $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) zstdcli.c util.c timefn.c fileio.c |
7c673cae FG |
232 | $(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NODECOMPRESS $^ -o $@$(EXT) |
233 | ||
11fdf7f2 TL |
234 | zstdmt: zstd |
235 | ln -sf zstd zstdmt | |
7c673cae | 236 | |
11fdf7f2 | 237 | .PHONY: generate_res |
7c673cae FG |
238 | generate_res: |
239 | windres/generate_res.bat | |
240 | ||
11fdf7f2 | 241 | .PHONY: clean |
7c673cae | 242 | clean: |
11fdf7f2 | 243 | $(MAKE) -C $(ZSTDDIR) clean |
7c673cae FG |
244 | @$(RM) $(ZSTDDIR)/decompress/*.o $(ZSTDDIR)/decompress/zstd_decompress.gcda |
245 | @$(RM) core *.o tmp* result* *.gcda dictionary *.zst \ | |
246 | zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) \ | |
11fdf7f2 TL |
247 | zstd-small$(EXT) zstd-frugal$(EXT) zstd-nolegacy$(EXT) zstd4$(EXT) \ |
248 | *.gcda default.profraw have_zlib$(EXT) | |
7c673cae FG |
249 | @echo Cleaning completed |
250 | ||
11fdf7f2 TL |
251 | MD2ROFF = ronn |
252 | MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="zstd $(ZSTD_VERSION)" | |
253 | ||
9f95a23c TL |
254 | zstd.1: zstd.1.md ../lib/zstd.h |
255 | cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@ | |
256 | ||
257 | zstdgrep.1: zstdgrep.1.md ../lib/zstd.h | |
258 | cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@ | |
259 | ||
260 | zstdless.1: zstdless.1.md ../lib/zstd.h | |
261 | cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@ | |
11fdf7f2 TL |
262 | |
263 | .PHONY: man | |
9f95a23c | 264 | man: zstd.1 zstdgrep.1 zstdless.1 |
11fdf7f2 TL |
265 | |
266 | .PHONY: clean-man | |
267 | clean-man: | |
9f95a23c TL |
268 | $(RM) zstd.1 |
269 | $(RM) zstdgrep.1 | |
270 | $(RM) zstdless.1 | |
11fdf7f2 TL |
271 | |
272 | .PHONY: preview-man | |
273 | preview-man: clean-man man | |
274 | man ./zstd.1 | |
9f95a23c TL |
275 | man ./zstdgrep.1 |
276 | man ./zstdless.1 | |
11fdf7f2 TL |
277 | |
278 | #----------------------------------------------------------------------------- | |
9f95a23c | 279 | # make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets |
11fdf7f2 | 280 | #----------------------------------------------------------------------------- |
9f95a23c | 281 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku)) |
11fdf7f2 | 282 | |
9f95a23c TL |
283 | HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0) |
284 | EGREP_OPTIONS ?= | |
285 | ifeq ($HAVE_COLORNEVER, 1) | |
286 | EGREP_OPTIONS += --color=never | |
287 | endif | |
288 | EGREP = egrep $(EGREP_OPTIONS) | |
289 | ||
290 | # Print a two column output of targets and their description. To add a target description, put a | |
291 | # comment in the Makefile with the format "## <TARGET>: <DESCRIPTION>". For example: | |
292 | # | |
293 | ## list: Print all targets and their descriptions (if provided) | |
11fdf7f2 TL |
294 | .PHONY: list |
295 | list: | |
9f95a23c TL |
296 | @TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \ |
297 | | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \ | |
298 | | $(EGREP) -v -e '^[^[:alnum:]]' | sort); \ | |
299 | { \ | |
300 | printf "Target Name\tDescription\n"; \ | |
301 | printf "%0.s-" {1..16}; printf "\t"; printf "%0.s-" {1..40}; printf "\n"; \ | |
302 | for target in $$TARGETS; do \ | |
303 | line=$$($(EGREP) "^##[[:space:]]+$$target:" $(lastword $(MAKEFILE_LIST))); \ | |
304 | description=$$(echo $$line | awk '{i=index($$0,":"); print substr($$0,i+1)}' | xargs); \ | |
305 | printf "$$target\t$$description\n"; \ | |
306 | done \ | |
307 | } | column -t -s $$'\t' | |
308 | ||
11fdf7f2 TL |
309 | |
310 | DESTDIR ?= | |
311 | # directory variables : GNU conventions prefer lowercase | |
312 | # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html | |
313 | # support both lower and uppercase (BSD), use uppercase in script | |
314 | prefix ?= /usr/local | |
315 | PREFIX ?= $(prefix) | |
316 | exec_prefix ?= $(PREFIX) | |
317 | bindir ?= $(exec_prefix)/bin | |
318 | BINDIR ?= $(bindir) | |
319 | datarootdir ?= $(PREFIX)/share | |
320 | mandir ?= $(datarootdir)/man | |
321 | man1dir ?= $(mandir)/man1 | |
322 | ||
323 | ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS)) | |
9f95a23c TL |
324 | MANDIR ?= $(PREFIX)/man |
325 | MAN1DIR ?= $(MANDIR)/man1 | |
11fdf7f2 | 326 | else |
9f95a23c | 327 | MAN1DIR ?= $(man1dir) |
11fdf7f2 | 328 | endif |
7c673cae | 329 | |
11fdf7f2 TL |
330 | ifneq (,$(filter $(shell uname),SunOS)) |
331 | INSTALL ?= ginstall | |
332 | else | |
333 | INSTALL ?= install | |
334 | endif | |
335 | ||
336 | INSTALL_PROGRAM ?= $(INSTALL) | |
337 | INSTALL_SCRIPT ?= $(INSTALL_PROGRAM) | |
338 | INSTALL_DATA ?= $(INSTALL) -m 644 | |
339 | INSTALL_MAN ?= $(INSTALL_DATA) | |
7c673cae | 340 | |
11fdf7f2 | 341 | .PHONY: install |
7c673cae FG |
342 | install: zstd |
343 | @echo Installing binaries | |
9f95a23c | 344 | @$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MAN1DIR)/ |
11fdf7f2 | 345 | @$(INSTALL_PROGRAM) zstd $(DESTDIR)$(BINDIR)/zstd |
7c673cae FG |
346 | @ln -sf zstd $(DESTDIR)$(BINDIR)/zstdcat |
347 | @ln -sf zstd $(DESTDIR)$(BINDIR)/unzstd | |
11fdf7f2 TL |
348 | @ln -sf zstd $(DESTDIR)$(BINDIR)/zstdmt |
349 | @$(INSTALL_SCRIPT) zstdless $(DESTDIR)$(BINDIR)/zstdless | |
350 | @$(INSTALL_SCRIPT) zstdgrep $(DESTDIR)$(BINDIR)/zstdgrep | |
7c673cae | 351 | @echo Installing man pages |
9f95a23c TL |
352 | @$(INSTALL_MAN) zstd.1 $(DESTDIR)$(MAN1DIR)/zstd.1 |
353 | @ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/zstdcat.1 | |
354 | @ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/unzstd.1 | |
355 | @$(INSTALL_MAN) zstdgrep.1 $(DESTDIR)$(MAN1DIR)/zstdgrep.1 | |
356 | @$(INSTALL_MAN) zstdless.1 $(DESTDIR)$(MAN1DIR)/zstdless.1 | |
7c673cae FG |
357 | @echo zstd installation completed |
358 | ||
11fdf7f2 | 359 | .PHONY: uninstall |
7c673cae FG |
360 | uninstall: |
361 | @$(RM) $(DESTDIR)$(BINDIR)/zstdgrep | |
362 | @$(RM) $(DESTDIR)$(BINDIR)/zstdless | |
363 | @$(RM) $(DESTDIR)$(BINDIR)/zstdcat | |
364 | @$(RM) $(DESTDIR)$(BINDIR)/unzstd | |
9f95a23c | 365 | @$(RM) $(DESTDIR)$(BINDIR)/zstdmt |
7c673cae | 366 | @$(RM) $(DESTDIR)$(BINDIR)/zstd |
9f95a23c TL |
367 | @$(RM) $(DESTDIR)$(MAN1DIR)/zstdless.1 |
368 | @$(RM) $(DESTDIR)$(MAN1DIR)/zstdgrep.1 | |
369 | @$(RM) $(DESTDIR)$(MAN1DIR)/zstdcat.1 | |
370 | @$(RM) $(DESTDIR)$(MAN1DIR)/unzstd.1 | |
371 | @$(RM) $(DESTDIR)$(MAN1DIR)/zstd.1 | |
7c673cae | 372 | @echo zstd programs successfully uninstalled |
11fdf7f2 | 373 | |
7c673cae | 374 | endif |