fuzz: Support build with -fsanitize=fuzzer instead of libFuzzer.a
[strongswan.git] / fuzz / Makefile.am
1 AM_CPPFLAGS = @CPPFLAGS@ \
2         @FUZZING_CFLAGS@ \
3         -I$(top_srcdir)/src/libstrongswan \
4         -I$(top_srcdir)/src/libimcv \
5         -I$(top_srcdir)/src/libtncif \
6         -I$(top_srcdir)/src/libtpmtss \
7         -I$(top_srcdir)/src/libtnccs \
8         -I$(top_srcdir)/src/libtnccs/plugins/tnccs_20 \
9         -DPLUGINDIR=\""$(abs_top_builddir)/src/libstrongswan/plugins\"" \
10         -DPLUGINS="\"${fuzz_plugins}\""
11
12 fuzz_ldflags = ${libfuzzer} \
13         $(top_builddir)/src/libstrongswan/.libs/libstrongswan.a \
14         -Wl,-Bstatic -lgmp -Wl,-Bdynamic \
15         @FUZZING_LDFLAGS@
16
17 pa_tnc_ldflags = \
18         $(top_builddir)/src/libimcv/.libs/libimcv.a \
19         $(top_builddir)/src/libtncif/.libs/libtncif.a \
20         $(top_builddir)/src/libtpmtss/.libs/libtpmtss.a \
21         $(fuzz_ldflags)
22
23 pb_tnc_ldflags = \
24         $(top_builddir)/src/libtnccs/.libs/libtnccs.a \
25         $(top_builddir)/src/libtncif/.libs/libtncif.a \
26         $(fuzz_ldflags)
27
28 FUZZ_TARGETS=fuzz_certs fuzz_crls fuzz_pa_tnc fuzz_pb_tnc
29
30 all-local: $(FUZZ_TARGETS)
31
32 CLEANFILES=$(FUZZ_TARGETS)
33
34 fuzz_certs: fuzz_certs.c ${libfuzzer}
35         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)
36
37 fuzz_crls: fuzz_crls.c ${libfuzzer}
38         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(fuzz_ldflags)
39
40 fuzz_pa_tnc: fuzz_pa_tnc.c ${libfuzzer}
41         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(pa_tnc_ldflags)
42
43 fuzz_pb_tnc: fuzz_pb_tnc.c ${libfuzzer}
44         $(CC) $(AM_CPPFLAGS) $(CFLAGS) -o $@ $< $(pb_tnc_ldflags)
45
46 noinst_LIBRARIES = libFuzzerLocal.a
47 libFuzzerLocal_a_SOURCES = libFuzzerLocal.c
48 libFuzzerLocal_a_LIBADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
49
50 check: all
51         for f in $(FUZZ_TARGETS); do \
52                 corpus=$${f#fuzz_}; \
53                 ./$$f $(FUZZING_CORPORA)/$${corpus}/*; \
54                 crashes=$(FUZZING_CORPORA)/$${corpus}-crash; \
55                 test ! -d $${crashes} || ./$$f $${crashes}/*; \
56         done