• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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	round_trip_frame_uncompressed_fuzzer \
49	decompress_frame_fuzzer
50
51.PHONY: all
52all: $(FUZZERS)
53
54# Include a rule to build the static library if calling this target
55# directly.
56$(LZ4DIR)/liblz4.a:
57	$(MAKE) -C $(LZ4DIR) CFLAGS="$(LZ4_CFLAGS)" liblz4.a
58
59%.o: %.c
60	$(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) $< -o $@
61
62# Generic rule for generating fuzzers
63ifeq ($(LIB_FUZZING_ENGINE),)
64  LIB_FUZZING_DEPS := standaloneengine.o
65else
66  LIB_FUZZING_DEPS :=
67endif
68%_fuzzer: %_fuzzer.o lz4_helpers.o fuzz_data_producer.o $(LZ4DIR)/liblz4.a $(LIB_FUZZING_DEPS)
69	$(CXX) $(LZ4_CXXFLAGS) $(LZ4_CPPFLAGS) $(LDFLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT)
70
71%_fuzzer_clean:
72	$(RM) $*_fuzzer $*_fuzzer.o standaloneengine.o
73
74.PHONY: clean
75clean: compress_fuzzer_clean decompress_fuzzer_clean \
76	compress_frame_fuzzer_clean compress_hc_fuzzer_clean \
77	decompress_frame_fuzzer_clean round_trip_frame_fuzzer_clean \
78	round_trip_fuzzer_clean round_trip_hc_fuzzer_clean round_trip_stream_fuzzer_clean
79	$(MAKE) -C $(LZ4DIR) clean
80