blob: 0894f75d7ada6cdd369b684df8d091ad9be6d226 [file] [log] [blame]
Yann Collet4856a002015-01-24 01:58:16 +01001# ################################################################
2# zstd - Makefile
Yann Collet648959a2016-02-07 23:58:32 +01003# Copyright (C) Yann Collet 2014-2016
Yann Collet4856a002015-01-24 01:58:16 +01004# All rights reserved.
5#
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:
10#
11# * Redistributions of source code must retain the above copyright notice, this
12# list of conditions and the following disclaimer.
13#
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.
17#
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.
28#
29# You can contact the author at :
Yann Collet4f0a3932016-02-07 04:00:27 +010030# - zstd homepage : http://www.zstd.net/
Yann Collet4856a002015-01-24 01:58:16 +010031# ################################################################
32
Yann Collet4856a002015-01-24 01:58:16 +010033PRGDIR = programs
34ZSTDDIR = lib
35
Yann Collet88fcd292015-11-25 14:42:45 +010036# Define nul output
37ifneq (,$(filter Windows%,$(OS)))
38VOID = nul
39else
40VOID = /dev/null
41endif
42
43.PHONY: default all zstdprogram clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan
Yann Collet213089c2015-06-18 07:43:16 -080044
Yann Colletbf504092015-08-26 00:19:06 +010045default: zstdprogram
Yann Collet4856a002015-01-24 01:58:16 +010046
47all:
Yann Colletbf504092015-08-26 00:19:06 +010048 $(MAKE) -C $(ZSTDDIR) $@
49 $(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010050
Yann Colletbf504092015-08-26 00:19:06 +010051zstdprogram:
52 $(MAKE) -C $(PRGDIR)
Yann Collet4856a002015-01-24 01:58:16 +010053
Yann Collet6f9c0562016-05-01 10:26:30 +020054test:
55 $(MAKE) -C $(PRGDIR) $@
56
Yann Collet4856a002015-01-24 01:58:16 +010057clean:
Yann Collet88fcd292015-11-25 14:42:45 +010058 @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
59 @$(MAKE) -C $(PRGDIR) $@ > $(VOID)
Yann Collet4856a002015-01-24 01:58:16 +010060 @echo Cleaning completed
61
62
63#------------------------------------------------------------------------
64#make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
65ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
66
67install:
Yann Colletbf504092015-08-26 00:19:06 +010068 $(MAKE) -C $(ZSTDDIR) $@
69 $(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010070
71uninstall:
Yann Colletbf504092015-08-26 00:19:06 +010072 $(MAKE) -C $(ZSTDDIR) $@
73 $(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010074
75travis-install:
Yann Colletc620b482015-12-01 01:56:02 +010076 $(MAKE) install PREFIX=~/install_test_dir
Yann Collet4856a002015-01-24 01:58:16 +010077
Yann Collet3e5b73b2016-01-10 20:46:20 +010078cmaketest:
inikep33b8a892016-05-24 17:44:14 +020079 cd projects/cmake/build ; cmake .. ; $(MAKE)
Yann Collet3e5b73b2016-01-10 20:46:20 +010080
Yann Collet213089c2015-06-18 07:43:16 -080081clangtest: clean
Yann Colletf4ce8912015-08-11 14:18:45 +010082 clang -v
Yann Collet213089c2015-06-18 07:43:16 -080083 $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"
84
85gpptest: clean
86 $(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
87
Yann Colletddb8ebd2016-05-05 04:59:53 +020088c90test: clean
Yann Colletde4d4da2016-05-20 12:20:12 +020089 CFLAGS="-std=c90" $(MAKE) all # will fail, due to // and long long
90
91gnu90test: clean
92 CFLAGS="-std=gnu90" $(MAKE) all
93
94c99test: clean
95 CFLAGS="-std=c99" $(MAKE) all
96
97gnu99test: clean
98 CFLAGS="-std=gnu99" $(MAKE) all
99
100c11test: clean
101 CFLAGS="-std=c11" $(MAKE) all
Yann Collet3f8ed502016-05-05 03:01:13 +0200102
Yann Collet6f9c0562016-05-01 10:26:30 +0200103bmix64test: clean
104 CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(PRGDIR) test
105
106bmix32test: clean
107 CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(PRGDIR) test
108
109bmi32test: clean
110 CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(PRGDIR) test
111
Yann Collet7083b8a2015-07-06 23:58:59 -0800112armtest: clean
Yann Collet648959a2016-02-07 23:58:32 +0100113 $(MAKE) -C $(PRGDIR) datagen # use native, faster
Yann Collet74bd1192016-03-26 17:50:26 +0100114 $(MAKE) -C $(PRGDIR) test CC=arm-linux-gnueabi-gcc ZSTDRTTEST= MOREFLAGS="-Werror -static"
Yann Collet521b0102016-02-08 01:27:59 +0100115
116# for Travis CI
117arminstall: clean
118 sudo apt-get install -q qemu
119 sudo apt-get install -q binfmt-support
120 sudo apt-get install -q qemu-user-static
121 sudo apt-get install -q gcc-arm-linux-gnueabi
122
123# for Travis CI
124armtest-w-install: clean arminstall armtest
125
126ppctest: clean
127 $(MAKE) -C $(PRGDIR) datagen # use native, faster
Yann Collet74bd1192016-03-26 17:50:26 +0100128 $(MAKE) -C $(PRGDIR) test CC=powerpc-linux-gnu-gcc ZSTDRTTEST= MOREFLAGS="-Werror -static"
Yann Collet521b0102016-02-08 01:27:59 +0100129
130# for Travis CI
131ppcinstall: clean
132 sudo apt-get install -q qemu
133 sudo apt-get install -q binfmt-support
134 sudo apt-get install -q qemu-user-static
Yann Collet991b3902016-02-08 20:58:37 +0100135 sudo apt-get update -q
136 sudo apt-get install -q gcc-powerpc-linux-gnu # unfortunately, doesn't work on Travis CI (package not available)
Yann Collet521b0102016-02-08 01:27:59 +0100137
138# for Travis CI
139ppctest-w-install: clean ppcinstall ppctest
Yann Collet7083b8a2015-07-06 23:58:59 -0800140
Yann Collet83fae972015-10-23 15:21:53 +0100141usan: clean
Yann Collet674d91b2015-07-07 00:36:49 -0800142 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined"
Yann Collet213089c2015-06-18 07:43:16 -0800143
Yann Collet83fae972015-10-23 15:21:53 +0100144asan: clean
145 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address"
146
Yann Colletd9967432016-05-18 14:16:49 +0200147msan: clean
Yann Colletbde926f2016-05-18 17:18:48 +0200148 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=memory" # datagen.c fails this test, for no obvious reason
Yann Colletd9967432016-05-18 14:16:49 +0200149
Yann Collet6c3e2e72015-12-11 10:44:07 +0100150asan32: clean
151 $(MAKE) -C $(PRGDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address"
152
Yann Collet83fae972015-10-23 15:21:53 +0100153uasan: clean
154 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined"
155
Yann Collet4856a002015-01-24 01:58:16 +0100156endif