2016-05-12 08:15:41 -07:00
|
|
|
# Makefile for example of using zstd wrapper for zlib
|
|
|
|
#
|
|
|
|
# make - compiles statically and dynamically linked examples/example.c
|
|
|
|
# make test testdll - compiles and runs statically and dynamically linked examples/example.c
|
|
|
|
# make LOC=-DZWRAP_USE_ZSTD=1 - compiles statically and dynamically linked examples/example.c with zstd compression turned on
|
|
|
|
|
|
|
|
|
|
|
|
# Paths to static and dynamic zlib and zstd libraries
|
2016-06-03 03:56:56 -07:00
|
|
|
# Use "make ZLIBDIR=path/to/zlib" to select a path to library
|
|
|
|
ifdef ZLIBDIR
|
2016-06-02 01:19:35 -07:00
|
|
|
STATICLIB = $(ZLIBDIR)/libz.a ../lib/libzstd.a
|
|
|
|
IMPLIB = $(ZLIBDIR)/libz.dll.a ../lib/libzstd.a
|
2016-05-12 08:15:41 -07:00
|
|
|
else
|
|
|
|
STATICLIB = -static -lz ../lib/libzstd.a
|
|
|
|
IMPLIB = -lz ../lib/libzstd.a
|
|
|
|
endif
|
|
|
|
|
|
|
|
ZLIBWRAPPER_PATH = .
|
2016-05-27 02:56:15 -07:00
|
|
|
EXAMPLE_PATH = examples
|
2016-05-12 08:15:41 -07:00
|
|
|
CC = gcc
|
2016-06-02 09:40:41 -07:00
|
|
|
CFLAGS = $(LOC) -I../lib/common -I$(ZLIBDIR) -I$(ZLIBWRAPPER_PATH) -O3 -std=gnu90
|
2016-06-02 13:15:09 -07:00
|
|
|
CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
|
2016-05-12 08:15:41 -07:00
|
|
|
LDFLAGS = $(LOC)
|
|
|
|
RM = rm -f
|
|
|
|
|
|
|
|
|
2016-06-02 01:19:35 -07:00
|
|
|
all: clean test testzstd
|
2016-05-12 08:15:41 -07:00
|
|
|
|
|
|
|
test: example
|
|
|
|
./example
|
|
|
|
|
|
|
|
testdll: example_d
|
|
|
|
./example_d
|
|
|
|
|
2016-06-01 01:15:25 -07:00
|
|
|
testzstd: example_zstd
|
|
|
|
./example_zstd
|
|
|
|
|
2016-05-12 08:15:41 -07:00
|
|
|
.c.o:
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
example: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o
|
|
|
|
$(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-06-01 01:15:25 -07:00
|
|
|
example_zstd: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(STATICLIB)
|
|
|
|
|
2016-05-12 08:15:41 -07:00
|
|
|
$(EXAMPLE_PATH)/example.o: $(EXAMPLE_PATH)/example.c
|
|
|
|
$(CC) $(CFLAGS) -I. -c -o $@ $(EXAMPLE_PATH)/example.c
|
|
|
|
|
|
|
|
$(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 01:15:25 -07: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-05-12 08:15:41 -07:00
|
|
|
clean:
|
2016-06-03 07:36:50 -07:00
|
|
|
-$(RM) $(ZLIBWRAPPER_PATH)/*.o $(EXAMPLE_PATH)/*.o *.o *.exe foo.gz example example_d example_zstd
|
|
|
|
@echo Cleaning completed
|