Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 1 | # ########################################################################## |
| 2 | # ZSTD programs - Makefile |
| 3 | # Copyright (C) Yann Collet 2015 |
| 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 : |
| 22 | # - ZSTD source repository : http://code.google.com/p/zstd/ |
| 23 | # - Public forum : https://groups.google.com/forum/#!forum/lz4c |
| 24 | # ########################################################################## |
| 25 | # zstd : Command Line Utility, supporting gzip-like arguments |
| 26 | # datagen : Synthetic and parametrable data generator, for tests |
| 27 | # fuzzer : Test tool, to check zstd integrity on target platform |
| 28 | # fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode |
| 29 | # fullbench : Precisely measure speed for each zstd inner function |
| 30 | # fullbench32: Same as fullbench, but forced to compile in 32-bits mode |
| 31 | # ########################################################################## |
| 32 | |
Yann Collet | 6610cb3 | 2015-02-09 08:00:26 +0100 | [diff] [blame] | 33 | RELEASE?= r1 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 34 | |
| 35 | DESTDIR?= |
| 36 | PREFIX ?= /usr |
| 37 | CFLAGS ?= -O3 |
| 38 | CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -DZSTD_VERSION=\"$(RELEASE)\" |
| 39 | FLAGS = -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) |
| 40 | |
| 41 | BINDIR=$(PREFIX)/bin |
| 42 | MANDIR=$(PREFIX)/share/man/man1 |
| 43 | ZSTDDIR=../lib |
| 44 | |
| 45 | TEST_FILES = COPYING |
| 46 | TEST_TARGETS=test-native |
| 47 | |
| 48 | |
| 49 | # Define *.exe as extension for Windows systems |
| 50 | ifneq (,$(filter Windows%,$(OS))) |
| 51 | EXT =.exe |
| 52 | VOID = nul |
| 53 | else |
| 54 | EXT = |
| 55 | VOID = /dev/null |
| 56 | endif |
| 57 | |
| 58 | |
| 59 | default: zstd |
| 60 | |
| 61 | all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32 |
| 62 | |
| 63 | zstd: $(ZSTDDIR)/zstd.c xxhash.c bench.c fileio.c zstdcli.c |
| 64 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 65 | |
| 66 | zstd32: $(ZSTDDIR)/zstd.c xxhash.c bench.c fileio.c zstdcli.c |
| 67 | $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) |
| 68 | |
Yann Collet | f967806 | 2015-02-11 08:19:57 +0100 | [diff] [blame] | 69 | fullbench : $(ZSTDDIR)/zstd.c datagen.c fullbench.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 70 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 71 | |
Yann Collet | f967806 | 2015-02-11 08:19:57 +0100 | [diff] [blame] | 72 | fullbench32: $(ZSTDDIR)/zstd.c datagen.c fullbench.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 73 | $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) |
| 74 | |
| 75 | fuzzer : $(ZSTDDIR)/zstd.c xxhash.c fuzzer.c |
| 76 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 77 | |
| 78 | fuzzer32: $(ZSTDDIR)/zstd.c xxhash.c fuzzer.c |
| 79 | $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) |
| 80 | |
Yann Collet | 6610cb3 | 2015-02-09 08:00:26 +0100 | [diff] [blame] | 81 | datagen : datagen.c datagencli.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 82 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 83 | |
| 84 | clean: |
| 85 | @rm -f core *.o tmp \ |
| 86 | zstd$(EXT) zstd32$(EXT) \ |
| 87 | fullbench$(EXT) fullbench32$(EXT) \ |
| 88 | fuzzer$(EXT) fuzzer32$(EXT) \ |
| 89 | datagen$(EXT) |
| 90 | @echo Cleaning completed |
| 91 | |
| 92 | |
| 93 | #------------------------------------------------------------------------ |
| 94 | #make install is validated only for Linux, OSX, kFreeBSD and Hurd targets |
| 95 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU)) |
| 96 | |
| 97 | install: zstd |
| 98 | @echo Installing binaries |
| 99 | @install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/ |
| 100 | @install -m 755 zstd$(EXT) $(DESTDIR)$(BINDIR)/zstd$(EXT) |
| 101 | @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdcat |
Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame^] | 102 | @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 103 | @echo Installing man pages |
| 104 | @install -m 644 zstd.1 $(DESTDIR)$(MANDIR)/zstd.1 |
| 105 | @install -m 644 zstdcat.1 $(DESTDIR)$(MANDIR)/zstdcat.1 |
Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame^] | 106 | @install -m 644 unzstd.1 $(DESTDIR)$(MANDIR)/unzstd.1 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 107 | @echo zstd installation completed |
| 108 | |
| 109 | uninstall: |
| 110 | rm -f $(DESTDIR)$(BINDIR)/zstdcat |
Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame^] | 111 | rm -f $(DESTDIR)$(BINDIR)/unzstd |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 112 | [ -x $(DESTDIR)$(BINDIR)/zstd$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/zstd$(EXT) |
| 113 | [ -f $(DESTDIR)$(MANDIR)/zstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstd.1 |
| 114 | [ -f $(DESTDIR)$(MANDIR)/zstdcat.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstdcat.1 |
Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame^] | 115 | [ -f $(DESTDIR)$(MANDIR)/unzstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/unzstd.1 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 116 | @echo zstd programs successfully uninstalled |
| 117 | |
| 118 | test: test-zstd test-fullbench test-fuzzer test-mem |
| 119 | |
| 120 | test32: test-zstd32 test-fullbench32 test-fuzzer32 |
| 121 | |
| 122 | test-all: test test32 |
| 123 | |
| 124 | test-zstd: zstd datagen |
| 125 | ./datagen | ./zstd -v | ./zstd -d > $(VOID) |
| 126 | ./datagen -g256MB | ./zstd -v | ./zstd -d > $(VOID) |
| 127 | ./datagen -g6GB | ./zstd -vq | ./zstd -d > $(VOID) |
| 128 | |
| 129 | test-zstd32: zstd32 datagen |
| 130 | ./datagen | ./zstd32 -v | ./zstd32 -d > $(VOID) |
| 131 | ./datagen -g256MB | ./zstd32 -v | ./zstd32 -d > $(VOID) |
| 132 | ./datagen -g6GB | ./zstd32 -vq | ./zstd32 -d > $(VOID) |
| 133 | |
Yann Collet | 759433d | 2015-01-24 13:31:55 +0100 | [diff] [blame] | 134 | test-fullbench: fullbench datagen |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 135 | ./fullbench -i1 |
Yann Collet | f66d2ba | 2015-02-11 08:34:50 +0100 | [diff] [blame] | 136 | ./fullbench -i1 -P0 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 137 | |
Yann Collet | 759433d | 2015-01-24 13:31:55 +0100 | [diff] [blame] | 138 | test-fullbench32: fullbench32 datagen |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 139 | ./fullbench32 -i1 |
Yann Collet | f66d2ba | 2015-02-11 08:34:50 +0100 | [diff] [blame] | 140 | ./fullbench32 -i1 -P0 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 141 | |
| 142 | test-fuzzer: fuzzer |
| 143 | ./fuzzer |
| 144 | |
| 145 | test-fuzzer32: fuzzer32 |
| 146 | ./fuzzer32 |
| 147 | |
| 148 | test-mem: zstd datagen fuzzer fullbench |
Yann Collet | 1d62914 | 2015-03-09 13:48:34 +0100 | [diff] [blame] | 149 | valgrind --leak-check=yes ./datagen -g50M > /dev/null |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 150 | ./datagen -g16KB > tmp |
| 151 | valgrind --leak-check=yes ./zstd -vf tmp /dev/null |
| 152 | ./datagen -g128MB > tmp |
| 153 | valgrind --leak-check=yes ./zstd -vf tmp /dev/null |
Yann Collet | 6434adc | 2015-01-29 07:00:43 +0100 | [diff] [blame] | 154 | @rm tmp |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 155 | valgrind --leak-check=yes ./fuzzer -i128 -t1 |
| 156 | valgrind --leak-check=yes ./fullbench -i1 |
| 157 | |
| 158 | endif |