Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 1 | # ################################################################ |
Yann Collet | 599c69d | 2016-08-30 13:33:20 -0700 | [diff] [blame] | 2 | # Copyright (c) 2016-present, Yann Collet, Facebook, Inc. |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 3 | # All rights reserved. |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 4 | # |
Yann Collet | 599c69d | 2016-08-30 13:33:20 -0700 | [diff] [blame] | 5 | # This source code is licensed under the BSD-style license found in the |
| 6 | # LICENSE file in the root directory of this source tree. An additional grant |
| 7 | # of patent rights can be found in the PATENTS file in the same directory. |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 8 | # ################################################################ |
| 9 | |
Yann Collet | 4c9a4c1 | 2016-09-19 14:58:14 +0200 | [diff] [blame] | 10 | PRGDIR = programs |
| 11 | ZSTDDIR = lib |
| 12 | BUILDIR = build |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 13 | ZWRAPDIR = zlibWrapper |
inikep | a1c8115 | 2016-08-18 13:35:36 +0200 | [diff] [blame] | 14 | TESTDIR = tests |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 15 | |
Yann Collet | 88fcd29 | 2015-11-25 14:42:45 +0100 | [diff] [blame] | 16 | # Define nul output |
Yann Collet | 88fcd29 | 2015-11-25 14:42:45 +0100 | [diff] [blame] | 17 | VOID = /dev/null |
Przemyslaw Skibinski | 3a41559 | 2016-11-03 12:59:20 +0100 | [diff] [blame] | 18 | |
| 19 | ifneq (,$(filter Windows%,$(OS))) |
| 20 | EXT =.exe |
| 21 | else |
| 22 | EXT = |
Yann Collet | 88fcd29 | 2015-11-25 14:42:45 +0100 | [diff] [blame] | 23 | endif |
| 24 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 25 | .PHONY: default |
| 26 | default: lib zstd |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 27 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 28 | .PHONY: all |
Yann Collet | a86a09e | 2016-12-22 11:31:39 +0100 | [diff] [blame] | 29 | all: allmost |
| 30 | CPPFLAGS=-I../lib LDFLAGS=-L../lib $(MAKE) -C examples/ $@ |
| 31 | |
| 32 | .PHONY: allmost |
Yann Collet | 7cedbd1 | 2016-12-22 12:43:00 +0100 | [diff] [blame] | 33 | allmost: |
| 34 | $(MAKE) -C $(ZSTDDIR) all |
| 35 | $(MAKE) -C $(PRGDIR) all |
| 36 | $(MAKE) -C $(TESTDIR) all |
| 37 | $(MAKE) -C $(ZWRAPDIR) all |
| 38 | |
| 39 | .PHONY: all32 |
| 40 | all32: |
| 41 | $(MAKE) -C $(PRGDIR) zstd32 |
| 42 | $(MAKE) -C $(TESTDIR) all32 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 43 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 44 | .PHONY: lib |
| 45 | lib: |
Yann Collet | e19111c | 2016-10-12 11:09:36 -0700 | [diff] [blame] | 46 | @$(MAKE) -C $(ZSTDDIR) |
| 47 | |
Yann Collet | d41380e | 2016-11-07 14:55:12 -0800 | [diff] [blame] | 48 | .PHONY: zstd |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 49 | zstd: |
Yann Collet | d41380e | 2016-11-07 14:55:12 -0800 | [diff] [blame] | 50 | @$(MAKE) -C $(PRGDIR) $@ |
Przemyslaw Skibinski | 3a41559 | 2016-11-03 12:59:20 +0100 | [diff] [blame] | 51 | cp $(PRGDIR)/zstd$(EXT) . |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 52 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 53 | .PHONY: zlibwrapper |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 54 | zlibwrapper: |
inikep | 68cd476 | 2016-09-23 12:42:21 +0200 | [diff] [blame] | 55 | $(MAKE) -C $(ZWRAPDIR) test |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 56 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 57 | .PHONY: test |
Yann Collet | 6f9c056 | 2016-05-01 10:26:30 +0200 | [diff] [blame] | 58 | test: |
inikep | a1c8115 | 2016-08-18 13:35:36 +0200 | [diff] [blame] | 59 | $(MAKE) -C $(TESTDIR) $@ |
Yann Collet | 6f9c056 | 2016-05-01 10:26:30 +0200 | [diff] [blame] | 60 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 61 | .PHONY: clean |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 62 | clean: |
Yann Collet | 88fcd29 | 2015-11-25 14:42:45 +0100 | [diff] [blame] | 63 | @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID) |
| 64 | @$(MAKE) -C $(PRGDIR) $@ > $(VOID) |
inikep | a1c8115 | 2016-08-18 13:35:36 +0200 | [diff] [blame] | 65 | @$(MAKE) -C $(TESTDIR) $@ > $(VOID) |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 66 | @$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID) |
Yann Collet | 1f57c2e | 2016-12-21 16:20:11 +0100 | [diff] [blame] | 67 | @$(MAKE) -C examples/ $@ > $(VOID) |
Yann Collet | 900f39e | 2017-01-20 16:36:29 -0800 | [diff] [blame^] | 68 | @$(RM) zstd$(EXT) zstdmt$(EXT) tmp* |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 69 | @echo Cleaning completed |
| 70 | |
| 71 | |
Yann Collet | e405c7a | 2016-10-12 15:29:22 -0700 | [diff] [blame] | 72 | #------------------------------------------------------------------------------ |
| 73 | # make install is validated only for Linux, OSX, Hurd and some BSD targets |
| 74 | #------------------------------------------------------------------------------ |
Thomas Klausner | b85cdab | 2016-09-04 14:37:57 +0200 | [diff] [blame] | 75 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD DragonFly NetBSD)) |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 76 | HOST_OS = POSIX |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 77 | .PHONY: install uninstall travis-install clangtest gpptest armtest usan asan uasan |
| 78 | |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 79 | install: |
Yann Collet | e19111c | 2016-10-12 11:09:36 -0700 | [diff] [blame] | 80 | @$(MAKE) -C $(ZSTDDIR) $@ |
| 81 | @$(MAKE) -C $(PRGDIR) $@ |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 82 | |
| 83 | uninstall: |
Yann Collet | e19111c | 2016-10-12 11:09:36 -0700 | [diff] [blame] | 84 | @$(MAKE) -C $(ZSTDDIR) $@ |
| 85 | @$(MAKE) -C $(PRGDIR) $@ |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 86 | |
| 87 | travis-install: |
Yann Collet | c620b48 | 2015-12-01 01:56:02 +0100 | [diff] [blame] | 88 | $(MAKE) install PREFIX=~/install_test_dir |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 89 | |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 90 | gpptest: clean |
Yann Collet | 33fce03 | 2017-01-16 19:46:22 -0800 | [diff] [blame] | 91 | CC=g++ $(MAKE) -C programs all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" |
Yann Collet | 3e5b73b | 2016-01-10 20:46:20 +0100 | [diff] [blame] | 92 | |
inikep | c9bb102 | 2016-06-21 18:04:13 +0200 | [diff] [blame] | 93 | gcc5test: clean |
| 94 | gcc-5 -v |
| 95 | $(MAKE) all CC=gcc-5 MOREFLAGS="-Werror" |
| 96 | |
| 97 | gcc6test: clean |
| 98 | gcc-6 -v |
| 99 | $(MAKE) all CC=gcc-6 MOREFLAGS="-Werror" |
| 100 | |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 101 | clangtest: clean |
Yann Collet | f4ce891 | 2015-08-11 14:18:45 +0100 | [diff] [blame] | 102 | clang -v |
Yann Collet | cb5a320 | 2016-08-26 08:06:36 +0200 | [diff] [blame] | 103 | $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation" |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 104 | |
Yann Collet | 7083b8a | 2015-07-06 23:58:59 -0800 | [diff] [blame] | 105 | armtest: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 106 | $(MAKE) -C $(TESTDIR) datagen # use native, faster |
Przemyslaw Skibinski | e579ab5 | 2016-11-14 12:57:05 +0100 | [diff] [blame] | 107 | $(MAKE) -C $(TESTDIR) test CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static ZSTDRTTEST= MOREFLAGS="-Werror -static" |
| 108 | |
| 109 | aarch64test: |
| 110 | $(MAKE) -C $(TESTDIR) datagen # use native, faster |
| 111 | $(MAKE) -C $(TESTDIR) test CC=aarch64-linux-gnu-gcc QEMU_SYS=qemu-aarch64-static ZSTDRTTEST= MOREFLAGS="-Werror -static" |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 112 | |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 113 | ppctest: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 114 | $(MAKE) -C $(TESTDIR) datagen # use native, faster |
Przemyslaw Skibinski | e579ab5 | 2016-11-14 12:57:05 +0100 | [diff] [blame] | 115 | $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static" |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 116 | |
inikep | 1981d5a | 2016-05-30 10:18:56 +0200 | [diff] [blame] | 117 | ppc64test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 118 | $(MAKE) -C $(TESTDIR) datagen # use native, faster |
Przemyslaw Skibinski | e579ab5 | 2016-11-14 12:57:05 +0100 | [diff] [blame] | 119 | $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static ZSTDRTTEST= MOREFLAGS="-m64 -static" |
inikep | 1981d5a | 2016-05-30 10:18:56 +0200 | [diff] [blame] | 120 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 121 | usan: clean |
Yann Collet | 674d91b | 2015-07-07 00:36:49 -0800 | [diff] [blame] | 122 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined" |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 123 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 124 | asan: clean |
| 125 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address" |
| 126 | |
Yann Collet | d996743 | 2016-05-18 14:16:49 +0200 | [diff] [blame] | 127 | msan: clean |
Yann Collet | 6c36449 | 2016-08-12 00:05:59 +0200 | [diff] [blame] | 128 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=memory -fno-omit-frame-pointer" # datagen.c fails this test for no obvious reason |
Yann Collet | d996743 | 2016-05-18 14:16:49 +0200 | [diff] [blame] | 129 | |
Yann Collet | 6c3e2e7 | 2015-12-11 10:44:07 +0100 | [diff] [blame] | 130 | asan32: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 131 | $(MAKE) -C $(TESTDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address" |
Yann Collet | 6c3e2e7 | 2015-12-11 10:44:07 +0100 | [diff] [blame] | 132 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 133 | uasan: clean |
| 134 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined" |
| 135 | |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 136 | endif |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 137 | |
| 138 | |
| 139 | ifneq (,$(filter MSYS%,$(shell uname))) |
| 140 | HOST_OS = MSYS |
| 141 | CMAKE_PARAMS = -G"MSYS Makefiles" |
| 142 | endif |
| 143 | |
| 144 | |
| 145 | #------------------------------------------------------------------------ |
| 146 | #make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets |
| 147 | #------------------------------------------------------------------------ |
| 148 | ifneq (,$(filter $(HOST_OS),MSYS POSIX)) |
| 149 | cmaketest: |
| 150 | cmake --version |
Yann Collet | 0704df3 | 2016-09-19 16:55:35 +0200 | [diff] [blame] | 151 | $(RM) -r $(BUILDIR)/cmake/build |
| 152 | mkdir $(BUILDIR)/cmake/build |
| 153 | cd $(BUILDIR)/cmake/build ; cmake -DPREFIX:STRING=~/install_test_dir $(CMAKE_PARAMS) .. ; $(MAKE) install ; $(MAKE) uninstall |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 154 | |
| 155 | c90test: clean |
| 156 | CFLAGS="-std=c90" $(MAKE) all # will fail, due to // and long long |
| 157 | |
| 158 | gnu90test: clean |
| 159 | CFLAGS="-std=gnu90" $(MAKE) all |
| 160 | |
| 161 | c99test: clean |
Yann Collet | a86a09e | 2016-12-22 11:31:39 +0100 | [diff] [blame] | 162 | CFLAGS="-std=c99" $(MAKE) allmost |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 163 | |
| 164 | gnu99test: clean |
| 165 | CFLAGS="-std=gnu99" $(MAKE) all |
| 166 | |
| 167 | c11test: clean |
Yann Collet | a86a09e | 2016-12-22 11:31:39 +0100 | [diff] [blame] | 168 | CFLAGS="-std=c11" $(MAKE) allmost |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 169 | |
| 170 | bmix64test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 171 | CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(TESTDIR) test |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 172 | |
| 173 | bmix32test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 174 | CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(TESTDIR) test |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 175 | |
| 176 | bmi32test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 177 | CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(TESTDIR) test |
Yann Collet | c35cd5b | 2016-06-30 15:40:28 +0200 | [diff] [blame] | 178 | |
| 179 | staticAnalyze: clean |
Yann Collet | 677ed26 | 2016-07-10 14:23:30 +0200 | [diff] [blame] | 180 | CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 181 | endif |