Makefile.am 1.98 KB
Newer Older
1
AM_CPPFLAGS = \
2 3
	-include $(top_builddir)/src/config.h	\
	-I$(top_srcdir)/src			\
4 5
	-DCONFIG_DIR='"${config_dir}"'		\
	-DSTORAGE_DIR='"${storage_dir}"'	\
6 7
	-DRUN_DIR='"${run_dir}"'		\
	-DSRCDIR=\"$(abs_srcdir)\"
8

9
FUZZERS = \
10 11
	fuzz_packet	\
	fuzz_zscanner
12

13
check_PROGRAMS = $(FUZZERS)
14

15
if HAVE_DAEMON
16
# knotd_stdio (AFL)
17
check_PROGRAMS += knotd_stdio
18 19 20 21

nodist_knotd_stdio_SOURCES = knotd_wrap/main.c

knotd_stdio_SOURCES = \
22
	knotd_wrap/afl-loop.h		\
23 24 25 26 27 28 29 30 31 32 33
	knotd_wrap/server.c		\
	knotd_wrap/tcp-handler.c	\
	knotd_wrap/udp-handler.c

knotd_stdio_CPPFLAGS = $(AM_CPPFLAGS) $(liburcu_CFLAGS)
knotd_stdio_LDADD = $(top_builddir)/src/libknotd.la $(top_builddir)/src/libcontrib.la \
                    $(liburcu_LIBS)

BUILT_SOURCES = knotd_wrap/main.c
CLEANFILES = knotd_wrap/main.c
knotd_wrap/main.c: $(top_builddir)/src/utils/knotd/main.c
34
	@echo '#include "knotd_wrap/afl-loop.h"' > $@
35
	@$(SED) -e 's/for (;;)/while (__AFL_LOOP(10000))/' $(top_srcdir)/src/utils/knotd/main.c >> $@
36
endif HAVE_DAEMON
37 38

# Simple function wrappers (AFL, libFuzzer, tests)
39

40 41 42
fuzz_packet_SOURCES    = fuzz_packet.c
fuzz_packet_CPPFLAGS   = $(AM_CPPFLAGS)
fuzz_packet_LDADD      = $(top_builddir)/src/libknot.la
43

44 45
fuzz_zscanner_SOURCES  = fuzz_zscanner.c
fuzz_zscanner_CPPFLAGS = $(AM_CPPFLAGS)
46
fuzz_zscanner_LDADD    = $(top_builddir)/src/libzscanner.la
47

48 49 50 51 52
if OSS_FUZZ

# CFLAGS, LDFLAGS, etc. are defined by the oss-fuzz environment; just link
# in the fuzzing engine

53
fuzz_packet_LDADD   += ${LIB_FUZZING_ENGINE} -lc++
54
fuzz_zscanner_LDADD += ${LIB_FUZZING_ENGINE} -lc++
55 56 57

else

58
if FUZZER
59

60 61 62 63 64
fuzz_packet_CPPFLAGS   += ${fuzzer_CFLAGS}
fuzz_packet_LDFLAGS     = ${fuzzer_LDFLAGS}

fuzz_zscanner_CPPFLAGS += ${fuzzer_CFLAGS}
fuzz_zscanner_LDFLAGS   = ${fuzzer_LDFLAGS}
65 66 67 68 69 70

# Ensure that fuzzers execute successfully with a benign input

TESTS = check/check_fuzzers.test
EXTRA_DIST = check/check_fuzzers.test

71
else
72

73 74
fuzz_packet_SOURCES   += main.c
fuzz_zscanner_SOURCES += main.c
75

76
TESTS = $(FUZZERS)
77

78
endif # if FUZZER
79 80

endif # if OSS_FUZZ
81 82

check-compile: $(check_PROGRAMS)