zstd/zlibWrapper/Makefile

84 lines
3.6 KiB
Makefile
Raw Normal View History

# Makefile for example of using zstd wrapper for zlib
#
# make - compiles examples
2016-11-04 15:50:39 +00:00
# make MOREFLAGS=-DZWRAP_USE_ZSTD=1 - compiles examples with zstd compression turned on
# make test - runs examples
# Paths to static and dynamic zlib and zstd libraries
# Use "make ZLIB_LIBRARY=path/to/zlib" to select a path to library
ZLIB_LIBRARY ?= -lz
2016-09-22 12:42:32 +00:00
ZSTDLIBDIR = ../lib
ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.a
ZLIBWRAPPER_PATH = .
2016-05-27 09:56:15 +00:00
EXAMPLE_PATH = examples
2016-09-22 08:23:58 +00:00
PROGRAMS_PATH = ../programs
TEST_FILE = ../doc/zstd_compression_format.md
2016-11-04 15:50:39 +00:00
CPPFLAGS = -I$(PROGRAMS_PATH) -I$(ZSTDLIBDIR) -I$(ZSTDLIBDIR)/common -I$(ZLIBWRAPPER_PATH)
CFLAGS ?= $(MOREFLAGS) -O3 -std=gnu99
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wstrict-aliasing=1 -Wundef
all: clean fitblk example zwrapbench
2016-09-23 10:42:21 +00:00
test: example fitblk example_zstd fitblk_zstd zwrapbench
./example
2016-09-23 10:42:21 +00:00
./example_zstd
./fitblk 10240 <$(TEST_FILE)
./fitblk 40960 <$(TEST_FILE)
./fitblk_zstd 10240 <$(TEST_FILE)
./fitblk_zstd 40960 <$(TEST_FILE)
./zwrapbench -qb3B1K $(TEST_FILE)
2016-09-26 20:47:39 +00:00
./zwrapbench -rqb1e5 ../lib ../programs ../tests
#valgrindTest: ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.so
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
$(VALGRIND) ./fitblk 10240 <$(TEST_FILE)
$(VALGRIND) ./fitblk 40960 <$(TEST_FILE)
$(VALGRIND) ./fitblk_zstd 10240 <$(TEST_FILE)
$(VALGRIND) ./fitblk_zstd 40960 <$(TEST_FILE)
$(VALGRIND) ./zwrapbench -qb3B1K $(TEST_FILE)
2016-09-26 20:47:39 +00:00
$(VALGRIND) ./zwrapbench -rqb1e5 ../lib ../programs ../tests
2016-09-23 08:43:37 +00:00
2016-11-04 15:50:39 +00:00
#.c.o:
# $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
2016-11-03 07:44:02 +00:00
example: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBRARY)
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBRARY) $(ZLIB_LIBRARY)
example_zstd: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(ZSTDLIBRARY)
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(ZSTDLIBRARY) $(ZLIB_LIBRARY)
fitblk: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBRARY)
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBRARY) $(ZLIB_LIBRARY)
fitblk_zstd: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBRARY)
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(ZSTDLIBRARY) $(ZLIB_LIBRARY)
2016-09-22 08:23:58 +00:00
zwrapbench: $(EXAMPLE_PATH)/zwrapbench.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(PROGRAMS_PATH)/datagen.o $(ZSTDLIBRARY)
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/zwrapbench.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(PROGRAMS_PATH)/datagen.o $(ZSTDLIBRARY) $(ZLIB_LIBRARY)
2016-09-22 09:52:00 +00:00
$(EXAMPLE_PATH)/zwrapbench.o: $(EXAMPLE_PATH)/zwrapbench.c
$(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h
2016-11-04 15:50:39 +00:00
$(CC) $(CFLAGS) $(CPPFLAGS) -I. -c -o $@ $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c
$(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h
2016-11-04 15:50:39 +00:00
$(CC) $(CFLAGS) $(CPPFLAGS) -DZWRAP_USE_ZSTD=1 -I. -c -o $@ $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c
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
$(ZSTDLIBDIR)/libzstd.so:
2016-11-03 07:44:02 +00:00
$(MAKE) -C $(ZSTDLIBDIR) libzstd
clean:
-$(RM) $(ZLIBWRAPPER_PATH)/*.o $(EXAMPLE_PATH)/*.o *.o *.exe foo.gz example example_zstd fitblk fitblk_zstd zwrapbench
@echo Cleaning completed