~mmach/netext73/lz4

« back to all changes in this revision

Viewing changes to .pc/0002-Change-optimize-to-O2.patch/Makefile

  • Committer: mmach
  • Date: 2022-11-09 18:52:10 UTC
  • Revision ID: netbit73@gmail.com-20221109185210-w358idlhh0phq688
1.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ################################################################
 
2
# LZ4 - Makefile
 
3
# Copyright (C) Yann Collet 2011-2020
 
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
 
 
33
LZ4DIR  = lib
 
34
PRGDIR  = programs
 
35
TESTDIR = tests
 
36
EXDIR   = examples
 
37
FUZZDIR = ossfuzz
 
38
 
 
39
include Makefile.inc
 
40
 
 
41
 
 
42
.PHONY: default
 
43
default: lib-release lz4-release
 
44
 
 
45
# silent mode by default; verbose can be triggered by V=1 or VERBOSE=1
 
46
$(V)$(VERBOSE).SILENT:
 
47
 
 
48
.PHONY: all
 
49
all: allmost examples manuals build_tests
 
50
 
 
51
.PHONY: allmost
 
52
allmost: lib lz4
 
53
 
 
54
.PHONY: lib lib-release liblz4.a
 
55
lib: liblz4.a
 
56
lib lib-release liblz4.a:
 
57
        $(MAKE) -C $(LZ4DIR) $@
 
58
 
 
59
.PHONY: lz4 lz4-release
 
60
lz4 : liblz4.a
 
61
lz4-release : lib-release
 
62
lz4 lz4-release :
 
63
        $(MAKE) -C $(PRGDIR) $@
 
64
        cp $(PRGDIR)/lz4$(EXT) .
 
65
 
 
66
.PHONY: examples
 
67
examples: liblz4.a
 
68
        $(MAKE) -C $(EXDIR) all
 
69
 
 
70
.PHONY: manuals
 
71
manuals:
 
72
        $(MAKE) -C contrib/gen_manual $@
 
73
 
 
74
.PHONY: build_tests
 
75
build_tests:
 
76
        $(MAKE) -C $(TESTDIR) all
 
77
 
 
78
.PHONY: clean
 
79
clean:
 
80
        $(MAKE) -C $(LZ4DIR) $@ > $(VOID)
 
81
        $(MAKE) -C $(PRGDIR) $@ > $(VOID)
 
82
        $(MAKE) -C $(TESTDIR) $@ > $(VOID)
 
83
        $(MAKE) -C $(EXDIR) $@ > $(VOID)
 
84
        $(MAKE) -C $(FUZZDIR) $@ > $(VOID)
 
85
        $(MAKE) -C contrib/gen_manual $@ > $(VOID)
 
86
        $(RM) lz4$(EXT)
 
87
        $(RM) -r $(CMAKE_BUILD_DIR)
 
88
        @echo Cleaning completed
 
89
 
 
90
 
 
91
#-----------------------------------------------------------------------------
 
92
# make install is validated only for Posix environments
 
93
#-----------------------------------------------------------------------------
 
94
ifeq ($(POSIX_ENV),Yes)
 
95
HOST_OS = POSIX
 
96
 
 
97
.PHONY: install uninstall
 
98
install uninstall:
 
99
        $(MAKE) -C $(LZ4DIR) $@
 
100
        $(MAKE) -C $(PRGDIR) $@
 
101
 
 
102
.PHONY: travis-install
 
103
travis-install:
 
104
        $(MAKE) -j1 install DESTDIR=~/install_test_dir
 
105
 
 
106
endif   # POSIX_ENV
 
107
 
 
108
 
 
109
CMAKE ?= cmake
 
110
CMAKE_BUILD_DIR ?= build/cmake/build
 
111
ifneq (,$(filter MSYS%,$(shell $(UNAME))))
 
112
HOST_OS = MSYS
 
113
CMAKE_PARAMS = -G"MSYS Makefiles"
 
114
endif
 
115
 
 
116
.PHONY: cmake
 
117
cmake:
 
118
        mkdir -p $(CMAKE_BUILD_DIR)
 
119
        cd $(CMAKE_BUILD_DIR); $(CMAKE) $(CMAKE_PARAMS) ..; $(CMAKE) --build .
 
120
 
 
121
 
 
122
#------------------------------------------------------------------------
 
123
# make tests validated only for MSYS and Posix environments
 
124
#------------------------------------------------------------------------
 
125
ifneq (,$(filter $(HOST_OS),MSYS POSIX))
 
126
 
 
127
.PHONY: list
 
128
list:
 
