xref: /freebsd/sys/contrib/zstd/examples/Makefile (revision 5ff13fbc199bdf5f0572845351c68ee5ca828e71)
12b9c00cbSConrad Meyer# ################################################################
2*5ff13fbcSAllan Jude# Copyright (c) Yann Collet, Facebook, Inc.
32b9c00cbSConrad Meyer# All rights reserved.
42b9c00cbSConrad Meyer#
52b9c00cbSConrad Meyer# This source code is licensed under both the BSD-style license (found in the
62b9c00cbSConrad Meyer# LICENSE file in the root directory of this source tree) and the GPLv2 (found
72b9c00cbSConrad Meyer# in the COPYING file in the root directory of this source tree).
837f1f268SConrad Meyer# You may select, at your option, one of the above-listed licenses.
92b9c00cbSConrad Meyer# ################################################################
102b9c00cbSConrad Meyer
11f7cd7fe5SConrad MeyerLIBDIR =../lib
12f7cd7fe5SConrad MeyerCPPFLAGS += -I$(LIBDIR)
13f7cd7fe5SConrad MeyerLIB = $(LIBDIR)/libzstd.a
142b9c00cbSConrad Meyer
152b9c00cbSConrad Meyer
16f7cd7fe5SConrad Meyer.PHONY: default
172b9c00cbSConrad Meyerdefault: all
182b9c00cbSConrad Meyer
19f7cd7fe5SConrad Meyer.PHONY: all
202b9c00cbSConrad Meyerall: simple_compression simple_decompression \
212b9c00cbSConrad Meyer	multiple_simple_compression\
222b9c00cbSConrad Meyer	dictionary_compression dictionary_decompression \
232b9c00cbSConrad Meyer	streaming_compression streaming_decompression \
242b9c00cbSConrad Meyer	multiple_streaming_compression streaming_memory_usage
252b9c00cbSConrad Meyer
262b9c00cbSConrad Meyer$(LIB) :
27f7cd7fe5SConrad Meyer	$(MAKE) -C $(LIBDIR) libzstd.a
282b9c00cbSConrad Meyer
29f7cd7fe5SConrad Meyersimple_compression.o: common.h
30f7cd7fe5SConrad Meyersimple_compression : $(LIB)
312b9c00cbSConrad Meyer
32f7cd7fe5SConrad Meyersimple_decompression.o: common.h
33f7cd7fe5SConrad Meyersimple_decompression : $(LIB)
342b9c00cbSConrad Meyer
35f7cd7fe5SConrad Meyermultiple_simple_compression.o: common.h
36f7cd7fe5SConrad Meyermultiple_simple_compression : $(LIB)
372b9c00cbSConrad Meyer
38f7cd7fe5SConrad Meyerdictionary_compression.o: common.h
39f7cd7fe5SConrad Meyerdictionary_compression : $(LIB)
402b9c00cbSConrad Meyer
41f7cd7fe5SConrad Meyerdictionary_decompression.o: common.h
42f7cd7fe5SConrad Meyerdictionary_decompression : $(LIB)
432b9c00cbSConrad Meyer
44f7cd7fe5SConrad Meyerstreaming_compression.o: common.h
45f7cd7fe5SConrad Meyerstreaming_compression : $(LIB)
462b9c00cbSConrad Meyer
47f7cd7fe5SConrad Meyermultiple_streaming_compression.o: common.h
48f7cd7fe5SConrad Meyermultiple_streaming_compression : $(LIB)
492b9c00cbSConrad Meyer
50f7cd7fe5SConrad Meyerstreaming_decompression.o: common.h
51f7cd7fe5SConrad Meyerstreaming_decompression : $(LIB)
522b9c00cbSConrad Meyer
53f7cd7fe5SConrad Meyerstreaming_memory_usage.o: common.h
54f7cd7fe5SConrad Meyerstreaming_memory_usage : $(LIB)
552b9c00cbSConrad Meyer
56f7cd7fe5SConrad Meyer
57f7cd7fe5SConrad Meyer.PHONY:clean
582b9c00cbSConrad Meyerclean:
59f7cd7fe5SConrad Meyer	@$(RM) core *.o tmp* result* *.zst \
602b9c00cbSConrad Meyer        simple_compression simple_decompression \
612b9c00cbSConrad Meyer        multiple_simple_compression \
622b9c00cbSConrad Meyer        dictionary_compression dictionary_decompression \
632b9c00cbSConrad Meyer        streaming_compression streaming_decompression \
642b9c00cbSConrad Meyer        multiple_streaming_compression streaming_memory_usage
652b9c00cbSConrad Meyer	@echo Cleaning completed
662b9c00cbSConrad Meyer
67f7cd7fe5SConrad Meyer.PHONY:test
682b9c00cbSConrad Meyertest: all
692b9c00cbSConrad Meyer	cp README.md tmp
702b9c00cbSConrad Meyer	cp Makefile tmp2
712b9c00cbSConrad Meyer	@echo -- Simple compression tests
722b9c00cbSConrad Meyer	./simple_compression tmp
732b9c00cbSConrad Meyer	./simple_decompression tmp.zst
742b9c00cbSConrad Meyer	./multiple_simple_compression *.c
752b9c00cbSConrad Meyer	./streaming_decompression tmp.zst > /dev/null
762b9c00cbSConrad Meyer	@echo -- Streaming memory usage
772b9c00cbSConrad Meyer	./streaming_memory_usage
782b9c00cbSConrad Meyer	@echo -- Streaming compression tests
792b9c00cbSConrad Meyer	./streaming_compression tmp
802b9c00cbSConrad Meyer	./streaming_decompression tmp.zst > /dev/null
812b9c00cbSConrad Meyer	@echo -- Edge cases detection
822b9c00cbSConrad Meyer	! ./streaming_decompression tmp    # invalid input, must fail
832b9c00cbSConrad Meyer	! ./simple_decompression tmp       # invalid input, must fail
842b9c00cbSConrad Meyer	touch tmpNull                      # create 0-size file
852b9c00cbSConrad Meyer	./simple_compression tmpNull
862b9c00cbSConrad Meyer	./simple_decompression tmpNull.zst # 0-size frame : must work
872b9c00cbSConrad Meyer	@echo -- Multiple streaming tests
882b9c00cbSConrad Meyer	./multiple_streaming_compression *.c
892b9c00cbSConrad Meyer	@echo -- Dictionary compression tests
902b9c00cbSConrad Meyer	./dictionary_compression tmp2 tmp README.md
912b9c00cbSConrad Meyer	./dictionary_decompression tmp2.zst tmp.zst README.md
922b9c00cbSConrad Meyer	$(RM) tmp* *.zst
932b9c00cbSConrad Meyer	@echo tests completed
94