| 1 |
# ################################################################ |
| 2 |
# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# This source code is licensed under both the BSD-style license (found in the |
| 6 |
# LICENSE file in the root directory of this source tree) and the GPLv2 (found |
| 7 |
# in the COPYING file in the root directory of this source tree). |
| 8 |
# You may select, at your option, one of the above-listed licenses. |
| 9 |
# ################################################################ |
| 10 |
|
| 11 |
LIBDIR =../lib |
| 12 |
CPPFLAGS += -I$(LIBDIR) |
| 13 |
LIB = $(LIBDIR)/libzstd.a |
| 14 |
|
| 15 |
|
| 16 |
.PHONY: default |
| 17 |
default: all |
| 18 |
|
| 19 |
.PHONY: all |
| 20 |
all: simple_compression simple_decompression \ |
| 21 |
multiple_simple_compression\ |
| 22 |
dictionary_compression dictionary_decompression \ |
| 23 |
streaming_compression streaming_decompression \ |
| 24 |
multiple_streaming_compression streaming_memory_usage |
| 25 |
|
| 26 |
$(LIB) : |
| 27 |
$(MAKE) -C $(LIBDIR) libzstd.a |
| 28 |
|
| 29 |
simple_compression.o: common.h |
| 30 |
simple_compression : $(LIB) |
| 31 |
|
| 32 |
simple_decompression.o: common.h |
| 33 |
simple_decompression : $(LIB) |
| 34 |
|
| 35 |
multiple_simple_compression.o: common.h |
| 36 |
multiple_simple_compression : $(LIB) |
| 37 |
|
| 38 |
dictionary_compression.o: common.h |
| 39 |
dictionary_compression : $(LIB) |
| 40 |
|
| 41 |
dictionary_decompression.o: common.h |
| 42 |
dictionary_decompression : $(LIB) |
| 43 |
|
| 44 |
streaming_compression.o: common.h |
| 45 |
streaming_compression : $(LIB) |
| 46 |
|
| 47 |
multiple_streaming_compression.o: common.h |
| 48 |
multiple_streaming_compression : $(LIB) |
| 49 |
|
| 50 |
streaming_decompression.o: common.h |
| 51 |
streaming_decompression : $(LIB) |
| 52 |
|
| 53 |
streaming_memory_usage.o: common.h |
| 54 |
streaming_memory_usage : $(LIB) |
| 55 |
|
| 56 |
|
| 57 |
.PHONY:clean |
| 58 |
clean: |
| 59 |
@$(RM) core *.o tmp* result* *.zst \ |
| 60 |
simple_compression simple_decompression \ |
| 61 |
multiple_simple_compression \ |
| 62 |
dictionary_compression dictionary_decompression \ |
| 63 |
streaming_compression streaming_decompression \ |
| 64 |
multiple_streaming_compression streaming_memory_usage |
| 65 |
@echo Cleaning completed |
| 66 |
|
| 67 |
.PHONY:test |
| 68 |
test: all |
| 69 |
cp README.md tmp |
| 70 |
cp Makefile tmp2 |
| 71 |
@echo -- Simple compression tests |
| 72 |
./simple_compression tmp |
| 73 |
./simple_decompression tmp.zst |
| 74 |
./multiple_simple_compression *.c |
| 75 |
./streaming_decompression tmp.zst > /dev/null |
| 76 |
@echo -- Streaming memory usage |
| 77 |
./streaming_memory_usage |
| 78 |
@echo -- Streaming compression tests |
| 79 |
./streaming_compression tmp |
| 80 |
./streaming_decompression tmp.zst > /dev/null |
| 81 |
@echo -- Edge cases detection |
| 82 |
! ./streaming_decompression tmp # invalid input, must fail |
| 83 |
! ./simple_decompression tmp # invalid input, must fail |
| 84 |
touch tmpNull # create 0-size file |
| 85 |
./simple_compression tmpNull |
| 86 |
./simple_decompression tmpNull.zst # 0-size frame : must work |
| 87 |
@echo -- Multiple streaming tests |
| 88 |
./multiple_streaming_compression *.c |
| 89 |
@echo -- Dictionary compression tests |
| 90 |
./dictionary_compression tmp2 tmp README.md |
| 91 |
./dictionary_decompression tmp2.zst tmp.zst README.md |
| 92 |
$(RM) tmp* *.zst |
| 93 |
@echo tests completed |