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