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 |
| 17 | ifneq (,$(filter Windows%,$(OS))) |
| 18 | VOID = nul |
| 19 | else |
| 20 | VOID = /dev/null |
| 21 | endif |
| 22 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 23 | .PHONY: default |
| 24 | default: lib zstd |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 25 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 26 | .PHONY: all |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 27 | all: |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 28 | $(MAKE) -C $(ZSTDDIR) $@ |
inikep | a1c8115 | 2016-08-18 13:35:36 +0200 | [diff] [blame] | 29 | $(MAKE) -C $(PRGDIR) $@ zstd32 |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 30 | $(MAKE) -C $(TESTDIR) $@ all32 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 31 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 32 | .PHONY: lib |
| 33 | lib: |
Yann Collet | e19111c | 2016-10-12 11:09:36 -0700 | [diff] [blame] | 34 | @$(MAKE) -C $(ZSTDDIR) |
| 35 | |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 36 | zstd: |
Yann Collet | e19111c | 2016-10-12 11:09:36 -0700 | [diff] [blame] | 37 | @$(MAKE) -C $(PRGDIR) |
inikep | c9bb102 | 2016-06-21 18:04:13 +0200 | [diff] [blame] | 38 | cp $(PRGDIR)/zstd . |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 39 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 40 | .PHONY: zlibwrapper |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 41 | zlibwrapper: |
inikep | 68cd476 | 2016-09-23 12:42:21 +0200 | [diff] [blame] | 42 | $(MAKE) -C $(ZWRAPDIR) test |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 43 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 44 | .PHONY: test |
Yann Collet | 6f9c056 | 2016-05-01 10:26:30 +0200 | [diff] [blame] | 45 | test: |
inikep | a1c8115 | 2016-08-18 13:35:36 +0200 | [diff] [blame] | 46 | $(MAKE) -C $(TESTDIR) $@ |
Yann Collet | 6f9c056 | 2016-05-01 10:26:30 +0200 | [diff] [blame] | 47 | |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 48 | .PHONY: clean |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 49 | clean: |
Yann Collet | 88fcd29 | 2015-11-25 14:42:45 +0100 | [diff] [blame] | 50 | @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID) |
| 51 | @$(MAKE) -C $(PRGDIR) $@ > $(VOID) |
inikep | a1c8115 | 2016-08-18 13:35:36 +0200 | [diff] [blame] | 52 | @$(MAKE) -C $(TESTDIR) $@ > $(VOID) |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 53 | @$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID) |
Yann Collet | a266464 | 2016-09-09 19:33:56 +0200 | [diff] [blame] | 54 | @$(RM) zstd |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 55 | @echo Cleaning completed |
| 56 | |
| 57 | |
Yann Collet | e405c7a | 2016-10-12 15:29:22 -0700 | [diff] [blame] | 58 | #------------------------------------------------------------------------------ |
| 59 | # make install is validated only for Linux, OSX, Hurd and some BSD targets |
| 60 | #------------------------------------------------------------------------------ |
Thomas Klausner | b85cdab | 2016-09-04 14:37:57 +0200 | [diff] [blame] | 61 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD DragonFly NetBSD)) |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 62 | HOST_OS = POSIX |
Yann Collet | f3f1321 | 2016-11-02 17:02:45 -0700 | [diff] [blame] | 63 | .PHONY: install uninstall travis-install clangtest gpptest armtest usan asan uasan |
| 64 | |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 65 | install: |
Yann Collet | e19111c | 2016-10-12 11:09:36 -0700 | [diff] [blame] | 66 | @$(MAKE) -C $(ZSTDDIR) $@ |
| 67 | @$(MAKE) -C $(PRGDIR) $@ |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 68 | |
| 69 | uninstall: |
Yann Collet | e19111c | 2016-10-12 11:09:36 -0700 | [diff] [blame] | 70 | @$(MAKE) -C $(ZSTDDIR) $@ |
| 71 | @$(MAKE) -C $(PRGDIR) $@ |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 72 | |
| 73 | travis-install: |
Yann Collet | c620b48 | 2015-12-01 01:56:02 +0100 | [diff] [blame] | 74 | $(MAKE) install PREFIX=~/install_test_dir |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 75 | |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 76 | gpptest: clean |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 77 | $(MAKE) -C programs all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" |
Yann Collet | 3e5b73b | 2016-01-10 20:46:20 +0100 | [diff] [blame] | 78 | |
inikep | c9bb102 | 2016-06-21 18:04:13 +0200 | [diff] [blame] | 79 | gcc5test: clean |
| 80 | gcc-5 -v |
| 81 | $(MAKE) all CC=gcc-5 MOREFLAGS="-Werror" |
| 82 | |
| 83 | gcc6test: clean |
| 84 | gcc-6 -v |
| 85 | $(MAKE) all CC=gcc-6 MOREFLAGS="-Werror" |
| 86 | |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 87 | clangtest: clean |
Yann Collet | f4ce891 | 2015-08-11 14:18:45 +0100 | [diff] [blame] | 88 | clang -v |
Yann Collet | cb5a320 | 2016-08-26 08:06:36 +0200 | [diff] [blame] | 89 | $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation" |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 90 | |
Yann Collet | 7083b8a | 2015-07-06 23:58:59 -0800 | [diff] [blame] | 91 | armtest: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 92 | $(MAKE) -C $(TESTDIR) datagen # use native, faster |
| 93 | $(MAKE) -C $(TESTDIR) test CC=arm-linux-gnueabi-gcc ZSTDRTTEST= MOREFLAGS="-Werror -static" |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 94 | |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 95 | ppctest: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 96 | $(MAKE) -C $(TESTDIR) datagen # use native, faster |
| 97 | $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static" |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 98 | |
inikep | 1981d5a | 2016-05-30 10:18:56 +0200 | [diff] [blame] | 99 | ppc64test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 100 | $(MAKE) -C $(TESTDIR) datagen # use native, faster |
| 101 | $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc ZSTDRTTEST= MOREFLAGS="-m64 -static" |
inikep | 1981d5a | 2016-05-30 10:18:56 +0200 | [diff] [blame] | 102 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 103 | usan: clean |
Yann Collet | 674d91b | 2015-07-07 00:36:49 -0800 | [diff] [blame] | 104 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined" |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 105 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 106 | asan: clean |
| 107 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address" |
| 108 | |
Yann Collet | d996743 | 2016-05-18 14:16:49 +0200 | [diff] [blame] | 109 | msan: clean |
Yann Collet | 6c36449 | 2016-08-12 00:05:59 +0200 | [diff] [blame] | 110 | $(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] | 111 | |
Yann Collet | 6c3e2e7 | 2015-12-11 10:44:07 +0100 | [diff] [blame] | 112 | asan32: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 113 | $(MAKE) -C $(TESTDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address" |
Yann Collet | 6c3e2e7 | 2015-12-11 10:44:07 +0100 | [diff] [blame] | 114 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 115 | uasan: clean |
| 116 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined" |
| 117 | |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 118 | endif |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 119 | |
| 120 | |
| 121 | ifneq (,$(filter MSYS%,$(shell uname))) |
| 122 | HOST_OS = MSYS |
| 123 | CMAKE_PARAMS = -G"MSYS Makefiles" |
| 124 | endif |
| 125 | |
| 126 | |
| 127 | #------------------------------------------------------------------------ |
| 128 | #make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets |
| 129 | #------------------------------------------------------------------------ |
| 130 | ifneq (,$(filter $(HOST_OS),MSYS POSIX)) |
| 131 | cmaketest: |
| 132 | cmake --version |
Yann Collet | 0704df3 | 2016-09-19 16:55:35 +0200 | [diff] [blame] | 133 | $(RM) -r $(BUILDIR)/cmake/build |
| 134 | mkdir $(BUILDIR)/cmake/build |
| 135 | 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] | 136 | |
| 137 | c90test: clean |
| 138 | CFLAGS="-std=c90" $(MAKE) all # will fail, due to // and long long |
| 139 | |
| 140 | gnu90test: clean |
| 141 | CFLAGS="-std=gnu90" $(MAKE) all |
| 142 | |
| 143 | c99test: clean |
| 144 | CFLAGS="-std=c99" $(MAKE) all |
| 145 | |
| 146 | gnu99test: clean |
| 147 | CFLAGS="-std=gnu99" $(MAKE) all |
| 148 | |
| 149 | c11test: clean |
| 150 | CFLAGS="-std=c11" $(MAKE) all |
| 151 | |
| 152 | bmix64test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 153 | CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(TESTDIR) test |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 154 | |
| 155 | bmix32test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 156 | CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(TESTDIR) test |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 157 | |
| 158 | bmi32test: clean |
inikep | 2d5eb2b | 2016-08-18 13:53:26 +0200 | [diff] [blame] | 159 | CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(TESTDIR) test |
Yann Collet | c35cd5b | 2016-06-30 15:40:28 +0200 | [diff] [blame] | 160 | |
| 161 | staticAnalyze: clean |
Yann Collet | 677ed26 | 2016-07-10 14:23:30 +0200 | [diff] [blame] | 162 | CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 163 | endif |