summaryrefslogtreecommitdiffstats
path: root/ossfuzz/Makefile
diff options
context:
space:
mode:
authorMax Dymond <cmeister2@gmail.com>2019-06-25 16:22:02 (GMT)
committerMax Dymond <cmeister2@gmail.com>2019-06-28 07:30:02 (GMT)
commita5cf079d4dc9097c4e58f0eb7b0996b0a6d91696 (patch)
tree9c91b612a8bcbcfb0137518509d0fe3bcead50cc /ossfuzz/Makefile
parent798301b4e144fab5d25fc34566c1419685f5f1eb (diff)
downloadlz4-a5cf079d4dc9097c4e58f0eb7b0996b0a6d91696.zip
lz4-a5cf079d4dc9097c4e58f0eb7b0996b0a6d91696.tar.gz
lz4-a5cf079d4dc9097c4e58f0eb7b0996b0a6d91696.tar.bz2
Add a fuzzing target that compiles in the oss-fuzz environment
Diffstat (limited to 'ossfuzz/Makefile')
-rw-r--r--ossfuzz/Makefile54
1 files changed, 54 insertions, 0 deletions
diff --git a/ossfuzz/Makefile b/ossfuzz/Makefile
new file mode 100644
index 0000000..94829b2
--- /dev/null
+++ b/ossfuzz/Makefile
@@ -0,0 +1,54 @@
+# ##########################################################################
+# LZ4 oss fuzzer - Makefile
+#
+# GPL v2 License
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# You can contact the author at :
+# - LZ4 homepage : http://www.lz4.org
+# - LZ4 source repository : https://github.com/lz4/lz4
+# ##########################################################################
+# lz4_fuzzer : OSS Fuzz test tool
+# ##########################################################################
+
+LZ4DIR := ../lib
+LIB_FUZZING_ENGINE ?= standaloneengine.o
+
+DEBUGLEVEL?= 1
+DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL)
+
+CFLAGS += -I$(LZ4DIR) $(DEBUGFLAGS) $(MOREFLAGS)
+CPPFLAGS+= -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
+FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
+
+include ../Makefile.inc
+
+# Include a rule to build the static library if calling this target
+# directly.
+$(LZ4DIR)/liblz4.a:
+ $(MAKE) -C $(LZ4DIR) CFLAGS="$(CFLAGS)" liblz4.a
+
+%.o: %.cc
+ $(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+.PHONY: compress_fuzzer
+compress_fuzzer: compress_fuzzer.o $(LZ4DIR)/liblz4.a
+ # Compile the standalone code just in case. The OSS-Fuzz code might
+ # override the LIB_FUZZING_ENGINE value to "-fsanitize=fuzzer"
+ $(CXX) -c $(CFLAGS) $(CPPFLAGS) standaloneengine.cc -o standaloneengine.o
+
+ # Now compile the actual fuzzer.
+ $(CXX) $(FLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT)