fuzz: Change how fuzz_certs is built
authorTobias Brunner <tobias@strongswan.org>
Mon, 1 May 2017 14:23:55 +0000 (16:23 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 23 May 2017 16:29:12 +0000 (18:29 +0200)
We mainly do this because we have to create a self-contained executable
and it isn't so easy to actually get libtool to link e.g. libgmp
statically.

fuzz/Makefile.am

index a2c225f..66debc2 100644 (file)
@@ -1,12 +1,18 @@
-AM_CPPFLAGS = \
+CPPFLAGS = @CPPFLAGS@ \
        -I$(top_srcdir)/src/libstrongswan \
        -DPLUGINDIR=\""$(abs_top_builddir)/src/libstrongswan/plugins\"" \
        -DPLUGINS="\"${fuzz_plugins}\""
 
-noinst_PROGRAMS = fuzz_certs
+LDFLAGS = @LDFLAGS@ ${libfuzzer} \
+       $(top_builddir)/src/libstrongswan/.libs/libstrongswan.a \
+       -Wl,-Bstatic -lgmp -Wl,-Bdynamic \
+       -stdlib=libc++ -lstdc++
 
-fuzz_certs_SOURCES = fuzz_certs.c
+FUZZ_TARGETS=fuzz_certs
 
-fuzz_certs_LDFLAGS = ${libfuzzer} -lstdc++
+all-local: $(FUZZ_TARGETS)
 
-fuzz_certs_LDADD = $(top_builddir)/src/libstrongswan/libstrongswan.la
+CLEANFILES=$(FUZZ_TARGETS)
+
+fuzz_certs: fuzz_certs.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS)