1#!/bin/bash -eu
2# Copyright 2020 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
18cd clib
19make -j$(nproc)
20
21sed 's/int main(int argc/int main2(int argc/g' -i ./src/clib-search.c
22sed 's/int main(int argc/int main2(int argc/g' -i ./src/clib-configure.c
23
24find . -name "*.o" -exec ar rcs fuzz_lib.a {} \;
25
26$CC $CFLAGS -Wno-unused-function -U__STRICT_ANSI__  \
27	-DHAVE_PTHREADS=1 -pthread -o fuzz_manifest.o \
28	-c test/fuzzing/fuzz_manifest.c -I./asprintf -I./deps/ \
29	-I./deps/asprintf
30
31$CC $CFLAGS $LIB_FUZZING_ENGINE fuzz_manifest.o \
32	-o $OUT/fuzz_manifest src/common/clib-package.c \
33	src/common/clib-cache.c src/clib-configure.c \
34	-I./deps/asprintf -I./deps -I./asprintf \
35	fuzz_lib.a -L/usr/lib/x86_64-linux-gnu -lcurl
36
37