129
        $(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
 
130
 
 
131
.PHONY: check
 
132
check:
 
133
        $(MAKE) -C $(TESTDIR) test-lz4-essentials
 
134
 
 
135
.PHONY: test
 
136
test:
 
137
        $(MAKE) -C $(TESTDIR) $@
 
138
        $(MAKE) -C $(EXDIR) $@
 
139
 
 
140
.PHONY: clangtest
 
141
clangtest: CFLAGS += -Werror -Wconversion -Wno-sign-conversion
 
142
clangtest: CC = clang
 
143
clangtest: clean
 
144
        $(CC) -v
 
145
        $(MAKE) -C $(LZ4DIR)  all CC=$(CC)
 
146
        $(MAKE) -C $(PRGDIR)  all CC=$(CC)
 
147
        $(MAKE) -C $(TESTDIR) all CC=$(CC)
 
148
 
 
149
.PHONY: clangtest-native
 
150
clangtest-native: CFLAGS = -O3 -Werror -Wconversion -Wno-sign-conversion
 
151
clangtest-native: clean
 
152
        clang -v
 
153
        $(MAKE) -C $(LZ4DIR)  all    CC=clang
 
154
        $(MAKE) -C $(PRGDIR)  native CC=clang
 
155
        $(MAKE) -C $(TESTDIR) native CC=clang
 
156
 
 
157
.PHONY: usan
 
158
usan: CC      = clang
 
159
usan: CFLAGS  = -O3 -g -fsanitize=undefined -fno-sanitize-recover=undefined -fsanitize-recover=pointer-overflow
 
160
usan: LDFLAGS = $(CFLAGS)
 
161
usan: clean
 
162
        CC=$(CC) CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
 
163
 
 
164
.PHONY: usan32
 
165
usan32: CFLAGS = -m32 -O3 -g -fsanitize=undefined
 
166
usan32: LDFLAGS = $(CFLAGS)
 
167
usan32: clean
 
168
        $(MAKE) test FUZZER_TIME="-T30s" NB_LOOPS=-i1
 
169
 
 
170
SCANBUILD ?= scan-build
 
171
SCANBUILD_FLAGS += --status-bugs -v --force-analyze-debug-code
 
172
.PHONY: staticAnalyze
 
173
staticAnalyze: clean
 
174
        CPPFLAGS=-DLZ4_DEBUG=1 CFLAGS=-g $(SCANBUILD) $(SCANBUILD_FLAGS) $(MAKE) all V=1 DEBUGLEVEL=1
 
175
 
 
176
.PHONY: cppcheck
 
177
cppcheck:
 
178
        cppcheck . --force --enable=warning,portability,performance,style --error-exitcode=1 > /dev/null
 
179
 
 
180
.PHONY: platformTest
 
181
platformTest: clean
 
182
        @echo "\n ---- test lz4 with $(CC) compiler ----"
 
183
        $(CC) -v
 
184
        CFLAGS="-O3 -Werror"         $(MAKE) -C $(LZ4DIR) all
 
185
        CFLAGS="-O3 -Werror -static" $(MAKE) -C $(PRGDIR) all
 
186
        CFLAGS="-O3 -Werror -static" $(MAKE) -C $(TESTDIR) all
 
187
        $(MAKE) -C $(TESTDIR) test-platform
 
188
 
 
189
.PHONY: versionsTest
 
190
versionsTest: clean
 
191
        $(MAKE) -C $(TESTDIR) $@
 
192
 
 
193
.PHONY: test-freestanding
 
194
test-freestanding:
 
195
        $(MAKE) -C $(TESTDIR) clean $@
 
196
 
 
197
.PHONY: cxxtest cxx32test
 
198
cxxtest cxx32test: CC := "$(CXX) -Wno-deprecated"
 
199
cxxtest cxx32test: CFLAGS = -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror
 
200
cxx32test: CFLAGS += -m32
 
201
cxxtest cxx32test: clean
 
202
        $(CXX) -v
 
203
        CC=$(CC) $(MAKE) -C $(LZ4DIR)  all CFLAGS="$(CFLAGS)"
 
204
        CC=$(CC) $(MAKE) -C $(PRGDIR)  all CFLAGS="$(CFLAGS)"
 
205
        CC=$(CC) $(MAKE) -C $(TESTDIR) all CFLAGS="$(CFLAGS)"
 
206
 
 
207
.PHONY: cxx17build
 
208
cxx17build : CC = "$(CXX) -Wno-deprecated"
 
209
cxx17build : CFLAGS = -std=c++17 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -pedantic
 
210
cxx17build : clean
 
211
        $(CXX) -v
 
212
        CC=$(CC) $(MAKE) -C $(LZ4DIR)  all CFLAGS="$(CFLAGS)"
 
213
        CC=$(CC) $(MAKE) -C $(PRGDIR)  all CFLAGS="$(CFLAGS)"
 
214
        CC=$(CC) $(MAKE) -C $(TESTDIR) all CFLAGS="$(CFLAGS)"
 
215
 
 
216
.PHONY: ctocpptest
 
217
ctocpptest: LIBCC="$(CC)"
 
218
ctocpptest: TESTCC="$(CXX)"
 
219
ctocpptest: CFLAGS=
 
220
ctocpptest: clean
 
221
        CC=$(LIBCC)  $(MAKE) -C $(LZ4DIR)  CFLAGS="$(CFLAGS)" all
 
222
        CC=$(LIBCC)  $(MAKE) -C $(TESTDIR) CFLAGS="$(CFLAGS)" lz4.o lz4hc.o lz4frame.o
 
223
        CC=$(TESTCC) $(MAKE) -C $(TESTDIR) CFLAGS="$(CFLAGS)" all
 
224
 
 
225
.PHONY: c_standards
 
226
c_standards: clean c_standards_c11 c_standards_c99 c_standards_c90
 
227
 
 
228
.PHONY: c_standards_c90
 
229
c_standards_c90: clean
 
230
        $(MAKE) clean; CFLAGS="-std=c90   -Werror -pedantic -Wno-long-long -Wno-variadic-macros" $(MAKE) allmost
 
231
        $(MAKE) clean; CFLAGS="-std=gnu90 -Werror -pedantic -Wno-long-long -Wno-variadic-macros" $(MAKE) allmost
 
232
 
 
233
.PHONY: c_standards_c99
 
234
c_standards_c99: clean
 
235
        $(MAKE) clean; CFLAGS="-std=c99   -Werror -pedantic" $(MAKE) all
 
236
        $(MAKE) clean; CFLAGS="-std=gnu99 -Werror -pedantic" $(MAKE) all
 
237
 
 
238
.PHONY: c_standards_c11
 
239
c_standards_c11: clean
 
240
        $(MAKE) clean; CFLAGS="-std=c11 -Werror" $(MAKE) all
 
241
 
 
242
# The following test ensures that standard Makefile variables set through environment
 
243
# are correctly transmitted at compilation stage.
 
244
# This test is meant to detect issues like https://github.com/lz4/lz4/issues/958
 
245
.PHONY: standard_variables
 
246
standard_variables: clean
 
247
        @echo =================
 
248
        @echo Check support of Makefile Standard variables through environment
 
249
        @echo note : this test requires V=1 to work properly
 
250
        @echo =================
 
251
        CC="cc -DCC_TEST" \
 
252
        CFLAGS=-DCFLAGS_TEST \
 
253
        CPPFLAGS=-DCPPFLAGS_TEST \
 
254
        LDFLAGS=-DLDFLAGS_TEST \
 
255
        LDLIBS=-DLDLIBS_TEST \
 
256
        $(MAKE) V=1 > tmpsv
 
257
        # Note: just checking the presence of custom flags
 
258
        # would not detect situations where custom flags are
 
259
        # supported in some part of the Makefile, and missed in others.
 
260
        # So the test checks if they are present the _right nb of times_.
 
261
        # However, checking static quantities makes this test brittle,
 
262
        # because quantities (7, 2 and 1) can still evolve in future,
 
263
        # for example when source directories or Makefile evolve.
 
264
        if [ $$(grep CC_TEST tmpsv | wc -l) -ne 7 ]; then \
 
265
                echo "CC environment variable missed" && False; fi
 
266
        if [ $$(grep CFLAGS_TEST tmpsv | wc -l) -ne 7 ]; then \
 
267
                echo "CFLAGS environment variable missed" && False; fi
 
268
        if [ $$(grep CPPFLAGS_TEST tmpsv | wc -l) -ne 7 ]; then \
 
269
                echo "CPPFLAGS environment variable missed" && False; fi
 
270
        if [ $$(grep LDFLAGS_TEST tmpsv | wc -l) -ne 2 ]; then \
 
271
                echo "LDFLAGS environment variable missed" && False; fi
 
272
        if [ $$(grep LDLIBS_TEST tmpsv | wc -l) -ne 1 ]; then \
 
273
                echo "LDLIBS environment variable missed" && False; fi
 
274
        @echo =================
 
275
        @echo all custom variables detected
 
276
        @echo =================
 
277
        $(RM) tmpsv
 
278
 
 
279
endif   # MSYS POSIX