| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 1 | # ########################################################################## |
| 2 | # ZSTD programs - Makefile |
| Yann Collet | 648959a | 2016-02-07 23:58:32 +0100 | [diff] [blame] | 3 | # Copyright (C) Yann Collet 2015-2016 |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 4 | # |
| 5 | # GPL v2 License |
| 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 2 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License along |
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | # |
| 21 | # You can contact the author at : |
| Yann Collet | 648959a | 2016-02-07 23:58:32 +0100 | [diff] [blame] | 22 | # - zstd homepage : http://www.zstd.net/ |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 23 | # ########################################################################## |
| 24 | # zstd : Command Line Utility, supporting gzip-like arguments |
| inikep | 2868d56 | 2016-08-18 13:18:11 +0200 | [diff] [blame] | 25 | # zstd32 : Same as zstd, but forced to compile in 32-bits mode |
| 26 | # zstd_nolegacy : zstd without support of decompression of legacy versions |
| inikep | ab2f770 | 2016-08-25 10:07:20 +0200 | [diff] [blame] | 27 | # zstd-small : minimal zstd without dictionary builder and benchmark |
| 28 | # zstd-compress : compressor-only version of zstd |
| 29 | # zstd-decompress : decompressor-only version of zstd |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 30 | # ########################################################################## |
| 31 | |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 32 | DESTDIR?= |
| Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 33 | PREFIX ?= /usr/local |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 34 | BINDIR = $(PREFIX)/bin |
| 35 | MANDIR = $(PREFIX)/share/man/man1 |
| 36 | |
| 37 | ZSTDDIR = ../lib |
| 38 | |
| Yann Collet | 5e45a5f | 2016-07-21 18:36:50 -0700 | [diff] [blame] | 39 | ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version "), 1) |
| 40 | ALIGN_LOOP = -falign-loops=32 |
| 41 | else |
| 42 | ALIGN_LOOP = |
| 43 | endif |
| 44 | |
| Yann Collet | 666398e | 2016-08-10 08:14:48 +0200 | [diff] [blame] | 45 | CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder |
| Yann Collet | 5e45a5f | 2016-07-21 18:36:50 -0700 | [diff] [blame] | 46 | CFLAGS ?= -O3 |
| Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 47 | CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \ |
| 48 | -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef |
| Yann Collet | e5a817a | 2016-07-24 17:46:05 +0200 | [diff] [blame] | 49 | CFLAGS += $(MOREFLAGS) |
| 50 | FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 51 | |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 52 | |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 53 | ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c |
| Yann Collet | 0c5e8b1 | 2016-05-29 01:06:30 +0200 | [diff] [blame] | 54 | ZSTDCOMP_FILES := $(ZSTDDIR)/compress/zstd_compress.c $(ZSTDDIR)/compress/fse_compress.c $(ZSTDDIR)/compress/huf_compress.c |
| inikep | d0c270f | 2016-08-17 15:59:50 +0200 | [diff] [blame] | 55 | ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/huf_decompress.c |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 56 | ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 57 | ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c |
| inikep | d0c270f | 2016-08-17 15:59:50 +0200 | [diff] [blame] | 58 | ZSTDDECOMP_O = $(ZSTDDIR)/decompress/zstd_decompress.o |
| 59 | ZSTDDECOMP32_O = $(ZSTDDIR)/decompress/zstd_decompress32.o |
| Yann Collet | b096cbf | 2015-11-27 16:18:56 +0100 | [diff] [blame] | 60 | |
| Yann Collet | aead1bf | 2015-11-30 14:18:47 +0100 | [diff] [blame] | 61 | ifeq ($(ZSTD_LEGACY_SUPPORT), 0) |
| Yann Collet | b096cbf | 2015-11-27 16:18:56 +0100 | [diff] [blame] | 62 | CPPFLAGS += -DZSTD_LEGACY_SUPPORT=0 |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 63 | ZSTDLEGACY_FILES:= |
| Yann Collet | b096cbf | 2015-11-27 16:18:56 +0100 | [diff] [blame] | 64 | else |
| Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 65 | ZSTD_LEGACY_SUPPORT:=1 |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 66 | CPPFLAGS += -I$(ZSTDDIR)/legacy -I./legacy |
| 67 | ZSTDLEGACY_FILES:= $(ZSTDDIR)/legacy/*.c legacy/fileio_legacy.c |
| Yann Collet | b096cbf | 2015-11-27 16:18:56 +0100 | [diff] [blame] | 68 | endif |
| 69 | |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 70 | |
| 71 | # Define *.exe as extension for Windows systems |
| 72 | ifneq (,$(filter Windows%,$(OS))) |
| 73 | EXT =.exe |
| 74 | VOID = nul |
| 75 | else |
| 76 | EXT = |
| 77 | VOID = /dev/null |
| 78 | endif |
| 79 | |
| Yann Collet | 7447ee9 | 2015-11-26 10:52:30 +0100 | [diff] [blame] | 80 | |
| inikep | 2868d56 | 2016-08-18 13:18:11 +0200 | [diff] [blame] | 81 | .PHONY: default all clean install uninstall |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 82 | |
| 83 | default: zstd |
| 84 | |
| inikep | 2868d56 | 2016-08-18 13:18:11 +0200 | [diff] [blame] | 85 | all: zstd |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 86 | |
| Yann Collet | 5e45a5f | 2016-07-21 18:36:50 -0700 | [diff] [blame] | 87 | |
| inikep | d0c270f | 2016-08-17 15:59:50 +0200 | [diff] [blame] | 88 | $(ZSTDDECOMP_O): $(ZSTDDIR)/decompress/zstd_decompress.c |
| 89 | $(CC) $(ALIGN_LOOP) $(FLAGS) $^ -c -o $@ |
| 90 | |
| 91 | $(ZSTDDECOMP32_O): $(ZSTDDIR)/decompress/zstd_decompress.c |
| 92 | $(CC) -m32 $(ALIGN_LOOP) $(FLAGS) $^ -c -o $@ |
| 93 | |
| 94 | zstd : $(ZSTDDECOMP_O) $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZDICT_FILES) \ |
| Yann Collet | 0c5e8b1 | 2016-05-29 01:06:30 +0200 | [diff] [blame] | 95 | zstdcli.c fileio.c bench.c datagen.c dibio.c |
| inikep | 33ad251 | 2016-03-30 09:55:37 +0200 | [diff] [blame] | 96 | $(CC) $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT) |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 97 | |
| inikep | d0c270f | 2016-08-17 15:59:50 +0200 | [diff] [blame] | 98 | zstd32 : $(ZSTDDECOMP32_O) $(ZSTD_FILES) $(ZSTDLEGACY_FILES) $(ZDICT_FILES) \ |
| 99 | zstdcli.c fileio.c bench.c datagen.c dibio.c |
| 100 | $(CC) -m32 $(FLAGS) -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) $^ -o $@$(EXT) |
| 101 | |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 102 | |
| Yann Collet | a85a8dd | 2015-11-30 11:53:11 +0100 | [diff] [blame] | 103 | zstd_nolegacy : |
| Yann Collet | aead1bf | 2015-11-30 14:18:47 +0100 | [diff] [blame] | 104 | $(MAKE) zstd ZSTD_LEGACY_SUPPORT=0 |
| Yann Collet | a85a8dd | 2015-11-30 11:53:11 +0100 | [diff] [blame] | 105 | |
| Yann Collet | 0338635 | 2015-12-01 01:28:32 +0100 | [diff] [blame] | 106 | zstd-pgo : MOREFLAGS = -fprofile-generate |
| 107 | zstd-pgo : clean zstd |
| Yann Collet | 728c8fc | 2016-02-17 17:04:12 +0100 | [diff] [blame] | 108 | ./zstd -b19i1 $(PROFILE_WITH) |
| 109 | ./zstd -b16i1 $(PROFILE_WITH) |
| 110 | ./zstd -b9i2 $(PROFILE_WITH) |
| Yann Collet | 0338635 | 2015-12-01 01:28:32 +0100 | [diff] [blame] | 111 | ./zstd -b $(PROFILE_WITH) |
| Yann Collet | 728c8fc | 2016-02-17 17:04:12 +0100 | [diff] [blame] | 112 | ./zstd -b7i2 $(PROFILE_WITH) |
| 113 | ./zstd -b5 $(PROFILE_WITH) |
| Yann Collet | 0338635 | 2015-12-01 01:28:32 +0100 | [diff] [blame] | 114 | rm zstd |
| 115 | $(MAKE) zstd MOREFLAGS=-fprofile-use |
| 116 | |
| inikep | 79b4062 | 2016-08-17 16:29:57 +0200 | [diff] [blame] | 117 | zstd-frugal: $(ZSTDDECOMP_O) $(ZSTD_FILES) zstdcli.c fileio.c |
| Yann Collet | c8da2c9 | 2016-02-12 02:56:27 +0100 | [diff] [blame] | 118 | $(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_LEGACY_SUPPORT=0 $^ -o zstd$(EXT) |
| Yann Collet | 28e7cef | 2015-12-03 12:11:30 +0100 | [diff] [blame] | 119 | |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 120 | zstd-compress: $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) \ |
| Yann Collet | 6263ba5 | 2016-08-13 23:45:45 +0200 | [diff] [blame] | 121 | zstdcli.c fileio.c |
| inikep | a1febea | 2016-04-22 17:14:25 +0200 | [diff] [blame] | 122 | $(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NODECOMPRESS -DZSTD_LEGACY_SUPPORT=0 $^ -o $@$(EXT) |
| 123 | |
| Yann Collet | f51e066 | 2016-05-29 01:39:19 +0200 | [diff] [blame] | 124 | zstd-decompress: $(ZSTDCOMMON_FILES) $(ZSTDDECOMP_FILES) \ |
| Yann Collet | 6263ba5 | 2016-08-13 23:45:45 +0200 | [diff] [blame] | 125 | zstdcli.c fileio.c |
| inikep | 3c7c352 | 2016-04-22 13:59:05 +0200 | [diff] [blame] | 126 | $(CC) $(FLAGS) -DZSTD_NOBENCH -DZSTD_NODICT -DZSTD_NOCOMPRESS -DZSTD_LEGACY_SUPPORT=0 $^ -o $@$(EXT) |
| 127 | |
| Yann Collet | fb0ba59 | 2016-05-28 15:30:01 +0200 | [diff] [blame] | 128 | zstd-small: clean |
| 129 | CFLAGS="-Os -s" $(MAKE) zstd-frugal |
| Yann Collet | 28e7cef | 2015-12-03 12:11:30 +0100 | [diff] [blame] | 130 | |
| Yann Collet | fb0ba59 | 2016-05-28 15:30:01 +0200 | [diff] [blame] | 131 | |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 132 | clean: |
| Yann Collet | 5e45a5f | 2016-07-21 18:36:50 -0700 | [diff] [blame] | 133 | $(MAKE) -C ../lib clean |
| inikep | c629776 | 2016-08-19 10:45:59 +0200 | [diff] [blame] | 134 | @rm -f ../lib/decompress/*.o |
| Yann Collet | 71eafdd | 2016-02-12 02:31:57 +0100 | [diff] [blame] | 135 | @rm -f core *.o tmp* result* *.gcda dictionary *.zst \ |
| inikep | 2868d56 | 2016-08-18 13:18:11 +0200 | [diff] [blame] | 136 | zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 137 | @echo Cleaning completed |
| 138 | |
| 139 | |
| jrmarino | 0d07ec0 | 2016-07-30 19:10:36 -0500 | [diff] [blame] | 140 | #---------------------------------------------------------------------------------- |
| 141 | #make install is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets |
| 142 | #---------------------------------------------------------------------------------- |
| 143 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly)) |
| Yann Collet | c620b48 | 2015-12-01 01:56:02 +0100 | [diff] [blame] | 144 | install: zstd |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 145 | @echo Installing binaries |
| 146 | @install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/ |
| 147 | @install -m 755 zstd$(EXT) $(DESTDIR)$(BINDIR)/zstd$(EXT) |
| 148 | @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdcat |
| Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame] | 149 | @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 150 | @echo Installing man pages |
| 151 | @install -m 644 zstd.1 $(DESTDIR)$(MANDIR)/zstd.1 |
| Yann Collet | 5abd820 | 2015-08-27 03:16:04 +0100 | [diff] [blame] | 152 | @ln -sf zstd.1 $(DESTDIR)$(MANDIR)/zstdcat.1 |
| 153 | @ln -sf zstd.1 $(DESTDIR)$(MANDIR)/unzstd.1 |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 154 | @echo zstd installation completed |
| 155 | |
| 156 | uninstall: |
| 157 | rm -f $(DESTDIR)$(BINDIR)/zstdcat |
| Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame] | 158 | rm -f $(DESTDIR)$(BINDIR)/unzstd |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 159 | [ -x $(DESTDIR)$(BINDIR)/zstd$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/zstd$(EXT) |
| Yann Collet | 5abd820 | 2015-08-27 03:16:04 +0100 | [diff] [blame] | 160 | rm -f $(DESTDIR)$(MANDIR)/zstdcat.1 |
| 161 | rm -f $(DESTDIR)$(MANDIR)/unzstd.1 |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 162 | [ -f $(DESTDIR)$(MANDIR)/zstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstd.1 |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 163 | @echo zstd programs successfully uninstalled |
| Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 164 | endif |