Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 1 | # ################################################################ |
| 2 | # zstd - Makefile |
Yann Collet | 648959a | 2016-02-07 23:58:32 +0100 | [diff] [blame] | 3 | # Copyright (C) Yann Collet 2014-2016 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 4 | # All rights reserved. |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 5 | # |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 6 | # BSD license |
| 7 | # |
| 8 | # Redistribution and use in source and binary forms, with or without modification, |
| 9 | # are permitted provided that the following conditions are met: |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 10 | # |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 11 | # * Redistributions of source code must retain the above copyright notice, this |
| 12 | # list of conditions and the following disclaimer. |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 13 | # |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 14 | # * Redistributions in binary form must reproduce the above copyright notice, this |
| 15 | # list of conditions and the following disclaimer in the documentation and/or |
| 16 | # other materials provided with the distribution. |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 17 | # |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 19 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
| 22 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 | # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 25 | # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 28 | # |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 29 | # You can contact the author at : |
Yann Collet | 4f0a393 | 2016-02-07 04:00:27 +0100 | [diff] [blame] | 30 | # - zstd homepage : http://www.zstd.net/ |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 31 | # ################################################################ |
| 32 | |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 33 | PRGDIR = programs |
| 34 | ZSTDDIR = lib |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 35 | ZWRAPDIR = zlibWrapper |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 36 | |
Yann Collet | 88fcd29 | 2015-11-25 14:42:45 +0100 | [diff] [blame] | 37 | # Define nul output |
| 38 | ifneq (,$(filter Windows%,$(OS))) |
| 39 | VOID = nul |
| 40 | else |
| 41 | VOID = /dev/null |
| 42 | endif |
| 43 | |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 44 | .PHONY: default all zlibwrapper zstd clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 45 | |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 46 | default: zstd |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 47 | |
Yann Collet | 118bfc4 | 2016-05-30 18:50:28 +0200 | [diff] [blame] | 48 | all: |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 49 | $(MAKE) -C $(ZSTDDIR) $@ |
| 50 | $(MAKE) -C $(PRGDIR) $@ |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 51 | @rm -f lib/decompress/*.o |
| 52 | $(MAKE) -C $(PRGDIR) all32 |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 53 | |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 54 | zstd: |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 55 | $(MAKE) -C $(PRGDIR) |
inikep | c9bb102 | 2016-06-21 18:04:13 +0200 | [diff] [blame] | 56 | cp $(PRGDIR)/zstd . |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 57 | |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 58 | zlibwrapper: |
| 59 | $(MAKE) -C $(ZSTDDIR) all |
| 60 | $(MAKE) -C $(ZWRAPDIR) all |
| 61 | |
Yann Collet | 6f9c056 | 2016-05-01 10:26:30 +0200 | [diff] [blame] | 62 | test: |
| 63 | $(MAKE) -C $(PRGDIR) $@ |
| 64 | |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 65 | clean: |
Yann Collet | 88fcd29 | 2015-11-25 14:42:45 +0100 | [diff] [blame] | 66 | @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID) |
| 67 | @$(MAKE) -C $(PRGDIR) $@ > $(VOID) |
inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 68 | @$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID) |
Yann Collet | 06d9a73 | 2016-06-19 14:27:21 +0200 | [diff] [blame] | 69 | @rm -f zstd |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 70 | @echo Cleaning completed |
| 71 | |
| 72 | |
jrmarino | 0d07ec0 | 2016-07-30 19:10:36 -0500 | [diff] [blame] | 73 | #---------------------------------------------------------------------------------- |
| 74 | #make install is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets |
| 75 | #---------------------------------------------------------------------------------- |
| 76 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD DragonFly)) |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 77 | HOST_OS = POSIX |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 78 | install: |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 79 | $(MAKE) -C $(ZSTDDIR) $@ |
| 80 | $(MAKE) -C $(PRGDIR) $@ |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 81 | |
| 82 | uninstall: |
Yann Collet | bf50409 | 2015-08-26 00:19:06 +0100 | [diff] [blame] | 83 | $(MAKE) -C $(ZSTDDIR) $@ |
| 84 | $(MAKE) -C $(PRGDIR) $@ |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 85 | |
| 86 | travis-install: |
Yann Collet | c620b48 | 2015-12-01 01:56:02 +0100 | [diff] [blame] | 87 | $(MAKE) install PREFIX=~/install_test_dir |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 88 | |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 89 | gpptest: clean |
Yann Collet | 32faf6c | 2016-07-22 04:45:06 +0200 | [diff] [blame] | 90 | $(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] | 91 | |
inikep | c9bb102 | 2016-06-21 18:04:13 +0200 | [diff] [blame] | 92 | gcc5test: clean |
| 93 | gcc-5 -v |
| 94 | $(MAKE) all CC=gcc-5 MOREFLAGS="-Werror" |
| 95 | |
| 96 | gcc6test: clean |
| 97 | gcc-6 -v |
| 98 | $(MAKE) all CC=gcc-6 MOREFLAGS="-Werror" |
| 99 | |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 100 | clangtest: clean |
Yann Collet | f4ce891 | 2015-08-11 14:18:45 +0100 | [diff] [blame] | 101 | clang -v |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 102 | $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion" |
| 103 | |
Yann Collet | 7083b8a | 2015-07-06 23:58:59 -0800 | [diff] [blame] | 104 | armtest: clean |
Yann Collet | 648959a | 2016-02-07 23:58:32 +0100 | [diff] [blame] | 105 | $(MAKE) -C $(PRGDIR) datagen # use native, faster |
Yann Collet | 74bd119 | 2016-03-26 17:50:26 +0100 | [diff] [blame] | 106 | $(MAKE) -C $(PRGDIR) test CC=arm-linux-gnueabi-gcc ZSTDRTTEST= MOREFLAGS="-Werror -static" |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 107 | |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 108 | ppctest: clean |
| 109 | $(MAKE) -C $(PRGDIR) datagen # use native, faster |
inikep | 003c7a8 | 2016-07-27 11:07:13 +0200 | [diff] [blame] | 110 | $(MAKE) -C $(PRGDIR) test CC=powerpc-linux-gnu-gcc ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static" |
Yann Collet | 521b010 | 2016-02-08 01:27:59 +0100 | [diff] [blame] | 111 | |
inikep | 1981d5a | 2016-05-30 10:18:56 +0200 | [diff] [blame] | 112 | ppc64test: clean |
| 113 | $(MAKE) -C $(PRGDIR) datagen # use native, faster |
inikep | 5e0ed48 | 2016-07-26 08:37:53 +0200 | [diff] [blame] | 114 | $(MAKE) -C $(PRGDIR) test CC=powerpc-linux-gnu-gcc ZSTDRTTEST= MOREFLAGS="-m64 -static" |
inikep | 1981d5a | 2016-05-30 10:18:56 +0200 | [diff] [blame] | 115 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 116 | usan: clean |
Yann Collet | 674d91b | 2015-07-07 00:36:49 -0800 | [diff] [blame] | 117 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined" |
Yann Collet | 213089c | 2015-06-18 07:43:16 -0800 | [diff] [blame] | 118 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 119 | asan: clean |
| 120 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address" |
| 121 | |
Yann Collet | d996743 | 2016-05-18 14:16:49 +0200 | [diff] [blame] | 122 | msan: clean |
Yann Collet | c28f9e2 | 2016-06-06 18:00:00 +0200 | [diff] [blame] | 123 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=memory" # datagen.c used to fail this test for no obvious reason |
Yann Collet | d996743 | 2016-05-18 14:16:49 +0200 | [diff] [blame] | 124 | |
Yann Collet | 6c3e2e7 | 2015-12-11 10:44:07 +0100 | [diff] [blame] | 125 | asan32: clean |
| 126 | $(MAKE) -C $(PRGDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address" |
| 127 | |
Yann Collet | 83fae97 | 2015-10-23 15:21:53 +0100 | [diff] [blame] | 128 | uasan: clean |
| 129 | $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined" |
| 130 | |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 131 | endif |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 132 | |
| 133 | |
| 134 | ifneq (,$(filter MSYS%,$(shell uname))) |
| 135 | HOST_OS = MSYS |
| 136 | CMAKE_PARAMS = -G"MSYS Makefiles" |
| 137 | endif |
| 138 | |
| 139 | |
| 140 | #------------------------------------------------------------------------ |
| 141 | #make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets |
| 142 | #------------------------------------------------------------------------ |
| 143 | ifneq (,$(filter $(HOST_OS),MSYS POSIX)) |
| 144 | cmaketest: |
| 145 | cmake --version |
| 146 | rm -rf projects/cmake/build |
| 147 | mkdir projects/cmake/build |
inikep | c7f008b | 2016-06-03 11:40:15 +0200 | [diff] [blame] | 148 | cd projects/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] | 149 | |
| 150 | c90test: clean |
| 151 | CFLAGS="-std=c90" $(MAKE) all # will fail, due to // and long long |
| 152 | |
| 153 | gnu90test: clean |
| 154 | CFLAGS="-std=gnu90" $(MAKE) all |
| 155 | |
| 156 | c99test: clean |
| 157 | CFLAGS="-std=c99" $(MAKE) all |
| 158 | |
| 159 | gnu99test: clean |
| 160 | CFLAGS="-std=gnu99" $(MAKE) all |
| 161 | |
| 162 | c11test: clean |
| 163 | CFLAGS="-std=c11" $(MAKE) all |
| 164 | |
| 165 | bmix64test: clean |
| 166 | CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(PRGDIR) test |
| 167 | |
| 168 | bmix32test: clean |
| 169 | CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(PRGDIR) test |
| 170 | |
| 171 | bmi32test: clean |
| 172 | CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(PRGDIR) test |
Yann Collet | c35cd5b | 2016-06-30 15:40:28 +0200 | [diff] [blame] | 173 | |
| 174 | staticAnalyze: clean |
Yann Collet | 677ed26 | 2016-07-10 14:23:30 +0200 | [diff] [blame] | 175 | CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all |
inikep | 13f42d9 | 2016-06-01 14:44:31 +0200 | [diff] [blame] | 176 | endif |
inikep | c9bb102 | 2016-06-21 18:04:13 +0200 | [diff] [blame] | 177 | |
| 178 | |
| 179 | #------------------------------------------------------------------------ |
| 180 | # for Travis CI |
| 181 | #------------------------------------------------------------------------ |
| 182 | libc6install: |
| 183 | sudo apt-get install -y -qq libc6-dev-i386 |
| 184 | |
| 185 | gppinstall: |
| 186 | sudo apt-get install -y -qq g++-multilib |
| 187 | |
| 188 | gcc5install: |
| 189 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test |
| 190 | sudo apt-get update -y -qq |
| 191 | sudo apt-get install -y -qq gcc-5-multilib |
| 192 | |
| 193 | gcc6install: |
| 194 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test |
Yann Collet | c35cd5b | 2016-06-30 15:40:28 +0200 | [diff] [blame] | 195 | sudo apt-get update -y -qq |
inikep | c9bb102 | 2016-06-21 18:04:13 +0200 | [diff] [blame] | 196 | sudo apt-get install -y -qq gcc-6-multilib |
| 197 | |
| 198 | arminstall: clean |
| 199 | sudo apt-get install -y -q qemu binfmt-support qemu-user-static gcc-arm-linux-gnueabi |
| 200 | |
| 201 | ppcinstall: clean |
| 202 | sudo apt-get install -y -q qemu-system-ppc binfmt-support qemu-user-static gcc-powerpc-linux-gnu # doesn't work with Ubuntu 12.04 |
| 203 | |
| 204 | ppc64install: clean # compilation works but cannot be executed |
| 205 | sudo apt-get install -y -q qemu-system-ppc binfmt-support qemu-user-static gcc-powerpc-linux-gnu |
| 206 | update-binfmts --displ |
| 207 | |
| 208 | valgrindinstall: |
| 209 | echo sudo apt-get install -y -qq valgrind |
| 210 | sudo apt-get install -y -qq valgrind |