2016-05-12 15:15:41 +00:00
|
|
|
# Makefile for example of using zstd wrapper for zlib
|
|
|
|
#
|
2016-09-22 08:23:58 +00:00
|
|
|
# make - compiles statically and dynamically linked examples
|
|
|
|
# make LOC=-DZWRAP_USE_ZSTD=1 - compiles statically and dynamically linked examples with zstd compression turned on
|
2016-09-22 09:52:00 +00:00
|
|
|
# make test test_d - runs statically and dynamically linked examples
|
2016-05-12 15:15:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Paths to static and dynamic zlib and zstd libraries
|
2016-06-03 10:56:56 +00:00
|
|
|
# Use "make ZLIBDIR=path/to/zlib" to select a path to library
|
|
|
|
ifdef ZLIBDIR
|
2016-09-22 12:42:32 +00:00
|
|
|
STATICLIB = $(ZLIBDIR)/libz.a $(ZSTDLIBDIR)/libzstd.a
|
|
|
|
IMPLIB = $(ZLIBDIR)/libz.dll.a $(ZSTDLIBDIR)/libzstd.a
|
2016-05-12 15:15:41 +00:00
|
|
|
else
|
2016-09-22 12:42:32 +00:00
|
|
|
STATICLIB = -static -lz $(ZSTDLIBDIR)/libzstd.a
|
|
|
|
IMPLIB = -lz $(ZSTDLIBDIR)/libzstd.a
|
2016-09-22 08:23:58 +00:00
|
|
|
ZLIBDIR = .
|
2016-05-12 15:15:41 +00:00
|
|
|
endif
|
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
ZSTDLIBDIR = ../lib
|
2016-05-12 15:15:41 +00:00
|
|
|
ZLIBWRAPPER_PATH = .
|
2016-05-27 09:56:15 +00:00
|
|
|
EXAMPLE_PATH = examples
|
2016-09-22 08:23:58 +00:00
|
|
|
PROGRAMS_PATH = ../programs
|
2016-07-18 01:27:26 +00:00
|
|
|
CC ?= gcc
|
2016-09-22 12:42:32 +00:00
|
|
|
CFLAGS = $(LOC) -I$(PROGRAMS_PATH) -I$(ZSTDLIBDIR) -I$(ZSTDLIBDIR)/common -I$(ZLIBWRAPPER_PATH) -I$(ZLIBDIR) -O3 -std=gnu90
|
2016-06-02 20:15:09 +00:00
|
|
|
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
|
2016-05-12 15:15:41 +00:00
|
|
|
LDFLAGS = $(LOC)
|
|
|
|
RM = rm -f
|
|
|
|
|
|
|
|
|
2016-09-22 08:23:58 +00:00
|
|
|
all: clean fitblk example example_d zwrapbench
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2016-09-22 08:23:58 +00:00
|
|
|
test: example fitblk
|
2016-05-12 15:15:41 +00:00
|
|
|
./example
|
2016-09-22 08:23:58 +00:00
|
|
|
./fitblk 10240 <../zstd_compression_format.md
|
|
|
|
./fitblk 40960 <../zstd_compression_format.md
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2016-09-22 08:23:58 +00:00
|
|
|
test_d: example_d
|
2016-05-12 15:15:41 +00:00
|
|
|
./example_d
|
|
|
|
|
2016-09-22 09:52:00 +00:00
|
|
|
test_zstd: example_zstd fitblk_zstd zwrapbench
|
2016-06-01 08:15:25 +00:00
|
|
|
./example_zstd
|
2016-09-22 08:23:58 +00:00
|
|
|
./fitblk_zstd 10240 <../zstd_compression_format.md
|
|
|
|
./fitblk_zstd 40960 <../zstd_compression_format.md
|
2016-09-22 13:55:01 +00:00
|
|
|
./zwrapbench -qb1e5 ../zstd_compression_format.md
|
2016-09-20 10:49:39 +00:00
|
|
|
|
2016-09-23 08:43:37 +00:00
|
|
|
valgrindTest: VALGRIND = valgrind --leak-check=full --error-exitcode=1
|
|
|
|
valgrindTest: example_zstd fitblk_zstd zwrapbench
|
|
|
|
@echo "\n ---- valgrind tests ----"
|
|
|
|
$(VALGRIND) ./example_zstd
|
|
|
|
$(VALGRIND) ./fitblk_zstd 10240 <../zstd_compression_format.md
|
|
|
|
$(VALGRIND) ./fitblk_zstd 40960 <../zstd_compression_format.md
|
|
|
|
$(VALGRIND) ./zwrapbench -qb1e5 ../zstd_compression_format.md
|
|
|
|
|
2016-05-12 15:15:41 +00:00
|
|
|
.c.o:
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
2016-09-20 10:49:39 +00:00
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
example: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBDIR)/libzstd.a
|
2016-05-12 15:15:41 +00:00
|
|
|
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(STATICLIB)
|
|
|
|
|
|
|
|
example_d: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(IMPLIB)
|
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
example_zstd: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(ZSTDLIBDIR)/libzstd.a
|
2016-06-01 08:15:25 +00:00
|
|
|
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(STATICLIB)
|
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
fitblk: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBDIR)/libzstd.a
|
2016-09-22 08:23:58 +00:00
|
|
|
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(STATICLIB)
|
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
fitblk_zstd: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBDIR)/libzstd.a
|
2016-09-22 08:23:58 +00:00
|
|
|
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(STATICLIB)
|
2016-09-20 10:49:39 +00:00
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
zwrapbench: $(EXAMPLE_PATH)/zwrapbench.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(PROGRAMS_PATH)/datagen.o $(ZSTDLIBDIR)/libzstd.a
|
2016-09-22 08:23:58 +00:00
|
|
|
$(CC) $(LDFLAGS) -o $@ $^ $(STATICLIB)
|
2016-05-12 15:15:41 +00:00
|
|
|
|
2016-09-22 09:52:00 +00:00
|
|
|
$(EXAMPLE_PATH)/zwrapbench.o: $(EXAMPLE_PATH)/zwrapbench.c
|
|
|
|
|
2016-05-12 15:15:41 +00:00
|
|
|
$(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h
|
|
|
|
$(CC) $(CFLAGS) -I. -c -o $@ $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c
|
|
|
|
|
2016-06-01 08:15:25 +00:00
|
|
|
$(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h
|
|
|
|
$(CC) $(CFLAGS) -DZWRAP_USE_ZSTD=1 -I. -c -o $@ $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c
|
|
|
|
|
2016-09-22 12:42:32 +00:00
|
|
|
$(ZSTDLIBDIR)/libzstd.a:
|
|
|
|
$(MAKE) -C $(ZSTDLIBDIR) all
|
|
|
|
|
2016-05-12 15:15:41 +00:00
|
|
|
clean:
|
2016-09-22 12:42:32 +00:00
|
|
|
-$(RM) $(ZLIBWRAPPER_PATH)/*.o $(EXAMPLE_PATH)/*.o *.o *.exe foo.gz example example_d example_zstd fitblk fitblk_zstd zwrapbench
|
2016-06-03 14:36:50 +00:00
|
|
|
@echo Cleaning completed
|