1#!/bin/bash -eu 2# Copyright 2016 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 18export WGET_DEPS_PATH=$SRC/wget_deps 19export PKG_CONFIG_PATH=$WGET_DEPS_PATH/lib/pkgconfig 20export CPPFLAGS="-I$WGET_DEPS_PATH/include" 21export LDFLAGS="-L$WGET_DEPS_PATH/lib" 22export GNULIB_SRCDIR=$SRC/gnulib 23export LLVM_PROFILE_FILE=/tmp/prof.test 24 25cd $SRC/libunistring 26./autogen.sh 27./configure --enable-static --disable-shared --prefix=$WGET_DEPS_PATH --cache-file ../config.cache 28make -j$(nproc) 29make install 30 31cd $SRC/libidn2 32./bootstrap 33./configure --enable-static --disable-shared --disable-doc --disable-gcc-warnings --prefix=$WGET_DEPS_PATH --cache-file ../config.cache 34make -j$(nproc) 35make install 36 37cd $SRC/libpsl 38./autogen.sh 39./configure --enable-static --disable-shared --disable-gtk-doc --enable-runtime=libidn2 --enable-builtin=libidn2 --prefix=$WGET_DEPS_PATH --cache-file ../config.cache 40make -j$(nproc) 41make install 42 43GNUTLS_CONFIGURE_FLAGS="" 44NETTLE_CONFIGURE_FLAGS="" 45if [[ $CFLAGS = *sanitize=memory* ]]; then 46 GNUTLS_CONFIGURE_FLAGS="--disable-hardware-acceleration" 47 NETTLE_CONFIGURE_FLAGS="--disable-assembler --disable-fat" 48fi 49 50# We could use GMP from git repository to avoid false positives in 51# sanitizers, but GMP doesn't compile with clang. We use gmp-mini 52# instead. 53cd $SRC/nettle 54bash .bootstrap 55./configure --enable-mini-gmp --enable-static --disable-shared --disable-documentation --prefix=$WGET_DEPS_PATH $NETTLE_CONFIGURE_FLAGS --cache-file ../config.cache 56( make -j$(nproc) || make -j$(nproc) ) && make install 57if test $? != 0;then 58 echo "Failed to compile nettle" 59 exit 1 60fi 61 62cd $SRC/gnutls 63touch .submodule.stamp 64./bootstrap 65GNUTLS_CFLAGS=`echo $CFLAGS|sed s/-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION//` 66LIBS="-lunistring" \ 67CFLAGS="$GNUTLS_CFLAGS" \ 68./configure --with-nettle-mini --enable-gcc-warnings --enable-static --disable-shared --with-included-libtasn1 \ 69 --with-included-unistring --without-p11-kit --disable-doc --disable-tests --disable-tools --disable-cxx \ 70 --disable-maintainer-mode --disable-libdane --disable-gcc-warnings --disable-full-test-suite \ 71 --prefix=$WGET_DEPS_PATH $GNUTLS_CONFIGURE_FLAGS 72make -j$(nproc) 73make install 74 75 76# avoid iconv() memleak on Ubuntu 16.04 image (breaks test suite) 77export ASAN_OPTIONS=detect_leaks=0 78 79cd $SRC/wget 80./bootstrap 81 82# build and run non-networking tests 83LIBS="-lgnutls -lhogweed -lnettle -lidn2 -lunistring" \ 84 ./configure -C 85make clean 86make -j$(nproc) 87make -j$(nproc) -C fuzz check 88 89# build for fuzzing 90LIBS="-lgnutls -lhogweed -lnettle -lidn2 -lunistring" \ 91 ./configure --enable-fuzzing -C 92make clean 93make -j$(nproc) -C lib 94make -j$(nproc) -C src 95 96# build fuzzers 97cd fuzz 98make -j$(nproc) ../src/libunittest.a 99CXXFLAGS="$CXXFLAGS -L$WGET_DEPS_PATH/lib/" make oss-fuzz 100 101find . -name '*_fuzzer' -exec cp -v '{}' $OUT ';' 102find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';' 103find . -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';' 104 105for dir in *_fuzzer.in; do 106 fuzzer=$(basename $dir .in) 107 zip -rj "$OUT/${fuzzer}_seed_corpus.zip" "${dir}/" 108done 109