1*2b9c00cbSConrad Meyer# ################################################################ 2*2b9c00cbSConrad Meyer# Copyright (c) 2016-present, Yann Collet, Facebook, Inc. 3*2b9c00cbSConrad Meyer# All rights reserved. 4*2b9c00cbSConrad Meyer# 5*2b9c00cbSConrad Meyer# This source code is licensed under both the BSD-style license (found in the 6*2b9c00cbSConrad Meyer# LICENSE file in the root directory of this source tree) and the GPLv2 (found 7*2b9c00cbSConrad Meyer# in the COPYING file in the root directory of this source tree). 8*2b9c00cbSConrad Meyer# ################################################################ 9*2b9c00cbSConrad Meyer 10*2b9c00cbSConrad Meyer# This Makefile presumes libzstd is installed, using `sudo make install` 11*2b9c00cbSConrad Meyer 12*2b9c00cbSConrad MeyerCPPFLAGS += -I../lib 13*2b9c00cbSConrad MeyerLIB = ../lib/libzstd.a 14*2b9c00cbSConrad Meyer 15*2b9c00cbSConrad Meyer.PHONY: default all clean test 16*2b9c00cbSConrad Meyer 17*2b9c00cbSConrad Meyerdefault: all 18*2b9c00cbSConrad Meyer 19*2b9c00cbSConrad Meyerall: simple_compression simple_decompression \ 20*2b9c00cbSConrad Meyer multiple_simple_compression\ 21*2b9c00cbSConrad Meyer dictionary_compression dictionary_decompression \ 22*2b9c00cbSConrad Meyer streaming_compression streaming_decompression \ 23*2b9c00cbSConrad Meyer multiple_streaming_compression streaming_memory_usage 24*2b9c00cbSConrad Meyer 25*2b9c00cbSConrad Meyer$(LIB) : 26*2b9c00cbSConrad Meyer $(MAKE) -C ../lib libzstd.a 27*2b9c00cbSConrad Meyer 28*2b9c00cbSConrad Meyersimple_compression : simple_compression.c common.h $(LIB) 29*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 30*2b9c00cbSConrad Meyer 31*2b9c00cbSConrad Meyersimple_decompression : simple_decompression.c common.h $(LIB) 32*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 33*2b9c00cbSConrad Meyer 34*2b9c00cbSConrad Meyermultiple_simple_compression : multiple_simple_compression.c common.h $(LIB) 35*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 36*2b9c00cbSConrad Meyer 37*2b9c00cbSConrad Meyerdictionary_compression : dictionary_compression.c common.h $(LIB) 38*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 39*2b9c00cbSConrad Meyer 40*2b9c00cbSConrad Meyerdictionary_decompression : dictionary_decompression.c common.h $(LIB) 41*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 42*2b9c00cbSConrad Meyer 43*2b9c00cbSConrad Meyerstreaming_compression : streaming_compression.c common.h $(LIB) 44*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 45*2b9c00cbSConrad Meyer 46*2b9c00cbSConrad Meyermultiple_streaming_compression : multiple_streaming_compression.c common.h $(LIB) 47*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 48*2b9c00cbSConrad Meyer 49*2b9c00cbSConrad Meyerstreaming_decompression : streaming_decompression.c common.h $(LIB) 50*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 51*2b9c00cbSConrad Meyer 52*2b9c00cbSConrad Meyerstreaming_memory_usage : streaming_memory_usage.c $(LIB) 53*2b9c00cbSConrad Meyer $(CC) $(CPPFLAGS) $(CFLAGS) $< $(LIB) $(LDFLAGS) -o $@ 54*2b9c00cbSConrad Meyer 55*2b9c00cbSConrad Meyerclean: 56*2b9c00cbSConrad Meyer @rm -f core *.o tmp* result* *.zst \ 57*2b9c00cbSConrad Meyer simple_compression simple_decompression \ 58*2b9c00cbSConrad Meyer multiple_simple_compression \ 59*2b9c00cbSConrad Meyer dictionary_compression dictionary_decompression \ 60*2b9c00cbSConrad Meyer streaming_compression streaming_decompression \ 61*2b9c00cbSConrad Meyer multiple_streaming_compression streaming_memory_usage 62*2b9c00cbSConrad Meyer @echo Cleaning completed 63*2b9c00cbSConrad Meyer 64*2b9c00cbSConrad Meyertest: all 65*2b9c00cbSConrad Meyer cp README.md tmp 66*2b9c00cbSConrad Meyer cp Makefile tmp2 67*2b9c00cbSConrad Meyer @echo -- Simple compression tests 68*2b9c00cbSConrad Meyer ./simple_compression tmp 69*2b9c00cbSConrad Meyer ./simple_decompression tmp.zst 70*2b9c00cbSConrad Meyer ./multiple_simple_compression *.c 71*2b9c00cbSConrad Meyer ./streaming_decompression tmp.zst > /dev/null 72*2b9c00cbSConrad Meyer @echo -- Streaming memory usage 73*2b9c00cbSConrad Meyer ./streaming_memory_usage 74*2b9c00cbSConrad Meyer @echo -- Streaming compression tests 75*2b9c00cbSConrad Meyer ./streaming_compression tmp 76*2b9c00cbSConrad Meyer ./streaming_decompression tmp.zst > /dev/null 77*2b9c00cbSConrad Meyer @echo -- Edge cases detection 78*2b9c00cbSConrad Meyer ! ./streaming_decompression tmp # invalid input, must fail 79*2b9c00cbSConrad Meyer ! ./simple_decompression tmp # invalid input, must fail 80*2b9c00cbSConrad Meyer ! ./simple_decompression tmp.zst # unknown input size, must fail 81*2b9c00cbSConrad Meyer touch tmpNull # create 0-size file 82*2b9c00cbSConrad Meyer ./simple_compression tmpNull 83*2b9c00cbSConrad Meyer ./simple_decompression tmpNull.zst # 0-size frame : must work 84*2b9c00cbSConrad Meyer @echo -- Multiple streaming tests 85*2b9c00cbSConrad Meyer ./multiple_streaming_compression *.c 86*2b9c00cbSConrad Meyer @echo -- Dictionary compression tests 87*2b9c00cbSConrad Meyer ./dictionary_compression tmp2 tmp README.md 88*2b9c00cbSConrad Meyer ./dictionary_decompression tmp2.zst tmp.zst README.md 89*2b9c00cbSConrad Meyer $(RM) tmp* *.zst 90*2b9c00cbSConrad Meyer @echo tests completed 91