2016-05-12 15:15:41 +00:00
|
|
|
# Makefile for example of using zstd wrapper for zlib
|
|
|
|
#
|
2016-09-23 12:59:46 +00:00
|
|
|
# make - compiles examples
|
2016-11-04 15:50:39 +00:00
|
|
|
# make MOREFLAGS=-DZWRAP_USE_ZSTD=1 - compiles examples with zstd compression turned on
|
2016-09-23 12:59:46 +00:00
|
|
|
# make test - runs examples
|
2016-05-12 15:15:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Paths to static and dynamic zlib and zstd libraries
|
2016-11-28 14:41:36 +00:00
|
|
|
# Use "make ZLIB_PATH=path/to/zlib ZLIB_LIBRARY=path/to/libz.a" to select a path to library
|
2016-09-23 11:38:02 +00:00
|
|
|
ZLIB_LIBRARY ?= -lz
|
2016-11-28 15:55:14 +00:00
|
|
|
ZLIB_PATH ?= .
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
ZSTDLIBDIR = ../lib
|
2016-09-23 11:38:02 +00:00
|
|
|
ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.a
|
2016-05-12 15:15:41 +00:00
|
|
|
ZLIBWRAPPER_PATH = .
|
2016-12-06 07:52:53 +00:00
|
|
|
GZFILES = gzclose.o gzlib.o gzread.o gzwrite.o
|
2016-05-27 09:56:15 +00:00
|
|
|
EXAMPLE_PATH = examples
|
2016-09-22 08:23:58 +00:00
|
|
|
PROGRAMS_PATH = ../programs
|
2016-10-24 13:58:07 +00:00
|
|
|
TEST_FILE = ../doc/zstd_compression_format.md
|
2016-11-04 15:50:39 +00:00
|
|
|
|
2019-09-26 20:08:25 +00:00
|
|
|
CPPFLAGS = -DXXH_NAMESPACE=ZSTD_ -I$(ZLIB_PATH) -I$(PROGRAMS_PATH) \
|
2017-06-03 00:10:49 +00:00
|
|
|
-I$(ZSTDLIBDIR) -I$(ZSTDLIBDIR)/common -I$(ZLIBWRAPPER_PATH)
|
2019-09-26 20:08:25 +00:00
|
|
|
STDFLAGS = -std=c90 -pedantic -Wno-long-long -Wno-variadic-macros -Wc++-compat
|
|
|
|
DEBUGFLAGS=-Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \
|
2017-06-03 00:10:49 +00:00
|
|
|
-Wdeclaration-after-statement -Wstrict-prototypes -Wundef \
|
|
|
|
-Wstrict-aliasing=1
|
2019-09-26 20:08:25 +00:00
|
|
|
CFLAGS ?= -O3
|
|
|
|
CFLAGS += $(STDFLAGS) $(DEBUGFLAGS) $(MOREFLAGS)
|
2016-05-12 15:15:41 +00:00
|
|
|
|
|
|
|
|
2016-11-25 13:45:55 +00:00
|
|
|
# Define *.exe as extension for Windows systems
|
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
|
|
|
EXT =.exe
|
|
|
|
else
|
|
|
|
EXT =
|
|
|
|
endif
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2016-11-25 13:45:55 +00:00
|
|
|
|
2017-09-09 08:03:29 +00:00
|
|
|
all: fitblk example zwrapbench minigzip
|
2016-11-25 13:45:55 +00:00
|
|
|
|
2016-11-29 16:57:00 +00:00
|
|
|
test: example fitblk example_zstd fitblk_zstd zwrapbench minigzip minigzip_zstd
|
2016-05-12 15:15:41 +00:00
|
|
|
./example
|
2016-09-23 10:42:21 +00:00
|
|
|
./example_zstd
|
2016-10-24 13:58:07 +00:00
|
|
|
./fitblk 10240 <$(TEST_FILE)
|
|
|
|
./fitblk 40960 <$(TEST_FILE)
|
|
|
|
./fitblk_zstd 10240 <$(TEST_FILE)
|
|
|
|
./fitblk_zstd 40960 <$(TEST_FILE)
|
2016-11-25 13:45:55 +00:00
|
|
|
@echo ---- minigzip start ----
|
2016-11-28 14:41:36 +00:00
|
|
|
./minigzip_zstd example$(EXT)
|
2016-12-06 10:36:24 +00:00
|
|
|
#cp example$(EXT).gz example$(EXT)_zstd.gz
|
2016-11-29 16:57:00 +00:00
|
|
|
./minigzip_zstd -d example$(EXT).gz
|
|
|
|
./minigzip example$(EXT)
|
2016-12-06 10:36:24 +00:00
|
|
|
#cp example$(EXT).gz example$(EXT)_gz.gz
|
2016-11-28 14:41:36 +00:00
|
|
|
./minigzip_zstd -d example$(EXT).gz
|
2016-11-25 13:45:55 +00:00
|
|
|
@echo ---- minigzip end ----
|
2017-06-03 00:10:49 +00:00
|
|
|
./zwrapbench -qi1b3B1K $(TEST_FILE)
|
|
|
|
./zwrapbench -rqi1b1e5 ../lib ../programs ../tests
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2016-09-23 12:59:46 +00:00
|
|
|
#valgrindTest: ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.so
|
2016-09-23 11:38:02 +00:00
|
|
|
valgrindTest: VALGRIND = LD_LIBRARY_PATH=$(ZSTDLIBDIR) valgrind --track-origins=yes --leak-check=full --error-exitcode=1
|
2016-09-23 10:01:38 +00:00
|
|
|
valgrindTest: clean example fitblk example_zstd fitblk_zstd zwrapbench
|
2016-09-23 08:43:37 +00:00
|
|
|
@echo "\n ---- valgrind tests ----"
|
2016-09-23 10:01:38 +00:00
|
|
|
$(VALGRIND) ./example
|
2016-09-23 10:42:21 +00:00
|
|
|
$(VALGRIND) ./example_zstd
|
2016-10-24 13:58:07 +00:00
|
|
|
$(VALGRIND) ./fitblk 10240 <$(TEST_FILE)
|
|
|
|
$(VALGRIND) ./fitblk 40960 <$(TEST_FILE)
|
|
|
|
$(VALGRIND) ./fitblk_zstd 10240 <$(TEST_FILE)
|
|
|
|
$(VALGRIND) ./fitblk_zstd 40960 <$(TEST_FILE)
|
2017-06-03 00:10:49 +00:00
|
|
|
$(VALGRIND) ./zwrapbench -qi1b3B1K $(TEST_FILE)
|
|
|
|
$(VALGRIND) ./zwrapbench -rqi1b1e5 ../lib ../programs ../tests
|
2016-09-23 08:43:37 +00:00
|
|
|
|
2016-11-04 15:50:39 +00:00
|
|
|
#.c.o:
|
2019-09-26 22:01:29 +00:00
|
|
|
# $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
|
2016-11-03 07:44:02 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
minigzip: $(EXAMPLE_PATH)/minigzip.o zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
2018-12-20 23:28:03 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@
|
2016-11-24 17:26:47 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
minigzip_zstd: $(EXAMPLE_PATH)/minigzip.o zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
2018-12-20 23:28:03 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
example: $(EXAMPLE_PATH)/example.o zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
2018-12-20 23:28:03 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@
|
2016-11-25 13:45:55 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
example_zstd: $(EXAMPLE_PATH)/example.o zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY)
|
2018-12-20 23:28:03 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
fitblk: $(EXAMPLE_PATH)/fitblk.o zstd_zlibwrapper.o $(ZSTDLIBRARY)
|
2018-12-20 23:28:03 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@
|
2016-06-01 08:15:25 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
fitblk_zstd: $(EXAMPLE_PATH)/fitblk.o zstdTurnedOn_zlibwrapper.o $(ZSTDLIBRARY)
|
2018-12-20 23:28:03 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@
|
2016-09-22 08:23:58 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
zwrapbench: $(EXAMPLE_PATH)/zwrapbench.o zstd_zlibwrapper.o $(PROGRAMS_PATH)/util.o $(PROGRAMS_PATH)/timefn.o $(PROGRAMS_PATH)/datagen.o $(ZSTDLIBRARY)
|
2018-12-20 23:28:03 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2016-09-22 09:52:00 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
zstd_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2019-09-26 22:01:29 +00:00
|
|
|
zstdTurnedOn_zlibwrapper.o: CPPFLAGS += -DZWRAP_USE_ZSTD=1
|
|
|
|
zstdTurnedOn_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h
|
2016-06-01 08:15:25 +00:00
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
$(ZSTDLIBDIR)/libzstd.a:
|
2016-11-03 07:44:02 +00:00
|
|
|
$(MAKE) -C $(ZSTDLIBDIR) libzstd.a
|
2016-09-22 12:42:32 +00:00
|
|
|
|
2016-09-23 11:38:02 +00:00
|
|
|
$(ZSTDLIBDIR)/libzstd.so:
|
2016-11-03 07:44:02 +00:00
|
|
|
$(MAKE) -C $(ZSTDLIBDIR) libzstd
|
2016-09-23 11:38:02 +00:00
|
|
|
|
2016-11-25 13:45:55 +00:00
|
|
|
|
2016-05-12 15:15:41 +00:00
|
|
|
clean:
|
2016-11-25 16:13:25 +00:00
|
|
|
-$(RM) $(ZLIBWRAPPER_PATH)/*.o $(EXAMPLE_PATH)/*.o *.o foo.gz example$(EXT) example_zstd$(EXT) fitblk$(EXT) fitblk_zstd$(EXT) zwrapbench$(EXT) minigzip$(EXT) minigzip_zstd$(EXT)
|
2016-06-03 14:36:50 +00:00
|
|
|
@echo Cleaning completed
|