blob: 9ff867fbb2a6712f1488659717859ae8bba37875 [file] [log] [blame]
Yann Collet4856a002015-01-24 01:58:16 +01001# ################################################################
2# zstd - Makefile
3# Copyright (C) Yann Collet 2014-2015
4# 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 :
30# - zstd source repository : https://github.com/Cyan4973/zstd
31# - Public forum : https://groups.google.com/forum/#!forum/lz4c
32# ################################################################
33
Yann Collet722504c2015-12-31 18:32:15 +010034# force a version number : uncomment below export (otherwise, default to the one declared into zstd.h)
35#export VERSION := 0.4.6
Yann Collet4856a002015-01-24 01:58:16 +010036
Yann Collet4856a002015-01-24 01:58:16 +010037PRGDIR = programs
38ZSTDDIR = lib
Yann Collet9cadd082016-01-28 15:39:52 +010039DICTDIR = dictBuilder
Yann Collet4856a002015-01-24 01:58:16 +010040
Yann Collet88fcd292015-11-25 14:42:45 +010041# Define nul output
42ifneq (,$(filter Windows%,$(OS)))
43VOID = nul
44else
45VOID = /dev/null
46endif
47
48.PHONY: default all zstdprogram clean install uninstall travis-install test clangtest gpptest armtest usan asan uasan
Yann Collet213089c2015-06-18 07:43:16 -080049
Yann Colletbf504092015-08-26 00:19:06 +010050default: zstdprogram
Yann Collet4856a002015-01-24 01:58:16 +010051
52all:
Yann Colletbf504092015-08-26 00:19:06 +010053 $(MAKE) -C $(ZSTDDIR) $@
54 $(MAKE) -C $(PRGDIR) $@
Yann Collet9cadd082016-01-28 15:39:52 +010055 $(MAKE) -C $(DICTDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010056
Yann Colletbf504092015-08-26 00:19:06 +010057zstdprogram:
58 $(MAKE) -C $(PRGDIR)
Yann Collet4856a002015-01-24 01:58:16 +010059
60clean:
Yann Collet88fcd292015-11-25 14:42:45 +010061 @$(MAKE) -C $(ZSTDDIR) $@ > $(VOID)
62 @$(MAKE) -C $(PRGDIR) $@ > $(VOID)
Yann Collet9cadd082016-01-28 15:39:52 +010063 @$(MAKE) -C $(DICTDIR) $@ > $(VOID)
Yann Collet4856a002015-01-24 01:58:16 +010064 @echo Cleaning completed
65
66
67#------------------------------------------------------------------------
68#make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
69ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
70
71install:
Yann Colletbf504092015-08-26 00:19:06 +010072 $(MAKE) -C $(ZSTDDIR) $@
73 $(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010074
75uninstall:
Yann Colletbf504092015-08-26 00:19:06 +010076 $(MAKE) -C $(ZSTDDIR) $@
77 $(MAKE) -C $(PRGDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010078
79travis-install:
Yann Colletc620b482015-12-01 01:56:02 +010080 $(MAKE) install PREFIX=~/install_test_dir
Yann Collet4856a002015-01-24 01:58:16 +010081
82test:
Yann Colletbf504092015-08-26 00:19:06 +010083 $(MAKE) -C $(PRGDIR) $@
Yann Collet9cadd082016-01-28 15:39:52 +010084 $(MAKE) -C $(DICTDIR) $@
Yann Collet4856a002015-01-24 01:58:16 +010085
Yann Collet3e5b73b2016-01-10 20:46:20 +010086cmaketest:
87 cd contrib/cmake ; cmake . ; $(MAKE)
88
Yann Collet213089c2015-06-18 07:43:16 -080089clangtest: clean
Yann Colletf4ce8912015-08-11 14:18:45 +010090 clang -v
Yann Collet213089c2015-06-18 07:43:16 -080091 $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"
92
93gpptest: clean
94 $(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
95
Yann Collet7083b8a2015-07-06 23:58:59 -080096armtest: clean
Yann Collet417890c2015-12-04 17:16:37 +010097 $(MAKE) -C $(ZSTDDIR) all CC=arm-linux-gnueabi-gcc MOREFLAGS="-Werror"
98 $(MAKE) -C $(PRGDIR) CC=arm-linux-gnueabi-gcc MOREFLAGS="-Werror -static"
Yann Collet7083b8a2015-07-06 23:58:59 -080099
Yann Collet83fae972015-10-23 15:21:53 +0100100usan: clean
Yann Collet674d91b2015-07-07 00:36:49 -0800101 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined"
Yann Collet213089c2015-06-18 07:43:16 -0800102
Yann Collet83fae972015-10-23 15:21:53 +0100103asan: clean
104 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address"
105
Yann Collet6c3e2e72015-12-11 10:44:07 +0100106asan32: clean
107 $(MAKE) -C $(PRGDIR) test32 CC=clang MOREFLAGS="-g -fsanitize=address"
108
Yann Collet83fae972015-10-23 15:21:53 +0100109uasan: clean
110 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=address -fsanitize=undefined"
111
Yann Collet4856a002015-01-24 01:58:16 +0100112endif