Makefile 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # ##########################################################################
  2. # LZ4 oss fuzzer - Makefile
  3. #
  4. # GPL v2 License
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License along
  17. # with this program; if not, write to the Free Software Foundation, Inc.,
  18. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. #
  20. # You can contact the author at :
  21. # - LZ4 homepage : http://www.lz4.org
  22. # - LZ4 source repository : https://github.com/lz4/lz4
  23. # ##########################################################################
  24. # compress_fuzzer : OSS Fuzz test tool
  25. # decompress_fuzzer : OSS Fuzz test tool
  26. # ##########################################################################
  27. LZ4DIR := ../lib
  28. LIB_FUZZING_ENGINE ?=
  29. DEBUGLEVEL?= 1
  30. DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL)
  31. LZ4_CFLAGS = $(CFLAGS) $(DEBUGFLAGS) $(MOREFLAGS)
  32. LZ4_CXXFLAGS = $(CXXFLAGS) $(DEBUGFLAGS) $(MOREFLAGS)
  33. LZ4_CPPFLAGS = $(CPPFLAGS) -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ \
  34. -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  35. FUZZERS := \
  36. compress_fuzzer \
  37. decompress_fuzzer \
  38. round_trip_fuzzer \
  39. round_trip_stream_fuzzer \
  40. compress_hc_fuzzer \
  41. round_trip_hc_fuzzer \
  42. compress_frame_fuzzer \
  43. round_trip_frame_fuzzer \
  44. round_trip_frame_uncompressed_fuzzer \
  45. decompress_frame_fuzzer
  46. .PHONY: all
  47. all: $(FUZZERS)
  48. # Include a rule to build the static library if calling this target
  49. # directly.
  50. $(LZ4DIR)/liblz4.a:
  51. $(MAKE) -C $(LZ4DIR) CFLAGS="$(LZ4_CFLAGS)" liblz4.a
  52. %.o: %.c
  53. $(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) $< -o $@
  54. # Generic rule for generating fuzzers
  55. ifeq ($(LIB_FUZZING_ENGINE),)
  56. LIB_FUZZING_DEPS := standaloneengine.o
  57. else
  58. LIB_FUZZING_DEPS :=
  59. endif
  60. %_fuzzer: %_fuzzer.o lz4_helpers.o fuzz_data_producer.o $(LZ4DIR)/liblz4.a $(LIB_FUZZING_DEPS)
  61. $(CXX) $(LZ4_CXXFLAGS) $(LZ4_CPPFLAGS) $(LDFLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT)
  62. %_fuzzer_clean:
  63. $(RM) $*_fuzzer $*_fuzzer.o standaloneengine.o
  64. .PHONY: clean
  65. clean: compress_fuzzer_clean decompress_fuzzer_clean \
  66. compress_frame_fuzzer_clean compress_hc_fuzzer_clean \
  67. decompress_frame_fuzzer_clean round_trip_frame_fuzzer_clean \
  68. round_trip_fuzzer_clean round_trip_hc_fuzzer_clean round_trip_stream_fuzzer_clean
  69. $(MAKE) -C $(LZ4DIR) clean