• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ################################################################
2# LZ4 - Makefile
3# Copyright (C) Yann Collet 2011-present
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/lz4/lz4
30#  - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
31# ################################################################
32
33LZ4DIR  = lib
34PRGDIR  = programs
35TESTDIR = tests
36EXDIR   = examples
37
38
39# Define nul output
40ifneq (,$(filter Windows%,$(OS)))
41EXT  = .exe
42VOID = nul
43else
44EXT  =
45VOID = /dev/null
46endif
47
48
49.PHONY: default
50default: lib-release lz4-release
51
52.PHONY: all
53all: allmost manuals
54
55.PHONY: allmost
56allmost: lib lz4 examples
57
58.PHONY: lib lib-release liblz4.a
59lib: liblz4.a
60lib lib-release liblz4.a:
61	@$(MAKE) -C $(LZ4DIR) $@
62
63.PHONY: lz4 lz4-release
64lz4 : liblz4.a
65lz4-release : lib-release
66lz4 lz4-release :
67	@$(MAKE) -C $(PRGDIR) $@
68	@cp $(PRGDIR)/lz4$(EXT) .
69
70.PHONY: examples
71examples: liblz4.a
72	$(MAKE) -C $(EXDIR) all
73
74.PHONY: manuals
75manuals:
76	@$(MAKE) -C contrib/gen_manual $@
77
78.PHONY: clean
79clean:
80	@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
81	@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
82	@$(MAKE) -C $(TESTDIR) $@ > $(VOID)
83	@$(MAKE) -C $(EXDIR) $@ > $(VOID)
84	@$(MAKE) -C contrib/gen_manual $@ > $(VOID)
85	@$(RM) lz4$(EXT)
86	@echo Cleaning completed
87
88
89#-----------------------------------------------------------------------------
90# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
91#-----------------------------------------------------------------------------
92ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD))
93HOST_OS = POSIX
94
95.PHONY: install uninstall
96install uninstall:
97	@$(MAKE) -C $(LZ4DIR) $@
98	@$(MAKE) -C $(PRGDIR) $@
99
100travis-install:
101	$(MAKE) -j1 install DESTDIR=~/install_test_dir
102
103cmake:
104	@cd contrib/cmake_unofficial; cmake $(CMAKE_PARAMS) CMakeLists.txt; $(MAKE)
105
106endif
107
108
109ifneq (,$(filter MSYS%,$(shell uname)))
110HOST_OS = MSYS
111CMAKE_PARAMS = -G"MSYS Makefiles"
112endif
113
114
115#------------------------------------------------------------------------
116#make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets
117#------------------------------------------------------------------------
118ifneq (,$(filter $(HOST_OS),MSYS POSIX))
119
120.PHONY: list
121list:
122	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
123
124.PHONY: check
125check:
126	$(MAKE) -C $(TESTDIR) test-lz4-essentials
127
128.PHONY: test
129test:
130	$(MAKE) -C $(TESTDIR) $@
131	$(MAKE) -C $(EXDIR) $@
132
133clangtest: clean
134	clang -v
135	@CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR)  all CC=clang
136	@CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR)  all CC=clang
137	@CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) all CC=clang
138
139clangtest-native: clean
140	clang -v
141	@CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(LZ4DIR)  all    CC=clang
142	@CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(PRGDIR)  native CC=clang
143	@CFLAGS="-O3 -Werror -Wconversion -Wno-sign-conversion" $(MAKE) -C $(TESTDIR) native CC=clang
144
145usan: clean
146	CC=clang CFLAGS="-O3 -g -fsanitize=undefined" $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
147
148usan32: clean
149	CFLAGS="-m32 -O3 -g -fsanitize=undefined" $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
150
151staticAnalyze: clean
152	CFLAGS=-g scan-build --status-bugs -v $(MAKE) all
153
154platformTest: clean
155	@echo "\n ---- test lz4 with $(CC) compiler ----"
156	@$(CC) -v
157	CFLAGS="-O3 -Werror"         $(MAKE) -C $(LZ4DIR) all
158	CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) all
159	CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) all
160	$(MAKE) -C $(TESTDIR) test-platform
161
162.PHONY: versionsTest
163versionsTest: clean
164	$(MAKE) -C $(TESTDIR) $@
165
166gpptest gpptest32: CC = "$(CXX) -Wno-deprecated"
167gpptest gpptest32: CFLAGS = -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror
168gpptest32: CFLAGS += -m32
169gpptest gpptest32: clean
170	$(CXX) -v
171	CC=$(CC) $(MAKE) -C $(LZ4DIR)  all CFLAGS="$(CFLAGS)"
172	CC=$(CC) $(MAKE) -C $(PRGDIR)  all CFLAGS="$(CFLAGS)"
173	CC=$(CC) $(MAKE) -C $(TESTDIR) all CFLAGS="$(CFLAGS)"
174
175ctocpptest: LIBCC="$(CC)"
176ctocpptest: TESTCC="$(CXX)"
177ctocpptest: CFLAGS=""
178ctocpptest: clean
179	CC=$(LIBCC)  $(MAKE) -C $(LZ4DIR)  CFLAGS="$(CFLAGS)" all
180	CC=$(LIBCC)  $(MAKE) -C $(TESTDIR) CFLAGS="$(CFLAGS)" lz4.o lz4hc.o lz4frame.o
181	CC=$(TESTCC) $(MAKE) -C $(TESTDIR) CFLAGS="$(CFLAGS)" all
182
183c_standards: clean
184	CFLAGS="-std=c90   -Werror" $(MAKE) clean allmost
185	CFLAGS="-std=gnu90 -Werror" $(MAKE) clean allmost
186	CFLAGS="-std=c99   -Werror" $(MAKE) clean allmost
187	CFLAGS="-std=gnu99 -Werror" $(MAKE) clean allmost
188	CFLAGS="-std=c11   -Werror" $(MAKE) clean allmost
189
190endif
191