• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2017 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# Wpantund's configure script is fuzzer-aware, so we
19# move those flags into their own environment variables.
20FUZZ_CFLAGS="${CFLAGS}"
21FUZZ_CXXFLAGS="${CXXFLAGS}"
22unset CFLAGS
23unset CXXFLAGS
24
25./bootstrap.sh
26
27./configure                               \
28        --enable-fuzz-targets             \
29        --disable-shared                  \
30        --enable-static                   \
31		CC="${CC}"                        \
32		CXX="${CXX}"                      \
33		FUZZ_LIBS="${LIB_FUZZING_ENGINE}" \
34		FUZZ_CFLAGS="${FUZZ_CFLAGS}"      \
35		FUZZ_CXXFLAGS="${FUZZ_CXXFLAGS}"  \
36		LDFLAGS="-lpthread"               \
37		CXXFLAGS="-stdlib=libc++"
38
39# Build everything.
40make -j$(nproc)
41
42# Copy all fuzzers and related options/dictionaries.
43find . -name '*[-_]fuzz' -type f -exec cp -v '{}' $OUT ';'
44find . -name '*[-_]fuzz.dict' -type f -exec cp -v '{}' $OUT ';'
45find . -name '*[-_]fuzz.options' -type f -exec cp -v '{}' $OUT ';'
46
47# Copy all of the fuzzers' related corpi.
48for f in etc/fuzz-corpus/*[-_]fuzz
49do
50    fuzzer=$(basename $f)
51    if test -d "${f}"
52	then zip -j $OUT/${fuzzer}_seed_corpus.zip ${f}/*
53    fi
54done
55
56# Dump out all of the files in the output.
57find $OUT -type f > /dev/stderr
58