1 # ################################################################ 2 # LZ4 - Makefile 3 # Copyright (C) Yann Collet 2011-2016 4 # All rights reserved. 5 # 6 # BSD license 7 # Redistribution and use in source and binary forms, with or without modification, 8 # are permitted provided that the following conditions are met: 9 # 10 # * Redistributions of source code must retain the above copyright notice, this 11 # list of conditions and the following disclaimer. 12 # 13 # * Redistributions in binary form must reproduce the above copyright notice, this 14 # list of conditions and the following disclaimer in the documentation and/or 15 # other materials provided with the distribution. 16 # 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # 28 # You can contact the author at : 29 # - LZ4 source repository : https://github.com/Cyan4973/lz4 30 # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c 31 # ################################################################ 32 33 DESTDIR ?= 34 PREFIX ?= /usr/local 35 VOID := /dev/null 36 37 LIBDIR ?= $(PREFIX)/lib 38 INCLUDEDIR=$(PREFIX)/include 39 LZ4DIR = lib 40 PRGDIR = programs 41 TESTDIR = tests 42 EXDIR = examples 43 44 45 # Define nul output 46 ifneq (,$(filter Windows%,$(OS))) 47 EXT = .exe 48 else 49 EXT = 50 endif 51 52 53 .PHONY: default all lib lz4 clean test versionsTest examples 54 55 default: 56 @$(MAKE) -C $(LZ4DIR) 57 @$(MAKE) -C $(PRGDIR) 58 @cp $(PRGDIR)/lz4$(EXT) . 59 60 all: 61 @$(MAKE) -C $(LZ4DIR) $@ 62 @$(MAKE) -C $(PRGDIR) $@ 63 @$(MAKE) -C $(TESTDIR) $@ 64 @$(MAKE) -C $(EXDIR) $@ 65 66 lib: 67 @$(MAKE) -C $(LZ4DIR) 68 69 lz4: 70 @$(MAKE) -C $(PRGDIR) $@ 71 @cp $(PRGDIR)/lz4$(EXT) . 72 73 lz4-release: 74 @$(MAKE) -C $(PRGDIR) 75 @cp $(PRGDIR)/lz4$(EXT) . 76 77 clean: 78 @$(MAKE) -C $(PRGDIR) $@ > $(VOID) 79 @$(MAKE) -C $(TESTDIR) $@ > $(VOID) 80 @$(MAKE) -C $(LZ4DIR) $@ > $(VOID) 81 @$(MAKE) -C $(EXDIR) $@ > $(VOID) 82 @$(MAKE) -C examples $@ > $(VOID) 83 @$(RM) lz4$(EXT) 84 @echo Cleaning completed 85 86 87 #------------------------------------------------------------------------ 88 #make install is validated only for Linux, OSX, kFreeBSD, Hurd and 89 #FreeBSD targets 90 ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD)) 91 HOST_OS = POSIX 92 93 install: 94 @$(MAKE) -C $(LZ4DIR) $@ 95 @$(MAKE) -C $(PRGDIR) $@ 96 97 uninstall: 98 @$(MAKE) -C $(LZ4DIR) $@ 99 @$(MAKE) -C $(PRGDIR) $@ 100 101 travis-install: 102 $(MAKE) -j1 install PREFIX=~/install_test_dir 103 104 test: 105 $(MAKE) -C $(TESTDIR) $@ 106 107 clangtest: clean 108 clang -v 109 @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR) all CC=clang 110 @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR) all CC=clang 111 @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) all CC=clang 112 113 clangtest-native: clean 114 clang -v 115 @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR) all CC=clang 116 @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR) native CC=clang 117 @CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) native CC=clang 118 119 usan: clean 120 CC=clang CFLAGS="-O3 -g -fsanitize=undefined" $(MAKE) test FUZZER_TIME="-T1mn" NB_LOOPS=-i1 121 122 usan32: clean 123 CFLAGS="-m32 -O3 -g -fsanitize=undefined" $(MAKE) test FUZZER_TIME="-T1mn" NB_LOOPS=-i1 124 125 staticAnalyze: clean 126 CFLAGS=-g scan-build --status-bugs -v $(MAKE) all 127 128 platformTest: clean 129 @echo "\n ---- test lz4 with $(CC) compiler ----" 130 @$(CC) -v 131 CFLAGS="-O3 -Werror" $(MAKE) -C $(LZ4DIR) all 132 CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) all 133 CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) all 134 $(MAKE) -C $(TESTDIR) test-platform 135 136 versionsTest: clean 137 $(MAKE) -C $(TESTDIR) $@ 138 139 examples: 140 $(MAKE) -C $(LZ4DIR) 141 $(MAKE) -C $(PRGDIR) lz4 142 $(MAKE) -C examples test 143 144 endif 145 146 147 ifneq (,$(filter MSYS%,$(shell uname))) 148 HOST_OS = MSYS 149 CMAKE_PARAMS = -G"MSYS Makefiles" 150 endif 151 152 153 #------------------------------------------------------------------------ 154 #make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets 155 #------------------------------------------------------------------------ 156 ifneq (,$(filter $(HOST_OS),MSYS POSIX)) 157 158 cmake: 159 @cd contrib/cmake_unofficial; cmake $(CMAKE_PARAMS) CMakeLists.txt; $(MAKE) 160 161 gpptest: clean 162 g++ -v 163 CC=g++ $(MAKE) -C $(LZ4DIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" 164 CC=g++ $(MAKE) -C $(PRGDIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" 165 CC=g++ $(MAKE) -C $(TESTDIR) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" 166 167 gpptest32: clean 168 g++ -v 169 CC=g++ $(MAKE) -C $(LZ4DIR) all CFLAGS="-m32 -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" 170 CC=g++ $(MAKE) -C $(PRGDIR) native CFLAGS="-m32 -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" 171 CC=g++ $(MAKE) -C $(TESTDIR) native CFLAGS="-m32 -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror" 172 173 c_standards: clean 174 $(MAKE) all MOREFLAGS="-std=gnu90 -Werror" 175 $(MAKE) clean 176 $(MAKE) all MOREFLAGS="-std=c99 -Werror" 177 $(MAKE) clean 178 $(MAKE) all MOREFLAGS="-std=gnu99 -Werror" 179 $(MAKE) clean 180 $(MAKE) all MOREFLAGS="-std=c11 -Werror" 181 $(MAKE) clean 182 183 endif 184