summaryrefslogtreecommitdiff
path: root/fuzz/Makefile.am
blob: 2e0b6b9f6fabd5211f154668d1d9dba5f52d0af2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS) -Wno-unused-parameter -Wno-pedantic
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) -I$(top_builddir)/lib -I$(top_srcdir)/lib \
 -DSRCDIR=\"$(abs_srcdir)\"
LDADD = ../lib/libgnu.a \
 $(GETADDRINFO_LIB) $(HOSTENT_LIB) $(INET_NTOP_LIB) $(INET_PTON_LIB) \
 $(LIBSOCKET) $(LIB_CLOCK_GETTIME) $(LIB_CRYPTO) $(LIB_GETLOGIN) $(LIB_NANOSLEEP) $(LIB_POLL) \
 $(LIB_POSIX_SPAWN) $(LIB_PTHREAD_SIGMASK) $(LIB_SELECT) $(LTLIBICONV) $(LTLIBINTL) \
 $(LTLIBMULTITHREAD) $(LTLIBTHREAD) $(SERVENT_LIB) @INTL_MACOSX_LIBS@ \
 -ldl

WGET_TESTS = \
 wget_css_fuzzer$(EXEEXT) \
 wget_cookie_fuzzer$(EXEEXT) \
 wget_ftpls_fuzzer$(EXEEXT) \
 wget_html_fuzzer$(EXEEXT) \
 wget_netrc_fuzzer$(EXEEXT) \
 wget_options_fuzzer$(EXEEXT) \
 wget_robots_fuzzer$(EXEEXT) \
 wget_url_fuzzer$(EXEEXT)

if FUZZING
  bin_PROGRAMS = $(WGET_TESTS)
  LDADD += $(LIB_FUZZING_ENGINE)
  MAIN = fuzzer.h
#  AM_LDFLAGS = -no-install -all-static
else
  AM_CPPFLAGS += -DTEST_RUN
  AM_TESTS_ENVIRONMENT = export VALGRIND_TESTS"=@VALGRIND_TESTS@";
  TESTS = $(WGET_TESTS)
  check_PROGRAMS = $(WGET_TESTS)
  MAIN = main.c fuzzer.h
endif

# Make libunittest "PHONY" so we're always sure we're up-to-date.
.PHONY: ../src/libunittest.a
../src/libunittest.a:
	$(MAKE) $(AM_MAKEFLAGS) -C ../src libunittest.a

wget_css_fuzzer_SOURCES = wget_css_fuzzer.c $(MAIN)
wget_css_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

wget_cookie_fuzzer_SOURCES = wget_cookie_fuzzer.c $(MAIN)
wget_cookie_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

wget_ftpls_fuzzer_SOURCES = wget_ftpls_fuzzer.c $(MAIN)
wget_ftpls_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

wget_html_fuzzer_SOURCES = wget_html_fuzzer.c $(MAIN)
wget_html_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

wget_netrc_fuzzer_SOURCES = wget_netrc_fuzzer.c $(MAIN)
wget_netrc_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

wget_options_fuzzer_SOURCES = wget_options_fuzzer.c $(MAIN)
wget_options_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

wget_robots_fuzzer_SOURCES = wget_robots_fuzzer.c $(MAIN)
wget_robots_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

wget_url_fuzzer_SOURCES = wget_url_fuzzer.c $(MAIN)
wget_url_fuzzer_LDADD = ../src/libunittest.a $(LDADD)

#EXTRA_DIST = $(wildcard *.options) $(wildcard *.dict) \
# $(wildcard *.in) $(wildcard *.repro)

dist-hook:
	find $(srcdir) -name '*.options' -exec cp -v '{}' $(distdir) ';'
	find $(srcdir) -name '*.dict' -exec cp -v '{}' $(distdir) ';'
#	find $(srcdir) -name '*.in' -exec cp -vr '{}' $(distdir) ';'
	find $(srcdir) -name '*.repro' -exec cp -vr '{}' $(distdir) ';'

clean-local:
	rm -rf *.gc?? *.log lcov

oss-fuzz:
	if test "$$OUT" != ""; then \
	XLIBS="-lpsl -lgnutls -lnettle -lhogweed -lidn2 -lunistring"; \
	for ccfile in wget*_fuzzer.c; do \
	fuzzer=$$(basename $$ccfile .c); \
	$$CXX $$CXXFLAGS -I$(top_srcdir)/src -I$(top_srcdir) -I$(top_srcdir)/lib \
	"$${fuzzer}.c" -o "$${fuzzer}" \
	../src/libunittest.a ../lib/libgnu.a $${LIB_FUZZING_ENGINE} \
	-Wl,-Bstatic $${XLIBS} -Wl,-Bdynamic; \
	done; \
	fi

.PHONY: oss-fuzz