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 ?= standaloneengine.o 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 50all: $(FUZZERS) 51 52# Include a rule to build the static library if calling this target 53# directly. 54$(LZ4DIR)/liblz4.a: 55 $(MAKE) -C $(LZ4DIR) CFLAGS="$(LZ4_CFLAGS)" liblz4.a 56 57%.o: %.c 58 $(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) $< -o $@ 59 60# Generic rule for generating fuzzers 61%_fuzzer: %_fuzzer.o lz4_helpers.o $(LZ4DIR)/liblz4.a 62 # Compile the standalone code just in case. The OSS-Fuzz code might 63 # override the LIB_FUZZING_ENGINE value to "-fsanitize=fuzzer" 64 $(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) standaloneengine.c -o standaloneengine.o 65 66 # Now compile the actual fuzzer. 67 $(CXX) $(LZ4_CXXFLAGS) $(LZ4_CPPFLAGS) $(LDFLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT) 68 69%_fuzzer_clean: 70 $(RM) $*_fuzzer $*_fuzzer.o standaloneengine.o 71 72.PHONY: clean 73clean: compress_fuzzer_clean decompress_fuzzer_clean 74 $(MAKE) -C $(LZ4DIR) clean 75