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 | f48e35c | 2015-11-07 01:13:31 +0100 | [diff] [blame^] | 33 | VERSION?= 0.3.5 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 34 | |
| 35 | DESTDIR?= |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 36 | PREFIX ?= /usr/local |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 37 | CPPFLAGS= -I../lib -I../lib/legacy -I./legacy -DZSTD_VERSION=\"$(VERSION)\" -DZSTD_LEGACY_SUPPORT=1 |
Yann Collet | 1c00dc3 | 2015-10-21 08:22:25 +0100 | [diff] [blame] | 38 | CFLAGS ?= -O3 # -falign-loops=32 # not always positive |
Yann Collet | b1f3f4b | 2015-10-18 22:18:32 +0100 | [diff] [blame] | 39 | CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes |
Yann Collet | 17867ce | 2015-07-07 00:14:27 -0800 | [diff] [blame] | 40 | FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS) |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 41 | |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 42 | BINDIR = $(PREFIX)/bin |
| 43 | MANDIR = $(PREFIX)/share/man/man1 |
| 44 | ZSTDDIR = ../lib |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 45 | |
| 46 | |
| 47 | # Define *.exe as extension for Windows systems |
| 48 | ifneq (,$(filter Windows%,$(OS))) |
| 49 | EXT =.exe |
| 50 | VOID = nul |
| 51 | else |
| 52 | EXT = |
| 53 | VOID = /dev/null |
| 54 | endif |
| 55 | |
| 56 | |
| 57 | default: zstd |
| 58 | |
Yann Collet | 78d0f39 | 2015-10-26 00:07:32 +0100 | [diff] [blame] | 59 | all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32 paramgrill datagen |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 60 | |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 61 | zstd: $(ZSTDDIR)/zstd.c $(ZSTDDIR)/zstdhc.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \ |
| 62 | $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c \ |
| 63 | xxhash.c bench.c fileio.c zstdcli.c legacy/fileio_legacy.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 64 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 65 | |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 66 | zstd32: $(ZSTDDIR)/zstd.c $(ZSTDDIR)/zstdhc.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \ |
| 67 | $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c \ |
| 68 | xxhash.c bench.c fileio.c zstdcli.c legacy/fileio_legacy.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 69 | $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) |
| 70 | |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 71 | fullbench : $(ZSTDDIR)/zstd.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \ |
| 72 | $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c \ |
| 73 | datagen.c fullbench.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 74 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 75 | |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 76 | fullbench32: $(ZSTDDIR)/zstd.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \ |
| 77 | $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c \ |
| 78 | datagen.c fullbench.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 79 | $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) |
| 80 | |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 81 | fuzzer : $(ZSTDDIR)/zstd.c $(ZSTDDIR)/zstdhc.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \ |
| 82 | $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c \ |
| 83 | datagen.c xxhash.c fuzzer.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 84 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 85 | |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 86 | fuzzer32: $(ZSTDDIR)/zstd.c $(ZSTDDIR)/zstdhc.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \ |
| 87 | $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c \ |
| 88 | datagen.c xxhash.c fuzzer.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 89 | $(CC) -m32 $(FLAGS) $^ -o $@$(EXT) |
| 90 | |
Yann Collet | aa07405 | 2015-10-30 11:21:50 +0100 | [diff] [blame] | 91 | paramgrill : $(ZSTDDIR)/zstdhc.c $(ZSTDDIR)/zstd.c $(ZSTDDIR)/fse.c $(ZSTDDIR)/huff0.c \ |
| 92 | $(ZSTDDIR)/legacy/zstd_v01.c $(ZSTDDIR)/legacy/zstd_v02.c \ |
| 93 | datagen.c xxhash.c paramgrill.c |
Yann Collet | 1077bb8 | 2015-10-28 12:32:25 +0100 | [diff] [blame] | 94 | $(CC) $(FLAGS) $^ -lm -o $@$(EXT) |
Yann Collet | 78d0f39 | 2015-10-26 00:07:32 +0100 | [diff] [blame] | 95 | |
Yann Collet | 6610cb3 | 2015-02-09 08:00:26 +0100 | [diff] [blame] | 96 | datagen : datagen.c datagencli.c |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 97 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
| 98 | |
| 99 | clean: |
| 100 | @rm -f core *.o tmp \ |
| 101 | zstd$(EXT) zstd32$(EXT) \ |
| 102 | fullbench$(EXT) fullbench32$(EXT) \ |
| 103 | fuzzer$(EXT) fuzzer32$(EXT) \ |
Yann Collet | 0b87939 | 2015-10-26 00:11:16 +0100 | [diff] [blame] | 104 | datagen$(EXT) paramgrill$(EXT) |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 105 | @echo Cleaning completed |
| 106 | |
| 107 | |
| 108 | #------------------------------------------------------------------------ |
| 109 | #make install is validated only for Linux, OSX, kFreeBSD and Hurd targets |
| 110 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU)) |
| 111 | |
| 112 | install: zstd |
| 113 | @echo Installing binaries |
| 114 | @install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/ |
| 115 | @install -m 755 zstd$(EXT) $(DESTDIR)$(BINDIR)/zstd$(EXT) |
| 116 | @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdcat |
Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame] | 117 | @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 118 | @echo Installing man pages |
| 119 | @install -m 644 zstd.1 $(DESTDIR)$(MANDIR)/zstd.1 |
Yann Collet | 5abd820 | 2015-08-27 03:16:04 +0100 | [diff] [blame] | 120 | @ln -sf zstd.1 $(DESTDIR)$(MANDIR)/zstdcat.1 |
| 121 | @ln -sf zstd.1 $(DESTDIR)$(MANDIR)/unzstd.1 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 122 | @echo zstd installation completed |
| 123 | |
| 124 | uninstall: |
| 125 | rm -f $(DESTDIR)$(BINDIR)/zstdcat |
Johan Förberg | 273d049 | 2015-03-24 20:15:56 +0100 | [diff] [blame] | 126 | rm -f $(DESTDIR)$(BINDIR)/unzstd |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 127 | [ -x $(DESTDIR)$(BINDIR)/zstd$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/zstd$(EXT) |
Yann Collet | 5abd820 | 2015-08-27 03:16:04 +0100 | [diff] [blame] | 128 | rm -f $(DESTDIR)$(MANDIR)/zstdcat.1 |
| 129 | rm -f $(DESTDIR)$(MANDIR)/unzstd.1 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 130 | [ -f $(DESTDIR)$(MANDIR)/zstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstd.1 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 131 | @echo zstd programs successfully uninstalled |
| 132 | |
Yann Collet | 674d91b | 2015-07-07 00:36:49 -0800 | [diff] [blame] | 133 | test: test-zstd test-fullbench test-fuzzer |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 134 | |
| 135 | test32: test-zstd32 test-fullbench32 test-fuzzer32 |
| 136 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 137 | test-all: test test32 valgrindTest |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 138 | |
| 139 | test-zstd: zstd datagen |
Yann Collet | be50aaa | 2015-09-10 23:26:09 +0100 | [diff] [blame] | 140 | @echo "\n**** frame concatenation **** " |
| 141 | @echo "hello " > hello.tmp |
| 142 | @echo "world!" > world.tmp |
| 143 | @cat hello.tmp world.tmp > helloworld.tmp |
| 144 | ./zstd hello.tmp > hello.zstd |
| 145 | ./zstd world.tmp > world.zstd |
| 146 | @cat hello.zstd world.zstd > helloworld.zstd |
| 147 | ./zstd -d helloworld.zstd > result.tmp |
| 148 | cat result.tmp |
| 149 | sdiff helloworld.tmp result.tmp |
| 150 | @rm *.tmp *.zstd |
| 151 | @echo frame concatenation test completed |
| 152 | @echo "**** flush write error test **** " |
Yann Collet | 5b14760 | 2015-08-25 17:41:46 +0100 | [diff] [blame] | 153 | echo foo | ./zstd > /dev/full; if [ $$? -eq 0 ] ; then echo "write error not detected!"; false; fi |
Yann Collet | 5abd820 | 2015-08-27 03:16:04 +0100 | [diff] [blame] | 154 | echo foo | ./zstd | ./zstd -d > /dev/full; if [ $$? -eq 0 ] ; then echo "write error not detected!"; false; fi |
Yann Collet | be50aaa | 2015-09-10 23:26:09 +0100 | [diff] [blame] | 155 | @echo "**** zstd round-trip tests **** " |
Yann Collet | 7083b8a | 2015-07-06 23:58:59 -0800 | [diff] [blame] | 156 | ./datagen | ./zstd -v | ./zstd -d > $(VOID) |
Yann Collet | f8eaf0e | 2015-10-30 05:59:18 +0100 | [diff] [blame] | 157 | ./datagen | ./zstd -6 -v | ./zstd -d > $(VOID) |
Yann Collet | 7083b8a | 2015-07-06 23:58:59 -0800 | [diff] [blame] | 158 | ./datagen -g256MB | ./zstd -v | ./zstd -d > $(VOID) |
Yann Collet | f8eaf0e | 2015-10-30 05:59:18 +0100 | [diff] [blame] | 159 | ./datagen -g256MB | ./zstd -3 -v | ./zstd -d > $(VOID) |
Yann Collet | 7083b8a | 2015-07-06 23:58:59 -0800 | [diff] [blame] | 160 | ./datagen -g6GB -P99 | ./zstd -vq | ./zstd -d > $(VOID) |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 161 | |
| 162 | test-zstd32: zstd32 datagen |
Yann Collet | 7083b8a | 2015-07-06 23:58:59 -0800 | [diff] [blame] | 163 | ./datagen | ./zstd32 -v | ./zstd32 -d > $(VOID) |
| 164 | ./datagen -g256MB | ./zstd32 -v | ./zstd32 -d > $(VOID) |
| 165 | ./datagen -g6GB -P99 | ./zstd32 -vq | ./zstd32 -d > $(VOID) |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 166 | |
Yann Collet | 759433d | 2015-01-24 13:31:55 +0100 | [diff] [blame] | 167 | test-fullbench: fullbench datagen |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 168 | ./fullbench -i1 |
Yann Collet | f66d2ba | 2015-02-11 08:34:50 +0100 | [diff] [blame] | 169 | ./fullbench -i1 -P0 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 170 | |
Yann Collet | 759433d | 2015-01-24 13:31:55 +0100 | [diff] [blame] | 171 | test-fullbench32: fullbench32 datagen |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 172 | ./fullbench32 -i1 |
Yann Collet | f66d2ba | 2015-02-11 08:34:50 +0100 | [diff] [blame] | 173 | ./fullbench32 -i1 -P0 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 174 | |
| 175 | test-fuzzer: fuzzer |
| 176 | ./fuzzer |
| 177 | |
| 178 | test-fuzzer32: fuzzer32 |
| 179 | ./fuzzer32 |
| 180 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 181 | valgrindTest: zstd datagen fuzzer fullbench |
Yann Collet | 078a9a2 | 2015-06-20 19:37:53 -0800 | [diff] [blame] | 182 | @echo "\n ---- valgrind tests : memory analyzer ----" |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 183 | valgrind --leak-check=yes --error-exitcode=1 ./datagen -g50M > $(VOID) |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 184 | ./datagen -g16KB > tmp |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 185 | valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp $(VOID) |
Yann Collet | fc04bcc | 2015-10-30 07:11:07 +0100 | [diff] [blame] | 186 | ./datagen -g2930KB > tmp |
| 187 | valgrind --leak-check=yes --error-exitcode=1 ./zstd -4 -vf tmp $(VOID) |
Yann Collet | 674d91b | 2015-07-07 00:36:49 -0800 | [diff] [blame] | 188 | ./datagen -g64MB > tmp |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 189 | valgrind --leak-check=yes --error-exitcode=1 ./zstd -vf tmp $(VOID) |
Yann Collet | 6434adc | 2015-01-29 07:00:43 +0100 | [diff] [blame] | 190 | @rm tmp |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 191 | valgrind --leak-check=yes --error-exitcode=1 ./fuzzer -i1000 -t1 |
Yann Collet | 078a9a2 | 2015-06-20 19:37:53 -0800 | [diff] [blame] | 192 | valgrind --leak-check=yes --error-exitcode=1 ./fullbench -i1 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 193 | |
| 194 | endif |