blob: 6e83f33a91df45519dc2977e078e1d8ac77a8eed [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.
Yann Collet118bfc42016-05-30 18:50:28 +02005#
Yann Collet4856a002015-01-24 01:58:16 +01006# 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 Collet118bfc42016-05-30 18:50:28 +020010#
Yann Collet4856a002015-01-24 01:58:16 +010011# * Redistributions of source code must retain the above copyright notice, this
12# list of conditions and the following disclaimer.
Yann Collet118bfc42016-05-30 18:50:28 +020013#
Yann Collet4856a002015-01-24 01:58:16 +010014# * 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 Collet118bfc42016-05-30 18:50:28 +020017#
Yann Collet4856a002015-01-24 01:58:16 +010018# 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 Collet118bfc42016-05-30 18:50:28 +020028#
Yann Collet4856a002015-01-24 01:58:16 +010029# 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
inikepe9dfdf62016-05-27 11:56:15 +020035ZWRAPDIR = zlibWrapper
Yann Collet4856a002015-01-24 01:58:16 +010036
Yann Collet88fcd292015-11-25 14:42:45 +010037# Define nul output
38ifneq (,$(filter Windows%,$(OS)))
39VOID = nul
40else
41VOID = /dev/null
42endif
43
Yann Collet32faf6c2016-07-22 04:45:06 +020044.PHONY: default all zlibwrapper zstd clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan
Yann Collet213089c2015-06-18 07:43:16 -080045
Yann Collet32faf6c2016-07-22 04:45:06 +020046default: zstd
Yann Collet4856a002015-01-24 01:58:16 +010047
Yann Collet118bfc42016-05-30 18:50:28 +020048all:
Yann Colletbf504092015-08-26 00:19:06 +010049 $(MAKE) -C $(ZSTDDIR) $@
50 $(MAKE) -C $(PRGDIR) $@
Yann Collet32faf6c2016-07-22 04:45:06 +020051 @rm -f lib/decompress/*.o
52 $(MAKE) -C $(PRGDIR) all32
Yann Collet4856a002015-01-24 01:58:16 +010053
Yann Collet32faf6c2016-07-22 04:45:06 +020054zstd:
Yann Colletbf504092015-08-26 00:19:06 +010055 $(MAKE) -C $(PRGDIR)
inikepc9bb1022016-06-21 18:04:13 +020056 cp $(PRGDIR)/zstd .
Yann Collet4856a002015-01-24 01:58:16 +010057
inikepe9dfdf62016-05-27 11:56:15 +020058zlibwrapper:
59 $(MAKE) -C $(ZSTDDIR) all
60 $(MAKE) -C $(ZWRAPDIR) all
61
Yann Collet6f9c0562016-05-01 10:26:30 +020062test:
63 $(MAKE) -C $(PRGDIR) $@
64
Yann Collet4856a002015-01-24 01:58:16 +010065clean:
Yann Collet88fcd292015-11-25 14:42:45 +010066 @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
67 @$(MAKE) -C $(PRGDIR) $@ > $(VOID)
inikepe9dfdf62016-05-27 11:56:15 +020068 @$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID)
Yann Collet06d9a732016-06-19 14:27:21 +020069 @rm -f zstd
Yann Collet4856a002015-01-24 01:58:16 +010070 @echo Cleaning completed
71
72
jrmarino0d07ec02016-07-30 19:10:36 -050073#----------------------------------------------------------------------------------
74#make install is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets
75#----------------------------------------------------------------------------------
76ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD DragonFly))
inikep13f42d92016-06-01 14:44:31 +020077HOST_OS = POSIX
Yann Collet4856a002015-01-24 01:58:16 +010078install:
Yann Colletbf504092015-08-26 00:19:06 +010079 $(MAKE) -C $(ZSTDDIR) $@
80 $(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010081
82uninstall:
Yann Colletbf504092015-08-26 00:19:06 +010083 $(MAKE) -C $(ZSTDDIR) $@
84 $(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010085
86travis-install:
Yann Colletc620b482015-12-01 01:56:02 +010087 $(MAKE) install PREFIX=~/install_test_dir
Yann Collet4856a002015-01-24 01:58:16 +010088
inikep13f42d92016-06-01 14:44:31 +020089gpptest: clean
Yann Collet32faf6c2016-07-22 04:45:06 +020090 $(MAKE) -C programs all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
Yann Collet3e5b73b2016-01-10 20:46:20 +010091
inikepc9bb1022016-06-21 18:04:13 +020092gcc5test: clean
93 gcc-5 -v
94 $(MAKE) all CC=gcc-5 MOREFLAGS="-Werror"
95
96gcc6test: clean
97 gcc-6 -v
98 $(MAKE) all CC=gcc-6 MOREFLAGS="-Werror"
99
Yann Collet213089c2015-06-18 07:43:16 -0800100clangtest: clean
Yann Colletf4ce8912015-08-11 14:18:45 +0100101 clang -v
Yann Collet213089c2015-06-18 07:43:16 -0800102 $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"
103
Yann Collet7083b8a2015-07-06 23:58:59 -0800104armtest: clean
Yann Collet648959a2016-02-07 23:58:32 +0100105 $(MAKE) -C $(PRGDIR) datagen # use native, faster
Yann Collet74bd1192016-03-26 17:50:26 +0100106 $(MAKE) -C $(PRGDIR) test CC=arm-linux-gnueabi-gcc ZSTDRTTEST= MOREFLAGS="-Werror -static"
Yann Collet521b0102016-02-08 01:27:59 +0100107
Yann Collet521b0102016-02-08 01:27:59 +0100108ppctest: clean
109 $(MAKE) -C $(PRGDIR) datagen # use native, faster
inikep003c7a82016-07-27 11:07:13 +0200110 $(MAKE) -C $(PRGDIR) test CC=powerpc-linux-gnu-gcc ZSTDRTTEST= MOREFLAGS="-Werror -Wno-attributes -static"
Yann Collet521b0102016-02-08 01:27:59 +0100111
inikep1981d5a2016-05-30 10:18:56 +0200112ppc64test: clean
113 $(MAKE) -C $(PRGDIR) datagen # use native, faster
inikep5e0ed482016-07-26 08:37:53 +0200114 $(MAKE) -C $(PRGDIR) test CC=powerpc-linux-gnu-gcc ZSTDRTTEST= MOREFLAGS="-m64 -static"
inikep1981d5a2016-05-30 10:18:56 +0200115
Yann Collet83fae972015-10-23 15:21:53 +0100116usan: clean
Yann Collet674d91b2015-07-07 00:36:49 -0800117 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined"
Yann Collet213089c2015-06-18 07:43:16 -0800118
Yann Collet83fae972015-10-23 15:21:53 +0100119asan: clean
120 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address"
121
Yann Colletd9967432016-05-18 14:16:49 +0200122msan: clean
Yann Collet6c364492016-08-12 00:05:59 +0200123 $(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 +0200124
Yann Collet6c3e2e72015-12-11 10:44:07 +0100125asan32: clean
126 $(MAKE) -C $(PRGDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address"
127
Yann Collet83fae972015-10-23 15:21:53 +0100128uasan: clean
129 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined"
130
Yann Collet4856a002015-01-24 01:58:16 +0100131endif
inikep13f42d92016-06-01 14:44:31 +0200132
133
134ifneq (,$(filter MSYS%,$(shell uname)))
135HOST_OS = MSYS
136CMAKE_PARAMS = -G"MSYS Makefiles"
137endif
138
139
140#------------------------------------------------------------------------
141#make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets
142#------------------------------------------------------------------------
143ifneq (,$(filter $(HOST_OS),MSYS POSIX))
144cmaketest:
145 cmake --version
146 rm -rf projects/cmake/build
147 mkdir projects/cmake/build
inikepc7f008b2016-06-03 11:40:15 +0200148 cd projects/cmake/build ; cmake -DPREFIX:STRING=~/install_test_dir $(CMAKE_PARAMS) .. ; $(MAKE) install ; $(MAKE) uninstall
inikep13f42d92016-06-01 14:44:31 +0200149
150c90test: clean
151 CFLAGS="-std=c90" $(MAKE) all # will fail, due to // and long long
152
153gnu90test: clean
154 CFLAGS="-std=gnu90" $(MAKE) all
155
156c99test: clean
157 CFLAGS="-std=c99" $(MAKE) all
158
159gnu99test: clean
160 CFLAGS="-std=gnu99" $(MAKE) all
161
162c11test: clean
163 CFLAGS="-std=c11" $(MAKE) all
164
165bmix64test: clean
166 CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(PRGDIR) test
167
168bmix32test: clean
169 CFLAGS="-O3 -mbmi -mx32 -Werror" $(MAKE) -C $(PRGDIR) test
170
171bmi32test: clean
172 CFLAGS="-O3 -mbmi -m32 -Werror" $(MAKE) -C $(PRGDIR) test
Yann Colletc35cd5b2016-06-30 15:40:28 +0200173
174staticAnalyze: clean
Yann Collet677ed262016-07-10 14:23:30 +0200175 CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all
inikep13f42d92016-06-01 14:44:31 +0200176endif
inikepc9bb1022016-06-21 18:04:13 +0200177
178
179#------------------------------------------------------------------------
180# for Travis CI
181#------------------------------------------------------------------------
182libc6install:
183 sudo apt-get install -y -qq libc6-dev-i386
184
185gppinstall:
186 sudo apt-get install -y -qq g++-multilib
187
188gcc5install:
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
193gcc6install:
194 sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
Yann Colletc35cd5b2016-06-30 15:40:28 +0200195 sudo apt-get update -y -qq
inikepc9bb1022016-06-21 18:04:13 +0200196 sudo apt-get install -y -qq gcc-6-multilib
197
198arminstall: clean
199 sudo apt-get install -y -q qemu binfmt-support qemu-user-static gcc-arm-linux-gnueabi
200
201ppcinstall: 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
204ppc64install: 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
208valgrindinstall:
209 echo sudo apt-get install -y -qq valgrind
210 sudo apt-get install -y -qq valgrind