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 28LZ4DIR := ../lib 29LIB_FUZZING_ENGINE ?= 30 31DEBUGLEVEL?= 1 32DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL) 33 34LZ4_CFLAGS = $(CFLAGS) $(DEBUGFLAGS) $(MOREFLAGS) 35LZ4_CXXFLAGS = $(CXXFLAGS) $(DEBUGFLAGS) $(MOREFLAGS) 36LZ4_CPPFLAGS = $(CPPFLAGS) -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ \ 37 -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION 38 39FUZZERS := \ 40 compress_fuzzer \ 41 decompress_fuzzer \ 42 round_trip_fuzzer \ 43 round_trip_stream_fuzzer \ 44 compress_hc_fuzzer \ 45 round_trip_hc_fuzzer \ 46 compress_frame_fuzzer \ 47 round_trip_frame_fuzzer \ 48 decompress_frame_fuzzer 49 50.PHONY: all 51all: $(FUZZERS) 52 53# Include a rule to build the static library if calling this target 54# directly. 55$(LZ4DIR)/liblz4.a: 56 $(MAKE) -C $(LZ4DIR) CFLAGS="$(LZ4_CFLAGS)" liblz4.a 57 58%.o: %.c 59 $(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) $< -o $@ 60 61# Generic rule for generating fuzzers 62ifeq ($(LIB_FUZZING_ENGINE),) 63 LIB_FUZZING_DEPS := standaloneengine.o 64else 65 LIB_FUZZING_DEPS := 66endif 67%_fuzzer: %_fuzzer.o lz4_helpers.o fuzz_data_producer.o $(LZ4DIR)/liblz4.a $(LIB_FUZZING_DEPS) 68 $(CXX) $(LZ4_CXXFLAGS) $(LZ4_CPPFLAGS) $(LDFLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT) 69 70%_fuzzer_clean: 71 $(RM) $*_fuzzer $*_fuzzer.o standaloneengine.o 72 73.PHONY: clean 74clean: compress_fuzzer_clean decompress_fuzzer_clean \ 75 compress_frame_fuzzer_clean compress_hc_fuzzer_clean \ 76 decompress_frame_fuzzer_clean round_trip_frame_fuzzer_clean \ 77 round_trip_fuzzer_clean round_trip_hc_fuzzer_clean round_trip_stream_fuzzer_clean 78 $(MAKE) -C $(LZ4DIR) clean 79