1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
|
# ##########################################################################
# LZ4 programs - Makefile
# Copyright (C) Yann Collet 2011-2020
#
# GPL v2 License
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# You can contact the author at :
# - LZ4 homepage : http://www.lz4.org
# - LZ4 source repository : https://github.com/lz4/lz4
# ##########################################################################
# fuzzer : Test tool, to check lz4 integrity on target platform
# frametest : Test tool, to check lz4frame integrity on target platform
# fullbench : Precisely measure speed for each LZ4 function variant
# datagen : generates synthetic data samples for tests & benchmarks
# ##########################################################################
LIBDIR := ../lib
PRGDIR := ../programs
TESTDIR := versionsTest
PYTHON ?= python3
DEBUGLEVEL?= 1
DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL)
USERCFLAGS:= -O3 $(CFLAGS) # appended for higher priority
WFLAGS = -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
-Wpointer-arith -Wstrict-aliasing=1
CFLAGS = $(WFLAGS) $(DEBUGFLAGS) $(USERCFLAGS)
CPPFLAGS += -I$(LIBDIR) -I$(PRGDIR) -DXXH_NAMESPACE=LZ4_
ALLFLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
include ../Makefile.inc
LZ4 := $(PRGDIR)/lz4$(EXT)
# Default test parameters
TEST_FILES := COPYING
FUZZER_TIME := -T90s
NB_LOOPS ?= -i1
.PHONY: default
default: all
.PHONY: all
all: fullbench fuzzer frametest roundTripTest datagen checkFrame decompress-partial
.PHONY: all32
all32: CFLAGS+=-m32
all32: all
.PHONY: lz4
lz4:
$(MAKE) -C $(PRGDIR) $@ CFLAGS="$(CFLAGS)"
.PHONY: lib liblz4.pc
lib liblz4.pc:
$(MAKE) -C $(LIBDIR) $@ CFLAGS="$(CFLAGS)"
lz4c unlz4 lz4cat: lz4
$(LN_SF) $(LZ4) $(PRGDIR)/$@
.PHONY: lz4c32
lz4c32: # create a 32-bits version for 32/64 interop tests
$(MAKE) -C $(PRGDIR) $@ CFLAGS="-m32 $(CFLAGS)"
# *.o objects are from library
%.o : $(LIBDIR)/%.c $(LIBDIR)/%.h
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
CLEAN += fullbench
fullbench : DEBUGLEVEL=0
fullbench : CPPFLAGS += -DNDEBUG
fullbench : lz4.o lz4hc.o lz4frame.o xxhash.o fullbench.c
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
.PHONY: $(LIBDIR)/liblz4.a
$(LIBDIR)/liblz4.a:
$(MAKE) -C $(LIBDIR) liblz4.a
CLEAN += fullbench-lib
fullbench-lib : DEBUGLEVEL=0
fullbench-lib : CPPFLAGS += -DNDEBUG
fullbench-lib: fullbench.c $(LIBDIR)/liblz4.a
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
# Note: Windows only
ifeq ($(WINBASED),yes)
CLEAN += fullbench-dll
fullbench-dll : DEBUGLEVEL=0
fullbench-dll : CPPFLAGS += -DNDEBUG
fullbench-dll: fullbench.c $(LIBDIR)/xxhash.c
$(MAKE) -C $(LIBDIR) liblz4
$(CC) $(ALLFLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(LIBDIR)/dll/$(LIBLZ4).dll
endif
# test LZ4_USER_MEMORY_FUNCTIONS
fullbench-wmalloc: CPPFLAGS += -DLZ4_USER_MEMORY_FUNCTIONS
fullbench-wmalloc: fullbench
CLEAN += fuzzer
fuzzer : lz4.o lz4hc.o xxhash.o fuzzer.c
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
CLEAN += frametest
frametest: lz4frame.o lz4.o lz4hc.o xxhash.o frametest.c
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
CLEAN += roundTripTest
roundTripTest : lz4.o lz4hc.o xxhash.o roundTripTest.c
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
CLEAN += datagen
datagen: CPPFLAGS+=-DNDEBUG
datagen : datagen.c $(PRGDIR)/lorem.c loremOut.c datagencli.c
$(CC) $(ALLFLAGS) -I$(PRGDIR) $^ -o $@$(EXT)
CLEAN += checkFrame
checkFrame : lz4frame.o lz4.o lz4hc.o xxhash.o checkFrame.c
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
CLEAN += decompress-partial
decompress-partial: lz4.o decompress-partial.c
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
CLEAN += decompress-partial-usingDict
decompress-partial-usingDict: lz4.o decompress-partial-usingDict.c
$(CC) $(ALLFLAGS) $^ -o $@$(EXT)
.PHONY: clean
clean:
@$(MAKE) -C $(LIBDIR) $@ > $(VOID)
@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
@$(RM) $(CLEAN) core *.o *.test tmp*
@$(RM) -r $(TESTDIR)
@echo Cleaning completed
.PHONY: versionsTest
versionsTest:
$(PYTHON) test-lz4-versions.py
.PHONY: listTest
listTest: lz4
QEMU_SYS=$(QEMU_SYS) $(PYTHON) test-lz4-list.py
# Note: requires liblz4 installed
CLEAN += abiTest
abiTest: LDLIBS += -llz4
.PHONY: abiTests
abiTests:
$(PYTHON) test-lz4-abi.py
CLEAN += checkTag
checkTag: checkTag.c $(LIBDIR)/lz4.h
$(CC) $(ALLFLAGS) $< -o $@$(EXT)
#-----------------------------------------------------------------------------
# validated only for Linux, OSX, BSD, Hurd and Solaris targets
#-----------------------------------------------------------------------------
ifeq ($(POSIX_ENV),Yes)
MD5 ?= $(if $(filter Darwin,$(shell $(UNAME))),md5 -r,md5sum)
GREP?= grep
CAT ?= cat
DATAGEN?=./datagen
PATH:=../programs:$(shell pwd):$(PATH)
.PHONY: list
list:
$(GREP) '^[^#[:space:]].*:' Makefile | sed 's/:.*//' | sort | uniq
ifneq ($(TARGETSEARCH),NO)
ALL_TARGETS := $(shell make list TARGETSEARCH=NO)
endif
TEST_TARGETS := $(filter test%,$(ALL_TARGETS))
.PHONY: $(TEST_TARGETS) # all targets starting by `test` are now .PHONY
test_targets:
@echo TEST_TARGETS = $(TEST_TARGETS)
.PHONY: check
check: test-lz4-essentials
test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-amalgamation listTest test-decompress-partial
test32: CFLAGS+=-m32
test32: test
test-amalgamation: lz4_all.o
CLEAN += lz4_all.c
lz4_all.c: $(LIBDIR)/lz4.c $(LIBDIR)/lz4hc.c $(LIBDIR)/lz4frame.c
$(CAT) $^ > $@
test-install: lz4 lib liblz4.pc
lz4_root=.. ./test_install.sh
test-compile-with-lz4-memory-usage:
$(MAKE) clean; CFLAGS=-O0 CPPFLAGS=-D'LZ4_MEMORY_USAGE=LZ4_MEMORY_USAGE_MIN' $(MAKE) all
$(MAKE) clean; CFLAGS=-O0 CPPFLAGS=-D'LZ4_MEMORY_USAGE=LZ4_MEMORY_USAGE_MAX' $(MAKE) all
# Rules regarding Temporary test files :
# Each test must use its own unique set of names during execution.
# Each temporary test file must begin by an FPREFIX.
# Each FPREFIX must be unique for each test.
# All FPREFIX must start with `tmp`, for `make clean`
# All tests must clean their temporary test files on successful completion,
# and only their test files : do not employ sweeping statements such `rm tmp*` or `rm *.lz4`
test-lz4-sparse: lz4 datagen
@echo "\n ---- test sparse file support ----"
./test-lz4-sparse.sh
test-lz4-contentSize: lz4 datagen
@echo "\n ---- test original size support ----"
./test-lz4-contentSize.sh
test-lz4-frame-concatenation: lz4 datagen
@echo "\n ---- test frame concatenation ----"
./test-lz4-frame-concatenation.sh
test-lz4-multiple: lz4 datagen
@echo "\n ---- test multiple files ----"
./test-lz4-multiple.sh
test-lz4-multiple-legacy: lz4 datagen
@echo "\n ---- test multiple files (Legacy format) ----"
./test-lz4-multiple-legacy.sh
test-lz4-skippable: lz4
@echo "\n ---- test lz4 with skippable frames ----"
./test-lz4-skippable.sh
test-lz4-basic: lz4 datagen unlz4 lz4cat
@echo "\n ---- test lz4 basic compression/decompression ----"
./test-lz4-basic.sh
test-lz4-dict: lz4 datagen
@echo "\n ---- test lz4 compression/decompression with dictionary ----"
./test-lz4-dict.sh
test-lz4hc-hugefile: lz4 datagen
@echo "\n ---- test HC compression/decompression of huge files ----"
./test-lz4hc-hugefile.sh
test-lz4-fast-hugefile: lz4 datagen
@echo "\n ---- test huge files compression/decompression ----"
./test-lz4-fast-hugefile.sh
test-lz4-hugefile: test-lz4-fast-hugefile test-lz4hc-hugefile
test-lz4-testmode: lz4 datagen
@echo "\n ---- bench mode ----"
./test-lz4-testmode.sh
test-lz4-opt-parser: lz4 datagen
@echo "\n ---- test opt-parser ----"
./test-lz4-opt-parser.sh
test-lz4-essentials : lz4 datagen test-lz4-basic test-lz4-multiple test-lz4-multiple-legacy \
test-lz4-frame-concatenation test-lz4-testmode \
test-lz4-contentSize test-lz4-dict
test-lz4: lz4 datagen test-lz4-essentials test-lz4-opt-parser \
test-lz4-sparse test-lz4-hugefile test-lz4-dict \
test-lz4-skippable
test-lz4c: LZ4C = $(LZ4)c
test-lz4c: lz4c datagen
@echo "\n ---- test lz4c variant ----"
$(DATAGEN) -g256MB | $(LZ4C) -l -v | $(LZ4C) -t
test-lz4c32: CFLAGS+=-m32
test-lz4c32: test-lz4
test-interop-32-64: lz4 lz4c32 datagen
@echo "\n ---- test interoperability 32-bits -vs- 64 bits ----"
$(DATAGEN) -g16KB | $(LZ4)c32 -9 | $(LZ4) -t
$(DATAGEN) -P10 | $(LZ4) -9B4 | $(LZ4)c32 -t
$(DATAGEN) | $(LZ4)c32 | $(LZ4) -t
$(DATAGEN) -g1M | $(LZ4) -3B5 | $(LZ4)c32 -t
$(DATAGEN) -g256MB | $(LZ4)c32 -vqB4D | $(LZ4) -qt
$(DATAGEN) -g1G -P90 | $(LZ4) | $(LZ4)c32 -t
$(DATAGEN) -g6GB | $(LZ4)c32 -vq9BD | $(LZ4) -qt
test-lz4c32-basic: lz4c32 datagen
@echo "\n ---- test lz4c32 32-bits version ----"
$(DATAGEN) -g16KB | $(LZ4)c32 -9 | $(LZ4)c32 -t
$(DATAGEN) | $(LZ4)c32 | $(LZ4)c32 -t
$(DATAGEN) -g256MB | $(LZ4)c32 -vqB4D | $(LZ4)c32 -qt
$(DATAGEN) -g6GB | $(LZ4)c32 -vqB5D | $(LZ4)c32 -qt
test-platform:
@echo "\n ---- test lz4 $(QEMU_SYS) platform ----"
$(QEMU_SYS) $(DATAGEN) -g16KB | $(QEMU_SYS) $(LZ4) -9 | $(QEMU_SYS) $(LZ4) -t
$(QEMU_SYS) $(DATAGEN) | $(QEMU_SYS) $(LZ4) | $(QEMU_SYS) $(LZ4) -t
$(QEMU_SYS) $(DATAGEN) -g256MB | $(QEMU_SYS) $(LZ4) -vqB4D | $(QEMU_SYS) $(LZ4) -qt
ifneq ($(QEMU_SYS),qemu-arm-static)
$(QEMU_SYS) $(DATAGEN) -g3GB | $(QEMU_SYS) $(LZ4) -vqB5D | $(QEMU_SYS) $(LZ4) -qt
endif
test-fullbench: fullbench
./fullbench --no-prompt $(NB_LOOPS) $(TEST_FILES)
test-fullbench32: CFLAGS += -m32
test-fullbench32: test-fullbench
test-fuzzer: fuzzer
./fuzzer $(FUZZER_TIME)
test-fuzzer32: CFLAGS += -m32
test-fuzzer32: test-fuzzer
test-frametest: frametest
./frametest -v $(FUZZER_TIME)
test-frametest32: CFLAGS += -m32
test-frametest32: test-frametest
VALGRIND = valgrind --leak-check=yes --error-exitcode=1
test-mem: FPREFIX = tmp-tvm
test-mem: lz4 datagen fuzzer frametest fullbench
@echo "\n ---- valgrind tests : memory analyzer ----"
$(VALGRIND) $(DATAGEN) -g50M > $(VOID)
$(DATAGEN) -g16KB > $(FPREFIX)dg16K
$(VALGRIND) $(LZ4) -9 -BD -f $(FPREFIX)dg16K $(VOID)
$(DATAGEN) -g16KB -s2 > $(FPREFIX)dg16K2
$(DATAGEN) -g16KB -s3 > $(FPREFIX)dg16K3
$(VALGRIND) $(LZ4) --force --multiple $(FPREFIX)dg16K $(FPREFIX)dg16K2 $(FPREFIX)dg16K3
$(DATAGEN) -g7MB > $(FPREFIX)dg7M
$(VALGRIND) $(LZ4) -9 -B5D -f $(FPREFIX)dg7M $(FPREFIX)dg16K2
$(VALGRIND) $(LZ4) -t $(FPREFIX)dg16K2
$(VALGRIND) $(LZ4) -bi1 $(FPREFIX)dg7M
$(VALGRIND) ./fullbench -i1 $(FPREFIX)dg7M $(FPREFIX)dg16K2
$(VALGRIND) $(LZ4) -B4D -f -vq $(FPREFIX)dg7M $(VOID)
$(VALGRIND) $(LZ4) --list -m $(FPREFIX)*.lz4
$(VALGRIND) $(LZ4) --list -m -v $(FPREFIX)*.lz4
$(RM) $(FPREFIX)*
$(VALGRIND) ./fuzzer -i64 -t1
$(VALGRIND) ./frametest -i256
test-mem32: lz4c32 datagen
# unfortunately, valgrind doesn't seem to work with non-native binary...
test-decompress-partial : decompress-partial decompress-partial-usingDict
@echo "\n ---- test decompress-partial ----"
./decompress-partial$(EXT)
@echo "\n ---- test decompress-partial-usingDict ----"
./decompress-partial-usingDict$(EXT)
#-----------------------------------------------------------------------------
# freestanding test only for Linux x86_64
#-----------------------------------------------------------------------------
UNAME_S ?= $(if $(filter Windows_NT,$(OS)),Windows,$(shell uname -s))
UNAME_P ?= $(if $(filter Windows_NT,$(OS)),Unknown,$(shell uname -p))
FREESTANDING_CFLAGS := -ffreestanding -nostdlib
ifneq ($(UNAME_S), Linux)
FREESTANDING_CFLAGS :=
endif
ifneq ($(UNAME_P), x86_64)
FREESTANDING_CFLAGS :=
endif
CLEAN += freestanding
freestanding: freestanding.c
$(CC) $(FREESTANDING_CFLAGS) $^ -o $@$(EXT)
test-freestanding: freestanding
@echo "\n ---- test freestanding ----"
ifeq ($(FREESTANDING_CFLAGS),)
@echo "\n (skip)"
else
./freestanding$(EXT)
-strace ./freestanding$(EXT)
-ltrace ./freestanding$(EXT)
endif
endif
|