• 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
37FUZZDIR = ossfuzz
38
39include Makefile.inc
40
41.PHONY: default
42default: lib-release lz4-release
43
44.PHONY: all
45all: allmost examples manuals build_tests
46
47.PHONY: allmost
48allmost: lib lz4
49
50.PHONY: lib lib-release liblz4.a
51lib: liblz4.a
52lib lib-release liblz4.a:
53	@$(MAKE) -C $(LZ4DIR) $@
54
55.PHONY: lz4 lz4-release
56lz4 : liblz4.a
57lz4-release : lib-release
58lz4 lz4-release :
59	@$(MAKE) -C $(PRGDIR) $@
60	@cp $(PRGDIR)/lz4$(EXT) .
61
62.PHONY: examples
63examples: liblz4.a
64	$(MAKE) -C $(EXDIR) all
65
66.PHONY: manuals
67manuals:
68	@$(MAKE) -C contrib/gen_manual $@
69
70.PHONY: build_tests
71build_tests:
72	@$(MAKE) -C $(TESTDIR) all
73
74.PHONY: clean
75clean:
76	@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
77	@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
78	@$(MAKE) -C $(TESTDIR) $@ > $(VOID)
79	@$(MAKE) -C $(EXDIR) $@ > $(VOID)
80	@$(MAKE) -C $(FUZZDIR) $@ > $(VOID)
81	@$(MAKE) -C contrib/gen_manual $@ > $(VOID)
82	@$(RM) lz4$(EXT)
83	@echo Cleaning completed
84
85
86#-----------------------------------------------------------------------------
87# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
88#-----------------------------------------------------------------------------
89ifeq ($(POSIX_ENV),Yes)
90HOST_OS = POSIX
91
92.PHONY: install uninstall
93install uninstall:
94	@$(MAKE) -C $(LZ4DIR) $@
95	@$(MAKE) -C $(PRGDIR) $@
96
97travis-install:
98	$(MAKE) -j1 install DESTDIR=~/install_test_dir
99
100cmake:
101	@cd contrib/cmake_unofficial; cmake $(CMAKE_PARAMS) CMakeLists.txt; $(MAKE)
102
103endif
104
105
106ifneq (,$(filter MSYS%,$(shell uname)))
107HOST_OS = MSYS
108CMAKE_PARAMS = -G"MSYS Makefiles"
109endif
110
111
112#------------------------------------------------------------------------
113#make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets
114#------------------------------------------------------------------------
115ifneq (,$(filter $(HOST_OS),MSYS POSIX))
116
117.PHONY: list
118list:
119	@$(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
120
121.PHONY: check
122check:
123	$(MAKE) -C $(TESTDIR) test-lz4-essentials
124
125.PHONY: test
126test:
127	$(MAKE) -C $(TESTDIR) $@
128	$(MAKE) -C $(EXDIR) $@
129
130clangtest: CFLAGS ?= -O3
131clangtest: CFLAGS += -Werror -Wconversion -Wno-sign-conversion
132clangtest: CC = clang
133clangtest: clean
134	$(CC) -v
135	@CFLAGS="$(CFLAGS)" $(MAKE) -C $(LZ4DIR)  all CC=$(CC)
136	@CFLAGS="$(CFLAGS)" $(MAKE) -C $(PRGDIR)  all CC=$(CC)
137	@CFLAGS="$(CFLAGS)" $(MAKE) -C $(TESTDIR) all CC=$(CC)
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
151.PHONY: staticAnalyze
152staticAnalyze: clean
153	CFLAGS=-g scan-build --status-bugs -v $(MAKE) all
154
155.PHONY: cppcheck
156cppcheck:
157	cppcheck . --force --enable=warning,portability,performance,style --error-exitcode=1 > /dev/null
158
159platformTest: clean
160	@echo "\n ---- test lz4 with $(CC) compiler ----"
161	@$(CC) -v
162	CFLAGS="-O3 -Werror"         $(MAKE) -C $(LZ4DIR) all
163	CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) all
164	CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) all
165	$(MAKE) -C $(TESTDIR) test-platform
166
167.PHONY: versionsTest
168versionsTest: clean
169	$(MAKE) -C $(TESTDIR) $@
170
171gpptest gpptest32: CC = "$(CXX) -Wno-deprecated"
172gpptest gpptest32: CFLAGS = -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror
173gpptest32: CFLAGS += -m32
174gpptest gpptest32: clean
175	$(CXX) -v
176	CC=$(CC) $(MAKE) -C $(LZ4DIR)  all CFLAGS="$(CFLAGS)"
177	CC=$(CC) $(MAKE) -C $(PRGDIR)  all CFLAGS="$(CFLAGS)"
178	CC=$(CC) $(MAKE) -C $(TESTDIR) all CFLAGS="$(CFLAGS)"
179
180cxx17build : CC = "$(CXX) -Wno-deprecated"
181cxx17build : CFLAGS = -std=c++17 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -pedantic
182cxx17build : clean
183	$(CXX) -v
184	CC=$(CC) $(MAKE) -C $(LZ4DIR)  all CFLAGS="$(CFLAGS)"
185	CC=$(CC) $(MAKE) -C $(PRGDIR)  all CFLAGS="$(CFLAGS)"
186	CC=$(CC) $(MAKE) -C $(TESTDIR) all CFLAGS="$(CFLAGS)"
187
188ctocpptest: LIBCC="$(CC)"
189ctocpptest: TESTCC="$(CXX)"
190ctocpptest: CFLAGS=""
191ctocpptest: clean
192	CC=$(LIBCC)  $(MAKE) -C $(LZ4DIR)  CFLAGS="$(CFLAGS)" all
193	CC=$(LIBCC)  $(MAKE) -C $(TESTDIR) CFLAGS="$(CFLAGS)" lz4.o lz4hc.o lz4frame.o
194	CC=$(TESTCC) $(MAKE) -C $(TESTDIR) CFLAGS="$(CFLAGS)" all
195
196c_standards: clean
197	$(MAKE) clean; CFLAGS="-std=c90   -Werror -pedantic -Wno-long-long -Wno-variadic-macros" $(MAKE) allmost
198	$(MAKE) clean; CFLAGS="-std=gnu90 -Werror -pedantic -Wno-long-long -Wno-variadic-macros" $(MAKE) allmost
199	$(MAKE) clean; CFLAGS="-std=c99   -Werror -pedantic" $(MAKE) all
200	$(MAKE) clean; CFLAGS="-std=gnu99 -Werror -pedantic" $(MAKE) all
201	$(MAKE) clean; CFLAGS="-std=c11   -Werror" $(MAKE) all
202
203endif
204