| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 1 | # Makefile for example of using zstd wrapper for zlib |
| 2 | # |
| inikep | 57b9708 | 2016-09-23 14:59:46 +0200 | [diff] [blame] | 3 | # make - compiles examples |
| Przemyslaw Skibinski | 7e06e6a | 2016-11-04 16:50:39 +0100 | [diff] [blame] | 4 | # make MOREFLAGS=-DZWRAP_USE_ZSTD=1 - compiles examples with zstd compression turned on |
| inikep | 57b9708 | 2016-09-23 14:59:46 +0200 | [diff] [blame] | 5 | # make test - runs examples |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 6 | |
| 7 | |
| 8 | # Paths to static and dynamic zlib and zstd libraries |
| inikep | b88accf | 2016-09-23 13:38:02 +0200 | [diff] [blame] | 9 | # Use "make ZLIB_LIBRARY=path/to/zlib" to select a path to library |
| 10 | ZLIB_LIBRARY ?= -lz |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 11 | |
| inikep | 8e8b046 | 2016-09-22 14:42:32 +0200 | [diff] [blame] | 12 | ZSTDLIBDIR = ../lib |
| inikep | b88accf | 2016-09-23 13:38:02 +0200 | [diff] [blame] | 13 | ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.a |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 14 | ZLIBWRAPPER_PATH = . |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 15 | GZFILES = gzclose.o gzlib.o gzread.o gzwrite.o |
| inikep | e9dfdf6 | 2016-05-27 11:56:15 +0200 | [diff] [blame] | 16 | EXAMPLE_PATH = examples |
| inikep | 3be5c6e | 2016-09-22 10:23:58 +0200 | [diff] [blame] | 17 | PROGRAMS_PATH = ../programs |
| Przemyslaw Skibinski | 3ee94a7 | 2016-10-24 15:58:07 +0200 | [diff] [blame] | 18 | TEST_FILE = ../doc/zstd_compression_format.md |
| Przemyslaw Skibinski | 7e06e6a | 2016-11-04 16:50:39 +0100 | [diff] [blame] | 19 | |
| Przemyslaw Skibinski | de4b4fc | 2016-11-21 15:03:05 +0100 | [diff] [blame] | 20 | CPPFLAGS = -DXXH_NAMESPACE=XXH_ -I$(PROGRAMS_PATH) -I$(ZSTDLIBDIR) -I$(ZSTDLIBDIR)/common -I$(ZLIBWRAPPER_PATH) |
| Przemyslaw Skibinski | 7e06e6a | 2016-11-04 16:50:39 +0100 | [diff] [blame] | 21 | CFLAGS ?= $(MOREFLAGS) -O3 -std=gnu99 |
| Przemyslaw Skibinski | 6b3c201 | 2016-11-24 18:26:47 +0100 | [diff] [blame] | 22 | CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef |
| 23 | #-Wstrict-aliasing=1 |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 24 | |
| 25 | |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 26 | # Define *.exe as extension for Windows systems |
| 27 | ifneq (,$(filter Windows%,$(OS))) |
| 28 | EXT =.exe |
| 29 | else |
| 30 | EXT = |
| 31 | endif |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 32 | |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 33 | |
| 34 | all: clean fitblk example zwrapbench minigzip |
| 35 | |
| 36 | test: example fitblk example_zstd fitblk_zstd zwrapbench minigzip_zstd |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 37 | ./example |
| inikep | 68cd476 | 2016-09-23 12:42:21 +0200 | [diff] [blame] | 38 | ./example_zstd |
| Przemyslaw Skibinski | 3ee94a7 | 2016-10-24 15:58:07 +0200 | [diff] [blame] | 39 | ./fitblk 10240 <$(TEST_FILE) |
| 40 | ./fitblk 40960 <$(TEST_FILE) |
| 41 | ./fitblk_zstd 10240 <$(TEST_FILE) |
| 42 | ./fitblk_zstd 40960 <$(TEST_FILE) |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 43 | @echo ---- minigzip start ---- |
| 44 | ./minigzip_zstd zwrapbench$(EXT) |
| 45 | ./minigzip_zstd -d zwrapbench$(EXT).gz |
| 46 | @echo ---- minigzip end ---- |
| Przemyslaw Skibinski | 3ee94a7 | 2016-10-24 15:58:07 +0200 | [diff] [blame] | 47 | ./zwrapbench -qb3B1K $(TEST_FILE) |
| inikep | 60dddc2 | 2016-09-26 22:47:39 +0200 | [diff] [blame] | 48 | ./zwrapbench -rqb1e5 ../lib ../programs ../tests |
| inikep | 7b546e5 | 2016-09-20 12:49:39 +0200 | [diff] [blame] | 49 | |
| inikep | 57b9708 | 2016-09-23 14:59:46 +0200 | [diff] [blame] | 50 | #valgrindTest: ZSTDLIBRARY = $(ZSTDLIBDIR)/libzstd.so |
| inikep | b88accf | 2016-09-23 13:38:02 +0200 | [diff] [blame] | 51 | valgrindTest: VALGRIND = LD_LIBRARY_PATH=$(ZSTDLIBDIR) valgrind --track-origins=yes --leak-check=full --error-exitcode=1 |
| inikep | f77a113 | 2016-09-23 12:01:38 +0200 | [diff] [blame] | 52 | valgrindTest: clean example fitblk example_zstd fitblk_zstd zwrapbench |
| inikep | 4602e53 | 2016-09-23 10:43:37 +0200 | [diff] [blame] | 53 | @echo "\n ---- valgrind tests ----" |
| inikep | f77a113 | 2016-09-23 12:01:38 +0200 | [diff] [blame] | 54 | $(VALGRIND) ./example |
| inikep | 68cd476 | 2016-09-23 12:42:21 +0200 | [diff] [blame] | 55 | $(VALGRIND) ./example_zstd |
| Przemyslaw Skibinski | 3ee94a7 | 2016-10-24 15:58:07 +0200 | [diff] [blame] | 56 | $(VALGRIND) ./fitblk 10240 <$(TEST_FILE) |
| 57 | $(VALGRIND) ./fitblk 40960 <$(TEST_FILE) |
| 58 | $(VALGRIND) ./fitblk_zstd 10240 <$(TEST_FILE) |
| 59 | $(VALGRIND) ./fitblk_zstd 40960 <$(TEST_FILE) |
| 60 | $(VALGRIND) ./zwrapbench -qb3B1K $(TEST_FILE) |
| inikep | 60dddc2 | 2016-09-26 22:47:39 +0200 | [diff] [blame] | 61 | $(VALGRIND) ./zwrapbench -rqb1e5 ../lib ../programs ../tests |
| inikep | 4602e53 | 2016-09-23 10:43:37 +0200 | [diff] [blame] | 62 | |
| Przemyslaw Skibinski | 7e06e6a | 2016-11-04 16:50:39 +0100 | [diff] [blame] | 63 | #.c.o: |
| 64 | # $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< |
| Yann Collet | 6c111fa | 2016-11-03 00:44:02 -0700 | [diff] [blame] | 65 | |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 66 | minigzip: $(EXAMPLE_PATH)/minigzip.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) |
| 67 | $(CC) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@ |
| Przemyslaw Skibinski | 6b3c201 | 2016-11-24 18:26:47 +0100 | [diff] [blame] | 68 | |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 69 | minigzip_zstd: $(EXAMPLE_PATH)/minigzip.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) |
| 70 | $(CC) $(LDFLAGS) $^ $(ZSTDLIBRARY) $(ZLIB_LIBRARY) -o $@ |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 71 | |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 72 | example: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) |
| 73 | $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ |
| 74 | |
| 75 | example_zstd: $(EXAMPLE_PATH)/example.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(GZFILES) $(ZSTDLIBRARY) |
| 76 | $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 77 | |
| inikep | b88accf | 2016-09-23 13:38:02 +0200 | [diff] [blame] | 78 | fitblk: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(ZSTDLIBRARY) |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 79 | $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ |
| inikep | 043b3c0 | 2016-06-01 10:15:25 +0200 | [diff] [blame] | 80 | |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 81 | fitblk_zstd: $(EXAMPLE_PATH)/fitblk.o $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o $(ZSTDLIBRARY) |
| 82 | $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ |
| inikep | 7b546e5 | 2016-09-20 12:49:39 +0200 | [diff] [blame] | 83 | |
| inikep | b88accf | 2016-09-23 13:38:02 +0200 | [diff] [blame] | 84 | zwrapbench: $(EXAMPLE_PATH)/zwrapbench.o $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o $(PROGRAMS_PATH)/datagen.o $(ZSTDLIBRARY) |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 85 | $(CC) $(LDFLAGS) $^ $(ZLIB_LIBRARY) -o $@ |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 86 | |
| inikep | d755717 | 2016-09-22 11:52:00 +0200 | [diff] [blame] | 87 | |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 88 | $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h |
| Przemyslaw Skibinski | 7e06e6a | 2016-11-04 16:50:39 +0100 | [diff] [blame] | 89 | $(CC) $(CFLAGS) $(CPPFLAGS) -I. -c -o $@ $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 90 | |
| inikep | 043b3c0 | 2016-06-01 10:15:25 +0200 | [diff] [blame] | 91 | $(ZLIBWRAPPER_PATH)/zstdTurnedOn_zlibwrapper.o: $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.h |
| Przemyslaw Skibinski | 7e06e6a | 2016-11-04 16:50:39 +0100 | [diff] [blame] | 92 | $(CC) $(CFLAGS) $(CPPFLAGS) -DZWRAP_USE_ZSTD=1 -I. -c -o $@ $(ZLIBWRAPPER_PATH)/zstd_zlibwrapper.c |
| inikep | 043b3c0 | 2016-06-01 10:15:25 +0200 | [diff] [blame] | 93 | |
| inikep | 8e8b046 | 2016-09-22 14:42:32 +0200 | [diff] [blame] | 94 | $(ZSTDLIBDIR)/libzstd.a: |
| Yann Collet | 6c111fa | 2016-11-03 00:44:02 -0700 | [diff] [blame] | 95 | $(MAKE) -C $(ZSTDLIBDIR) libzstd.a |
| inikep | 8e8b046 | 2016-09-22 14:42:32 +0200 | [diff] [blame] | 96 | |
| inikep | b88accf | 2016-09-23 13:38:02 +0200 | [diff] [blame] | 97 | $(ZSTDLIBDIR)/libzstd.so: |
| Yann Collet | 6c111fa | 2016-11-03 00:44:02 -0700 | [diff] [blame] | 98 | $(MAKE) -C $(ZSTDLIBDIR) libzstd |
| inikep | b88accf | 2016-09-23 13:38:02 +0200 | [diff] [blame] | 99 | |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 100 | |
| inikep | 3eabe9b | 2016-05-12 17:15:41 +0200 | [diff] [blame] | 101 | clean: |
| Przemyslaw Skibinski | 4c69050 | 2016-11-25 14:45:55 +0100 | [diff] [blame^] | 102 | -$(RM) $(ZLIBWRAPPER_PATH)/*.o $(EXAMPLE_PATH)/*.o *.o *.exe foo.gz example example_zstd fitblk fitblk_zstd zwrapbench minigzip minigzip_zstd |
| inikep | 3640396 | 2016-06-03 16:36:50 +0200 | [diff] [blame] | 103 | @echo Cleaning completed |