blob: 8569ee660c8041fe4c4caf2b7624b8fe0888671d [file] [log] [blame]
Yann Collet4856a002015-01-24 01:58:16 +01001# ################################################################
Yann Collet599c69d2016-08-30 13:33:20 -07002# Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
Yann Collet4856a002015-01-24 01:58:16 +01003# All rights reserved.
Yann Collet118bfc42016-05-30 18:50:28 +02004#
Yann Collet599c69d2016-08-30 13:33:20 -07005# 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 Collet4856a002015-01-24 01:58:16 +01008# ################################################################
9
Yann Collet4c9a4c12016-09-19 14:58:14 +020010PRGDIR = programs
11ZSTDDIR = lib
12BUILDIR = build
inikepe9dfdf62016-05-27 11:56:15 +020013ZWRAPDIR = zlibWrapper
inikepa1c81152016-08-18 13:35:36 +020014TESTDIR = tests
Yann Collet4856a002015-01-24 01:58:16 +010015
Yann Collet88fcd292015-11-25 14:42:45 +010016# Define nul output
Yann Collet88fcd292015-11-25 14:42:45 +010017VOID = /dev/null
Przemyslaw Skibinski3a415592016-11-03 12:59:20 +010018
19ifneq (,$(filter Windows%,$(OS)))
20EXT =.exe
21else
22EXT =
Yann Collet88fcd292015-11-25 14:42:45 +010023endif
24
Yann Colletf3f13212016-11-02 17:02:45 -070025.PHONY: default
26default: lib zstd
Yann Collet213089c2015-06-18 07:43:16 -080027
Yann Colletf3f13212016-11-02 17:02:45 -070028.PHONY: all
Yann Colleta86a09e2016-12-22 11:31:39 +010029all: allmost
30 CPPFLAGS=-I../lib LDFLAGS=-L../lib $(MAKE) -C examples/ $@
31
32.PHONY: allmost
Yann Collet7cedbd12016-12-22 12:43:00 +010033allmost:
34 $(MAKE) -C $(ZSTDDIR) all
35 $(MAKE) -C $(PRGDIR) all
36 $(MAKE) -C $(TESTDIR) all
37 $(MAKE) -C $(ZWRAPDIR) all
38
39.PHONY: all32
40all32:
41 $(MAKE) -C $(PRGDIR) zstd32
42 $(MAKE) -C $(TESTDIR) all32
Yann Collet4856a002015-01-24 01:58:16 +010043
Yann Colletf3f13212016-11-02 17:02:45 -070044.PHONY: lib
45lib:
Yann Collete19111c2016-10-12 11:09:36 -070046 @$(MAKE) -C $(ZSTDDIR)
47
Yann Colletd41380e2016-11-07 14:55:12 -080048.PHONY: zstd
Yann Collet32faf6c2016-07-22 04:45:06 +020049zstd:
Yann Colletd41380e2016-11-07 14:55:12 -080050 @$(MAKE) -C $(PRGDIR) $@
Przemyslaw Skibinski3a415592016-11-03 12:59:20 +010051 cp $(PRGDIR)/zstd$(EXT) .
Yann Collet4856a002015-01-24 01:58:16 +010052
Yann Colletf3f13212016-11-02 17:02:45 -070053.PHONY: zlibwrapper
inikepe9dfdf62016-05-27 11:56:15 +020054zlibwrapper:
inikep68cd4762016-09-23 12:42:21 +020055 $(MAKE) -C $(ZWRAPDIR) test
inikepe9dfdf62016-05-27 11:56:15 +020056
Yann Colletf3f13212016-11-02 17:02:45 -070057.PHONY: test
Yann Collet6f9c0562016-05-01 10:26:30 +020058test:
inikepa1c81152016-08-18 13:35:36 +020059 $(MAKE) -C $(TESTDIR) $@
Yann Collet6f9c0562016-05-01 10:26:30 +020060
Yann Colletf3f13212016-11-02 17:02:45 -070061.PHONY: clean
Yann Collet4856a002015-01-24 01:58:16 +010062clean:
Yann Collet88fcd292015-11-25 14:42:45 +010063 @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
64 @$(MAKE) -C $(PRGDIR) $@ > $(VOID)
inikepa1c81152016-08-18 13:35:36 +020065 @$(MAKE) -C $(TESTDIR) $@ > $(VOID)
inikepe9dfdf62016-05-27 11:56:15 +020066 @$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID)
Yann Collet1f57c2e2016-12-21 16:20:11 +010067 @$(MAKE) -C examples/ $@ > $(VOID)
Yann Collet900f39e2017-01-20 16:36:29 -080068 @$(RM) zstd$(EXT) zstdmt$(EXT) tmp*
Yann Collet4856a002015-01-24 01:58:16 +010069 @echo Cleaning completed
70
71
Yann Collete405c7a2016-10-12 15:29:22 -070072#------------------------------------------------------------------------------
73# make install is validated only for Linux, OSX, Hurd and some BSD targets
74#------------------------------------------------------------------------------
Thomas Klausnerb85cdab2016-09-04 14:37:57 +020075ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD DragonFly NetBSD))
inikep13f42d92016-06-01 14:44:31 +020076HOST_OS = POSIX
Yann Colletf3f13212016-11-02 17:02:45 -070077.PHONY: install uninstall travis-install clangtest gpptest armtest usan asan uasan
78
Yann Collet4856a002015-01-24 01:58:16 +010079install:
Yann Collete19111c2016-10-12 11:09:36 -070080 @$(MAKE) -C $(ZSTDDIR) $@
81 @$(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010082
83uninstall:
Yann Collete19111c2016-10-12 11:09:36 -070084 @$(MAKE) -C $(ZSTDDIR) $@
85 @$(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010086
87travis-install:
Yann Colletc620b482015-12-01 01:56:02 +010088 $(MAKE) install PREFIX=~/install_test_dir
Yann Collet4856a002015-01-24 01:58:16 +010089
inikep13f42d92016-06-01 14:44:31 +020090gpptest: clean
Yann Collet33fce032017-01-16 19:46:22 -080091 CC=g++ $(MAKE) -C programs all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
Yann Collet3e5b73b2016-01-10 20:46:20 +010092
inikepc9bb1022016-06-21 18:04:13 +020093gcc5test: clean
94 gcc-5 -v
95 $(MAKE) all CC=gcc-5 MOREFLAGS="-Werror"
96
97gcc6test: clean
98 gcc-6 -v
99 $(MAKE) all CC=gcc-6 MOREFLAGS="-Werror"
100
Yann Collet213089c2015-06-18 07:43:16 -0800101clangtest: clean
Yann Colletf4ce8912015-08-11 14:18:45 +0100102 clang -v
Yann Colletcb5a3202016-08-26 08:06:36 +0200103 $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion -Wdocumentation"
Yann Collet213089c2015-06-18 07:43:16 -0800104
Yann Collet7083b8a2015-07-06 23:58:59 -0800105armtest: clean
inikep2d5eb2b2016-08-18 13:53:26 +0200106 $(MAKE) -C $(TESTDIR) datagen # use native, faster
Przemyslaw Skibinskie579ab52016-11-14 12:57:05 +0100107 $(MAKE) -C $(TESTDIR) test CC=arm-linux-gnueabi-gcc QEMU_SYS=qemu-arm-static ZSTDRTTEST= MOREFLAGS="-Werror -static"
108
109aarch64test:
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 Collet521b0102016-02-08 01:27:59 +0100112
Yann Collet521b0102016-02-08 01:27:59 +0100113ppctest: clean
inikep2d5eb2b2016-08-18 13:53:26 +0200114 $(MAKE) -C $(TESTDIR) datagen # use native, faster
Przemyslaw Skibinskie579ab52016-11-14 12:57:05 +0100115 $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc-static ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static"
Yann Collet521b0102016-02-08 01:27:59 +0100116
inikep1981d5a2016-05-30 10:18:56 +0200117ppc64test: clean
inikep2d5eb2b2016-08-18 13:53:26 +0200118 $(MAKE) -C $(TESTDIR) datagen # use native, faster
Przemyslaw Skibinskie579ab52016-11-14 12:57:05 +0100119 $(MAKE) -C $(TESTDIR) test CC=powerpc-linux-gnu-gcc QEMU_SYS=qemu-ppc64-static ZSTDRTTEST= MOREFLAGS="-m64 -static"
inikep1981d5a2016-05-30 10:18:56 +0200120
Yann Collet83fae972015-10-23 15:21:53 +0100121usan: clean
Yann Collet674d91b2015-07-07 00:36:49 -0800122 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined"
Yann Collet213089c2015-06-18 07:43:16 -0800123
Yann Collet83fae972015-10-23 15:21:53 +0100124asan: clean
125 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address"
126
Yann Colletd9967432016-05-18 14:16:49 +0200127msan: clean
Yann Collet6c364492016-08-12 00:05:59 +0200128 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=memory -fno-omit-frame-pointer" # datagen.c fails this test for no obvious reason
Yann Colletd9967432016-05-18 14:16:49 +0200129
Yann Collet6c3e2e72015-12-11 10:44:07 +0100130asan32: clean
inikep2d5eb2b2016-08-18 13:53:26 +0200131 $(MAKE) -C $(TESTDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address"
Yann Collet6c3e2e72015-12-11 10:44:07 +0100132
Yann Collet83fae972015-10-23 15:21:53 +0100133uasan: clean
134 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined"
135
Yann Collet4856a002015-01-24 01:58:16 +0100136endif
inikep13f42d92016-06-01 14:44:31 +0200137
138
139ifneq (,$(filter MSYS%,$(shell uname)))
140HOST_OS = MSYS
141CMAKE_PARAMS = -G"MSYS Makefiles"
142endif
143
144
145#------------------------------------------------------------------------
146#make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets
147#------------------------------------------------------------------------
148ifneq (,$(filter $(HOST_OS),MSYS POSIX))
149cmaketest:
150 cmake --version
Yann Collet0704df32016-09-19 16:55:35 +0200151 $(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
inikep13f42d92016-06-01 14:44:31 +0200154
155c90test: clean
156 CFLAGS="-std=c90" $(MAKE) all # will fail, due to // and long long
157
158gnu90test: clean
159 CFLAGS="-std=gnu90" $(MAKE) all
160
161c99test: clean
Yann Colleta86a09e2016-12-22 11:31:39 +0100162 CFLAGS="-std=c99" $(MAKE) allmost
inikep13f42d92016-06-01 14:44:31 +0200163
164gnu99test: clean
165 CFLAGS="-std=gnu99" $(MAKE) all
166
167c11test: clean
Yann Colleta86a09e2016-12-22 11:31:39 +0100168 CFLAGS="-std=c11" $(MAKE) allmost
inikep13f42d92016-06-01 14:44:31 +0200169
170bmix64test: clean
inikep2d5eb2b2016-08-18 13:53:26 +0200171 CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(TESTDIR) test
inikep13f42d92016-06-01 14:44:31 +0200172
173bmix32test: clean
inikep2d5eb2b2016-08-18 13:53:26 +0200174 CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(TESTDIR) test
inikep13f42d92016-06-01 14:44:31 +0200175
176bmi32test: clean
inikep2d5eb2b2016-08-18 13:53:26 +0200177 CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(TESTDIR) test
Yann Colletc35cd5b2016-06-30 15:40:28 +0200178
179staticAnalyze: clean
Yann Collet677ed262016-07-10 14:23:30 +0200180 CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all
inikep13f42d92016-06-01 14:44:31 +0200181endif