Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # ##########################################################################
  2. # LZ4 examples - Makefile
  3. # Copyright (C) Yann Collet 2011-2020
  4. #
  5. # GPL v2 License
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program; if not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. #
  21. # You can contact the author at :
  22. # - LZ4 source repository : https://github.com/lz4/lz4
  23. # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
  24. # ##########################################################################
  25. # This makefile compile and test
  26. # example programs, using (mostly) LZ4 streaming library,
  27. # kindly provided by Takayuki Matsuoka
  28. # ##########################################################################
  29. CPPFLAGS += -I../lib
  30. CFLAGS ?= -O3
  31. CFLAGS += -std=gnu99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes
  32. FLAGS := $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
  33. TESTFILE = Makefile
  34. LZ4DIR := ../lib
  35. LZ4 = ../programs/lz4
  36. include ../Makefile.inc
  37. default: all
  38. all: printVersion doubleBuffer dictionaryRandomAccess ringBuffer ringBufferHC \
  39. lineCompress frameCompress fileCompress simpleBuffer
  40. $(LZ4DIR)/liblz4.a: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.h $(LZ4DIR)/lz4hc.h $(LZ4DIR)/lz4frame.h $(LZ4DIR)/lz4frame_static.h
  41. $(MAKE) -C $(LZ4DIR) liblz4.a
  42. printVersion: printVersion.c $(LZ4DIR)/liblz4.a
  43. $(CC) $(FLAGS) $^ -o $@$(EXT)
  44. doubleBuffer: blockStreaming_doubleBuffer.c $(LZ4DIR)/liblz4.a
  45. $(CC) $(FLAGS) $^ -o $@$(EXT)
  46. dictionaryRandomAccess: dictionaryRandomAccess.c $(LZ4DIR)/liblz4.a
  47. $(CC) $(FLAGS) $^ -o $@$(EXT)
  48. ringBuffer : blockStreaming_ringBuffer.c $(LZ4DIR)/liblz4.a
  49. $(CC) $(FLAGS) $^ -o $@$(EXT)
  50. ringBufferHC: HCStreaming_ringBuffer.c $(LZ4DIR)/liblz4.a
  51. $(CC) $(FLAGS) $^ -o $@$(EXT)
  52. lineCompress: blockStreaming_lineByLine.c $(LZ4DIR)/liblz4.a
  53. $(CC) $(FLAGS) $^ -o $@$(EXT)
  54. frameCompress: frameCompress.c $(LZ4DIR)/liblz4.a
  55. $(CC) $(FLAGS) $^ -o $@$(EXT)
  56. fileCompress: fileCompress.c $(LZ4DIR)/liblz4.a
  57. $(CC) $(FLAGS) $^ -o $@$(EXT)
  58. compressFunctions: compress_functions.c $(LZ4DIR)/liblz4.a
  59. $(CC) $(FLAGS) $^ -o $@$(EXT) -lrt
  60. simpleBuffer: simple_buffer.c $(LZ4DIR)/liblz4.a
  61. $(CC) $(FLAGS) $^ -o $@$(EXT)
  62. $(LZ4) :
  63. $(MAKE) -C ../programs lz4
  64. test : all $(LZ4)
  65. @echo "\n=== Print Version ==="
  66. ./printVersion$(EXT)
  67. @echo "\n=== Simple compression example ==="
  68. ./simpleBuffer$(EXT)
  69. @echo "\n=== Double-buffer ==="
  70. ./doubleBuffer$(EXT) $(TESTFILE)
  71. @echo "\n=== Ring Buffer ==="
  72. ./ringBuffer$(EXT) $(TESTFILE)
  73. @echo "\n=== Ring Buffer + LZ4 HC ==="
  74. ./ringBufferHC$(EXT) $(TESTFILE)
  75. @echo "\n=== Compress line by line ==="
  76. ./lineCompress$(EXT) $(TESTFILE)
  77. @echo "\n=== Dictionary Random Access ==="
  78. ./dictionaryRandomAccess$(EXT) $(TESTFILE) $(TESTFILE) 1100 1400
  79. @echo "\n=== Frame compression ==="
  80. ./frameCompress$(EXT) $(TESTFILE)
  81. $(LZ4) -vt $(TESTFILE).lz4
  82. @echo "\n=== file compression ==="
  83. ./fileCompress$(EXT) $(TESTFILE)
  84. $(LZ4) -vt $(TESTFILE).lz4
  85. .PHONY: cxxtest
  86. cxxtest: CFLAGS := -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror
  87. cxxtest: clean
  88. CC=$(CXX) $(MAKE) -C . all CFLAGS="$(CFLAGS)"
  89. clean:
  90. @rm -f core *.o *.dec *-0 *-9 *-8192 *.lz4s *.lz4 \
  91. printVersion$(EXT) doubleBuffer$(EXT) dictionaryRandomAccess$(EXT) \
  92. ringBuffer$(EXT) ringBufferHC$(EXT) lineCompress$(EXT) frameCompress$(EXT) \
  93. fileCompress$(EXT) compressFunctions$(EXT) simpleBuffer$(EXT)
  94. @echo Cleaning completed